Xref: news2.mv.net comp.os.msdos.djgpp:3020 From: Broeker AT axp02 DOT physik DOT rwth-aachen DOT de (Hans-Bernhard Broeker) Newsgroups: comp.os.msdos.djgpp Subject: Re: [Q:] Recursive make ?? Date: 23 Apr 96 10:13:20 GMT Organization: RWTH -Aachen / Rechnerbetrieb Informatik Lines: 47 Message-ID: References: <4lhsaa$c5m AT news DOT cea DOT fr> NNTP-Posting-Host: axp02.physik.rwth-aachen.de To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp nicolas AT dsys DOT ceng DOT cea DOT fr (Eric NICOLAS) writes: >So, if I understood well, there is absolutely no way of perform a >recursive make in a portable fashion ??? Doch. (Sorry, intranslatable to English) Here's how: in the README, and at the top of your Makefile, put this text: "To build this program, you *will* need GNU make" and then you can use a rule like this for recursive make-ing: sub-all: $(MAKE) -C libsrc $(MAKE) -C utils $(MAKE) -C src And that's it. This method is about as portable as you can ever get (works wherever someone managed to build GNU make, i.e. pretty much everywhere, and without any changes), but may be slightly uncomfortable for non-GNU-infected users. BTW, Makefiles have *never* ever been really portable, at least not once you want to use any kind of loop construction. E.g., every true Unix programmer would have written the above rule a little bit clearer, like this (read some GNU or Linux Makefiles, and you'll see this *very* often): sub-all: libsrc utils src ( for f in $^ ; do $(MAKE) -C $$f ; done ) For this to work portably, you'ld have to add a sufficiently correct implementation of '/bin/sh' to the requirements for building your program. BAD THING if you try this in MS-DOG. The same problem arises once you need advanced textutilities like sed/awk or at least tr for your makefile. You *can* have GNU Make do some of their work, but at some point, you'll sure need The Real Thing (tm:-), which might not be available on all desirable platforms. There could also be bugs in their implementation on some of the weirder OS's out there, of which you won't ever know until someone gets hit by them using your 'innocent' little makefile. Hans-Bernhard Broeker (Aachen, Germany)