Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!ucsd!dog.ee.lbl.gov!pasteur!miro.Berkeley.EDU!seth From: seth@miro.Berkeley.EDU (Seth Teller) Newsgroups: comp.sys.sgi Subject: shells inside Makefiles Message-ID: <28936@pasteur.Berkeley.EDU> Date: 19 Oct 90 00:20:47 GMT Sender: news@pasteur.Berkeley.EDU Reply-To: seth@miro.Berkeley.EDU (Seth Teller) Organization: University of California at Berkeley Lines: 48 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