Makefile: If target name contains colon (:)
Suppose I’ve got a simple #Makefile 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?
Add comment