[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Make does not throw an error for target without a recipe?
From: |
Martin Dorey |
Subject: |
RE: Make does not throw an error for target without a recipe? |
Date: |
Thu, 26 Jun 2014 20:33:13 +0000 |
> Why is it trying to build target test.mk...???
That's explained by
https://www.gnu.org/software/make/manual/make.html#Remaking-Makefiles.
> Then it decides it was successful?
For some value of "successful". With your makefile:
address@hidden:~/tmp/batrick-2014-06-26$ make -f test.mk foo
make: Nothing to be done for `foo'.
address@hidden:~/tmp/batrick-2014-06-26$
If we add a semicolon, telling make that the recipe to update foo is empty:
address@hidden:~/tmp/batrick-2014-06-26$ sed -i -e 's/passwd/passwd;/' test.mk
address@hidden:~/tmp/batrick-2014-06-26$
Then the message changes:
address@hidden:~/tmp/batrick-2014-06-26$ make -f test.mk foo
make: `foo' is up to date.
address@hidden:~/tmp/batrick-2014-06-26$
If we give it a recipe that actually works:
address@hidden:~/tmp/batrick-2014-06-26$ sed -i -e 's/passwd;/passwd; @touch
$@/' test.mk
address@hidden:~/tmp/batrick-2014-06-26$
Then we get silent success, following the Unix Bushido:
address@hidden:~/tmp/batrick-2014-06-26$ make -f test.mk foo
address@hidden:~/tmp/batrick-2014-06-26$
Though a second invocation has nothing to do, and says so:
address@hidden:~/tmp/batrick-2014-06-26$ make -f test.mk foo
make: `foo' is up to date.
address@hidden:~/tmp/batrick-2014-06-26$
-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Patrick Donnelly
Sent: Thursday, June 26, 2014 13:20
To: address@hidden
Subject: Make does not throw an error for target without a recipe?
See example:
---8<---
TARGETS = foo
all: $(TARGETS)
$(TARGETS): /etc/passwd
--->8---
This is the debug output I get from running this test.mk, comments inline:
$ make -f test.mk -d foo
GNU Make 4.0
Built for x86_64-unknown-linux-gnu
Copyright (C) 1988-2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Reading makefile 'test.mk'...
Updating makefiles....
Considering target file 'test.mk'.
Looking for an implicit rule for 'test.mk'.
[...]
Why is it trying to build target test.mk...???
File 'foo' does not exist.
Looking for an implicit rule for 'foo'.
[...]
No implicit rule found for 'foo'.
Considering target file '/etc/passwd'.
Looking for an implicit rule for '/etc/passwd'.
[...]
No implicit rule found for '/etc/passwd'.
Finished prerequisites of target file '/etc/passwd'.
No need to remake target '/etc/passwd'.
Finished prerequisites of target file 'foo'.
Must remake target 'foo'.
Successfully remade target file 'foo'.
make: Nothing to be done for 'foo'.
So the interesting thing here is that Make decides it needs to remake
`foo' but it doesn't do anything (based on strace output). Then it
decides it was successful? That doesn't make any sense... How do I get
Make to fail if it can't make the target? In case it matters, I'm
bringing this problem up because targets are not being created (as
expected) by implicit rules but I don't know this because make claims
success.
Thanks for any help,
--
Patrick Donnelly
_______________________________________________
Bug-make mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/bug-make
Re: Make does not throw an error for target without a recipe?, Paul Smith, 2014/06/26
Re: Make does not throw an error for target without a recipe?, Paul Smith, 2014/06/26