From 2b28cb3d2daa3d6799db8a2135abc44d6d421de9 Mon Sep 17 00:00:00 2001 From: molivier Date: Mon, 3 Jul 2006 19:46:07 +0000 Subject: [PATCH] Cleaned the ugly code I committed for DP_FS_BASEDIR support (the environment variable is now only defined when needed) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6498 d7cf8633-e32d-0410-b094-e92efae38249 --- BSDmakefile | 12 ++++++++++-- fs.c | 6 +++--- makefile | 12 ++++++++++-- makefile.inc | 4 +--- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/BSDmakefile b/BSDmakefile index 1f8bad72..249a2bc9 100644 --- a/BSDmakefile +++ b/BSDmakefile @@ -7,8 +7,6 @@ DP_MAKE_TARGET=bsd .endif DP_ARCH != uname -CFLAGS_MAKEDEP=-MD - # Command used to delete files CMD_RM=$(CMD_UNIXRM) @@ -68,6 +66,16 @@ LIB_SOUND=$(LIB_SND_BSD) .endif +##### Extra CFLAGS ##### + +CFLAGS_MAKEDEP=-MD +.ifdef DP_FS_BASEDIR +CFLAGS_FS=-DDP_FS_BASEDIR='\"$(DP_FS_BASEDIR)\"' +.else +CFLAGS_FS= +.endif + + ##### BSD Make specific definitions ##### MAKE:=$(MAKE) -f BSDmakefile diff --git a/fs.c b/fs.c index ab981f5e..3aab0537 100644 --- a/fs.c +++ b/fs.c @@ -1,7 +1,7 @@ /* DarkPlaces file system - Copyright (C) 2003-2005 Mathieu Olivier + Copyright (C) 2003-2006 Mathieu Olivier This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -1068,11 +1068,10 @@ void FS_Init (void) strcpy(fs_basedir, DP_FS_BASEDIR); #else strcpy(fs_basedir, ""); -#endif #ifdef MACOSX // FIXME: is there a better way to find the directory outside the .app? - if (!fs_basedir[0] && strstr(com_argv[0], ".app/")) + if (strstr(com_argv[0], ".app/")) { char *split; @@ -1082,6 +1081,7 @@ void FS_Init (void) strlcpy(fs_basedir, com_argv[0], sizeof(fs_basedir)); fs_basedir[split - com_argv[0]] = 0; } +#endif #endif PK3_OpenLibrary (); diff --git a/makefile b/makefile index ba1b76ed..19272f83 100644 --- a/makefile +++ b/makefile @@ -26,8 +26,6 @@ endif # ifneq ($(filter %BSD,$(DP_ARCH)),) endif # ifdef windir endif # ifndef DP_MAKE_TARGET -CFLAGS_MAKEDEP=-MD - # If we're not on compiling for Win32, we need additional information ifneq ($(DP_MAKE_TARGET), mingw) DP_ARCH:=$(shell uname) @@ -209,6 +207,16 @@ ifeq ($(DP_SOUND_API), WIN) endif +##### Extra CFLAGS ##### + +CFLAGS_MAKEDEP?=-MD +ifdef DP_FS_BASEDIR + CFLAGS_FS=-DDP_FS_BASEDIR='\"$(DP_FS_BASEDIR)\"' +else + CFLAGS_FS= +endif + + ##### GNU Make specific definitions ##### DO_LD=$(CC) -o $@ $^ $(LDFLAGS) diff --git a/makefile.inc b/makefile.inc index 2b2a375d..eca83c29 100644 --- a/makefile.inc +++ b/makefile.inc @@ -18,8 +18,6 @@ CPUOPTIMIZATIONS= SDL_CONFIG?=sdl-config -DP_FS_BASEDIR?= - ###### Sound and audio CD ##### @@ -140,7 +138,7 @@ OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_SND_COMMON) snd_sdl.o cd_sdl.o $( # Compilation -CFLAGS_COMMON=$(CFLAGS_MAKEDEP) -D'DP_FS_BASEDIR=\"$(DP_FS_BASEDIR)\"' -Wall -Wsign-compare +CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_FS) -Wall -Wsign-compare CFLAGS_DEBUG=-ggdb CFLAGS_PROFILE=-g -pg -ggdb CFLAGS_RELEASE= -- 2.39.2