read a source file with gnu make?

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

read a source file with gnu make?

patrick
Hello,
I am begginer with gnu make and I am trying to implement the next:
-I have a source file which contains include directive
-I have a make file with the next content:

file_nam=demo_c0.txt
file_content=$(shell cat ${file_nam})
rez=$(word 1,$(file_content))
f:
        echo $(rez)

When I am executing this nothing is displayed,
 but if I change the content of my demo with something ordinary it works,
 what should I do in this case, is there any solution?
Reply | Threaded
Open this post in threaded view
|

Re: read a source file with gnu make?

Paul Smith-20
On Tue, 2014-05-27 at 14:01 -0700, patrick wrote:

> Hello,
> I am begginer with gnu make and I am trying to implement the next:
> -I have a source file which contains include directive
> -I have a make file with the next content:
>
> file_nam=demo_c0.txt
> file_content=$(shell cat ${file_nam})
> rez=$(word 1,$(file_content))
> f:
> echo $(rez)
>
> When I am executing this nothing is displayed,
>  but if I change the content of my demo with something ordinary it works,
>  what should I do in this case, is there any solution?

I'm sorry but I don't understand what you want to do.  What do you mean
by "an include directive"?

What the above does is print the first word in the file demo_c0.txt.  Is
that not what you want?  Is that not what it does?

Please provide a complete example, including the contents of the
"demo_c0.txt" file and the make command you run, and show output you get
(cut and paste it from the actual invocation, please, don't just
paraphrase it), and explain what output you WANTED to get.


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: read a source file with gnu make?

Philip Guenther-2
In reply to this post by patrick
On Tue, May 27, 2014 at 2:01 PM, patrick <[hidden email]> wrote:

> Hello,
> I am begginer with gnu make and I am trying to implement the next:
> -I have a source file which contains include directive

-I have a make file with the next content:
>
> file_nam=demo_c0.txt
> file_content=$(shell cat ${file_nam})
> rez=$(word 1,$(file_content))
> f:
>         echo $(rez)
>
> When I am executing this nothing is displayed,
>

I doubt it.  I would bet you're either seeing this:
   echo #include
or maybe this:
   make: 'f' is up to date.

...or you didn't quote your Makefile accurately.  If your makefile actually
had this rule:

f:
        @echo $(rez)

*then* you would see nothing...and removing the '@' makes the problem more
clear: the $(rez) is expanded before the command is passed to the shell, so
any shell meta-characters in it will still be magic to the shell.  The
shell treats words starting with a '#' as the start of a comment, so from
there to the end of the line will be ignored.  To pass it through you'll
need to quote it either with single or double-quotes, ala:

f:
        @echo '$(rez)'


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