Makefile: If target name contains colon (:)

Suppose I’ve got a simple w/ a few URLs that I’d like to process as dynamic targets.

For example here is a not working snippet:


<span style="color:#323232;">.DEFAULT_GOAL := all
</span><span style="color:#323232;">
</span><span style="color:#323232;">#####
</span><span style="color:#323232;">URLS  = https://foo.example.com
</span><span style="color:#323232;">URLS += https://bar.example.com
</span><span style="color:#323232;">URLS += https://www.example.org
</span><span style="color:#323232;">
</span><span style="color:#323232;">#####
</span><span style="color:#323232;">% :
</span><span style="color:#323232;">	@echo the url is $(*)
</span><span style="color:#323232;">
</span><span style="color:#323232;">#####
</span><span style="color:#323232;">.PHONY : all
</span><span style="color:#323232;">all : $(URLS)
</span>

It fails w/

*** target pattern contains no ‘%’

I believe that’s b/c of the character : being part of URLS which confuses Make after expansion (order o

As a workaround, I’ve removed https:// from all URLs. For example this works:


<span style="color:#323232;">URLS = foo.example.com
</span><span style="color:#323232;">URLS += bar.example.com
</span>

I know Make generally doesn’t play well w/ targets w/ space or colon in the name but I wonder if the above is the best I can do. What do you think?

jlsalvador,

I didn’t try yet: cmcrossroads.com/…/gnu-make-escaping-walk-wild-si…


<span style="color:#323232;">colon := :
</span><span style="color:#323232;">$(colon) := :
</span><span style="color:#323232;">url := https$(:)//something
</span>
bahmanm,
@bahmanm@lemmy.ml avatar

Unfortunately didn’t work. I got the same *** target pattern contains no ‘%’ error.

pnutzh4x0r,
@pnutzh4x0r@lemmy.ndlug.org avatar

You can escape the :


<span style="color:#323232;">URLS  = https://foo.example.com
</span><span style="color:#323232;">URLS += https://bar.example.com
</span><span style="color:#323232;">URLS += https://www.example.org
</span>
  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • Ask_kbincafe
  • oklahoma
  • feritale
  • SuperSentai
  • KamenRider
  • All magazines