Makefiles - Make and the Shell

LeftRight

In the Makefile each action line is a separate invocation of a shell child process and any shell variables or current working directory changes are independent of each other.

The following table shows how to compress the various Bourne shell statements onto a single logical line. However, it's a good idea to break up the statements with white-space formatting on to separate lines. This can be done by escaping the new-line.

Other hints:

Bourne Shell conditional and looping statements

Expanded Condensed
if com1
then
	com2
fi
if com1 ; then com2 ; fi
if com1
then
	com2
else
	com3
fi
if com1 ; then com2 ; else com3 ; fi
if com1
then
	com2
elif com3
then
	com4
else
	com5
fi
if com1 ; then com2 ; elif com3 ; \
	then com4 ; else com5 ; fi
case value in
pattern1)	com1 ;;
pattern2)	com2 ;;
pattern3)	com3 ;;
esac
case value in pattern1) com1 ;; \
	pattern2) com2 ;; \
	pattern3) com3 ;; esac
for variable in list
do
	command
done
for variable in list; do command ; done
while com1
do
	com2
done
while com1 ; do com2 ; done
until com1
do
	com2
done
until com1 ; do com2 ; done

LeftRight
Slide 9