[lug] OT: Makefile oddity

Ken Weinert mc at morat.net
Fri Apr 19 12:13:04 MDT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This might be relevant:

   If an included makefile cannot be found in any of these directories,
a warning message is generated, but it is not an immediately fatal
error; processing of the makefile containing the `include' continues.
Once it has finished reading makefiles, `make' will try to remake any
that are out of date or don't exist.  *Note How Makefiles Are Remade:
Remaking Makefiles.  Only after it has tried to find a way to remake a
makefile and failed, will `make' diagnose the missing makefile as a
fatal error.

   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 is 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 other thing I note (which might just be a typo) is that you said 
${SOMETHING} - this should be $(SOMETHING) and might have something to do 
with make thinking the included makefile is out of date.


On Friday 19 Apr 2002 11:48, you wrote:
> I'm using make from RH 7.1, which is the gnu make. This is supposed to
> support the "include" directive inside of a Makefile, and it seems to do
> this. For example, I can make macro definitions in a Makefile.whatever,
> that does something like give a variable name with a path for something:
> SOMETHING = /somewhere/to/look
>
> Ok, I can later use ${SOMETHING}, even if it is just echo. But, I was
> coming up with problems of dual attempts to build targets in a project
> split into separate directories. So I ran with -d for debug mode. Turns
> out that:
> include Makefile.something
>
>
> ...is doing the right thing, and after that, it is calling "include" a
> target! It then tries to figure out how to build Makefile.something,
> looking for Makefile.c, Makefile.o, Makefile.everything_under_the_sun.
> In its attempt to make the "include" directive an up-to-date target (and
> it isn't a target), it is ending up doing almost everything twice!
> Perhaps I need some sort of dummy rule that will force make to see
> target "include" as always up-to-date? I want to include separate files
> for subdirectory definitions, but I want it to only add definitions, I
> do not want it to end up doing multiple evaluations of everything under
> the mistaken assumption that "include Makefile.whatever" is a target and
> source file. Has anyone here seen this problem before or found a way to
> deal with it?

- -- 
Ken Weinert   mc at morat.net
GnuPG KeyID: 9274F1CE           GnuPG available at http://www.gnupg.org/
GnuPG Key Fingerprint: 1D87 3720 BB77 4489 A928  79D6 F8EC DD76 9274 F1CE
Cannot find REALITY.SYS. Universe halted.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAjzAXjQACgkQ+OzddpJ08c4EeQCgkRtVqaZl+FrC2Dd4+vSTE8k+
ejoAn0GRhEP8/mZa6jeSL6rGP/mNvgmE
=k90v
-----END PGP SIGNATURE-----



More information about the LUG mailing list