Make: Variables expansion in recursive make

From: Fabrice Gautier (droopycom_at_yahoo.com)
Date: 01/22/04


Date: 22 Jan 2004 04:07:12 -0800

Hi,

I have some trouble understanding how make expand variables when
passing trhough the environment (recursive make case).
Here is my situation:

  I have a first makefile that declares a INCLUDE variable

$(INCLUDES)= -I$(@D)
export INCLUDES

  and a target that calls a recursive make like this

libgcc: some_deps
    echo $@ --- $(@D) --- $(INCLUDES)
    $(MAKE) MAKEOVERRIDES= -f libgcc.mk

  The second makefile (libgcc.mk) have some targets like this:

libgcc/./_foo.o: some deps
    echo $@ --- $(@D) --- $(INCLUDES)
    $(GCC) $(INCLUDES) foo bar

So when running the first makefile, for the libgcc target, the echo
shows:
  echo libgcc --- . --- -I.
which is what I expect.

When running the second Makefile, the echo in the libgcc target shows:
  echo libgcc/./_foo.o --- libgcc/. --- -I

which will eventually make the build fail because -I is not a valid
flag for gcc.

I'm assuming that in this case the INCLUDES variable was expanded when
calling the second make. Am i correct here? If i am, then i dont
understand why include was received as "-I" instead of "-I." in the
second makefile.

I understand that $(@D) should expand to the directory part of the
target filename (ie $@). Some test showed that if $@ is of the form
"/filename" then the $(@D) will be empty. If theres no dir in $@ then
$(@D) is just ".". Otherwise its the directory name.

As you can imagine, this happens while compiling gcc, so this should
work in many case, but i'm trying to understand why not in this one
(which is cross compiling gcc for an arm-elf target on a mingw32 host)

Any suggestion?

Thanks

-- Fab.



Relevant Pages

  • Re: [9fans] plan9 httpd/pegasus on unix?
    ... I've got to maintain a several hundred packages for our emedded target ... > - Makefile dependencies only work with the timestamps on files. ... "make clean" after changing toolchain settings should be obvoius. ... >>> you're running qmail on the host and really can't afford to stop it ...
    (comp.os.plan9)
  • Re: Strange behavior with Make dependencies...
    ... later than the bootsect.MBR's and run the target if so... ... This is an unreliable workaround. ... timestamp does not reflect all changes to files inside it - it will ... Makefile should not need to know anything about how the file is ...
    (comp.unix.programmer)
  • Re: Compiling 64-bit Tcl/Tk8.4.19 with Sun Studio 12.1 Failed due to syntax error!!
    ... line is 832, target is tkTheme.o). ... I have to figure out how to tweak your environment ... I notice in your msg that the -I flag order at the compile ... Take a look in the Makefile to see where the $is used. ...
    (comp.lang.tcl)
  • ANN: GNU Make based linking system for CLISP images.
    ... I've written a replacement for nearly the entire functionality of the ... intermediate and final target objects. ... directory structure must be set up, and no link.sh script is required. ... The makefile finds ...
    (comp.lang.lisp)
  • Re: Multiple devices within one ISE project
    ... A makefile for this build can be a fairly good answer with dual core ... Using make doesn't prevent one from using a Tcl scriptfor the actual ... checks to see that the target is newer than the sources. ... xtclsh is the Xilinx Tcl shell, used to execute the script. ...
    (comp.arch.fpga)