From 5e7af308c146e5f65a87f61d0bead8017047720b Mon Sep 17 00:00:00 2001 From: nikoli Date: Fri, 26 Jul 2013 04:27:29 +0000 Subject: [PATCH] Build in subdirs Now this command works fine: make cl-debug sdl-release sv-release-profile -j9 git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11980 d7cf8633-e32d-0410-b094-e92efae38249 --- .gitignore | 1 + BSDmakefile | 10 ++++++++-- makefile | 10 ++++++++-- makefile.inc | 21 ++++++++++++++++----- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index de9a5adf..047e418e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +obj/ *.d *.o *.i diff --git a/BSDmakefile b/BSDmakefile index 8293e46c..74496edc 100644 --- a/BSDmakefile +++ b/BSDmakefile @@ -7,8 +7,14 @@ DP_MAKE_TARGET=bsd .endif DP_ARCH != uname -# Command used to delete files + +# Makefile name +MAKEFILE=BSDmakefile + +# Commands CMD_RM=$(CMD_UNIXRM) +CMD_CP=$(CMD_UNIXCP) +CMD_MKDIR=$(CMD_UNIXMKDIR) # default targets TARGETS_DEBUG=sv-debug cl-debug sdl-debug @@ -132,7 +138,7 @@ CFLAGS_PRELOAD=$(CFLAGS_UNIX_PRELOAD) MAKE:=$(MAKE) -f BSDmakefile -DO_LD=$(CC) -o $@ $> $(LDFLAGS) +DO_LD=$(CC) -o ../../../$@ $> $(LDFLAGS) ##### Definitions shared by all makefiles ##### diff --git a/makefile b/makefile index 920a9e84..1469f7e7 100644 --- a/makefile +++ b/makefile @@ -32,12 +32,18 @@ ifneq ($(DP_MAKE_TARGET), mingw) DP_MACHINE:=$(shell uname -m) endif +# Makefile name +MAKEFILE=makefile -# Command used to delete files +# Commands ifdef windir CMD_RM=del + CMD_CP=copy /y + CMD_MKDIR=mkdir else CMD_RM=$(CMD_UNIXRM) + CMD_CP=$(CMD_UNIXCP) + CMD_MKDIR=$(CMD_UNIXMKDIR) endif # 64bits AMD CPUs use another lib directory @@ -355,7 +361,7 @@ endif ##### GNU Make specific definitions ##### -DO_LD=$(CC) -o $@ $^ $(LDFLAGS) +DO_LD=$(CC) -o ../../../$@ $^ $(LDFLAGS) ##### Definitions shared by all makefiles ##### diff --git a/makefile.inc b/makefile.inc index 72d1856a..700f0cde 100644 --- a/makefile.inc +++ b/makefile.inc @@ -171,7 +171,7 @@ OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o thread_sdl.o $(OBJ_SND_COMMON) snd_sdl. # Compilation -CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) $(CFLAGS_WARNINGS) $(CFLAGS_LIBZ) $(CFLAGS_LIBJPEG) $(CFLAGS_D3D) -D_FILE_OFFSET_BITS=64 -D__KERNEL_STRICT_NAMES +CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) $(CFLAGS_WARNINGS) $(CFLAGS_LIBZ) $(CFLAGS_LIBJPEG) $(CFLAGS_D3D) -D_FILE_OFFSET_BITS=64 -D__KERNEL_STRICT_NAMES -I../../../ CFLAGS_DEBUG=-ggdb CFLAGS_PROFILE=-g -pg -ggdb -fprofile-arcs CFLAGS_RELEASE= @@ -218,6 +218,8 @@ EXE_UNIXSVNEXUIZ=nexuiz-dedicated EXE_UNIXSDLNEXUIZ=nexuiz-sdl CMD_UNIXRM=rm -rf +CMD_UNIXCP=cp -f +CMD_UNIXMKDIR=mkdir -p ##### Linux specific variables ##### @@ -297,6 +299,7 @@ EXE_WINCLNEXUIZ=nexuiz.exe EXE_WINSVNEXUIZ=nexuiz-dedicated.exe EXE_WINSDLNEXUIZ=nexuiz-sdl.exe +VPATH := ../../../ ##### Commands ##### @@ -435,7 +438,8 @@ bin-debug : $(CHECKLEVEL1) @echo @echo "========== $(EXE) (debug) ==========" - $(MAKE) $(EXE) \ + $(MAKE) prepare BUILD_DIR=obj/debug/$(EXE) + $(MAKE) -C obj/debug/$(EXE) -f ../../../$(MAKEFILE) $(EXE) \ DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \ CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\ LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)" LEVEL=2 @@ -444,7 +448,8 @@ bin-profile : $(CHECKLEVEL1) @echo @echo "========== $(EXE) (profile) ==========" - $(MAKE) $(EXE) \ + $(MAKE) prepare BUILD_DIR=obj/profile/$(EXE) + $(MAKE) -C obj/profile/$(EXE) -f ../../../$(MAKEFILE) $(EXE) \ DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \ CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\ LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)" LEVEL=2 @@ -453,7 +458,8 @@ bin-release : $(CHECKLEVEL1) @echo @echo "========== $(EXE) (release) ==========" - $(MAKE) $(EXE) \ + $(MAKE) prepare BUILD_DIR=obj/release/$(EXE) + $(MAKE) -C obj/release/$(EXE) -f ../../../$(MAKEFILE) $(EXE) \ DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \ CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\ LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)" LEVEL=2 @@ -463,12 +469,16 @@ bin-release-profile : $(CHECKLEVEL1) @echo @echo "========== $(EXE) (release) ==========" - $(MAKE) $(EXE) \ + $(MAKE) prepare BUILD_DIR=obj/release-profile/$(EXE) + $(MAKE) -C obj/release-profile/$(EXE) -f ../../../$(MAKEFILE) $(EXE) \ DP_MAKE_TARGET=$(DP_MAKE_TARGET) DP_SOUND_API=$(DP_SOUND_API) \ CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_EXTRA) $(CFLAGS_RELEASE_PROFILE) $(OPTIM_RELEASE)"\ LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)" LEVEL=2 $(STRIP) $(EXE) +prepare : + $(CMD_MKDIR) $(BUILD_DIR) + $(CMD_CP) makefile.inc $(BUILD_DIR)/ snd_modplug.o: snd_modplug.c $(CHECKLEVEL2) @@ -572,6 +582,7 @@ clean: -$(CMD_RM) $(EXE_SDLNEXUIZ) -$(CMD_RM) *.o -$(CMD_RM) *.d + -$(CMD_RM) obj/ clean-profile: clean -$(CMD_RM) *.gcda -- 2.39.2