bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking file generation for a test script


From: Henrik Carlqvist
Subject: Re: Checking file generation for a test script
Date: Sun, 18 Jun 2017 14:51:49 +0200

On Sun, 18 Jun 2017 13:03:10 +0200
SF Markus Elfring <address@hidden> wrote:

> I have tried the following small script out together with the program
> “GNU Make 4.2.1-1.7” on my openSUSE Tumbleweed system.

That "script" seems like a makefile to me.
 
> my_compilation?=echo
> my_preparation?=cat
> footer?=MOTD.txt
> prepared_file?=MOTD.in
> 
> MOTD%.log: MOTD%.txt MOTD%.in
>       ${my_compilation} "$<: $$(cat ${prepared_file} ${footer})" > $@
> 
> ${prepared_file}: MOTD.draft
>       ${my_preparation} $< > $@
> 
> 
> address@hidden:~/Projekte/Bau> my_message=MOTD.log && rm -f
> ${my_message}; touch MOTD.draft MOTD.txt && LANG=C make
> --no-builtin-rules -f ../rule-check2.make && LANG=C ls -l MOTD.in
> ${my_message} cat MOTD.draft > MOTD.in
> ls: cannot access 'MOTD.log': No such file or directory
> -rw-r--r-- 1 elfring users 6 Jun 18 12:56 MOTD.in
> 
> 
> Now I wonder why the log file is not generated by this build approach at
> the end. Where is my knowledge and understanding incomplete for this
> software situation?

Your MOTD.log is not generated because you did not tell make to generate
it. It would have been generated if you would have called make with a
command like:
LANG=C make --no-builtin-rules -f ../rule-check2.make MOTD.log
and if you had a rule to build MOTD.log

It would also have been generated if your makefile would have contained a
default rule which caused that file to be generated. 

The default rule in your makefile is ${prepared_file} which in this case
is MOTD.in gets generated.

There is no default rule for MOTD.txt, your makefile know how to generate
every MOTD?*.txt but it does not know if any of them should be generated
by default. In the documentation at
https://www.gnu.org/software/make/manual/html_node/Rules.html it says:

"a target that defines a pattern rule has no effect on the default goal."

In fact, there is no rule at all for MOTD.txt as your rule for MOTD%.txt
has a pattern which must match a none empty string.

regards Henrik



reply via email to

[Prev in Thread] Current Thread [Next in Thread]