[Top][All Lists]

[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 file that
adds to a list of SRC, where each can recursively include more
subdirs files. The problem I'm having is knowing where a
particular file was included from? At the moment I have to convey
this information through setting variables in each 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.


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

  tl> MODDIR := submod2
  tl> include $(MODDIR)/

  tl> ...

  tl> Change to:

  tl> MODDIRS := submod1 submod2
  tl> Some sort of iteration of MODDIRS 
  tl> {
  tl> MODDIR := ${dir}
  tl> include ${dir}/
  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 ...

    MODDIR := $$1
    include $$1/

  $(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:            
 "Please remain calm...I may be mad, but I am a professional." --Mad

Attachment: InterScan_Disclaimer.txt
Description: Text document

reply via email to

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