help-make
[Top][All Lists]
Advanced

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

Re: Question regarding multiple implicit targets


From: Todd Showalter
Subject: Re: Question regarding multiple implicit targets
Date: Fri, 30 Jul 2010 01:43:55 -0400

On Thu, Jul 29, 2010 at 6:38 AM, FloofLeBo <address@hidden> wrote:

> I am currently writing a Makefile which should work in several projects with
> minimal edits.
>
> What I want is that within the Makefile of particular project we find:
>
>
> SRC_DIRS  := Src0 Src1
> CPP_FILES := $(foreach SRC_DIR,$(SRC_DIRS),$(shell find $(SRC_DIR) -name
> "*.cpp"))
>
>
> And then a set of implicit rules generated by a foreach command:
>
>
> $(foreach, SRC_DIR,$(SRC_DIRS),\
> $(OBJDIR)/%.o : $(SRC_DIR)/%.cpp\
>        ${Q}${CPP} -o $@ $^\
> )

    Are you sure that's what you want?  It means that any code sitting
in that directory is implicitly a live part of the project and
therefore must compile and neither break nor conflict with anything.
Personally, I've found it better to have (in each code directory) a
file containing a list of the valid source files in that directory.
You can then grab those and stitch them together into a master build
list fairly easily.

    One advantage of the list is that it makes things play much more
nicely with version control; the list can be version controlled too,
and it means source files don't have to be moved around to change the
active sources in the build.  It's just a matter of commenting out the
files you don't want in the list.

    For extra points, one can institute per-architecture lists to do
platform-specific builds.

                                                    Todd.

-- 
 Todd Showalter, President,
 Electron Jump Games, Inc.



reply via email to

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