bug-make
[Top][All Lists]
Advanced

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

Re: include instruction question


From: Paul D. Smith
Subject: Re: include instruction question
Date: Thu, 17 Jan 2002 15:15:17 -0500

%% Kovalevich Victor <address@hidden> writes:

  kv> <html>
  kv> <head>
  kv> </head>
  kv> <body>

Please don't send HTML to the mailing lists; plain text is just fine.
Thanks!

  kv> Hi!<br>
  kv> I have one question: can I use 'include' instruction in a make file that
  kv> is included by this instruction in an other make file. For example:<br>
  kv> <br>
  kv> <b>~/dir1/Makefile.inc:<br>
  kv> </b><br>
  kv> <i>#<br>
  kv> # ~/dir1/Makefile.inc file body<br>
  kv> ROOT=${HOME}<br>
  kv> </i><br>
  kv> <b>~/dir1</b><i>/</i><b>dir2/Makefile.inc:<br>
  kv> </b><br>
  kv> <i>#<br>
  kv>  # ~/dir1/dir2/Makefile.inc file body<br>
  kv> include ../Makefile.inc<br>
  kv> </i><br>
  kv> <b>~/dir1/dir2/dir3/makefile:<br>
  kv> </b><br>
  kv> <i>#<br>
  kv>   # ~/dir1/dir2/dir3/makefile file body<br>
  kv>  include ../Makefile.inc<br>
  kv> usage:<br>
  kv> &nbsp;&nbsp;&nbsp; @ echo Root directory is ${ROOT}<br>
  kv> &nbsp;</i><br>
  kv> when I launched make process in ~/dir/dir2/dir2 directory I got following
  kv> messages:<br>
  kv> <br>
  kv> ../Makefile.inc:3: ../Makefile.inc: Too many open files<br>
  kv> Root directory is<br>
  kv> <br>
  kv> that means ROOT variable was not defined. Is there a defect of
  kv> make or did I do any mistake ? Unfortunately I did not find any
  kv> information about restriction of 'include' instruction usage in
  kv> make documentation. Can anyone explain me this effect?

There is no restriction on the include instruction and recursion.

The problem is that you are thinking that each makefile includes files
relative to where the makefile is.  That's not how it works: each
include is made relative to the directory make was invoked in.

So, in dir1/dir2/Makefile when you say "include ../Makefile.inc", if you
run that from dir1/dir2/dir3 then you'll include dir1/dir2/Makefile.inc,
_NOT_ (as you apparently want) dir1/Makefile.inc.

The "too many open files" error is a hint: make is recursively opening
the same makefile over and over again until it runs out of file
descriptors.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "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]