help-make
[Top][All Lists]
Advanced

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

generating 'object' files in a different to the 'src' directory


From: John Allen
Subject: generating 'object' files in a different to the 'src' directory
Date: Mon, 29 Dec 2003 19:17:15 -0000

Hi,

I have a been experimenting for some time with a makefile architecture that
outputs all generated object files into a different tree to the source tree.

My current system has about 100 distinct targets pretty much all located in
individual directories. The makefiles are reasonable complex in as much as
they are used in a heterogeneous environment (sol/cygwin/linux/win32) and
support the developers by doing most of the laborious work for them; the
developer simply includes the appropriate pre-canned component makefile
(libs,various network server exe types, IDL generations, SOAP generations
etc) and then provide extensions, minor modifications and local component
dependencies such as libs and includes in their top-level makefile.

All good and well. However the only way I have managed to generate object,
lib and exe files into a separate build dir is by providing my own compile,
link and archive commands that add the directory prefix for the build tree
to the target name. Thus the defines:-

define cxx-link-lib
        $(AR) $(AR_FLAGS) $(OBJ_DIR)/$@ $(addprefix $(OBJ_DIR)/,$(notdir
$^))
endef

define cxx-link-exe
        $(LD) $(LD_FLAGS) $(LD_DIRS) $(addprefix $(OBJ_DIR)/,$(notdir $^))
$(LD_LIBS) -o $(OBJ_DIR)/$@
endef

With supporting suffix rule(s):-

.cpp.o:
        @if [ ! -d $(OBJ_DIR) ]; then mkdir -p $(OBJ_DIR); fi
        $(CC) $(CXX_FLAGS) $(CXX_INCLUDES) -c $< -o $(OBJ_DIR)/$@

I find this pretty distasteful, especially the shell test and mkdir command
but a dependency of all object files on $(OBJ_DIR) with a make object dir
rule such as

$(OBJ_DIR):
    mkdir -p $(OBJ_DIR) .

has so far failed on me.

Whats more I am having problems integrating this approach into a make
depends system. mkdeps (the tool im considering at the moment) and other
general make approaches seem to make my approach somewhat unwieldy and
difficult to use.

So finally to my question! Does anyone have any recommendations or examples
of clever ways of doing this. I want to try and get back to using as much of
the implicit and built-in make behaviour as possible and redefining the
commands for compile,archive and link strike me as a kludge.

I have been considering moving the makefile execution to the build tree
itself. Some sort of copy the makefile to the build tree and then run
everything from there approach. I have however failed to get this to
working, my other concern is that the generated sources files (from IDL and
SOAP compilation stages) should probably remain local to the other source
files.

Comments/advice gratefully received!

John

----------------------------------------------------------------------------
John Allen - Technical Project Manager, EuroGamer Network Ltd

p: 01273 382521 m: 07919 222 863
e: address@hidden
Consumer site: http://www.eurogamer.net
Industry site: http://www.gamesindustry.biz
Shop: http://shop.eurogamer.net

This email is copyright of the author and may not be reproduced in whole or
in part or further published in any format without prior permission.





reply via email to

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