mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Merge branch 'dependency-files' into 'master'
Dependency files See merge request STJr/SRB2!1407
This commit is contained in:
commit
89e411c6ae
2 changed files with 75 additions and 41 deletions
90
src/Makefile
90
src/Makefile
|
@ -2,7 +2,7 @@
|
|||
# GNU Make makefile for SRB2
|
||||
#############################################################################
|
||||
# Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
# Copyright (C) 2003-2020 by Sonic Team Junior.
|
||||
# Copyright (C) 2003-2021 by Sonic Team Junior.
|
||||
#
|
||||
# This program is free software distributed under the
|
||||
# terms of the GNU General Public License, version 2.
|
||||
|
@ -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
|
||||
|
@ -79,6 +81,17 @@
|
|||
#
|
||||
#############################################################################
|
||||
|
||||
,=,
|
||||
|
||||
ifeq (,$(filter-out cleandep clean distclean,$(or $(MAKECMDGOALS),all)))
|
||||
CLEANONLY=1
|
||||
else ifndef SILENT
|
||||
echo=@echo "$(1)"
|
||||
ifndef MAKE_RESTARTS
|
||||
print=$(info $(1))
|
||||
endif
|
||||
endif
|
||||
|
||||
ALL_SYSTEMS=\
|
||||
PANDORA\
|
||||
LINUX64\
|
||||
|
@ -98,7 +111,7 @@ ALL_SYSTEMS=\
|
|||
ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES)))
|
||||
ifeq ($(OS),Windows_NT) # all windows are Windows_NT...
|
||||
|
||||
$(info Detected a Windows system, compiling for 32-bit MinGW SDL2...)
|
||||
$(call print,Detected a Windows system$(,) compiling for 32-bit MinGW SDL2...)
|
||||
|
||||
# go for a 32-bit sdl mingw exe by default
|
||||
MINGW=1
|
||||
|
@ -123,7 +136,7 @@ else # if you on the *nix
|
|||
new_system:=$(new_system)64
|
||||
endif
|
||||
|
||||
$(info Detected $(system) ($(new_system))...)
|
||||
$(call print,Detected $(system) ($(new_system))...)
|
||||
$(new_system)=1
|
||||
|
||||
endif
|
||||
|
@ -237,6 +250,12 @@ endif
|
|||
|
||||
MSGFMT?=msgfmt
|
||||
|
||||
ifdef WINDOWSHELL
|
||||
COMPTIME=-..\comptime.bat
|
||||
else
|
||||
COMPTIME=-../comptime.sh
|
||||
endif
|
||||
|
||||
ifndef ECHO
|
||||
NASM:=@$(NASM)
|
||||
REMOVE:=@$(REMOVE)
|
||||
|
@ -251,6 +270,7 @@ ifndef ECHO
|
|||
MSGFMT:=@$(MSGFMT)
|
||||
UPX:=@$(UPX)
|
||||
UPX_OPTS+=-q
|
||||
COMPTIME:=@$(COMPTIME)
|
||||
endif
|
||||
|
||||
ifdef NONET
|
||||
|
@ -455,7 +475,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 \
|
||||
|
@ -535,7 +554,10 @@ OBJS:=$(i_main_o) \
|
|||
$(i_sound_o) \
|
||||
$(OBJS)
|
||||
|
||||
DEPS:=$(patsubst $(OBJDIR)/%.o,$(DEPDIR)/%.d,$(OBJS))
|
||||
OBJS+=$(OBJDIR)/comptime.o
|
||||
|
||||
ifndef SILENT
|
||||
ifndef ECHO
|
||||
ifndef NOECHOFILENAMES
|
||||
define echoName =
|
||||
|
@ -543,6 +565,7 @@ define echoName =
|
|||
endef
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# List of languages to compile.
|
||||
# For reference, this is the command I use to build a srb2.pot file from the source code.
|
||||
|
@ -555,12 +578,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
|
||||
|
@ -568,20 +591,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
|
||||
|
@ -601,11 +619,11 @@ asm:
|
|||
|
||||
$(BIN)/$(EXENAME): $(POS) $(OBJS)
|
||||
-$(MKDIR) $(BIN)
|
||||
@echo Linking $(EXENAME)...
|
||||
$(call echo,Linking $(EXENAME)...)
|
||||
$(LD) $(LDFLAGS) $(OBJS) -o $(BIN)/$(EXENAME) $(LIBS)
|
||||
ifndef VALGRIND
|
||||
ifndef NOOBJDUMP
|
||||
@echo Dumping debugging info
|
||||
$(call echo,Dumping debugging info)
|
||||
$(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(EXENAME) > $(BIN)/$(DBGNAME).txt
|
||||
ifdef WINDOWSHELL
|
||||
-$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt
|
||||
|
@ -624,10 +642,10 @@ ifndef NOUPX
|
|||
-$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME)
|
||||
endif
|
||||
endif
|
||||
@echo Build is done, please look for $(EXENAME) in $(BIN), \(checking for post steps\)
|
||||
$(call echo,Build is done$(,) please look for $(EXENAME) in $(BIN)$(,) (checking for post steps))
|
||||
|
||||
reobjdump:
|
||||
@echo Redumping debugging info
|
||||
$(call echo,Redumping debugging info)
|
||||
$(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(DBGNAME) > $(BIN)/$(DBGNAME).txt
|
||||
ifdef WINDOWSHELL
|
||||
-$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt
|
||||
|
@ -663,24 +681,21 @@ endif
|
|||
endif
|
||||
|
||||
#dependecy made by gcc itself !
|
||||
$(OBJS):
|
||||
ifndef DUMMY
|
||||
-include $(OBJDIR)/depend.dep
|
||||
ifndef CLEANONLY
|
||||
$(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
|
||||
ifdef echoName
|
||||
@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
|
||||
|
@ -688,9 +703,12 @@ $(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 echoName
|
||||
@echo -- comptime.c ...
|
||||
endif
|
||||
$(COMPTIME) .
|
||||
$(CC) $(CFLAGS) $(WFLAGS) -c comptime.c -o $@
|
||||
|
||||
$(BIN)/%.mo: locale/%.po
|
||||
-$(MKDIR) $(BIN)
|
||||
|
|
|
@ -47,7 +47,8 @@ ifdef MACOSX
|
|||
endif
|
||||
|
||||
# Automatically set version flag, but not if one was manually set
|
||||
ifeq (,$(filter GCC%,$(.VARIABLES)))
|
||||
# And don't bother if this is a clean only run
|
||||
ifeq (,$(filter GCC% CLEANONLY,$(.VARIABLES)))
|
||||
version:=$(shell $(CC) --version)
|
||||
# check if this is in fact GCC
|
||||
ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version))))
|
||||
|
@ -60,12 +61,14 @@ ifeq (,$(filter GCC%,$(.VARIABLES)))
|
|||
|
||||
# If this version is not in the list, default to the latest supported
|
||||
ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS)))
|
||||
$(info\
|
||||
Your compiler version, GCC $(version), is not supported by the Makefile.\
|
||||
The Makefile will assume GCC $(LATEST_GCC_VERSION).)
|
||||
define line =
|
||||
Your compiler version, GCC $(version), is not supported by the Makefile.
|
||||
The Makefile will assume GCC $(LATEST_GCC_VERSION).))
|
||||
endef
|
||||
$(call print,$(line))
|
||||
GCC$(subst .,,$(LATEST_GCC_VERSION))=1
|
||||
else
|
||||
$(info Detected GCC $(version) (GCC$(v)))
|
||||
$(call print,Detected GCC $(version) (GCC$(v)))
|
||||
GCC$(v)=1
|
||||
endif
|
||||
endif
|
||||
|
@ -361,6 +364,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
|
||||
|
@ -383,6 +387,7 @@ ifdef DUMMY
|
|||
INTERFACE=dummy
|
||||
OBJDIR:=$(OBJDIR)/dummy
|
||||
BIN:=$(BIN)/dummy
|
||||
DEPDIR:=$(DEPDIR)/dummy
|
||||
else
|
||||
ifdef LINUX
|
||||
NASMFORMAT=elf -DLINUX
|
||||
|
@ -390,9 +395,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
|
||||
|
@ -402,6 +409,7 @@ ifdef FREEBSD
|
|||
|
||||
OBJDIR:=$(OBJDIR)/FreeBSD
|
||||
BIN:=$(BIN)/FreeBSD
|
||||
DEPDIR:=$(DEPDIR)/Linux
|
||||
else
|
||||
ifdef SOLARIS
|
||||
INTERFACE=sdl
|
||||
|
@ -410,6 +418,7 @@ ifdef SOLARIS
|
|||
|
||||
OBJDIR:=$(OBJDIR)/Solaris
|
||||
BIN:=$(BIN)/Solaris
|
||||
DEPDIR:=$(DEPDIR)/Solaris
|
||||
else
|
||||
ifdef CYGWIN32
|
||||
INTERFACE=sdl
|
||||
|
@ -418,18 +427,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
|
||||
|
@ -441,6 +453,7 @@ endif
|
|||
ifdef ARCHNAME
|
||||
OBJDIR:=$(OBJDIR)/$(ARCHNAME)
|
||||
BIN:=$(BIN)/$(ARCHNAME)
|
||||
DEPDIR:=$(DEPDIR)/$(ARCHNAME)
|
||||
endif
|
||||
|
||||
OBJDUMP_OPTS?=--wide --source --line-numbers
|
||||
|
@ -449,14 +462,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