jwp@uwmacc.UUCP (Jeffrey W Percival) (10/28/85)
Here's a simple makefile: DIRS = d1 d2 d3 d4 d5 depend: ; (for dir in $(DIRS); do (cd $dir; make depend); done) The problem with this is that 'make' is interpreting the $d as a null string, so the 'cd' command sees an argument of "ir". I tried escaping the $ preceding dir, to no avail. Can anybody make the above loop work, or suggest a better way? Thanks! Jeff -- Jeff Percival ...!uwvax!uwmacc!jwp
jpn@teddy.UUCP (10/29/85)
In article <1596@uwmacc.UUCP> jwp@uwmacc.UUCP (Jeffrey W Percival) writes: >Here's a simple makefile: > > DIRS = d1 d2 d3 d4 d5 > depend: ; (for dir in $(DIRS); do (cd $dir; make depend); done) > >The problem with this is that 'make' is interpreting the $d as a null >string, To pass a '$' to a command, double it. i.e. the command line should be: depend: ; (for dir in $(DIRS); do (cd $$dir; make depend); done)
ken@rochester.UUCP (and Vicki Herrieschopper) (10/30/85)
In article <1596@uwmacc.UUCP> jwp@uwmacc.UUCP (Jeffrey W Percival) writes: > DIRS = d1 d2 d3 d4 d5 > depend: ; (for dir in $(DIRS); do (cd $dir; make depend); done) > >The problem with this is that 'make' is interpreting the $d as a null >string, so the 'cd' command sees an argument of "ir". depend: ; (for dir in $(DIRS); do (cd $$dir; make depend); done) Ken -- UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken@rochester.arpa USnail: Dept. of Comp. Sci., U. of Rochester, NY 14627. Voice: Ken!
radzy@calma.UUCP (Tim Radzykewycz) (10/30/85)
In article <1596@uwmacc.UUCP> jwp@uwmacc.UUCP (Jeffrey W Percival) writes: >Here's a simple makefile: > DIRS = d1 d2 d3 d4 d5 > depend: ; (for dir in $(DIRS); do (cd $dir; make depend); done) >The problem with this is that 'make' is interpreting the $d as a null >string, so the 'cd' command sees an argument of "ir". I tried >escaping the $ preceding dir, to no avail. To get a '$' char down to the shell that actually executes the commands, simply double it: DIRS = d1 d2 d3 d4 d5 depend: ; (for dir in $(DIRS); do (cd $$dir; make depend); done) ^^ This prevents make from seeing it as a variable, and it does the right thing. -- Tim (radzy) Radzykewycz, The Incredible Radical Cabbage calma!radzy@ucbvax.ARPA {ucbvax,sun,csd-gould}!calma!radzy
fnf@unisoft.UUCP (10/31/85)
In article <1596@uwmacc.UUCP> jwp@uwmacc.UUCP (Jeffrey W Percival) writes: >Here's a simple makefile: > > DIRS = d1 d2 d3 d4 d5 > depend: ; (for dir in $(DIRS); do (cd $dir; make depend); done) > >The problem with this is that 'make' is interpreting the $d as a null >string, so the 'cd' command sees an argument of "ir". I tried >escaping the $ preceding dir, to no avail. Can anybody make the >above loop work, or suggest a better way? Thanks! Try: ========================== DIRS = d1 d2 d3 d4 d5 depend: $(DIRS) $(DIRS): FRC cd $@; make depend FRC: ========================== -Fred
david@cdp.UUCP (11/30/85)
> > DIRS = d1 d2 d3 d4 d5 > depend: ; (for dir in $(DIRS); do (cd $dir; make depend); done) > >The problem with this is that 'make' is interpreting the $d as a null >string, so the 'cd' command sees an argument of "ir". I tried >escaping the $ preceding dir, to no avail. Can anybody make the >above loop work, or suggest a better way? Thanks! # add the following line to insure that the bourne is called # called as the shell (make in many incarnations # reads the users environment). SHELL=/bin/sh depend: ; (for dir in $(DIRS); do (cd $$dir; make depend); done) ^ # to get a literal $ past make one must escape it with another $. david stone !{hplabs,glacier}!cdp!david