[iortcw] 372/497: build: define ARCH_STRING in Makefile on Linux and other GNU platforms

Simon McVittie smcv at debian.org
Fri Sep 8 10:37:30 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit 47dff9deb386df0830a532840665927094280b55
Author: Simon McVittie <smcv at debian.org>
Date:   Fri Jul 17 08:40:40 2015 +0100

    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 FILE_ARCH from the
    Makefile (which is the ARCH, except on i386 for historical reasons),
    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. I haven't included the ARCH/FILE_ARCH distinction
    here, because as far as I can tell the tools don't use this information
    anyway.
---
 MP/Makefile                  |  6 +++++-
 MP/code/qcommon/q_platform.h | 35 +++++------------------------------
 SP/Makefile                  |  6 +++++-
 SP/code/qcommon/q_platform.h | 35 +++++------------------------------
 4 files changed, 20 insertions(+), 62 deletions(-)

diff --git a/MP/Makefile b/MP/Makefile
index 530eaa7..c00c81d 100644
--- a/MP/Makefile
+++ b/MP/Makefile
@@ -360,10 +360,14 @@ 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 \
-    -pipe -DUSE_ICON
+    -pipe -DUSE_ICON -DARCH_STRING=\\\"$(FILE_ARCH)\\\"
   CLIENT_CFLAGS += $(SDL_CFLAGS)
 
   OPTIMIZEVM = -O3
diff --git a/MP/code/qcommon/q_platform.h b/MP/code/qcommon/q_platform.h
index e22bc3f..969fbbb 100644
--- a/MP/code/qcommon/q_platform.h
+++ b/MP/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 "i386"
-#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
diff --git a/SP/Makefile b/SP/Makefile
index 8de3486..ceceaac 100644
--- a/SP/Makefile
+++ b/SP/Makefile
@@ -352,10 +352,14 @@ 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 \
-    -pipe -DUSE_ICON
+    -pipe -DUSE_ICON -DARCH_STRING=\\\"$(FILE_ARCH)\\\"
   CLIENT_CFLAGS += $(SDL_CFLAGS)
 
   OPTIMIZEVM = -O3
diff --git a/SP/code/qcommon/q_platform.h b/SP/code/qcommon/q_platform.h
index e22bc3f..969fbbb 100644
--- a/SP/code/qcommon/q_platform.h
+++ b/SP/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 "i386"
-#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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list