[Top][All Lists]

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

Re: help needed on include and -I

From: Paul D. Smith
Subject: Re: help needed on include and -I
Date: Mon, 18 Apr 2005 11:49:18 -0400

%% "Martin Mensch" <address@hidden> writes:

  mm> --include-dir <pathname>       => makefile preprocessor error
  mm> -I <pathname>       => makefile preprocessor error
  mm> --include-dir = <pathname>     => no effect
  mm> -I = <pathname>   => no effect


You can't just put flags into your makefile.  All lines in the makefile
must be valid makefile lines as defined by the syntax in the GNU make

The first two are invalid syntax; the second two are setting variables
named "--include-dir" and "-I" respectively, but those variables don't
mean anything to make.

  mm> I also specified the path inside include but I want to include
  mm> dependecy files and if they don't exist I want them to be created
  mm> by the rule. But if a path is specified with the filename I always
  mm> get an error "no rule for target <pathname>/file.d

  mm> The rule is defined like this:
  mm> %.d: %.c
  mm>       @$(CC) -M -MP -MF $(OBJDIR)$(notdir $@) $(ALL_CFLAGS) $< 

This is invalid.  You are defining a rule to build "xxx.d" from "xxx.c",
but your rule doesn't build "xxx.d", instead it builds "$(OBJDIR)/xxx.d"
which is not the same thing at all.  Please see the "Rules of Makefiles"
on my site below.  When writing a (non-PHONY) rule it MUST create the
target make expects, and the target make expects is kept in "$@".  Your
rule must always create exactly "$@", not some different file that may
contain part of "$@".

If you rewrite your rule like this:

 $(OBJDIR)/%.d: %.c
       @$(CC) -M -MP -MF $@ $(ALL_CFLAGS) $< 

then you can do this:

    include $(OBJDIR)/foo.d

etc. and it will work.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

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