Here are another couple rule patterns that let “make” do its thing and you do yours.
Some targets (such as “install”) depend on target directories existing. Often you see:
install : $(things) ; mkdir -p $(DESTDIR); cp $^ $(DESTDIR)
A more make-ish way of expressing this is:
install : $(DESTDIR)/.. $(things) ; cp $(things) $(DESTDIR)/ %/.. : ;@mkdir -p $(@D)
The pattern rule means you don’t have to litter your makefile with prophylactic “mkdir -p” commands.
Another handy trick is:
%. : ;@echo '$($*)'
This is a handy way to check the value of any makefile variable, given all the nested and conditional expressions that contribute to its value. For example:
$ make CFLAGS.