help-gnu-utils
[Top][All Lists]
Advanced

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

Re: A Makefile question


From: David Logan
Subject: Re: A Makefile question
Date: Tue, 06 Jul 2004 11:40:01 GMT
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040316

I don't understand the complete problem, I think you are fuzzy in some aspects. But let me see if I can give you some general guidelines that should answer most of your questions.

First, rules are executed in order. If you have one library that needs to go multiple places, let me show you an example of a Makefile that would do that.

I have a library, built in dll/obj. The sources are in dll
The library is then copied to dll/bin.
The library is then copied to application/bin.

Note that none of these steps occur unless it's necessary. To do this:

# Sources needed to build library.f. These sources are in dll/
SOURCES=a.c b.c c.c d.c e.c etc.c

# This rule only checks for lib.f being in the app directory
# Since this is the ultimate goal, this is all we care about in 'all'
all: application/bin/library.f

# This rule "builds" app/bin/lib.f, by copying it from dll/bin.
# The dependency makes sure that dll/bin/lib.f exists first.
application/bin/library.f: dll/bin/library.f
  cp dll/bin/library.f application/bin/library.f

# This rule "builds" dll/bin/lib.f, by copying it from dll/obj.
# The dependency makes sure that dll/obj/lib.f exists first.
dll/bin/library.f: dll/obj/library.f
  cp dll/obj/library.f dll/bin/library.f

# This rule builds dll/obj/lib.f. It will rebuild if any of the
# sources have changed, which will also cause all of the previous
# rules to fire and recopy throughout the tree.
dll/obj/library.f: $(addprefix dll/,$(SOURCES))
  gcc -o dll/obj/library.f $(addprefix dll/,$(SOURCES))

Now, if you want builds to run based on certain things, like user, then your all can contain makefile conditions, and you can recursively call make with more information. Something like so:

all:
ifeq ($(U),djlogan)
        $(MAKE) lib1
else
ifeq ($(U),kat)
        $(MAKE) lib2
endif
endif

lib1: dll/bin/lib1.f
lib2: dll/bin/lib2.f

etc.

David Logan

zuheyr wrote:
Hello.

I am using GNU make. I want to find a good solution to the following:

There is a main directory with sources and this is the manager directory.
There are different users which have different applications, a copy of
library_users.f which differes for everybody. There are say 5-6 such
applications.

In the manager directory there are different libraries for each
applications.
The manager compiles the files in the manager directory. But depending on
which user will link afterwards he has to choose a library.

Each user has to compile his copy of library_users.f and link with the
objects
in the main (manager) directory.
The problem is once the manager compiles the objects in the manager
directory, for a given application by using a library specific to that
application,
if any other user tries to compile and link his sources. It will link with
the wrong objects.

I also want to save the objects created in the manager directory for a given
application
into a subdirectory.

I tried separating the targets for each application and put copy_to and
copy_from commands:

wing:   $(RADIALGEO) $(MULTI) $(PEN) $(PERTURB) $(GA) $(MAKEDB)  \
 $(WING_GEO)  $(GA2ANN) $(READ_DB) $(WGAIN) $(EVAL_DOE) select copy_from
copy_to

But I cannot specify the order they are executed. It copies_from, correctly,
but then copies_back before
the builts are made.

Can you please help me?

Many thanks and best regards.





reply via email to

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