Re: [SYSTEM-LINUX] Compiler obj files.

From: Mike Stilson (mike@velgarian.sytes.net)
Date: 09/15/02


On Sat, Sep 14, 2002 at 12:36:18AM -0400, Justin Adler wrote:
>Hello Circlemud guru's.
>
>   Is there any possible way to modify the stock circlemud MAKEFILE, so
>all the obj files are NOT created in the ../circle/src directory, but
>maybe into ../circle/bin/obj  or somewhere else? and when it makes the
>executable, it already ~knows~ where all the .obj files are?
>
>   Thanks in advance to any help.

I did this long ago, and don't use makefile.in for changes (bad, bad
me.).  both inc files and obj files go in their own dirs.

Here's part of my makefile that handles the obj file stuff though.
(I'll give ya probably more than you need, my makefile and stock's have
very little in common anymore.)

This might be more work than I really needed to do, but it works fine
and has been portable w/o modification for all my coders over the time.

You should probably be able to figure what goes where.


[--- >8 cut here 8< ---]
OBJ_DIR = $(SRC_DIR)/o

#
# The list of source files to compile.
#
SRC =  [ ... a list of all of the source files you want to compile ... ]
# You can generate this real quick by just doing a "s/\.o/.c/g" on the
# obj files.

# And I sort them just to make progress a little easier to keep track
# of.
SRC_FILES = $(sort $(SRC))

OBJ_FILES := $(patsubst %.c,$(OBJ_DIR)/%.o,$(SRC_FILES))

# with the number of compiler flags and dir paths and stuff, each file
# being compiled was starting to take up QUITE a lot of screen space.
# Warnings are still output, just not the compile directive.
$(OBJ_DIR)/%.o: %.c
        @echo "Compiling $<"
        @$(CCACHE) $(CC) $(CFLAGS) $(PROFILE) $< -o $@

$(BIN_DIR)/circle:      $(OBJ_FILES)
        $(MAKE) $(BIN_DIR)/circle

#
# The ugly little mess with the perl is so we can put the obj files in a different
# subdirectory to keep things neat.  The subst() is in case OBJ_DIR contains a / in the path.
#
depend deps .depend:
        @echo "Generating dependency file."
        @$(CC) -MM -Ih $(SRC_FILES) > .depend
        @$(PERL) -i -p -e 's/([^ ]+):/$(subst /,\/,$(OBJ_DIR))\/\1\:/g' .depend


-include .depend

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT