seth@miro.Berkeley.EDU (Seth Teller) (10/19/90)
someone (can't remember who) posted a question about shell constructs inside makefiles, and someone else (can't remember who that was, either) answered something about complicated things not being possible... well, although it's ugly, you can do anything inside a makefile. here's a while loop, all one line (sorry it's so long): NAME=tog FIRSTPAGE=1 LASTPAGE=50 SKIPPAGE=2 EJECTPAGE=3 PRINTER=uni syncprintR: firstpage=$(FIRSTPAGE) ; \ lastpage=$(LASTPAGE) ; \ skippage=$(SKIPPAGE) ; \ numbytes=0 ;\ totalbytes=0 ;\ page=$$lastpage ; \ while [ `expr \( $$page \>= $$firstpage \& $$page \<= $$lastpage \) \| \( $$page \>= $$lastpage \& $$page \<= $$firstpage \)` = 1 ] ; do \ echo printing page $$page of \[$$firstpage .. $$lastpage\] ; \ echo "dvi2ps -f $$page -t $$page $(NAME).dvi > $(NAME).$$page.ps" ; \ dvi2ps -f $$page -t $$page $(NAME).dvi > $(NAME).$$page.ps ; \ numbytes=`ls -l $(NAME).$$page.ps | awk '{print $$4}'` ; \ totalbytes=`expr $$totalbytes + $$numbytes`; \ echo "bin/syncprint $(NAME).$$page.ps $(PRINTER) ($$numbytes bytes; $$totalbytes total)" ; \ bin/syncprint $(NAME).$$page.ps $(PRINTER) ; \ echo "/bin/rm -f $(NAME).$$page.ps" ; \ /bin/rm -f $(NAME).$$page.ps ; \ page=`expr $$page - $$skippage` ; \ done ; \ echo "printed $$totalbytes bytes total." this example loops, uses shell variables, does expression evaluation, and passes make variables to shell commands. like i said, it's not pretty. in particular, notice the weirdness with $, $(), and $$. do your worst-- seth
peterk@foetus.syd.sgi.oz.au (Peter Kerney) (10/23/90)
From article <28936@pasteur.Berkeley.EDU>, by seth@miro.Berkeley.EDU (Seth Teller): > someone (can't remember who) posted a question about shell constructs > inside makefiles, and someone else (can't remember who that was, either) > answered something about complicated things not being possible... > > well, although it's ugly, you can do anything inside a makefile. > here's a while loop, all one line (sorry it's so long): > I confess, It was me. I posted the original article. The problems is not ussimply using shells in Makefiles. The problem is using 'csh' (THE C-SHELL) from within a Makefile. The example you gave was a Bourne shell eg: while [ test ] done This is allowed by the shell to be on a single line. The makefile I want to work is one that uses the C-shell. (I like it better) Here is a simple test that is anyone can get to work I would love it. all: foreach i (1 2) echo $i end If you can get this to work, everything else is possible. PS: All replies I received gave examples of using the Bourne shell. -- Peter Kerney. Silicon Graphics, Sydney, Australia. (peterk@syd.sgi.oz.au) If you can't have an IRIS at home, have the next best thing, an Amiga !!!