[Top][All Lists]

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

Re: some (trivial) observations on multi-arch builds

From: David Greene
Subject: Re: some (trivial) observations on multi-arch builds
Date: Fri, 12 May 2006 15:08:07 -0500
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.7.8) Gecko/20050512

Robert P. J. Day wrote:

>   for example, let's say the source directory has a local "include/"
> directory and gcc was originally invoked with "-I./include".  that
> will work fine if you're running in the source directory itself but
> will fail badly elsewhere.  in a case like that, it seems clear that
> your rule commands might need to incorporate a reference to ${SRCDIR}
> because vpath won't help you with things like compiler options.

That's correct, AFAIK.  At least, that's what I do.

>   as a simpler example, let's say i just wanted to collect a list of
> all of the source files in the directory.  originally, i might have
> just written:
>   SRCS := $(wildcard *.c)
> now, however, i have to be careful to write something like:
>   SRCS := $(wildcard ${SRCDIR}/*.c)

Also true, AFAIK.

I have a follow-up to your question about multi-arch and recursive

In my project, there are a number of source directories that contain
the code for various modules.  Some of these modules are program
drivers (i.e. the "main" routines) while others are program-specific
libraries and still others are shared components referenced by two
or more other modules.

Due to the shared component pieces, I've been reluctant to use
recursive make.  Building in parallel is commonplace here and I
don't want to create race conditions between separate recursive
invocations of make for the shared components.

I read "Recursive Make Considered Harmful" some time ago but
confess to having forgotten the details of when it is and is not
a problem.

To be on the safe side, rather than using recursive make, I simply
have the top-level Makefile include .mk files from each top-level
subdirectory which in turn may include .mk files to specify rules
for building components in deeper directories.  In effect, I get
one huge Makefile out that contains every single rule and dependency
to build everything.

This seems to be working rather well so far.  The only tricky part
has to do with specifying sources.  Because I don't actually
recurse into deeper source directories, I do this:

  SRCS := $(subst $(SRCDIR)/,,$(wildcard $(SRCDIR/$(module_dir)/*.c))

Then I only need to define VPATH once and $(SRCDIR) doesn't get
"hard-coded" into the dependency lists.

An alternative would be to use target-specific definitions of
VPATH and add $(module_dir)/ to the subst match string.

Any thoughts on this setup?  I am being overly paranoid concerning
recursive make?


reply via email to

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