bugmake - Bugs: bug #29074, -include target fails to issue...


bug #29074: -include target fails to issue Error in 3.81

Submitted by:  Hack Lee <hslee9>
Submitted on:  Fri 05 Mar 2010 02:51:27 AM UTC  
Votes:  1  
Severity:  3 - Normal Item Group:  Bug
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  3.81 Operating System:  Any
Fixed Release:  None Triage Status:  None

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Sat 16 Feb 2013 12:15:30 AM UTC, comment #9:

I thought I'd take a look at the source, so I did a git clone, the INSTALL doc says to do the "standard" ./configure; make ... there is no file configure, there is a configure.bat, what am I missing?

dave kerns <dtkerns>
Fri 15 Feb 2013 11:42:59 PM UTC, comment #8:

one more data point, from the gcc man page:

-MP This option instructs CPP to add a phony target for each dependency other than the main file, causing each to
depend on nothing. These dummy rules work around errors make gives if you remove header files without
updating the Makefile to match.

This is typical output:

test.o: test.c test.h


gcc devs thought it was a make bug too, so they added the -MP option

dave kerns <dtkerns>
Wed 13 Feb 2013 04:33:01 PM UTC, comment #7:

well drat, all of my backslashes got eaten ... I'll attach the Makefile

(file #27456)

dave kerns <dtkerns>
Wed 13 Feb 2013 04:30:04 PM UTC, comment #6:

I have a slight variation of this "bug"; when the included file (included with the -include) runs into a rule problem, make silently stops and does nothing. I argue it should give the same error that it does without the "-".

this make file will demonstrate the issue:

to test, do this:

$ make fix # restores all files
$ make # builds correctly
$ make break # remove .h file
$ make # demonstrates silent failure
$ make PRE381=1 # demonstrates desired failure message

<code save_as=Makefile>

all: app

app: x.o
$(CC) -o $@ $<

%.d: %.c
$(CC) -MM $< | sed -e 's,\($*\).o[ :]*,\1.o $@ : ,g' > $@; test $$? != 0 && $(RM) $@

$(RM) x.o app

clobber: clean
$(RM) x.?

break: clean
$(RM) x.h

fix: clobber x.c
touch x.h

@echo making $@
@printf "#include <stdio.h>\n#include <stdlib.h>\n\n#include \"x.h\"\n\nint main(int argc, char **argv)\n{\n\tprintf(\"hello world\\\\n\");\n}" > x.c

ifneq ($(filter-out fix clean clobber,$(or $(MAKECMDGOALS),all)),)
ifeq ($(PRE381),1)
$(info using include)
include x.d
$(info using -include)
-include x.d


dave kerns <dtkerns>
Sat 03 Dec 2011 12:22:41 PM UTC, comment #5:

I agree with Hack Lee.

There was a bug before 3.81.

You wouldn't want make to fall over on an
-include $(sources:%.c=%.d)
in the Makefile because of a source error when you're actually running
make clean

The behavior of GNUmake 3.81 is correct.

Christian Hujer <cherriedquat>
Tue 16 Mar 2010 12:20:12 AM UTC, comment #4:

Reply to Paul Smith,

So there was a bug before 3.81, since they issued an Error in this case. And the bug was fixed in 3.81. Is that what you are saying?

include done
=> is looking for a file named done and fails since no file named done.

-include done
=> is building a target called done (if no file is found).

Hack Lee <hslee9>
Fri 12 Mar 2010 07:08:59 PM UTC, comment #3:

Quoting from the make 3.81 manual:

If you want `make' to simply ignore a makefile which does not exist and cannot be remade, with no error message, use the `-include' directive instead of `include', like this:

-include FILENAMES...

This acts like `include' in every way except that there is no error (not even a warning) if any of the FILENAMES do not exist. For compatibility with some other `make' implementations, `sinclude' is another name for `-include'.

The "and cannot be remade" statement could be interpreted in several ways:
1: No rule exists for building the include target.
2: No rule exists for building the include target, or the target rule failed.

I do think it would be useful to have a syntax that supports ignoring include files that do not exist and which have no target rules for building them but which does issue an error if an attempt to rebuild them fails. I would argue that this is typically the desired behavior (and apparently the historical behavior prior to version 3.81).

Tom Honermann <tahonermann>
Fri 12 Mar 2010 06:46:37 PM UTC, comment #2:

The reason you see this is that make will automatically try to rebuild every file that it includes. Here you include "done", and "done" is out of date, so make tries to rebuild it before it is included.

But, the rebuild of "done" fails.

But, you have indicated, by using "-include", that you want to not issue an error if "done" does not exist, so no error is issued.

If you want make to fail when done cannot be built, then you should use "include" instead of "-include".

Paul D. Smith <psmith>
Project Administrator
Fri 12 Mar 2010 05:53:35 PM UTC, comment #1:

It was ok (meaning correctly issue an Error) until 3.81beta1.

We scratched our head wondering why the makefile would not give an error even though there is clearly an error. So it is not backward compatible and we need this to be fixed in 3.81.
Would it be possible to suggest a change in the source code so that we can modify 3.81 for our build system?

@exit 0
@echo $(MAKE_VERSION); exit 1
-include done

make-3.79.1: *** [done] Error 1

make-3.80: *** [done] Error 1

make-3.81b1: *** [done] Error 1




Hack Lee <hslee9>
Fri 05 Mar 2010 02:51:27 AM UTC, original submission:

Before 3.81, make issues Error correctly.

exit 1

exit 1

-include done

Hack Lee <hslee9>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #27456:  Makefile added by dtkerns (600B - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by ultrajoe (Voted in favor of this item)
  • -email is unavailable- added by dtkerns (Posted a comment)
  • -email is unavailable- added by cherriedquat (Posted a comment)
  • -email is unavailable- added by tahonermann (Posted a comment)
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by hslee9 (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 1 encouragement so far.

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-29 ultrajoe Carbon-Copy- => Added ultrajoe
    2013-02-13 dtkerns Attached File- => Added Makefile, #27456

    Back to the top

    Powered by Savane 3.3