shell command in a make file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

shell command in a make file

patrick
I have a bigg big issue, I am tryng the next but I could not perform to write some shell commands in a make file:

define example
$(shell \
particle=typedef \
source=$(1) \
)
endef

file_nam=PROJ1/SOURCES/demo_c1.c
file_content=$(shell cat ${file_nam})

rez5=$(call example,$(file_content))
f:
        @echo '$(rez5)'

It does not work, because the code associated with shell is seen as commands for f target. What I can do?
Reply | Threaded
Open this post in threaded view
|

Re: shell command in a make file

Paul Smith-20
On Sat, 2014-05-31 at 11:18 -0700, patrick wrote:
> define example
> $(shell \
> particle=typedef \
> source=$(1) \
> )
> endef

The above doesn't make sense.  When this variable is expanded it will
invoke a shell which will set the shell variables "particle" and
"source", then the shell will exit and those values will be lost.

> file_nam=PROJ1/SOURCES/demo_c1.c
> file_content=$(shell cat ${file_nam})
>
> rez5=$(call example,$(file_content))
> f:
> @echo '$(rez5)'
>
> It does not work, because the code associated with shell is seen as commands
> for f target. What I can do?

I have no idea what you're TRYING to do with this makefile, and you
don't explain, so there's little we can say.

I don't know what you mean by "the code associated with shell is seen as
commands for f target"; when I run the above it prints the empty string
just as I'd expect.

When asking questions please provide: the operating system you're using,
the version of GNU make you're using, the makefile (thank you), the
exact make command line you invoked, the exact output you got
(cut/paste), and a description of why that output is not what you wanted
and what you really did want.

Then we can help.


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make