how to pass macro definition from parent makefile to child makefile

  • Follow


Hi,

I need to write 2 makefile, say a.mk and b.mk. 'a.mk' is the main entrance,
and the macros are set in it. Some rules are defined in b.mk. For example,
the rules for TargetB.

#a.mk
CFG = Release
TargetB:
    $(MAKE) -f b.mk $@

#b.mk
TargetB:
    $(BLD_CMD)

But I want to pass $CFG from a.mk to b.mk. How to do this?

Thanks,
Liang





0
Reply Liang 7/20/2004 5:07:04 AM

Liang <leo2002chen@hotmail.com> wrote:
> I need to write 2 makefile, say a.mk and b.mk. 'a.mk' is the main entrance,
> and the macros are set in it. Some rules are defined in b.mk. For example,
> the rules for TargetB.

> #a.mk
> CFG = Release
> TargetB:
>     $(MAKE) -f b.mk $@

> #b.mk
> TargetB:
>     $(BLD_CMD)

> But I want to pass $CFG from a.mk to b.mk. How to do this?

Add a line like 

export CFG

or, putting assignment and exporting in a single line,

export CFG = Release

to a.mk, then it becomes visible in sub-makefiles

                                     Regards, Jens
-- 
  \   Jens Thoms Toerring  ___  Jens.Toerring@physik.fu-berlin.de
   \__________________________  http://www.toerring.de
0
Reply Jens 7/20/2004 7:47:54 AM


1 Replies
602 Views

(page loaded in 0.017 seconds)

Similiar Articles:





7/20/2012 9:32:42 PM


Reply: