mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Merge branch 'makefile-patches-1' into 'master'
Some issues with the Makefile See merge request STJr/SRB2!1553
This commit is contained in:
commit
1721b5b060
5 changed files with 61 additions and 33 deletions
68
src/Makefile
68
src/Makefile
|
@ -132,6 +132,10 @@ goals:=$(or $(MAKECMDGOALS),all)
|
||||||
cleanonly:=$(filter $(clean_targets),$(goals))
|
cleanonly:=$(filter $(clean_targets),$(goals))
|
||||||
destructive:=$(filter-out info,$(cleanonly))
|
destructive:=$(filter-out info,$(cleanonly))
|
||||||
|
|
||||||
|
ifndef cleanonly
|
||||||
|
include Makefile.d/old.mk
|
||||||
|
endif
|
||||||
|
|
||||||
include Makefile.d/util.mk
|
include Makefile.d/util.mk
|
||||||
|
|
||||||
ifdef PREFIX
|
ifdef PREFIX
|
||||||
|
@ -141,7 +145,7 @@ endif
|
||||||
OBJDUMP_OPTS?=--wide --source --line-numbers
|
OBJDUMP_OPTS?=--wide --source --line-numbers
|
||||||
|
|
||||||
OBJCOPY:=$(call Prefix,objcopy)
|
OBJCOPY:=$(call Prefix,objcopy)
|
||||||
OBJDUMP:=$(call Prefix,objdump) $(OBJDUMP_OPTS)
|
OBJDUMP:=$(call Prefix,objdump)
|
||||||
WINDRES:=$(call Prefix,windres)
|
WINDRES:=$(call Prefix,windres)
|
||||||
|
|
||||||
ifdef YASM
|
ifdef YASM
|
||||||
|
@ -176,11 +180,7 @@ include Makefile.d/detect.mk
|
||||||
# make would try to remove the implicitly made directories
|
# make would try to remove the implicitly made directories
|
||||||
.PRECIOUS : %/ comptime.c
|
.PRECIOUS : %/ comptime.c
|
||||||
|
|
||||||
# very sophisticated dependency
|
sources:=
|
||||||
sources:=\
|
|
||||||
$(call List,Sourcefile)\
|
|
||||||
$(call List,blua/Sourcefile)\
|
|
||||||
|
|
||||||
makedir:=../make
|
makedir:=../make
|
||||||
|
|
||||||
# -DCOMPVERSION: flag to use comptime.h
|
# -DCOMPVERSION: flag to use comptime.h
|
||||||
|
@ -204,6 +204,11 @@ endif
|
||||||
depdir:=$(makedir)/deps
|
depdir:=$(makedir)/deps
|
||||||
objdir:=$(makedir)/objs
|
objdir:=$(makedir)/objs
|
||||||
|
|
||||||
|
# very sophisticated dependency
|
||||||
|
sources+=\
|
||||||
|
$(call List,Sourcefile)\
|
||||||
|
$(call List,blua/Sourcefile)\
|
||||||
|
|
||||||
depends:=$(basename $(filter %.c %.s,$(sources)))
|
depends:=$(basename $(filter %.c %.s,$(sources)))
|
||||||
objects:=$(basename $(filter %.c %.s %.nas,$(sources)))
|
objects:=$(basename $(filter %.c %.s %.nas,$(sources)))
|
||||||
|
|
||||||
|
@ -268,16 +273,18 @@ opts+=$(debug_opts)
|
||||||
|
|
||||||
opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v)))
|
opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v)))
|
||||||
|
|
||||||
CFLAGS:=$(opts) $(WFLAGS) $(CPPFLAGS) $(CFLAGS)
|
opts+=$(WFLAGS) $(CPPFLAGS) $(CFLAGS)
|
||||||
LDFLAGS:=$(libs) $(LDFLAGS)
|
libs+=$(LDFLAGS)
|
||||||
ASFLAGS+=-x assembler-with-cpp
|
asflags:=$(ASFLAGS) -x assembler-with-cpp
|
||||||
|
|
||||||
|
cc=$(CC)
|
||||||
|
|
||||||
ifdef DISTCC
|
ifdef DISTCC
|
||||||
CC:=distcc $(CC)
|
cc=distcc $(CC)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef CCACHE
|
ifdef CCACHE
|
||||||
CC:=ccache $(CC)
|
cc=ccache $(CC)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef SILENT
|
ifndef SILENT
|
||||||
|
@ -288,11 +295,11 @@ ifndef destructive
|
||||||
$(shell $(CC) -v)
|
$(shell $(CC) -v)
|
||||||
define flags =
|
define flags =
|
||||||
|
|
||||||
CC ........ $(CC)
|
CC ........ $(cc)
|
||||||
|
|
||||||
CFLAGS .... $(CFLAGS)
|
CFLAGS .... $(opts)
|
||||||
|
|
||||||
LDFLAGS ... $(LDFLAGS)
|
LDFLAGS ... $(libs)
|
||||||
|
|
||||||
endef
|
endef
|
||||||
$(info $(flags))
|
$(info $(flags))
|
||||||
|
@ -306,13 +313,12 @@ endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LD:=$(CC)
|
LD:=$(CC)
|
||||||
CC:=$(CC) $(CFLAGS)
|
cc:=$(cc) $(opts)
|
||||||
NASM:=$(NASM) $(NASMOPTS) -f $(nasm_format)
|
nasm=$(NASM) $(NASMOPTS) -f $(nasm_format)
|
||||||
GZIP:=$(GZIP) $(GZIP_OPTS)
|
|
||||||
ifdef UPX
|
ifdef UPX
|
||||||
UPX:=$(UPX) $(UPX_OPTS)
|
upx=$(UPX) $(UPX_OPTS)
|
||||||
endif
|
endif
|
||||||
WINDRES:=$(WINDRES) $(WINDRESFLAGS)\
|
windres=$(WINDRES) $(WINDRESFLAGS)\
|
||||||
$(debug_opts) --include-dir=win32 -O coff
|
$(debug_opts) --include-dir=win32 -O coff
|
||||||
|
|
||||||
%/ :
|
%/ :
|
||||||
|
@ -322,7 +328,7 @@ WINDRES:=$(WINDRES) $(WINDRESFLAGS)\
|
||||||
# prerequisites
|
# prerequisites
|
||||||
.SECONDEXPANSION :
|
.SECONDEXPANSION :
|
||||||
|
|
||||||
# 'UPX' is also recognized in the enviornment by upx
|
# 'UPX' is also recognized in the environment by upx
|
||||||
unexport UPX
|
unexport UPX
|
||||||
|
|
||||||
# executable stripped of debugging symbols
|
# executable stripped of debugging symbols
|
||||||
|
@ -331,19 +337,19 @@ $(exe) : $(dbg) | $$(@D)/
|
||||||
$(.)-$(OBJCOPY) --add-gnu-debuglink=$< $@
|
$(.)-$(OBJCOPY) --add-gnu-debuglink=$< $@
|
||||||
ifdef UPX
|
ifdef UPX
|
||||||
$(call Echo,Compressing final executable...)
|
$(call Echo,Compressing final executable...)
|
||||||
$(.)-$(UPX) $@
|
$(.)-$(upx) $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# original executable with debugging symbols
|
# original executable with debugging symbols
|
||||||
$(dbg) : $(objects) | $$(@D)/
|
$(dbg) : $(objects) | $$(@D)/
|
||||||
$(call Echo,Linking $(@F)...)
|
$(call Echo,Linking $(@F)...)
|
||||||
$(.)$(LD) -o $@ $^ $(LDFLAGS)
|
$(.)$(LD) -o $@ $^ $(libs)
|
||||||
|
|
||||||
# disassembly of executable
|
# disassembly of executable
|
||||||
$(dbg).txt : $(dbg)
|
$(dbg).txt : $(dbg)
|
||||||
$(call Echo,Dumping debugging info...)
|
$(call Echo,Dumping debugging info...)
|
||||||
$(.)$(OBJDUMP) $< > $@
|
$(.)$(OBJDUMP) $(OBJDUMP_OPTS) $< > $@
|
||||||
$(.)$(GZIP) $@
|
$(.)$(GZIP) $(GZIP_OPTS) $@
|
||||||
|
|
||||||
# '::' means run unconditionally
|
# '::' means run unconditionally
|
||||||
# this really updates comptime.h
|
# this really updates comptime.h
|
||||||
|
@ -368,11 +374,11 @@ ifdef Echo_name
|
||||||
@printf '%-20.20s\r' $$<
|
@printf '%-20.20s\r' $$<
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
$(.)$(CC) -MM -MF $$@ -MT $(objdir)/$$(*F).o $(2) $$<
|
$(.)$(cc) -MM -MF $$@ -MT $(objdir)/$$(*F).o $(2) $$<
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call _recipe,c))
|
$(eval $(call _recipe,c))
|
||||||
$(eval $(call _recipe,s,$(ASFLAGS)))
|
$(eval $(call _recipe,s,$(asflags)))
|
||||||
|
|
||||||
# compiling recipe template
|
# compiling recipe template
|
||||||
# 1: target file suffix
|
# 1: target file suffix
|
||||||
|
@ -384,10 +390,10 @@ $(objdir)/%.$(1) : %.$(2) | $$$$(@D)/
|
||||||
$(.)$(3)
|
$(.)$(3)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call _recipe,o,c,$(CC) -c -o $$@ $$<))
|
$(eval $(call _recipe,o,c,$(cc) -c -o $$@ $$<))
|
||||||
$(eval $(call _recipe,o,nas,$(NASM) -o $$@ $$<))
|
$(eval $(call _recipe,o,nas,$(nasm) -o $$@ $$<))
|
||||||
$(eval $(call _recipe,o,s,$(CC) $(ASFLAGS) -c -o $$@ $$<))
|
$(eval $(call _recipe,o,s,$(cc) $(asflags) -c -o $$@ $$<))
|
||||||
$(eval $(call _recipe,res,rc,$(WINDRES) -i $$< -o $$@))
|
$(eval $(call _recipe,res,rc,$(windres) -i $$< -o $$@))
|
||||||
|
|
||||||
_rm=$(.)$(rmrf) $(call Windows_path,$(1))
|
_rm=$(.)$(rmrf) $(call Windows_path,$(1))
|
||||||
|
|
||||||
|
@ -398,7 +404,7 @@ clean :
|
||||||
$(call _rm,$(exe) $(dbg) $(dbg).txt $(objects))
|
$(call _rm,$(exe) $(dbg) $(dbg).txt $(objects))
|
||||||
|
|
||||||
distclean :
|
distclean :
|
||||||
$(call _rm,../bin ../objs ../deps comptime.h)
|
$(call _rm,../bin ../objs ../deps ../make comptime.h)
|
||||||
|
|
||||||
info:
|
info:
|
||||||
ifdef WINDOWSHELL
|
ifdef WINDOWSHELL
|
||||||
|
|
|
@ -29,7 +29,10 @@ $(call Print,$(_m))
|
||||||
|
|
||||||
# go for a 32-bit sdl mingw exe by default
|
# go for a 32-bit sdl mingw exe by default
|
||||||
MINGW:=1
|
MINGW:=1
|
||||||
|
# cmd.exe uses native Windows semicolon delimited PATH
|
||||||
|
ifneq (,$(findstring ;,$(PATH)))
|
||||||
WINDOWSHELL:=1
|
WINDOWSHELL:=1
|
||||||
|
endif
|
||||||
|
|
||||||
else # if you on the *nix
|
else # if you on the *nix
|
||||||
|
|
||||||
|
@ -91,7 +94,7 @@ ifeq (,$(filter $(v),$(gcc_versions)))
|
||||||
define line =
|
define line =
|
||||||
Your compiler version, GCC $(version), \
|
Your compiler version, GCC $(version), \
|
||||||
is not supported by the Makefile.
|
is not supported by the Makefile.
|
||||||
The Makefile will assume GCC $(latest_gcc_version).))
|
The Makefile will assume GCC $(latest_gcc_version).
|
||||||
endef
|
endef
|
||||||
$(call Print,$(line))
|
$(call Print,$(line))
|
||||||
GCC$(subst .,,$(latest_gcc_version)):=1
|
GCC$(subst .,,$(latest_gcc_version)):=1
|
||||||
|
|
16
src/Makefile.d/old.mk
Normal file
16
src/Makefile.d/old.mk
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#
|
||||||
|
# Warn about old build directories and offer to purge.
|
||||||
|
#
|
||||||
|
|
||||||
|
_old:=$(wildcard $(addprefix ../bin/,FreeBSD Linux \
|
||||||
|
Linux64 Mingw Mingw64 SDL dummy) ../objs ../deps)
|
||||||
|
|
||||||
|
ifdef _old
|
||||||
|
$(foreach v,$(_old),$(info $(abspath $(v))))
|
||||||
|
$(info )
|
||||||
|
$(info These directories are no longer\
|
||||||
|
required and should be removed.)
|
||||||
|
$(info You may remove them manually or\
|
||||||
|
by using 'make distclean')
|
||||||
|
$(error )
|
||||||
|
endif
|
|
@ -7,9 +7,11 @@ PKG_CONFIG?=pkg-config
|
||||||
ifdef WINDOWSHELL
|
ifdef WINDOWSHELL
|
||||||
rmrf=-2>NUL DEL /S /Q
|
rmrf=-2>NUL DEL /S /Q
|
||||||
mkdir=-2>NUL MD
|
mkdir=-2>NUL MD
|
||||||
|
cat=TYPE
|
||||||
else
|
else
|
||||||
rmrf=rm -rf
|
rmrf=rm -rf
|
||||||
mkdir=mkdir -p
|
mkdir=mkdir -p
|
||||||
|
cat=cat
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef LINUX64
|
ifdef LINUX64
|
||||||
|
|
|
@ -10,7 +10,8 @@ Wildvar=$(foreach v,$(filter $(1),$(.VARIABLES)),$($(v)))
|
||||||
|
|
||||||
# Read a list of words from file and prepend each with the
|
# Read a list of words from file and prepend each with the
|
||||||
# directory of the file.
|
# directory of the file.
|
||||||
List=$(addprefix $(dir $(1)),$(file < $(1)))
|
_cat=$(shell $(cat) $(call Windows_path,$(1)))
|
||||||
|
List=$(addprefix $(dir $(1)),$(call _cat,$(1)))
|
||||||
|
|
||||||
# Convert path separators to backslash on Windows.
|
# Convert path separators to backslash on Windows.
|
||||||
Windows_path=$(if $(WINDOWSHELL),$(subst /,\,$(1)),$(1))
|
Windows_path=$(if $(WINDOWSHELL),$(subst /,\,$(1)),$(1))
|
||||||
|
|
Loading…
Reference in a new issue