From 071965b3f0647385f3c32a49c1df5e125550969c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 14 Jul 2015 22:51:53 +0100 Subject: [PATCH 1/3] Makefile: confine $(LIB) to the one platform that needs it, namely irix64 It isn't mentioned anywhere else, and deleting it from the Linux code path means we don't need to maintain an exhaustive list of 64-bit architectures. --- Makefile | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/Makefile b/Makefile index f8ade884..fda9b96f 100644 --- a/Makefile +++ b/Makefile @@ -317,32 +317,12 @@ endif # SETUP AND BUILD -- LINUX ############################################################################# -## Defaults -LIB=lib - INSTALL=install MKDIR=mkdir EXTRA_FILES= CLIENT_EXTRA_FILES= ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu")) - - ifeq ($(ARCH),x86_64) - LIB=lib64 - else - ifeq ($(ARCH),ppc64) - LIB=lib64 - else - ifeq ($(ARCH),s390x) - LIB=lib64 - else - ifeq ($(ARCH),aarch64) - LIB=lib64 - endif - endif - endif - endif - BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ -pipe -DUSE_ICON CLIENT_CFLAGS += $(SDL_CFLAGS) @@ -824,6 +804,7 @@ else # ifeq netbsd ############################################################################# ifeq ($(PLATFORM),irix64) + LIB=lib ARCH=mips From c91fab3900345d047f085d1e467521bba1ebd28f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 14 Jul 2015 22:51:55 +0100 Subject: [PATCH 2/3] build: canonicalize all ARM variants to "arm", matching q_platform.h The ARCH in the Makefile must match the ARCH_STRING in q_platform.h; otherwise, ioquake3 will install (for instance) uiARCH.so but look for uiARCH_STRING.so, which isn't going to go well (particularly for the modular renderer). Like i386, but unlike most (all?) other Linux platforms, uname -m on 32-bit ARM machines can have various results starting with "arm", depending on the specific CPU version (e.g. Raspberry Pi is armv6l, RPi2 is armv7l). Again similar to the x86 family, it's appropriate for them to share an architecture suffix; q_platform.h has traditionally used "arm" so let's use that. 64-bit ARM makes a clean break from this, much like 64-bit x86 does: uname -m produces a string not starting with arm (specifically "aarch64"), and gcc predefines __aarch64__ instead of __arm__. As a result, it is unaffected by this change. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fda9b96f..d9f8a460 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ COMPILE_PLATFORM=$(shell uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]'|sed -e 's/\//_/g') -COMPILE_ARCH=$(shell uname -m | sed -e s/i.86/x86/) +COMPILE_ARCH=$(shell uname -m | sed -e s/i.86/x86/ | sed -e 's/^arm.*/arm/') ifeq ($(COMPILE_PLATFORM),sunos) # Solaris uname and GNU uname differ From 2a71948f21fe588dbce9b29409283e9c912ef8e7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 14 Jul 2015 22:51:57 +0100 Subject: [PATCH 3/3] build: define ARCH_STRING in Makefile on Linux and other GNU platforms GNU platforms (Linux, kFreeBSD, Hurd) have endian.h to determine endianness, so all architectures except x86_64 are in fact treated identically, except that their ARCH_STRING is different. The ARCH_STRING must always be identical to the ARCH from the Makefile, otherwise the engine will not find its cgame, game and ui plugins under their expected names and startup will fail. If we pass it in from the Makefile, then an identical value is guaranteed, and we can get rid of an increasingly long list of defined(__some_cpu__) tests. The one remaining quirk is that we test __x86_64__ to determine whether to define idx64; I've kept that, but separated it from the ARCH_STRING. On non-Linux platforms we only support a few architectures anyway, so keeping the list up to date is less of a burden; *BSD porters could probably use the same technique to get support for lots of architectures with little effort, but I have not done that here, because I cannot test it. Windows must continue to support preprocessor-based architecture tests in any case, so that the MSVC solutions (which do not use the Makefile) can continue to work. However, Windows only runs on a few CPU families, so this shouldn't be a significant burden in practice. When cross-compiling, the tools are compiled for the build architecture (COMPILE_PLATFORM, COMPILE_ARCH) rather than the host architecture (PLATFORM, ARCH), so define ARCH_STRING to COMPILE_ARCH on a GNU COMPILE_PLATFORM. --- Makefile | 6 +++++- code/qcommon/q_platform.h | 35 +++++------------------------------ 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index d9f8a460..edd0cdb6 100644 --- a/Makefile +++ b/Makefile @@ -322,9 +322,13 @@ MKDIR=mkdir EXTRA_FILES= CLIENT_EXTRA_FILES= +ifneq (,$(findstring "$(COMPILE_PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu")) + TOOLS_CFLAGS += -DARCH_STRING=\"$(COMPILE_ARCH)\" +endif + ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu")) BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ - -pipe -DUSE_ICON + -pipe -DUSE_ICON -DARCH_STRING=\\\"$(ARCH)\\\" CLIENT_CFLAGS += $(SDL_CFLAGS) OPTIMIZEVM = -O3 diff --git a/code/qcommon/q_platform.h b/code/qcommon/q_platform.h index e22fc7d9..3ed5357f 100644 --- a/code/qcommon/q_platform.h +++ b/code/qcommon/q_platform.h @@ -185,38 +185,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define PATH_SEP '/' -#if defined __i386__ -#define ARCH_STRING "x86" -#elif defined __x86_64__ +#if !defined(ARCH_STRING) +# error ARCH_STRING should be defined by the Makefile +#endif + +#if defined __x86_64__ #undef idx64 #define idx64 1 -#define ARCH_STRING "x86_64" -#elif defined __powerpc64__ -#define ARCH_STRING "ppc64" -#elif defined __powerpc__ -#define ARCH_STRING "ppc" -#elif defined __s390__ -#define ARCH_STRING "s390" -#elif defined __s390x__ -#define ARCH_STRING "s390x" -#elif defined __ia64__ -#define ARCH_STRING "ia64" -#elif defined __alpha__ -#define ARCH_STRING "alpha" -#elif defined __sparc__ -#define ARCH_STRING "sparc" -#elif defined __arm__ -#define ARCH_STRING "arm" -#elif defined __aarch64__ -#define ARCH_STRING "aarch64" -#elif defined __cris__ -#define ARCH_STRING "cris" -#elif defined __hppa__ -#define ARCH_STRING "hppa" -#elif defined __mips__ -#define ARCH_STRING "mips" -#elif defined __sh__ -#define ARCH_STRING "sh" #endif #if __FLOAT_WORD_ORDER == __BIG_ENDIAN