diff --git a/src/Makefile b/src/Makefile index 228738916..9e3f6d706 100644 --- a/src/Makefile +++ b/src/Makefile @@ -183,19 +183,6 @@ include Makefile.d/detect.mk sources:= makedir:=../make -exe:=ringracers - -# append branch name by default -ifndef EXENAME -branch:=$(shell git symbolic-ref -q --short HEAD) - -# not a detached HEAD -ifdef branch -exe:=$(exe)_$(branch) -endif - -endif - # -DCOMPVERSION: flag to use comptime.h opts:=-DCOMPVERSION -g libs:= @@ -206,6 +193,9 @@ nasm_format:= # also defines the name as a macro to the compiler. passthru_opts:= +# separate suffix with an underscore +exesuffix:=$(call _,$(EXESUFFIX)) + include Makefile.d/platform.mk include Makefile.d/features.mk include Makefile.d/versions.mk @@ -248,8 +238,13 @@ else EXEDIR?=../bin endif -# default EXENAME (usually set by platform) -EXENAME?=$(exe) +# append branch name by default +ifndef EXENAME +base:=ringracers +branch:=$(shell git symbolic-ref -q --short HEAD) +EXENAME:=$(base)$(call _,$(branch))$(exesuffix) +endif + DBGNAME?=$(EXENAME).debug exe:=$(EXEDIR)/$(EXENAME) diff --git a/src/Makefile.d/util.mk b/src/Makefile.d/util.mk index bda68df13..6d724b3e5 100644 --- a/src/Makefile.d/util.mk +++ b/src/Makefile.d/util.mk @@ -91,3 +91,6 @@ endif endif .=$(call Ifndef,ECHO,@) + +# prepends an underscore if not empty +_=$(if $(1),_$(1)) diff --git a/src/Makefile.d/win32.mk b/src/Makefile.d/win32.mk index 3cb0d4f38..7a2434cc5 100644 --- a/src/Makefile.d/win32.mk +++ b/src/Makefile.d/win32.mk @@ -2,7 +2,7 @@ # Mingw, if you don't know, that's Win32/Win64 # -exe:=$(exe)$(if $(MINGW64),64).exe +exesuffix:=$(exesuffix)$(if $(MINGW64),64).exe # disable dynamicbase if under msys2 ifdef MSYSTEM