Subject: make
To: None <>
From: Christos Zoulas <>
List: current-users
Date: 12/16/1993 05:35:12
Are there any plans to upgrade to the current version of make from 4.4?
A while ago, I added "for" loops to the 4.4BSD make. I use them extensively
in my makefiles because they facilitate writing rules like the ones found
in /usr/src/include:

	@-for i in ${DIRS}; do \
		if [ ! -d ${DESTDIR}/usr/include/$$i ]; \
		then \
			mkdir ${DESTDIR}/usr/include/$$i; \
		fi; \
		(cd $$i; for j in *.[ih]; do \
			cmp -s $$j ${DESTDIR}/usr/include/$$i/$$j || \
			install -c -m 644 $$j ${DESTDIR}/usr/include/$$i/$$j; \
		done); \

could be written as (minus the mkdir portion):

.for d in ${DIRS}

FILES_$d != cd $d && echo *.[ih]

.	for j in ${FILES_$d}

install:: ${DESTDIR}/$d/$j

${DESTDIR}/$d/$j: $d/$j
	install -c -m 644 ${.ALLSRC} ${.TARGET}

.	endfor


[and I would argue that the 644 should be 444...]

This can be done for most install rules (programs libraries etc.) where
there is currently no checking for the source being newer than the target.
Currently "make install" in a program directory will *always* install the
program even if the binary in the source tree is the same or older than
the one installed.

Note that the "for" loop is more general than gnu-make's pattern rules
and eliminates the need for them.