help-make
[Top][All Lists]
Advanced

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

RE: Macros and include?


From: timothy . llewellynn
Subject: RE: Macros and include?
Date: Wed, 23 Apr 2003 15:39:58 +0200

Hi Paul,

Yes I've looked at the eval function and it will probably work, thou
upgrading to 3.80 is sadly not an option, we are using 3.79.

Basically I have a list of subdirs that each contain a module.mk file that
adds to a list of SRC, where each module.mk can recursively include more
subdirs module.mk files. The problem I'm having is knowing where a
particular module.mk file was included from? At the moment I have to convey
this information through setting variables in each module.mk file, which is
becoming a bit cubersome. It would be nice if when a file was included using
the include directive, make would let that file know where it was included
from, this way I wouldn't have to manually keep track of the directory
hirechery. Just an idea.

Thanks,
Tim

-----Original Message-----
From: Paul D. Smith [mailto:address@hidden 
Sent: mercredi, 23. avril 2003 15:23
To: address@hidden
Cc: address@hidden
Subject: Re: Macros and include?


%% address@hidden writes:

  tl> I have a small problem that I'm trying to solve. I'd like somehow
  tl> to reduce the following include statements in make to some sort of
  tl> loop, e.g

  tl> MODDIR := submod1
  tl> include $(MODDIR)/module.mk

  tl> MODDIR := submod2
  tl> include $(MODDIR)/module.mk

  tl> ...

  tl> Change to:

  tl> MODDIRS := submod1 submod2
  tl> Some sort of iteration of MODDIRS 
  tl> {
  tl> MODDIR := ${dir}
  tl> include ${dir}/module.mk
  tl> }

  tl> Does anyone know how to do this, or if its possible? 

It's not possible using "traditional" make constructs.

If you get GNU make 3.80 you can use the $(eval ...) function to do it,
something like:

  MODDIR_LIST = submod1 submod2 ...

  define INCLUDE_MODDIR
    MODDIR := $$1
    include $$1/module.mk
  endef

  $(foreach D,$(MODDIR_LIST),$(eval $(call INCLUDE_MODDIR,$D)))

or something like that; I didn't actually try the above so it might not be
quite right in the quoting, etc.

Also note that there are a few bugs in eval in 3.80; these have been fixed
in the source and will be available in the next version of GNU make.

-- 
----------------------------------------------------------------------------
---
 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

Attachment: InterScan_Disclaimer.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]