| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Output an architecture and/or platform name that Quake 3 could use for the |
| 4 | # build or host CPU architecture or operating system. |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | case "$2" in |
| 9 | (BUILD|HOST) |
| 10 | eval "$(dpkg-architecture --print-set)" |
| 11 | eval "GNU_CPU=\"\${DEB_${2}_GNU_CPU}"\" |
| 12 | eval "GNU_SYSTEM=\"\${DEB_${2}_GNU_SYSTEM}"\" |
| 13 | ;; |
| 14 | (*) |
| 15 | GNU_CPU="$2" |
| 16 | GNU_SYSTEM="$3" |
| 17 | ;; |
| 18 | esac |
| 19 | |
| 20 | # In the upstream Makefile the architecture is given by uname -m, with the |
| 21 | # following substitutions: |
| 22 | # |
| 23 | # i.86 -> x86 (used to be i386) |
| 24 | # arm* -> arm |
| 25 | # powerpc -> ppc |
| 26 | # powerpc64 -> ppc64 |
| 27 | # axp -> alpha on Linux and FreeBSD (used to be axp) |
| 28 | # |
| 29 | # alpha, i386, ppc(64), sparc and x86_64 are the architectures with special |
| 30 | # handling in the Makefile (all except alpha can compile bytecode). |
| 31 | # |
| 32 | # Before PR #129 was merged, qcommon.h expected to see one of these: |
| 33 | # |
| 34 | # x86, x86_64, AXP (Windows) |
| 35 | # x86, x86_64, ppc64, ppc, s390, s390x, ia64, alpha, sparc, arm, cris, |
| 36 | # hppa, mips, sh (Linux, kFreeBSD) |
| 37 | # some subset of the Linux set (Mac OS, *BSD, SunOS, Irix) |
| 38 | |
| 39 | Q3ARCH="${GNU_CPU}" |
| 40 | |
| 41 | case ${GNU_CPU} in |
| 42 | i?86) |
| 43 | Q3ARCH=x86 |
| 44 | # previously Q3ARCH=i386 |
| 45 | # RTCW FILE_ARCH=i386 |
| 46 | ;; |
| 47 | |
| 48 | arm*) |
| 49 | Q3ARCH=arm |
| 50 | ;; |
| 51 | |
| 52 | alpha) |
| 53 | Q3ARCH=alpha |
| 54 | # previously Q3ARCH=axp |
| 55 | ;; |
| 56 | |
| 57 | powerpc) |
| 58 | Q3ARCH=ppc |
| 59 | ;; |
| 60 | |
| 61 | powerpc64) |
| 62 | Q3ARCH=ppc64 |
| 63 | ;; |
| 64 | |
| 65 | mipsel) |
| 66 | # both mips and mipsel have $(uname -m) = mips |
| 67 | Q3ARCH=mips |
| 68 | ;; |
| 69 | |
| 70 | sh4) |
| 71 | Q3ARCH=sh |
| 72 | ;; |
| 73 | esac |
| 74 | |
| 75 | # In the upstream Makefile the platform is given by uname, with the |
| 76 | # following substitutions: |
| 77 | # |
| 78 | # anything after _ removed |
| 79 | # folded to lower case |
| 80 | # / -> _ |
| 81 | # |
| 82 | # This would result in Debian builds being done for linux, gnu_kfreebsd and |
| 83 | # gnu. |
| 84 | # |
| 85 | # However, for most platform names the build system doesn't actually care, |
| 86 | # it's just "some other platform", so we can get away with using the |
| 87 | # GNU system as-is. |
| 88 | # |
| 89 | # (For instance, on Debian kFreeBSD buildd, uname says GNU/kFreeBSD whereas |
| 90 | # the GNU CPU type is kfreebsd-gnu, but that's not important because the |
| 91 | # Makefile doesn't actually do anything different.) |
| 92 | |
| 93 | case ${GNU_SYSTEM} in |
| 94 | linux-gnu*) |
| 95 | # including, but not limited to: |
| 96 | # arm-linux-gnueabi (Debian armel: ARM EABI, LE) |
| 97 | # arm-linux-gnueabihf (Debian armhf: ARM EABI, LE, hardfloat) |
| 98 | # powerpc-linux-gnuspe (Debian powerpcspe: Signal Processing Extension) |
| 99 | Q3OS=linux |
| 100 | ;; |
| 101 | *) |
| 102 | Q3OS=${GNU_SYSTEM} |
| 103 | ;; |
| 104 | esac |
| 105 | |
| 106 | echo "GNU CPU: ${GNU_CPU}" >&2 |
| 107 | echo " => Q3 ARCH: ${Q3ARCH}" >&2 |
| 108 | echo "GNU system ${GNU_SYSTEM}" >&2 |
| 109 | echo " => Q3 PLATFORM: ${Q3OS}" >&2 |
| 110 | |
| 111 | case $1 in |
| 112 | |
| 113 | (make) |
| 114 | echo "ARCH=\"${Q3ARCH}\" PLATFORM=\"${Q3OS}\"" |
| 115 | ;; |
| 116 | |
| 117 | (make-build) |
| 118 | echo "COMPILE_ARCH=\"${Q3ARCH}\" COMPILE_PLATFORM=\"${Q3OS}\"" |
| 119 | ;; |
| 120 | |
| 121 | (arch) |
| 122 | echo ${Q3ARCH} |
| 123 | ;; |
| 124 | |
| 125 | (platform) |
| 126 | echo ${Q3OS} |
| 127 | ;; |
| 128 | |
| 129 | *) |
| 130 | echo "Usage:" >&2 |
| 131 | echo " q3arch MODE BUILD|HOST" >&2 |
| 132 | echo " or q3arch MODE CPU SYSTEM" >&2 |
| 133 | echo "MODE is: make|make-build|arch|platform" >&2 |
| 134 | exit 1 |
| 135 | ;; |
| 136 | |
| 137 | esac |
| 138 | |
| 139 | # Copyright 2009-2015 Simon McVittie <[email protected]> |
| 140 | # Copying and distribution of this file, with or without modification, are |
| 141 | # permitted in any medium without royalty provided this notice is preserved. |
| 142 | # This file is offered as-is, without any warranty. |