[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Indirection Operators in the Command section of a makefile doesnt wo
RE: Indirection Operators in the Command section of a makefile doesnt work.
Mon, 20 Jan 2014 04:21:03 -0800
Thanks for a very detailed response to my query of the heredoc operator in make.
My goal for a heredoc inside a makefile was to create a file on the fly from a
Initially I tried using the "define" macro for a multiline for getting this
done but that didnt work either.
Then zeroed in on the "cat" utility with the heredoc operator.
I couldnt make the exmple you gave of the $LINES variable to work at my end.
But what I have at my end is :
i) setenv a multiline variable in a csh file .
ii) invoke the make from the csh file, so now the makefile will have access to
this multiline variable as well. then i do a printf $$multiline variable
inside the makefile.
> Date: Thu, 16 Jan 2014 14:41:54 +0000
> Subject: Re: Indirection Operators in the Command section of a makefile
> doesnt work.
> From: address@hidden
> To: address@hidden
> CC: address@hidden
> As I understand it that's a "here document", not merely indirection.
> First check that you have a tab character rather than 9 spaces before
> 'cat'. Then you should get another error like this:
> /bin/sh: warning: here-document at line 0 delimited by end-of-file
> (wanted `EOF')
> Commands in make are single lines but here-documents are multiline.
> You usage creates a line like this:
> cat - <<EOF ; Testing line 1 Testing line 2 EOF
> those '\' characters in your makefile remove the newlines and bash
> sees what I typed above. Try that at your bash commandline - it
> won't work either.
> So you're trying to use a multiline shell feature in a place where
> there will never be multiple lines because in a recipe, every line is
> a separate bash command.
> You can use .ONESHELL but that affects your entire makefile and you
> might not be happy about that.
> I don't know what your goal is (at the moment it seems strange to me
> to use a here document in a makefile) but you might be able to replace
> what you have with something like this:
> LINES=""; read X; while [ $$? -eq 0 ]; do if [ "$$X" == "EOF" ]; then
> break; fi; LINES="$$LINES\n$$X"; read X; done
> This gives you a bash variable, LINES, which you might echo to the
> terminal or whatever you want to do. Your action has to go on the end
> e.g. "; echo -e $$LINES"