mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-19 07:51:43 +00:00
Generate individual dependency files
This removes Makefile.depends. Instead, '.d' files are included from the 'dep' directory. This speeds up building because dependencies for every file don't need to be regenerated if only one changes. As a bonus, dependencies also won't be generated if only clean type targets are going to be run. Also added a 'distclean' target, which cleans both objects and dependency files.
This commit is contained in:
parent
3003c252d1
commit
3d32f3145c
2 changed files with 41 additions and 29 deletions
57
src/Makefile
57
src/Makefile
|
@ -24,7 +24,9 @@
|
||||||
# clean
|
# clean
|
||||||
# Remove all object files
|
# Remove all object files
|
||||||
# cleandep
|
# cleandep
|
||||||
# Remove depend.dep
|
# Remove dependency files
|
||||||
|
# distclean
|
||||||
|
# Remove autogenerated files
|
||||||
# dll
|
# dll
|
||||||
# compile primary HW render DLL/SO
|
# compile primary HW render DLL/SO
|
||||||
# all_dll
|
# all_dll
|
||||||
|
@ -459,7 +461,6 @@ DBGNAME?=$(EXENAME).debug
|
||||||
|
|
||||||
# not too sophisticated dependency
|
# not too sophisticated dependency
|
||||||
OBJS:=$(i_main_o) \
|
OBJS:=$(i_main_o) \
|
||||||
$(OBJDIR)/comptime.o \
|
|
||||||
$(OBJDIR)/string.o \
|
$(OBJDIR)/string.o \
|
||||||
$(OBJDIR)/d_main.o \
|
$(OBJDIR)/d_main.o \
|
||||||
$(OBJDIR)/d_clisrv.o \
|
$(OBJDIR)/d_clisrv.o \
|
||||||
|
@ -539,6 +540,8 @@ OBJS:=$(i_main_o) \
|
||||||
$(i_sound_o) \
|
$(i_sound_o) \
|
||||||
$(OBJS)
|
$(OBJS)
|
||||||
|
|
||||||
|
DEPS:=$(patsubst $(OBJDIR)/%.o,$(DEPDIR)/%.d,$(OBJS))
|
||||||
|
OBJS+=$(OBJDIR)/comptime.o
|
||||||
|
|
||||||
ifndef ECHO
|
ifndef ECHO
|
||||||
ifndef NOECHOFILENAMES
|
ifndef NOECHOFILENAMES
|
||||||
|
@ -559,12 +562,12 @@ OPTS+=-DGETTEXT
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef PANDORA
|
ifdef PANDORA
|
||||||
all: pre-build $(BIN)/$(PNDNAME)
|
all: $(BIN)/$(PNDNAME)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
ifdef SDL
|
ifdef SDL
|
||||||
all: pre-build $(BIN)/$(EXENAME)
|
all: $(BIN)/$(EXENAME)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef DUMMY
|
ifdef DUMMY
|
||||||
|
@ -572,20 +575,15 @@ all: $(BIN)/$(EXENAME)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
cleandep:
|
cleandep:
|
||||||
$(REMOVE) $(OBJDIR)/depend.dep
|
$(REMOVE) $(DEPS)
|
||||||
$(REMOVE) comptime.h
|
$(REMOVE) comptime.h
|
||||||
|
|
||||||
pre-build:
|
|
||||||
ifdef WINDOWSHELL
|
|
||||||
-..\comptime.bat .
|
|
||||||
else
|
|
||||||
-@../comptime.sh .
|
|
||||||
endif
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(REMOVE) *~ *.flc
|
$(REMOVE) *~ *.flc
|
||||||
$(REMOVE) $(OBJDIR)/*.o
|
$(REMOVE) $(OBJDIR)/*.o
|
||||||
|
|
||||||
|
distclean: clean cleandep
|
||||||
|
|
||||||
ifdef MINGW
|
ifdef MINGW
|
||||||
$(REMOVE) $(OBJDIR)/*.res
|
$(REMOVE) $(OBJDIR)/*.res
|
||||||
endif
|
endif
|
||||||
|
@ -667,24 +665,21 @@ endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#dependecy made by gcc itself !
|
#dependecy made by gcc itself !
|
||||||
$(OBJS):
|
|
||||||
ifndef DUMMY
|
ifndef DUMMY
|
||||||
-include $(OBJDIR)/depend.dep
|
ifneq (,$(filter-out cleandep clean distclean,$(or $(MAKECMDGOALS),all)))
|
||||||
|
$(call print,Checking dependency files...)
|
||||||
|
-include $(DEPS)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(OBJDIR)/depend.dep:
|
$(DEPDIR)/%.d: %.c
|
||||||
@echo "Creating dependency file, depend.dep"
|
# windows makes it too hard !
|
||||||
@echo > comptime.h
|
ifndef WINDOWSHELL
|
||||||
-$(MKDIR) $(OBJDIR)
|
ifndef ECHO
|
||||||
$(CC) $(CFLAGS) -MM *.c > $(OBJDIR)/depend.ped
|
@printf "%-20.20s\r" $<
|
||||||
$(CC) $(CFLAGS) -MM $(INTERFACE)/*.c >> $(OBJDIR)/depend.ped
|
|
||||||
ifndef NOHW
|
|
||||||
$(CC) $(CFLAGS) -MM hardware/*.c >> $(OBJDIR)/depend.ped
|
|
||||||
endif
|
endif
|
||||||
$(CC) $(CFLAGS) -MM blua/*.c >> $(OBJDIR)/depend.ped
|
endif
|
||||||
@sed -e 's,\(.*\)\.o: ,$(subst /,\/,$(OBJDIR))\/&,g' < $(OBJDIR)/depend.ped > $(OBJDIR)/depend.dep
|
$(CC) $(CFLAGS) -M -MF $@ -MT $(OBJDIR)/$< $<
|
||||||
$(REMOVE) $(OBJDIR)/depend.ped
|
|
||||||
@echo "Created dependency file, depend.dep"
|
|
||||||
|
|
||||||
ifdef VALGRIND
|
ifdef VALGRIND
|
||||||
$(OBJDIR)/z_zone.o: z_zone.c
|
$(OBJDIR)/z_zone.o: z_zone.c
|
||||||
|
@ -692,9 +687,13 @@ $(OBJDIR)/z_zone.o: z_zone.c
|
||||||
$(CC) $(CFLAGS) $(WFLAGS) -DHAVE_VALGRIND $(VALGRIND_CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) $(WFLAGS) -DHAVE_VALGRIND $(VALGRIND_CFLAGS) -c $< -o $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(OBJDIR)/comptime.o: comptime.c pre-build
|
$(OBJDIR)/comptime.o::
|
||||||
$(echoName)
|
ifdef WINDOWSHELL
|
||||||
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@
|
-..\comptime.bat .
|
||||||
|
else
|
||||||
|
-../comptime.sh .
|
||||||
|
endif
|
||||||
|
$(CC) $(CFLAGS) $(WFLAGS) -c comptime.c -o $@
|
||||||
|
|
||||||
$(BIN)/%.mo: locale/%.po
|
$(BIN)/%.mo: locale/%.po
|
||||||
-$(MKDIR) $(BIN)
|
-$(MKDIR) $(BIN)
|
||||||
|
|
|
@ -363,6 +363,7 @@ i_main_o=$(OBJDIR)/i_main.o
|
||||||
#set OBJDIR and BIN's starting place
|
#set OBJDIR and BIN's starting place
|
||||||
OBJDIR=../objs
|
OBJDIR=../objs
|
||||||
BIN=../bin
|
BIN=../bin
|
||||||
|
DEPDIR=../dep
|
||||||
#Nasm ASM and rm
|
#Nasm ASM and rm
|
||||||
ifdef YASM
|
ifdef YASM
|
||||||
NASM?=yasm
|
NASM?=yasm
|
||||||
|
@ -385,6 +386,7 @@ ifdef DUMMY
|
||||||
INTERFACE=dummy
|
INTERFACE=dummy
|
||||||
OBJDIR:=$(OBJDIR)/dummy
|
OBJDIR:=$(OBJDIR)/dummy
|
||||||
BIN:=$(BIN)/dummy
|
BIN:=$(BIN)/dummy
|
||||||
|
DEPDIR:=$(DEPDIR)/dummy
|
||||||
else
|
else
|
||||||
ifdef LINUX
|
ifdef LINUX
|
||||||
NASMFORMAT=elf -DLINUX
|
NASMFORMAT=elf -DLINUX
|
||||||
|
@ -392,9 +394,11 @@ ifdef LINUX
|
||||||
ifdef LINUX64
|
ifdef LINUX64
|
||||||
OBJDIR:=$(OBJDIR)/Linux64
|
OBJDIR:=$(OBJDIR)/Linux64
|
||||||
BIN:=$(BIN)/Linux64
|
BIN:=$(BIN)/Linux64
|
||||||
|
DEPDIR:=$(DEPDIR)/Linux64
|
||||||
else
|
else
|
||||||
OBJDIR:=$(OBJDIR)/Linux
|
OBJDIR:=$(OBJDIR)/Linux
|
||||||
BIN:=$(BIN)/Linux
|
BIN:=$(BIN)/Linux
|
||||||
|
DEPDIR:=$(DEPDIR)/Linux
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
ifdef FREEBSD
|
ifdef FREEBSD
|
||||||
|
@ -404,6 +408,7 @@ ifdef FREEBSD
|
||||||
|
|
||||||
OBJDIR:=$(OBJDIR)/FreeBSD
|
OBJDIR:=$(OBJDIR)/FreeBSD
|
||||||
BIN:=$(BIN)/FreeBSD
|
BIN:=$(BIN)/FreeBSD
|
||||||
|
DEPDIR:=$(DEPDIR)/Linux
|
||||||
else
|
else
|
||||||
ifdef SOLARIS
|
ifdef SOLARIS
|
||||||
INTERFACE=sdl
|
INTERFACE=sdl
|
||||||
|
@ -412,6 +417,7 @@ ifdef SOLARIS
|
||||||
|
|
||||||
OBJDIR:=$(OBJDIR)/Solaris
|
OBJDIR:=$(OBJDIR)/Solaris
|
||||||
BIN:=$(BIN)/Solaris
|
BIN:=$(BIN)/Solaris
|
||||||
|
DEPDIR:=$(DEPDIR)/Solaris
|
||||||
else
|
else
|
||||||
ifdef CYGWIN32
|
ifdef CYGWIN32
|
||||||
INTERFACE=sdl
|
INTERFACE=sdl
|
||||||
|
@ -420,18 +426,21 @@ ifdef CYGWIN32
|
||||||
|
|
||||||
OBJDIR:=$(OBJDIR)/cygwin
|
OBJDIR:=$(OBJDIR)/cygwin
|
||||||
BIN:=$(BIN)/Cygwin
|
BIN:=$(BIN)/Cygwin
|
||||||
|
DEPDIR:=$(DEPDIR)/Cygwin
|
||||||
else
|
else
|
||||||
ifdef MINGW64
|
ifdef MINGW64
|
||||||
#NASMFORMAT=win64
|
#NASMFORMAT=win64
|
||||||
SDL=1
|
SDL=1
|
||||||
OBJDIR:=$(OBJDIR)/Mingw64
|
OBJDIR:=$(OBJDIR)/Mingw64
|
||||||
BIN:=$(BIN)/Mingw64
|
BIN:=$(BIN)/Mingw64
|
||||||
|
DEPDIR:=$(DEPDIR)/Mingw64
|
||||||
else
|
else
|
||||||
ifdef MINGW
|
ifdef MINGW
|
||||||
NASMFORMAT=win32
|
NASMFORMAT=win32
|
||||||
SDL=1
|
SDL=1
|
||||||
OBJDIR:=$(OBJDIR)/Mingw
|
OBJDIR:=$(OBJDIR)/Mingw
|
||||||
BIN:=$(BIN)/Mingw
|
BIN:=$(BIN)/Mingw
|
||||||
|
DEPDIR:=$(DEPDIR)/Mingw
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -443,6 +452,7 @@ endif
|
||||||
ifdef ARCHNAME
|
ifdef ARCHNAME
|
||||||
OBJDIR:=$(OBJDIR)/$(ARCHNAME)
|
OBJDIR:=$(OBJDIR)/$(ARCHNAME)
|
||||||
BIN:=$(BIN)/$(ARCHNAME)
|
BIN:=$(BIN)/$(ARCHNAME)
|
||||||
|
DEPDIR:=$(DEPDIR)/$(ARCHNAME)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OBJDUMP_OPTS?=--wide --source --line-numbers
|
OBJDUMP_OPTS?=--wide --source --line-numbers
|
||||||
|
@ -451,14 +461,17 @@ LD=$(CC)
|
||||||
ifdef SDL
|
ifdef SDL
|
||||||
INTERFACE=sdl
|
INTERFACE=sdl
|
||||||
OBJDIR:=$(OBJDIR)/SDL
|
OBJDIR:=$(OBJDIR)/SDL
|
||||||
|
DEPDIR:=$(DEPDIR)/SDL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef DUMMY
|
ifndef DUMMY
|
||||||
ifdef DEBUGMODE
|
ifdef DEBUGMODE
|
||||||
OBJDIR:=$(OBJDIR)/Debug
|
OBJDIR:=$(OBJDIR)/Debug
|
||||||
BIN:=$(BIN)/Debug
|
BIN:=$(BIN)/Debug
|
||||||
|
DEPDIR:=$(DEPDIR)/Debug
|
||||||
else
|
else
|
||||||
OBJDIR:=$(OBJDIR)/Release
|
OBJDIR:=$(OBJDIR)/Release
|
||||||
BIN:=$(BIN)/Release
|
BIN:=$(BIN)/Release
|
||||||
|
DEPDIR:=$(DEPDIR)/Release
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in a new issue