Using sh in makefiles

Doug Gwyn gwyn at brl-smoke.ARPA
Sun Jun 29 15:22:03 AEST 1986


In article <1991 at dalcs.UUCP> silvert at dalcs.UUCP (Bill Silvert) writes:
-Would like advice on how to use shell commands (such as if...) in
-makefiles.  I know that it all has to be on one line, but the only way I
-can make a command work is through a kludge like:
-
-test:
-	echo "if x;then y;fi" | sh
-
-which seems pretty roundabout.  Is this the only way to do it?

I really don't understand why you've had any problems:

test:
	if x; then y; fi

OR

test:
	if x ; \
	then	y ; \
	fi

Perhaps you're using one of those antique versions of UNIX that has a
"make" and shell that conspire to report that the "if" command has
failed; if so, just use a dash prefix on the command:

test:
	-if x; \
	then	y; \
	fi

I would like to once again plea that people posting problems
tell us what version of UNIX they're running, since there are
several and they don't all behave the same way.



More information about the Comp.unix mailing list