Question

What is the standard ? And in which case we should use the following ?

$(MAKE) -C subdir

cd subdir && $(MAKE)

cd subdir ; $(MAKE)

same for when doing make clean ?

Was it helpful?

Solution

Here's a diagram:

Method  | Correct | Cross-platform
--------+---------+---------------
-C      |    X    |     
&&      |    X    |      X
 ;      |         |      X

-C works well for GNU make, but is not POSIX.

; works equally poorly on all platforms (if subdir is inaccessible, it results in an infinite loop).

&& is both correct and portable, and therefore the best option.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top