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 Mar 5 02:51:27 2010  
Votes:  1  
Severity: 3 - NormalItem Group: Bug
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Component Version: 3.81Operating System: Any
Fixed Release: NoneTriage Status: None

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

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


(Jump to the original submission Jump to the original submission)

Sat Feb 16 00:15:30 2013, 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 Feb 15 23:42:59 2013, 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 Feb 13 16:33:01 2013, comment #7:

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

(file #27456)

dave kerns <dtkerns>
Wed Feb 13 16:30:04 2013, 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 Dec 3 12:22:41 2011, 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 Mar 16 00:20:12 2010, 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 Mar 12 19:08:59 2010, 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 Mar 12 18:46:37 2010, 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 Mar 12 17:53:35 2010, 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 Mar 5 02:51:27 2010, 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 File(s):

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
  • -unavailable- added by ultrajoe (Voted in favor of this item)
  • -unavailable- added by dtkerns (Posted a comment)
  • -unavailable- added by cherriedquat (Posted a comment)
  • -unavailable- added by tahonermann (Posted a comment)
  • -unavailable- added by psmith (Posted a comment)
  • -unavailable- added by hslee9 (Submitted the item)

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

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon Jun 29 18:21:36 2015ultrajoeCarbon-Copy-=>Added ultrajoe
    Wed Feb 13 16:33:01 2013dtkernsAttached File-=>Added Makefile, #27456

    Back to the top

    Powered by Savane 3.1-cleanup1