afsipmh@cidsv01.cid.aes.doe.CA (05/09/91)
How can I use a here document within a makefile? Is this possible? -- Pat Hertel Canadian Meteorological Centre Analyst/Programmer 2121 N. Service Rd. phertel@cmc.aes.doe.ca Dorval,Quebec Environment Canada CANADA H9P1J3
fitz@mml0.meche.rpi.edu (Brian Fitzgerald) (05/10/91)
afsipmh@cidsv01.cid.aes.doe.CA writes: >How can I use a here document within a makefile? >Is this possible? I posted the same question in January. In <}7W^DZ_@rpi.edu>, you write in comp.unix.shell: >This shell script with an ed script splits my file into two new files: > >ed foo <<E_O_F >1,/^ *References$/-1w foo.body >/^ *References$/+1,$w foo.ref >q >E_O_F > >This makefile does the same thing for me: > >EDSCRIPT= 1,/^ *References$$/-1w $(DOC).body@\ >/^ *References$$/+1,$$w $(DOC).ref@\ >q > >ed: $(DOC) > echo '$(EDSCRIPT)' | tr @ '\012' | ed $(DOC) > >My question: Can a makefile rule contain a "here" document like my >first example? Please post tested solutions that use the standard >"ed", "sh", and "make". Thanks! By the way, in my original posting, I meant a "here" document embedded within the Makefile itself. I got a nice reply from a certain net guru (who spells his name with four rows of the keyboard!) who said: -- There isn't a way that is portable across all versions of make, no. The problem is that some makes take the backslash-newline and delete both. This is why /bin/sh scripts in Makefiles have all those semicolons, as in: @for I in $(LIST) ; do \ echo Creating $$I... ; \ sed -e s/foo/bar/ <template >$$I ; \ done That way when the lines are merged the ; will terminate the commands in the right place. Other versions of make just delete the \, however, and keep the newline. SysV "augmented" make was the first one to do this, I believe. -- Brian