shells inside Makefiles
Seth Teller
seth at miro.Berkeley.EDU
Fri Oct 19 10:20:47 AEST 1990
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
More information about the Comp.sys.sgi
mailing list