Makefile newbie question - Embedded

This is a discussion on Makefile newbie question - Embedded ; Hi, I've a Makefile that looks like this: ARCH = ppc all: linux app linux: cd linux && $(MAKE) My Q is, does this mean that 'ARCH = ppc' flag is passed to the make in linux or not? If ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Makefile newbie question

  1. Makefile newbie question

    Hi,
    I've a Makefile that looks like this:
    ARCH = ppc
    all: linux app
    linux:
    cd linux && $(MAKE)

    My Q is, does this mean that 'ARCH = ppc' flag is passed to the make in
    linux or not? If not, how do I pass it (short of putting $(MAKE)
    $(MAKEFLAGS) or $(MAKE) ARCH=ppc in the rule for 'linux'?)
    I believe $(MAKE) $(MAKEFLAGS) is the wrong construction since it
    translates to 'make -w'. My point is, if user doesn't put any 'ARCH='
    argument while invoking the top-level make, how do I pass ARCH=ppc flag
    to the make in the linux subdirectory?


  2. Re: Makefile newbie question



    knighttof3@yahoo.com wrote:
    > Hi,
    > I've a Makefile that looks like this:
    > ARCH = ppc
    > all: linux app
    > linux:
    > cd linux && $(MAKE)
    >
    > My Q is, does this mean that 'ARCH = ppc' flag is passed to the make in
    > linux or not? If not, how do I pass it (short of putting $(MAKE)
    > $(MAKEFLAGS) or $(MAKE) ARCH=ppc in the rule for 'linux'?)
    > I believe $(MAKE) $(MAKEFLAGS) is the wrong construction since it
    > translates to 'make -w'. My point is, if user doesn't put any 'ARCH='
    > argument while invoking the top-level make, how do I pass ARCH=ppc flag
    > to the make in the linux subdirectory?


    cd linux && ARCH=$(ARCH) $(MAKE)

    will work, to be thorough you ought to check that ARCH has been defined
    beforehand

    ifndef ARCH
    #default
    ARCH = ppc
    endif

    linux:
    cd linux && ARCH=$(ARCH) $(MAKE)

    Tom


+ Reply to Thread