help-make
[Top][All Lists]
Advanced

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

Re: executing make in a different directory from a Makefile


From: Paul D. Smith
Subject: Re: executing make in a different directory from a Makefile
Date: Mon, 1 Aug 2005 14:51:29 -0400

%% Ravi Parimi <address@hidden> writes:

  rp> I even tried with $(MAKE) but still cannot get make to work. 

$(MAKE) is what you always want to use, regardless of whether or not it
impacts this particular issue.
 
  >> If you want EVERYTHING to be exported you can use the "export"
  >> command by itself with no arguments.  See the GNU make manual.

  rp> Maybe I was not clear on what I wanted to do earlier

Indeed: it wasn't clear to me at all.

  rp> I do not want to pass variables in the current Makefile
  rp> (tests/Makefile) to be availble to the make process being
  rp> invoked. My problem is that the sub make is not able to read some
  rp> of the variables declared in the Makefile.  For e.g
  rp> /opt/src/main/build/Makefile has a variable called DEFAULT_ARCH :=
  rp> x86 Now I invoke make fomr /opt/src/main/tests/Makefile like this:

  rp>  build:
  rp>         cd ../build;$(MAKE) PRODUCT=server OBJDIR=obj host

  rp> I get the following warning saying:
  rp> WARNING: ARCH should be set at top-level, defaulting to x86

How is this printed?  If the test is happening in the shell remember
that you have to export any variable that you want to be passed to a
sub-process, INCLUDING the shell.  Also remember that exported variables
are not passed to $(shell ...) functions.

  rp> From the above, I can only assume that the variables in
  rp> build/Makefile are not being read.

Assuming I've understood what you're talking about this time, your
assumption is quite incorrect.  All variables set in the build/Makefile
will be read when make is invoked in that directory.

One of these is true: (a) I'm still not understanding what you mean, or
(b) there is something important about these makefiles or the way you're
invoking make that you haven't stated in your email, (c) your test that
shows the warning message above is incorrect, and/or (d) you are
misinterpreting the output of make.


There are many ways to proceed from here.  One is that you could create
a small example that shows the problem you're seeing and post it to the
list; that will go a long way towards helping us understand the actual
issue.

Another is you could debug this; typically people use $(warning ...)
etc. functions to determine what the values of variables are at various
points during the read-in of the makefile.  If a variable you set in the
makefile doesn't have the value you expected then it means it's being
overridden somehow: either on the make command line, or through the
environment if you use the "-e" option to make.  You can use the
$(origin ...) function to find out where a variable came from.  Finally,
you can use the -p option to force make to print out its database,
although it only prints the final state so this might not help.

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