this post was submitted on 12 Aug 2023
13 points (88.2% liked)

Programming

17450 readers
165 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

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:

.DEFAULT_GOAL := all

#####
URLS  = https://foo.example.com
URLS += https://bar.example.com
URLS += https://www.example.org

#####
% :
	@echo the url is $(*)

#####
.PHONY : all
all : $(URLS)

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:

URLS = foo.example.com
URLS += bar.example.com

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?

top 3 comments
sorted by: hot top controversial new old
[–] pnutzh4x0r@lemmy.ndlug.org 5 points 1 year ago

You can escape the :

URLS  = https\://foo.example.com
URLS += https\://bar.example.com
URLS += https\://www.example.org
[–] jlsalvador@lemmy.ml 2 points 1 year ago (1 children)
[–] bahmanm@lemmy.ml 3 points 1 year ago

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