mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-21 18:32:08 +00:00
Makefile: let variables be defined on Make line
If a variable is defined as in 'make CC=gcc-10', then that definition overrides anything other definition in the Makefile.
This commit is contained in:
parent
5f4d7e3c5b
commit
c3ad5de912
1 changed files with 26 additions and 25 deletions
51
src/Makefile
51
src/Makefile
|
@ -145,7 +145,7 @@ endif
|
|||
OBJDUMP_OPTS?=--wide --source --line-numbers
|
||||
|
||||
OBJCOPY:=$(call Prefix,objcopy)
|
||||
OBJDUMP:=$(call Prefix,objdump) $(OBJDUMP_OPTS)
|
||||
OBJDUMP:=$(call Prefix,objdump)
|
||||
WINDRES:=$(call Prefix,windres)
|
||||
|
||||
ifdef YASM
|
||||
|
@ -273,16 +273,18 @@ opts+=$(debug_opts)
|
|||
|
||||
opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v)))
|
||||
|
||||
CFLAGS:=$(opts) $(WFLAGS) $(CPPFLAGS) $(CFLAGS)
|
||||
LDFLAGS:=$(libs) $(LDFLAGS)
|
||||
ASFLAGS+=-x assembler-with-cpp
|
||||
opts+=$(WFLAGS) $(CPPFLAGS) $(CFLAGS)
|
||||
libs+=$(LDFLAGS)
|
||||
asflags:=$(ASFLAGS) -x assembler-with-cpp
|
||||
|
||||
cc=$(CC)
|
||||
|
||||
ifdef DISTCC
|
||||
CC:=distcc $(CC)
|
||||
cc=distcc $(CC)
|
||||
endif
|
||||
|
||||
ifdef CCACHE
|
||||
CC:=ccache $(CC)
|
||||
cc=ccache $(CC)
|
||||
endif
|
||||
|
||||
ifndef SILENT
|
||||
|
@ -293,11 +295,11 @@ ifndef destructive
|
|||
$(shell $(CC) -v)
|
||||
define flags =
|
||||
|
||||
CC ........ $(CC)
|
||||
CC ........ $(cc)
|
||||
|
||||
CFLAGS .... $(CFLAGS)
|
||||
CFLAGS .... $(opts)
|
||||
|
||||
LDFLAGS ... $(LDFLAGS)
|
||||
LDFLAGS ... $(libs)
|
||||
|
||||
endef
|
||||
$(info $(flags))
|
||||
|
@ -311,13 +313,12 @@ endif
|
|||
endif
|
||||
|
||||
LD:=$(CC)
|
||||
CC:=$(CC) $(CFLAGS)
|
||||
NASM:=$(NASM) $(NASMOPTS) -f $(nasm_format)
|
||||
GZIP:=$(GZIP) $(GZIP_OPTS)
|
||||
cc:=$(cc) $(opts)
|
||||
nasm=$(NASM) $(NASMOPTS) -f $(nasm_format)
|
||||
ifdef UPX
|
||||
UPX:=$(UPX) $(UPX_OPTS)
|
||||
upx=$(UPX) $(UPX_OPTS)
|
||||
endif
|
||||
WINDRES:=$(WINDRES) $(WINDRESFLAGS)\
|
||||
windres=$(WINDRES) $(WINDRESFLAGS)\
|
||||
$(debug_opts) --include-dir=win32 -O coff
|
||||
|
||||
%/ :
|
||||
|
@ -327,7 +328,7 @@ WINDRES:=$(WINDRES) $(WINDRESFLAGS)\
|
|||
# prerequisites
|
||||
.SECONDEXPANSION :
|
||||
|
||||
# 'UPX' is also recognized in the enviornment by upx
|
||||
# 'UPX' is also recognized in the environment by upx
|
||||
unexport UPX
|
||||
|
||||
# executable stripped of debugging symbols
|
||||
|
@ -336,19 +337,19 @@ $(exe) : $(dbg) | $$(@D)/
|
|||
$(.)-$(OBJCOPY) --add-gnu-debuglink=$< $@
|
||||
ifdef UPX
|
||||
$(call Echo,Compressing final executable...)
|
||||
$(.)-$(UPX) $@
|
||||
$(.)-$(upx) $@
|
||||
endif
|
||||
|
||||
# original executable with debugging symbols
|
||||
$(dbg) : $(objects) | $$(@D)/
|
||||
$(call Echo,Linking $(@F)...)
|
||||
$(.)$(LD) -o $@ $^ $(LDFLAGS)
|
||||
$(.)$(LD) -o $@ $^ $(libs)
|
||||
|
||||
# disassembly of executable
|
||||
$(dbg).txt : $(dbg)
|
||||
$(call Echo,Dumping debugging info...)
|
||||
$(.)$(OBJDUMP) $< > $@
|
||||
$(.)$(GZIP) $@
|
||||
$(.)$(OBJDUMP) $(OBJDUMP_OPTS) $< > $@
|
||||
$(.)$(GZIP) $(GZIP_OPTS) $@
|
||||
|
||||
# '::' means run unconditionally
|
||||
# this really updates comptime.h
|
||||
|
@ -373,11 +374,11 @@ ifdef Echo_name
|
|||
@printf '%-20.20s\r' $$<
|
||||
endif
|
||||
endif
|
||||
$(.)$(CC) -MM -MF $$@ -MT $(objdir)/$$(*F).o $(2) $$<
|
||||
$(.)$(cc) -MM -MF $$@ -MT $(objdir)/$$(*F).o $(2) $$<
|
||||
endef
|
||||
|
||||
$(eval $(call _recipe,c))
|
||||
$(eval $(call _recipe,s,$(ASFLAGS)))
|
||||
$(eval $(call _recipe,s,$(asflags)))
|
||||
|
||||
# compiling recipe template
|
||||
# 1: target file suffix
|
||||
|
@ -389,10 +390,10 @@ $(objdir)/%.$(1) : %.$(2) | $$$$(@D)/
|
|||
$(.)$(3)
|
||||
endef
|
||||
|
||||
$(eval $(call _recipe,o,c,$(CC) -c -o $$@ $$<))
|
||||
$(eval $(call _recipe,o,nas,$(NASM) -o $$@ $$<))
|
||||
$(eval $(call _recipe,o,s,$(CC) $(ASFLAGS) -c -o $$@ $$<))
|
||||
$(eval $(call _recipe,res,rc,$(WINDRES) -i $$< -o $$@))
|
||||
$(eval $(call _recipe,o,c,$(cc) -c -o $$@ $$<))
|
||||
$(eval $(call _recipe,o,nas,$(nasm) -o $$@ $$<))
|
||||
$(eval $(call _recipe,o,s,$(cc) $(asflags) -c -o $$@ $$<))
|
||||
$(eval $(call _recipe,res,rc,$(windres) -i $$< -o $$@))
|
||||
|
||||
_rm=$(.)$(rmrf) $(call Windows_path,$(1))
|
||||
|
||||
|
|
Loading…
Reference in a new issue