help-make
[Top][All Lists]
Advanced

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

Re: Problems with eval


From: Ronald Landheer-Cieslak
Subject: Re: Problems with eval
Date: Wed, 29 Sep 2004 15:27:36 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910

Greg Kilfoyle wrote:
I have a make file environment which builds objects, shared libraries
and executable programs, using a non-recursive top-level make, following
suggestions from Peter Miller's paper and Emile van Bergen's examples.

When a make file for a program is included, a variable is created which
lists the libraries that the program is dependent on. When a make file
for a library is included, a variable is created which lists any other
libraries that this library is dependent on.

These variables are used to define dependency information for make, but
also to allow a list of '-l<lib>' options to be constructed for the
final link step (for the program).
I have about the same approach for inter-dependant libraries in Jail's Makefile, which is here: http://tinyurl.com/69dyf

Basically, I have a module.mk file in each of the library's directories that adds to a <library_name>_SRC variable. I transform that to a set of object files like this:

# determine the object files
define OBJ_template
$(1)_OBJ :=     $$(patsubst %.c,$(1)/%.lo,$$(filter %.c,$$($(1)_SRC))) \
                $$(patsubst %.y,$(1)/%.lo,$$(filter %.y,$$($(1)_SRC))) \
                $$(patsubst %.cc,$(1)/%.lo,$$(filter %.cc,$$($(1)_SRC))) \
                $$(patsubst %.l,$(1)/%.lo,$$(filter %.l,$$($(1)_SRC)))
OBJ += $$($(1)_OBJ)
endef
$(foreach mod,$(MODULES),$(eval $(call OBJ_template,$(mod))))

and define inter-library dependencies in a separate link.mk file. The link.mk file (generated by a bootstrap script) contains an entry for each library I can make:

libreplace.la : $(libreplace_OBJ)
        $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $^

libarch.la : $(arch_OBJ)
        $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $^

libmemory.la : $(libmemory_OBJ) libarch.la
        $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $^

libcontain.la : $(libcontain_OBJ) libmemory.la libarch.la
        $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $^

libconf.la : $(libconf_OBJ) libcontain.la libmemory.la libarch.la
        $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $^

libthread.la : $(libthread_OBJ) libmemory.la libarch.la
        $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $^

Which ones are actually compiled depends on my real_all target,
real_all : $(patsubst %,%.la,$(LTLIBRARIES))
in which LTLIBRARIES depends on the directories found by the bootstrap script.

This works for me: all I have to do to compile is
$ bash bootstrap
$ mkdir .build
$ cd .build
$ ../configure
$ make

The bootstrap scripts takes care of generating the link.mk file and fills in some of the gaps in Makefile.in.in; configure converts Makefile.in (generated from Makefile.in.in by bootstrap) to Makefile filling in the last gaps..

I could probably add the inter-library dependencies to a <library_name>_DEPS variable in the module.mk files and have the link.mk file simply contain <library_name>.la : $(<library_name>_OBJ) $(<library_name>_DEPS), in which case I probably wouldn't need a link.mk file anymore (as an $(eval) could create that part too) but I haven't pushed it that far yet..

HTH

rlc





reply via email to

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