From b15e9ddf46afb28e7cf49bdcd099ed8f60bd25f3 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 1 Sep 2008 00:27:09 +0000 Subject: [PATCH] Importing NanoBlogger post "More make idoms" --- posts/More_make_idoms.mdwn | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 posts/More_make_idoms.mdwn diff --git a/posts/More_make_idoms.mdwn b/posts/More_make_idoms.mdwn new file mode 100644 index 0000000..814c15c --- /dev/null +++ b/posts/More_make_idoms.mdwn @@ -0,0 +1,43 @@ +[[!meta title="More make idoms"]] +[[!meta date="2008-08-31 20:27:09"]] +I'm rather proud of this one (can you tell I'm overhauling sawsim's +Makefile ;). + + $ cat Makefile + FILES = a b + DS = src + DT = targ + + all : $(FILES:%=$(DT)/%) + @echo "got $^" + @echo "done" + + clean : + rm -rf $(DT) + + .SECONDEXPANSION: + #$(FILES:%=$(DT)/%) : $$($$@:$(DT)/%=$(DS)/%) $(DT) + # This colon --^ produces: "target pattern contains no `%'." + # Instead use this idom --v + $(FILES:%=$(DT)/%) : $$(subst $(DT),$(DS),$$@) $(DT) + @echo "looking for $< for $@" + + $(DT) : + mkdir $@ + % : + @echo "missing rule for $@" + + $ make + looking for src/a for targ/a + looking for src/b for targ/b + got targ/a targ/b + done + +Of course you could accomplish the same effect with + + $(DT)/% : $(SRC)/% + @echo "looking for $< for %@" + +but what fun is that? ;) + +[[!tag programming]] -- 2.26.2