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
|
||||
# Remove all object files
|
||||
# cleandep
|
||||
# Remove depend.dep
|
||||
# Remove dependency files
|
||||
# distclean
|
||||
# Remove autogenerated files
|
||||
# dll
|
||||
# compile primary HW render DLL/SO
|
||||
# all_dll
|
||||
|
@ -459,7 +461,6 @@ DBGNAME?=$(EXENAME).debug
|
|||
|
||||
# not too sophisticated dependency
|
||||
OBJS:=$(i_main_o) \
|
||||
$(OBJDIR)/comptime.o \
|
||||
$(OBJDIR)/string.o \
|
||||
$(OBJDIR)/d_main.o \
|
||||
$(OBJDIR)/d_clisrv.o \
|
||||
|
@ -539,6 +540,8 @@ OBJS:=$(i_main_o) \
|
|||
$(i_sound_o) \
|
||||
$(OBJS)
|
||||
|
||||
DEPS:=$(patsubst $(OBJDIR)/%.o,$(DEPDIR)/%.d,$(OBJS))
|
||||
OBJS+=$(OBJDIR)/comptime.o
|
||||
|
||||
ifndef ECHO
|
||||
ifndef NOECHOFILENAMES
|
||||
|
@ -559,12 +562,12 @@ OPTS+=-DGETTEXT
|
|||
endif
|
||||
|
||||
ifdef PANDORA
|
||||
all: pre-build $(BIN)/$(PNDNAME)
|
||||
all: $(BIN)/$(PNDNAME)
|
||||
endif
|
||||
|
||||
|
||||
ifdef SDL
|
||||
all: pre-build $(BIN)/$(EXENAME)
|
||||
all: $(BIN)/$(EXENAME)
|
||||
endif
|
||||
|
||||
ifdef DUMMY
|
||||
|
@ -572,20 +575,15 @@ all: $(BIN)/$(EXENAME)
|
|||
endif
|
||||
|
||||
cleandep:
|
||||
$(REMOVE) $(OBJDIR)/depend.dep
|
||||
$(REMOVE) $(DEPS)
|
||||
$(REMOVE) comptime.h
|
||||
|
||||
pre-build:
|
||||
ifdef WINDOWSHELL
|
||||
-..\comptime.bat .
|
||||
else
|
||||
-@../comptime.sh .
|
||||
endif
|
||||
|
||||
clean:
|
||||
$(REMOVE) *~ *.flc
|
||||
$(REMOVE) $(OBJDIR)/*.o
|
||||
|
||||
distclean: clean cleandep
|
||||
|
||||
ifdef MINGW
|
||||
$(REMOVE) $(OBJDIR)/*.res
|
||||
endif
|
||||
|
@ -667,24 +665,21 @@ endif
|
|||
endif
|
||||
|
||||
#dependecy made by gcc itself !
|
||||
$(OBJS):
|
||||
ifndef DUMMY
|
||||
-include $(OBJDIR)/depend.dep
|
||||
ifneq (,$(filter-out cleandep clean distclean,$(or $(MAKECMDGOALS),all)))
|
||||
$(call print,Checking dependency files...)
|
||||
-include $(DEPS)
|
||||
endif
|
||||
endif
|
||||
|
||||
$(OBJDIR)/depend.dep:
|
||||
@echo "Creating dependency file, depend.dep"
|
||||
@echo > comptime.h
|
||||
-$(MKDIR) $(OBJDIR)
|
||||
$(CC) $(CFLAGS) -MM *.c > $(OBJDIR)/depend.ped
|
||||
$(CC) $(CFLAGS) -MM $(INTERFACE)/*.c >> $(OBJDIR)/depend.ped
|
||||
ifndef NOHW
|
||||
$(CC) $(CFLAGS) -MM hardware/*.c >> $(OBJDIR)/depend.ped
|
||||
$(DEPDIR)/%.d: %.c
|
||||
# windows makes it too hard !
|
||||
ifndef WINDOWSHELL
|
||||
ifndef ECHO
|
||||
@printf "%-20.20s\r" $<
|
||||
endif
|
||||
$(CC) $(CFLAGS) -MM blua/*.c >> $(OBJDIR)/depend.ped
|
||||
@sed -e 's,\(.*\)\.o: ,$(subst /,\/,$(OBJDIR))\/&,g' < $(OBJDIR)/depend.ped > $(OBJDIR)/depend.dep
|
||||
$(REMOVE) $(OBJDIR)/depend.ped
|
||||
@echo "Created dependency file, depend.dep"
|
||||
endif
|
||||
$(CC) $(CFLAGS) -M -MF $@ -MT $(OBJDIR)/$< $<
|
||||
|
||||
ifdef VALGRIND
|
||||
$(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 $@
|
||||
endif
|
||||
|
||||
$(OBJDIR)/comptime.o: comptime.c pre-build
|
||||
$(echoName)
|
||||
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@
|
||||
$(OBJDIR)/comptime.o::
|
||||
ifdef WINDOWSHELL
|
||||
-..\comptime.bat .
|
||||
else
|
||||
-../comptime.sh .
|
||||
endif
|
||||
$(CC) $(CFLAGS) $(WFLAGS) -c comptime.c -o $@
|
||||
|
||||
$(BIN)/%.mo: locale/%.po
|
||||
-$(MKDIR) $(BIN)
|
||||
|
|
|
@ -363,6 +363,7 @@ i_main_o=$(OBJDIR)/i_main.o
|
|||
#set OBJDIR and BIN's starting place
|
||||
OBJDIR=../objs
|
||||
BIN=../bin
|
||||
DEPDIR=../dep
|
||||
#Nasm ASM and rm
|
||||
ifdef YASM
|
||||
NASM?=yasm
|
||||
|
@ -385,6 +386,7 @@ ifdef DUMMY
|
|||
INTERFACE=dummy
|
||||
OBJDIR:=$(OBJDIR)/dummy
|
||||
BIN:=$(BIN)/dummy
|
||||
DEPDIR:=$(DEPDIR)/dummy
|
||||
else
|
||||
ifdef LINUX
|
||||
NASMFORMAT=elf -DLINUX
|
||||
|
@ -392,9 +394,11 @@ ifdef LINUX
|
|||
ifdef LINUX64
|
||||
OBJDIR:=$(OBJDIR)/Linux64
|
||||
BIN:=$(BIN)/Linux64
|
||||
DEPDIR:=$(DEPDIR)/Linux64
|
||||
else
|
||||
OBJDIR:=$(OBJDIR)/Linux
|
||||
BIN:=$(BIN)/Linux
|
||||
DEPDIR:=$(DEPDIR)/Linux
|
||||
endif
|
||||
else
|
||||
ifdef FREEBSD
|
||||
|
@ -404,6 +408,7 @@ ifdef FREEBSD
|
|||
|
||||
OBJDIR:=$(OBJDIR)/FreeBSD
|
||||
BIN:=$(BIN)/FreeBSD
|
||||
DEPDIR:=$(DEPDIR)/Linux
|
||||
else
|
||||
ifdef SOLARIS
|
||||
INTERFACE=sdl
|
||||
|
@ -412,6 +417,7 @@ ifdef SOLARIS
|
|||
|
||||
OBJDIR:=$(OBJDIR)/Solaris
|
||||
BIN:=$(BIN)/Solaris
|
||||
DEPDIR:=$(DEPDIR)/Solaris
|
||||
else
|
||||
ifdef CYGWIN32
|
||||
INTERFACE=sdl
|
||||
|
@ -420,18 +426,21 @@ ifdef CYGWIN32
|
|||
|
||||
OBJDIR:=$(OBJDIR)/cygwin
|
||||
BIN:=$(BIN)/Cygwin
|
||||
DEPDIR:=$(DEPDIR)/Cygwin
|
||||
else
|
||||
ifdef MINGW64
|
||||
#NASMFORMAT=win64
|
||||
SDL=1
|
||||
OBJDIR:=$(OBJDIR)/Mingw64
|
||||
BIN:=$(BIN)/Mingw64
|
||||
DEPDIR:=$(DEPDIR)/Mingw64
|
||||
else
|
||||
ifdef MINGW
|
||||
NASMFORMAT=win32
|
||||
SDL=1
|
||||
OBJDIR:=$(OBJDIR)/Mingw
|
||||
BIN:=$(BIN)/Mingw
|
||||
DEPDIR:=$(DEPDIR)/Mingw
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
@ -443,6 +452,7 @@ endif
|
|||
ifdef ARCHNAME
|
||||
OBJDIR:=$(OBJDIR)/$(ARCHNAME)
|
||||
BIN:=$(BIN)/$(ARCHNAME)
|
||||
DEPDIR:=$(DEPDIR)/$(ARCHNAME)
|
||||
endif
|
||||
|
||||
OBJDUMP_OPTS?=--wide --source --line-numbers
|
||||
|
@ -451,14 +461,17 @@ LD=$(CC)
|
|||
ifdef SDL
|
||||
INTERFACE=sdl
|
||||
OBJDIR:=$(OBJDIR)/SDL
|
||||
DEPDIR:=$(DEPDIR)/SDL
|
||||
endif
|
||||
|
||||
ifndef DUMMY
|
||||
ifdef DEBUGMODE
|
||||
OBJDIR:=$(OBJDIR)/Debug
|
||||
BIN:=$(BIN)/Debug
|
||||
DEPDIR:=$(DEPDIR)/Debug
|
||||
else
|
||||
OBJDIR:=$(OBJDIR)/Release
|
||||
BIN:=$(BIN)/Release
|
||||
DEPDIR:=$(DEPDIR)/Release
|
||||
endif
|
||||
endif
|
||||
|
|
Loading…
Reference in a new issue