help-make
[Top][All Lists]
Advanced

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

make Eval function / factoring out analagous rules & variables


From: Alister Shipman
Subject: make Eval function / factoring out analagous rules & variables
Date: Thu, 6 Feb 2003 19:56:57 -0800 (PST)

Hi, 

    I sent this directly to Paul but then realsied
others might answer these enquiries too - so...

I have a single makefile which builds many libraries -
i.e which is organised in part as follows - (in line
with a prior solution provided by Paul)

LIBRARY_LIST = libsl_dbtypes.a libsl_db_types_etc.a

## Db_types
dbtypes_CCSRCS = DataSourceBase.cc DbTypesBase.cc
ObjectName.cc 
dbtypes_CCOBJS = ${dbtypes_CCSRCS:.cc=.o} 
libsl_dbtypes.a : $(dbtypes_CCOBJS) 
VPATH +=
$(WORKAREA)/sl_libdbase,$(LNAME)/sl_libdbase/sl_dbtypes/src

## Db_types_etc
dbtypes_etc_CCSRCS = DataBase.cc DataSource.cc
Station.cc 
dbtypes_etc_CCOBJS = ${dbtypes_etc_CCSRCS:.cc=.o} 
libsl_dbtypes_etc.a : $(dbtypes_etc_CCOBJS)
VPATH +=
$(WORKAREA)/sl_libdbase,$(LNAME)/sl_libdbase/sl_dbtypes_etc/src

$(LIBRARY_LIST):
           $(AR) ARFLAGS $@ $^

- Now considering the analogous nature of the two
pattern matching lines and the two rules lines I would
like to automatically generate these off the library
list - possibly using the eval function ?? ( as per
the example in the gnu documentation). I want the
pattern matching rules because I want to avoid having
to type the .o list and the .cc list. 

- The plot then thickens - for each of these libraries
I wish to be able to supply compiler flags - say:

db_types_CCFLAGS = -g

and have this passed to the compiler. So I really want
to generate more rules, of the form

$(<libraryname>_CCOBJS) : $(<libraryname>_CCSRCS)
        COMPILER_CMND $(<libraryname>_CCFLAGS) -o $@ $^

(I am doing this because I am trying to write all my
rules in a single makefile rather than employing rules
files for each library and employing recursive make)

- So far I try and define these "dynamically"
generated macros by:

define PATTERN_MATCH_MACROS
$(1)_CCOBJS = $${$(1)_CCSRCS:.cc=.o}
endef

$(foreach library, $(LIBRARY_LIST), $(eval $(call
PATTERN_MATCH_MACROS,$(library))))

But when it gets to the rules - even when they are
just typed in (as opposed to generated) i.e 
libsl_dbtypes.a : $(dbtypes_CCOBJS)

it claims there are no pre-requisites for
libsl_dbtypes.a - and when I try an origin call on
dbtypes_CCOBJS it reports it as undefined.

************************************************************************************
I can, as an alternative, just create the rules, and
leave the pattern match macros in for Each library -
but we are talking 160 odd libraries and apps - I
would like to factor out these lines if possible.

It is entirely possible I am again not seeing the
"woods for the trees" again ! But..

When is the eval function evaluated ?
Does using a function (i.e. patsubst aka the pattern
match macro) inside an eval statement work ? Does this
function need to be wrapped inside an eval call itself
? i.e. nested eval calls ? Should I just use the eval
call, as per the example in the gnu manual, to
generate the rules for the .o files and leave the
pattern match macro's in for each library ? 

I hope I've explained this properly, just missed
something in my design and you can point my way back
to K.I.S.S land. Again any help is greatly appreciated
:-)

Alister 

PS: Paul if your answering this although they are sent
from different addresses either is fine to reply to. 

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com




reply via email to

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