diff options
| author | 2025-04-20 02:36:58 +1000 | |
|---|---|---|
| committer | 2025-04-20 02:36:58 +1000 | |
| commit | 8c28d3ff7eb420452a8f3499d77b3957ca7edf58 (patch) | |
| tree | ddd98c2e08b9be0146a0f80d0d24bc4130acd6ea /makefile | |
| parent | b1d2a52ddd96375d0608fee4d666998d621679c6 (diff) | |
Cleaned up build scripts and compiling documentation:
* Made it a bit easier to cross-compile for x86-64 or i686 on an AArch64
Windows system.
* Choose the default native recompiler back-end based on predefined
macros rather than requiring the build scripts to set it.
* Don't require every target without a native recompiler to declare
this.
* Got rid of the code that was supposed to set -m32 or -m64 when
building GENie (it didn't work - it tried to use ARCHITECTURE before
setting it).
* Avoid relying on the unreliable PROCESSOR_ARCHITECTURE environment
variable.
* Got rid of stuff for versions of Xcode that are definitely no longer
supported.
* Got rid of workarounds for very old Linux distros.
* Use newer makefile syntax for if/else/if structures, comment some else
and endif statements for clarity.
Diffstat (limited to 'makefile')
| -rw-r--r-- | makefile | 275 |
1 files changed, 98 insertions, 177 deletions
@@ -140,114 +140,108 @@ MAKEPARAMS := -R # ifeq ($(OS),Windows_NT) -OSARCH := $(shell wmic OS get OSArchitecture) OS := windows GENIEOS := windows + +ifeq ($(MSYSTEM),MINGW32) +PLATFORM := x86 +else ifeq ($(MSYSTEM),MINGW64) +PLATFORM := x86 +else ifeq ($(MSYSTEM),CLANGARM64) +PLATFORM := arm64 +else # MSYSTEM +OSARCH := $(shell wmic OS get OSArchitecture) ifneq ($(findstring ARM 64-bit,$(OSARCH)),) PLATFORM := arm64 -else +else # OSARCH PLATFORM := x86 -endif -else +endif # OSARCH +endif # MSYSTEM + +else # Windows_NT UNAME := $(shell uname -mps) UNAME_M := $(shell uname -m) UNAME_P := $(shell uname -p) GENIEOS := linux PLATFORM := unknown + ifneq ($(filter x86_64,$(UNAME_P)),) PLATFORM := x86 -endif -ifneq ($(filter %86,$(UNAME_P)),) +else ifneq ($(filter %86,$(UNAME_P)),) PLATFORM := x86 endif + ifneq ($(filter alpha,$(UNAME_M)),) PLATFORM := alpha -endif -ifneq ($(filter alpha,$(UNAME_P)),) +else ifneq ($(filter alpha,$(UNAME_P)),) PLATFORM := alpha -endif -ifneq ($(filter arm%,$(UNAME_M)),) -PLATFORM := arm -endif -ifneq ($(filter arm%,$(UNAME_P)),) -PLATFORM := arm -endif -ifneq ($(filter aarch64%,$(UNAME_M)),) +else ifneq ($(filter aarch64%,$(UNAME_M)),) PLATFORM := arm64 -endif -ifneq ($(filter arm64%,$(UNAME_M)),) +else ifneq ($(filter aarch64%,$(UNAME_P)),) PLATFORM := arm64 -endif -ifneq ($(filter aarch64%,$(UNAME_P)),) +else ifneq ($(filter arm64%,$(UNAME_M)),) PLATFORM := arm64 -endif -ifneq ($(filter powerpc,$(UNAME_P)),) +else ifneq ($(filter arm%,$(UNAME_M)),) +PLATFORM := arm +else ifneq ($(filter arm%,$(UNAME_P)),) +PLATFORM := arm +else ifneq ($(filter powerpc,$(UNAME_P)),) PLATFORM := powerpc -endif -ifneq ($(filter riscv64%,$(UNAME_M)),) +else ifneq ($(filter riscv64%,$(UNAME_M)),) PLATFORM := riscv64 -endif -ifneq ($(filter riscv64%,$(UNAME_P)),) +else ifneq ($(filter riscv64%,$(UNAME_P)),) PLATFORM := riscv64 -endif -ifneq ($(filter mips64%,$(UNAME_M)),) +else ifneq ($(filter mips64%,$(UNAME_M)),) ifeq ($(shell getconf LONG_BIT),64) PLATFORM := mips64 endif endif + ifeq ($(firstword $(filter Linux,$(UNAME))),Linux) OS := linux -endif -ifeq ($(firstword $(filter Solaris,$(UNAME))),Solaris) +else ifeq ($(firstword $(filter Solaris,$(UNAME))),Solaris) OS := solaris GENIEOS := solaris -endif -ifeq ($(firstword $(filter SunOS,$(UNAME))),SunOS) +else ifeq ($(firstword $(filter SunOS,$(UNAME))),SunOS) OS := solaris GENIEOS := solaris -endif -ifeq ($(firstword $(filter FreeBSD,$(UNAME))),FreeBSD) +else ifeq ($(firstword $(filter FreeBSD,$(UNAME))),FreeBSD) OS := freebsd GENIEOS := bsd -endif -ifeq ($(firstword $(filter GNU/kFreeBSD,$(UNAME))),GNU/kFreeBSD) +else ifeq ($(firstword $(filter GNU/kFreeBSD,$(UNAME))),GNU/kFreeBSD) OS := freebsd GENIEOS := freebsd -endif -ifeq ($(firstword $(filter NetBSD,$(UNAME))),NetBSD) +else ifeq ($(firstword $(filter NetBSD,$(UNAME))),NetBSD) OS := netbsd GENIEOS := freebsd -endif -ifeq ($(firstword $(filter OpenBSD,$(UNAME))),OpenBSD) +else ifeq ($(firstword $(filter OpenBSD,$(UNAME))),OpenBSD) OS := openbsd GENIEOS := freebsd -endif -ifeq ($(firstword $(filter Darwin,$(UNAME))),Darwin) +else ifeq ($(firstword $(filter Darwin,$(UNAME))),Darwin) OS := macosx GENIEOS := darwin -endif -ifeq ($(firstword $(filter Haiku,$(UNAME))),Haiku) +else ifeq ($(firstword $(filter Haiku,$(UNAME))),Haiku) OS := haiku endif + ifndef OS $(error Unable to detect OS from uname -a: $(UNAME)) endif -endif + +endif # Windows_NT ifdef MSYSTEM MINGW := $(MINGW_PREFIX) ifeq ($(MSYSTEM),MINGW32) MINGW32 := $(MINGW_PREFIX) -endif -ifeq ($(MSYSTEM),MINGW64) +else ifeq ($(MSYSTEM),MINGW64) MINGW64 := $(MINGW_PREFIX) -endif -ifeq ($(MSYSTEM),CLANGARM64) +else ifeq ($(MSYSTEM),CLANGARM64) MINGW64 := $(MINGW_PREFIX) -endif +endif # MSYSTEM ifndef TOOLCHAIN TOOLCHAIN := $(MINGW_PREFIX)/bin/ -endif +endif # TOOLCHAIN else # MSYSTEM MINGW := ifdef MINGW64 @@ -308,60 +302,48 @@ ifndef TARGETOS ifeq ($(OS),windows) TARGETOS := windows -ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) + +ifeq ($(MSYSTEM),MINGW32) +ARCHITECTURE = _x86 +else ifeq ($(MSYSTEM),MINGW64) ARCHITECTURE := _x64 -endif -ifeq ($(PROCESSOR_ARCHITECTURE),x86) +else ifeq ($(MSYSTEM),CLANGARM64) ARCHITECTURE := _x64 +else ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) +ARCHITECTURE := _x64 +else ifeq ($(PROCESSOR_ARCHITECTURE),x86) ifeq ($(PROCESSOR_ARCHITEW6432),AMD64) -else +ARCHITECTURE := _x64 +else # PROCESSOR_ARCHITEW6432 ARCHITECTURE := _x86 +endif # PROCESSOR_ARCHITEW6432 endif -endif -else + +else # windows UNAME := $(shell uname -mps) TARGETOS := $(OS) -#------------------------------------------------- -# determine the whether -m32, -m64 or nothing -# should be passed to gcc when building genie -#------------------------------------------------- - -ifeq ($(ARCHITECTURE),_x86) -MPARAM := -m32 -else -ifeq ($(ARCHITECTURE),_x64) -MPARAM := -m64 -else -MPARAM := -endif -endif - ARCHITECTURE := _x86 ifeq ($(firstword $(filter x86_64,$(UNAME))),x86_64) ARCHITECTURE := _x64 -endif -ifeq ($(firstword $(filter amd64,$(UNAME))),amd64) +else ifeq ($(firstword $(filter amd64,$(UNAME))),amd64) ARCHITECTURE := _x64 -endif -ifeq ($(firstword $(filter ppc64,$(UNAME))),ppc64) +else ifeq ($(firstword $(filter ppc64le,$(UNAME))),ppc64le) ARCHITECTURE := _x64 -endif -ifeq ($(firstword $(filter powerpc64,$(UNAME))),powerpc64) +else ifeq ($(firstword $(filter ppc64,$(UNAME))),ppc64) ARCHITECTURE := _x64 -endif -ifeq ($(firstword $(filter ppc64le,$(UNAME))),ppc64le) +else ifeq ($(firstword $(filter powerpc64,$(UNAME))),powerpc64) ARCHITECTURE := _x64 -endif -ifeq ($(firstword $(filter s390x,$(UNAME))),s390x) +else ifeq ($(firstword $(filter s390x,$(UNAME))),s390x) ARCHITECTURE := _x64 endif -endif -else +endif # windows + +else # TARGETOS CROSS_BUILD := 1 -endif # TARGET_OS +endif # TARGETOS ifdef PTR64 ifeq ($(PTR64),1) @@ -372,21 +354,25 @@ endif endif ifeq ($(OS),windows) + ifndef MINGW64 ARCHITECTURE := _x86 -endif -ifeq ($(ARCHITECTURE),_x64) -WINDRES := $(MINGW64)/bin/windres -else +endif # MINGW64 +ifeq ($(ARCHITECTURE),_x86) WINDRES := $(MINGW32)/bin/windres -endif -else -ifeq ($(ARCHITECTURE),_x64) -WINDRES := $(word 1,$(TOOLCHAIN) x86_64-w64-mingw32-)windres -else +else # ARCHITECTURE +WINDRES := $(MINGW64)/bin/windres +endif # ARCHITECTURE + +else # windows + +ifeq ($(ARCHITECTURE),_x86) WINDRES := $(word 1,$(TOOLCHAIN) i686-w64-mingw32-)windres -endif -endif +else # ARCHITECTURE +WINDRES := $(word 1,$(TOOLCHAIN) x86_64-w64-mingw32-)windres +endif # ARCHITECTURE + +endif # windows # Emscripten ifeq ($(findstring emcc,$(CC)),emcc) @@ -397,44 +383,10 @@ ifndef NOASM endif endif -ifeq ($(findstring ppc,$(UNAME)),ppc) -ifndef FORCE_DRC_C_BACKEND - FORCE_DRC_C_BACKEND := 1 -endif -endif - -ifeq ($(findstring powerpc,$(UNAME)),powerpc) -ifndef FORCE_DRC_C_BACKEND - FORCE_DRC_C_BACKEND := 1 -endif -endif - -ifeq ($(findstring arm,$(UNAME)),arm) -ARCHITECTURE := -ifneq ($(PLATFORM),arm64) - ifndef FORCE_DRC_C_BACKEND - FORCE_DRC_C_BACKEND := 1 - endif -endif -endif - ifeq ($(findstring aarch64,$(UNAME)),aarch64) ARCHITECTURE := endif -ifeq ($(findstring s390x,$(UNAME)),s390x) -ifndef FORCE_DRC_C_BACKEND - FORCE_DRC_C_BACKEND := 1 -endif -endif - -ifeq ($(findstring riscv64,$(UNAME)),riscv64) -ARCHITECTURE := -ifndef FORCE_DRC_C_BACKEND - FORCE_DRC_C_BACKEND := 1 -endif -endif - # Autodetect BIGENDIAN # MacOSX ifndef BIGENDIAN @@ -486,36 +438,23 @@ OSD := sdl ifeq ($(TARGETOS),windows) OSD := windows -endif - -ifeq ($(TARGETOS),linux) +else ifeq ($(TARGETOS),linux) OSD := sdl -endif - -ifeq ($(TARGETOS),freebsd) +else ifeq ($(TARGETOS),freebsd) OSD := sdl -endif - -ifeq ($(TARGETOS),netbsd) +else ifeq ($(TARGETOS),netbsd) OSD := sdl -endif - -ifeq ($(TARGETOS),openbsd) +else ifeq ($(TARGETOS),openbsd) OSD := sdl -endif - -ifeq ($(TARGETOS),solaris) +else ifeq ($(TARGETOS),solaris) OSD := sdl -endif - -ifeq ($(TARGETOS),macosx) +else ifeq ($(TARGETOS),macosx) OSD := sdl -endif - -ifeq ($(TARGETOS),asmjs) +else ifeq ($(TARGETOS),asmjs) OSD := sdl -endif -endif +endif # TARGETOS + +endif # OSD #------------------------------------------------- # which 3rdparty library to build; @@ -577,21 +516,6 @@ ifdef USE_SYSTEM_LIB_PUGIXML PARAMS += --with-system-pugixml='$(USE_SYSTEM_LIB_PUGIXML)' endif -#------------------------------------------------- -# distribution may change things -#------------------------------------------------- - -ifeq ($(DISTRO),) -DISTRO := generic -else -ifeq ($(DISTRO),debian-stable) -else -$(error DISTRO $(DISTRO) unknown) -endif -endif - -PARAMS+= --distro=$(DISTRO) - ifdef TOOLCHAIN PARAMS += --TOOLCHAIN='$(TOOLCHAIN)' endif @@ -1067,20 +991,18 @@ endif ifeq ($(CLANG_VERSION),) $(info GCC $(GCC_VERSION) detected) -else +else # CLANG_VERSION $(info Clang $(CLANG_VERSION) detected) ifneq ($(TARGETOS),asmjs) ifeq ($(ARCHITECTURE),_x64) ARCHITECTURE := _x64_clang -else -ifneq ($(filter arm64%,$(UNAME_M)),) +else ifneq ($(filter arm64%,$(UNAME_M)),) ARCHITECTURE := _arm64_clang else ARCHITECTURE := _x86_clang endif -endif -endif -endif +endif # asmjs +endif # CLANG_VERSION ifneq ($(PYTHON_AVAILABLE),python) $(error Python is not available in path) @@ -1543,13 +1465,13 @@ openbsd_x86_clang: generate $(PROJECTDIR)/$(MAKETYPE)-openbsd-clang/Makefile GENIE_SRC=$(wildcard 3rdparty/genie/src/host/*.c) $(GENIE): $(GENIE_SRC) - $(SILENT) $(MAKE) $(MAKEPARAMS) -C 3rdparty/genie/build/gmake.$(GENIEOS) -f genie.make MPARAM=$(MPARAM) + $(SILENT) $(MAKE) $(MAKEPARAMS) -C 3rdparty/genie/build/gmake.$(GENIEOS) -f genie.make 3rdparty/genie/src/hosts/%.c: .PHONY: genieclean genieclean: - $(SILENT) $(MAKE) $(MAKEPARAMS) -C 3rdparty/genie/build/gmake.$(GENIEOS) -f genie.make MPARAM=$(MPARAM) clean + $(SILENT) $(MAKE) $(MAKEPARAMS) -C 3rdparty/genie/build/gmake.$(GENIEOS) -f genie.make clean clean: genieclean @echo Cleaning... @@ -1709,7 +1631,6 @@ CPPCHECK_PARAMS += -DLSB_FIRST ifndef USE_SYSTEM_LIB_FLAC CPPCHECK_PARAMS += -DFLAC__NO_DLL endif -CPPCHECK_PARAMS += -DNATIVE_DRC=drcbe_x64 CPPCHECK_PARAMS += -DLUA_COMPAT_APIINTCASTS CPPCHECK_PARAMS += -DWIN32 CPPCHECK_PARAMS += -D__GNUC__ |
