Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | # |
michael@0 | 2 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 5 | |
michael@0 | 6 | ####################################################################### |
michael@0 | 7 | # Master "Core Components" macros for getting the OS architecture # |
michael@0 | 8 | # defines these symbols: |
michael@0 | 9 | # 64BIT_TAG |
michael@0 | 10 | # OS_ARCH (from uname -r) |
michael@0 | 11 | # OS_TEST (from uname -m) |
michael@0 | 12 | # OS_RELEASE (from uname -v and/or -r) |
michael@0 | 13 | # OS_TARGET User defined, or set to OS_ARCH |
michael@0 | 14 | # CPU_ARCH (from unmame -m or -p, ONLY on WINNT) |
michael@0 | 15 | # OS_CONFIG OS_TARGET + OS_RELEASE |
michael@0 | 16 | # OBJDIR_TAG |
michael@0 | 17 | # OBJDIR_NAME |
michael@0 | 18 | ####################################################################### |
michael@0 | 19 | |
michael@0 | 20 | # |
michael@0 | 21 | # Macros for getting the OS architecture |
michael@0 | 22 | # |
michael@0 | 23 | |
michael@0 | 24 | ifeq ($(USE_64), 1) |
michael@0 | 25 | 64BIT_TAG=_64 |
michael@0 | 26 | else |
michael@0 | 27 | 64BIT_TAG= |
michael@0 | 28 | endif |
michael@0 | 29 | |
michael@0 | 30 | OS_ARCH := $(subst /,_,$(shell uname -s)) |
michael@0 | 31 | |
michael@0 | 32 | # |
michael@0 | 33 | # Attempt to differentiate between sparc and x86 Solaris |
michael@0 | 34 | # |
michael@0 | 35 | |
michael@0 | 36 | OS_TEST := $(shell uname -m) |
michael@0 | 37 | ifeq ($(OS_TEST),i86pc) |
michael@0 | 38 | OS_RELEASE := $(shell uname -r)_$(OS_TEST) |
michael@0 | 39 | else |
michael@0 | 40 | OS_RELEASE := $(shell uname -r) |
michael@0 | 41 | endif |
michael@0 | 42 | |
michael@0 | 43 | # |
michael@0 | 44 | # Force the IRIX64 machines to use IRIX. |
michael@0 | 45 | # |
michael@0 | 46 | |
michael@0 | 47 | ifeq ($(OS_ARCH),IRIX64) |
michael@0 | 48 | OS_ARCH = IRIX |
michael@0 | 49 | endif |
michael@0 | 50 | |
michael@0 | 51 | # |
michael@0 | 52 | # Force the older BSD/OS versions to use the new arch name. |
michael@0 | 53 | # |
michael@0 | 54 | |
michael@0 | 55 | ifeq ($(OS_ARCH),BSD_386) |
michael@0 | 56 | OS_ARCH = BSD_OS |
michael@0 | 57 | endif |
michael@0 | 58 | |
michael@0 | 59 | # |
michael@0 | 60 | # Catch Deterim if SVR4 is NCR or UNIXWARE |
michael@0 | 61 | # |
michael@0 | 62 | |
michael@0 | 63 | ifeq ($(OS_ARCH),UNIX_SV) |
michael@0 | 64 | ifneq ($(findstring NCR, $(shell grep NCR /etc/bcheckrc | head -1 )),) |
michael@0 | 65 | OS_ARCH = NCR |
michael@0 | 66 | else |
michael@0 | 67 | # Make UnixWare something human readable |
michael@0 | 68 | OS_ARCH = UNIXWARE |
michael@0 | 69 | endif |
michael@0 | 70 | |
michael@0 | 71 | # Get the OS release number, not 4.2 |
michael@0 | 72 | OS_RELEASE := $(shell uname -v) |
michael@0 | 73 | endif |
michael@0 | 74 | |
michael@0 | 75 | ifeq ($(OS_ARCH),UNIX_System_V) |
michael@0 | 76 | OS_ARCH = NEC |
michael@0 | 77 | endif |
michael@0 | 78 | |
michael@0 | 79 | ifeq ($(OS_ARCH),AIX) |
michael@0 | 80 | OS_RELEASE := $(shell uname -v).$(shell uname -r) |
michael@0 | 81 | endif |
michael@0 | 82 | |
michael@0 | 83 | # |
michael@0 | 84 | # Distinguish between OSF1 V4.0B and V4.0D |
michael@0 | 85 | # |
michael@0 | 86 | |
michael@0 | 87 | ifeq ($(OS_ARCH)$(OS_RELEASE),OSF1V4.0) |
michael@0 | 88 | OS_VERSION := $(shell uname -v) |
michael@0 | 89 | ifeq ($(OS_VERSION),564) |
michael@0 | 90 | OS_RELEASE := V4.0B |
michael@0 | 91 | endif |
michael@0 | 92 | ifeq ($(OS_VERSION),878) |
michael@0 | 93 | OS_RELEASE := V4.0D |
michael@0 | 94 | endif |
michael@0 | 95 | endif |
michael@0 | 96 | |
michael@0 | 97 | # |
michael@0 | 98 | # SINIX changes name to ReliantUNIX with 5.43 |
michael@0 | 99 | # |
michael@0 | 100 | |
michael@0 | 101 | ifeq ($(OS_ARCH),ReliantUNIX-N) |
michael@0 | 102 | OS_ARCH = ReliantUNIX |
michael@0 | 103 | OS_RELEASE = 5.4 |
michael@0 | 104 | endif |
michael@0 | 105 | |
michael@0 | 106 | ifeq ($(OS_ARCH),SINIX-N) |
michael@0 | 107 | OS_ARCH = ReliantUNIX |
michael@0 | 108 | OS_RELEASE = 5.4 |
michael@0 | 109 | endif |
michael@0 | 110 | |
michael@0 | 111 | # |
michael@0 | 112 | # Handle FreeBSD 2.2-STABLE, Linux 2.0.30-osfmach3, and |
michael@0 | 113 | # IRIX 6.5-ALPHA-1289139620. |
michael@0 | 114 | # |
michael@0 | 115 | |
michael@0 | 116 | ifeq (,$(filter-out Linux FreeBSD IRIX,$(OS_ARCH))) |
michael@0 | 117 | OS_RELEASE := $(shell echo $(OS_RELEASE) | sed 's/-.*//') |
michael@0 | 118 | endif |
michael@0 | 119 | |
michael@0 | 120 | ifeq ($(OS_ARCH),Linux) |
michael@0 | 121 | OS_RELEASE := $(subst ., ,$(OS_RELEASE)) |
michael@0 | 122 | ifneq ($(words $(OS_RELEASE)),1) |
michael@0 | 123 | OS_RELEASE := $(word 1,$(OS_RELEASE)).$(word 2,$(OS_RELEASE)) |
michael@0 | 124 | endif |
michael@0 | 125 | endif |
michael@0 | 126 | |
michael@0 | 127 | # |
michael@0 | 128 | # For OS/2 |
michael@0 | 129 | # |
michael@0 | 130 | ifeq ($(OS_ARCH),OS_2) |
michael@0 | 131 | OS_ARCH = OS2 |
michael@0 | 132 | OS_RELEASE := $(shell uname -v) |
michael@0 | 133 | endif |
michael@0 | 134 | |
michael@0 | 135 | ####################################################################### |
michael@0 | 136 | # Master "Core Components" macros for getting the OS target # |
michael@0 | 137 | ####################################################################### |
michael@0 | 138 | |
michael@0 | 139 | # |
michael@0 | 140 | # Note: OS_TARGET should be specified on the command line for gmake. |
michael@0 | 141 | # When OS_TARGET=WIN95 is specified, then a Windows 95 target is built. |
michael@0 | 142 | # The difference between the Win95 target and the WinNT target is that |
michael@0 | 143 | # the WinNT target uses Windows NT specific features not available |
michael@0 | 144 | # in Windows 95. The Win95 target will run on Windows NT, but (supposedly) |
michael@0 | 145 | # at lesser performance (the Win95 target uses threads; the WinNT target |
michael@0 | 146 | # uses fibers). |
michael@0 | 147 | # |
michael@0 | 148 | # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no |
michael@0 | 149 | # cross-compilation, except on Windows, where it defaults to WIN95. |
michael@0 | 150 | # |
michael@0 | 151 | |
michael@0 | 152 | # |
michael@0 | 153 | # On WIN32, we also define the variable CPU_ARCH, if it isn't already. |
michael@0 | 154 | # |
michael@0 | 155 | ifndef CPU_ARCH |
michael@0 | 156 | ifeq ($(OS_ARCH), WINNT) |
michael@0 | 157 | CPU_ARCH := $(shell uname -p) |
michael@0 | 158 | ifeq ($(CPU_ARCH),I386) |
michael@0 | 159 | CPU_ARCH = x386 |
michael@0 | 160 | endif |
michael@0 | 161 | endif |
michael@0 | 162 | endif |
michael@0 | 163 | |
michael@0 | 164 | # If uname -s returns "Windows_NT", we assume that we are using |
michael@0 | 165 | # the uname.exe in MKS toolkit. |
michael@0 | 166 | # |
michael@0 | 167 | # The -r option of MKS uname only returns the major version number. |
michael@0 | 168 | # So we need to use its -v option to get the minor version number. |
michael@0 | 169 | # Moreover, it doesn't have the -p option, so we need to use uname -m. |
michael@0 | 170 | # |
michael@0 | 171 | ifeq ($(OS_ARCH), Windows_NT) |
michael@0 | 172 | OS_ARCH = WINNT |
michael@0 | 173 | OS_MINOR_RELEASE := $(shell uname -v) |
michael@0 | 174 | # strip leading 0 |
michael@0 | 175 | OS_MINOR_RELEASE := $(patsubst 0%,%,$(OS_MINOR_RELEASE)) |
michael@0 | 176 | OS_RELEASE := $(OS_RELEASE).$(OS_MINOR_RELEASE) |
michael@0 | 177 | ifndef CPU_ARCH |
michael@0 | 178 | CPU_ARCH := $(shell uname -m) |
michael@0 | 179 | # |
michael@0 | 180 | # MKS's uname -m returns "586" on a Pentium machine. |
michael@0 | 181 | # |
michael@0 | 182 | ifneq (,$(findstring 86,$(CPU_ARCH))) |
michael@0 | 183 | CPU_ARCH = x386 |
michael@0 | 184 | endif |
michael@0 | 185 | endif |
michael@0 | 186 | endif |
michael@0 | 187 | # |
michael@0 | 188 | # If uname -s returns "CYGWIN_NT-*", we assume that we are using |
michael@0 | 189 | # the uname.exe in the Cygwin tools. |
michael@0 | 190 | # |
michael@0 | 191 | ifeq (CYGWIN_NT,$(findstring CYGWIN_NT,$(OS_ARCH))) |
michael@0 | 192 | OS_RELEASE := $(patsubst CYGWIN_NT-%,%,$(OS_ARCH)) |
michael@0 | 193 | OS_ARCH = WINNT |
michael@0 | 194 | ifndef CPU_ARCH |
michael@0 | 195 | ifeq (WOW64,$(findstring WOW64,$(OS_RELEASE))) |
michael@0 | 196 | OS_RELEASE := $(patsubst %-WOW64,%,$(OS_RELEASE)) |
michael@0 | 197 | endif |
michael@0 | 198 | CPU_ARCH := $(shell uname -m) |
michael@0 | 199 | # |
michael@0 | 200 | # Cygwin's uname -m returns "i686" on a Pentium Pro machine. |
michael@0 | 201 | # |
michael@0 | 202 | ifneq (,$(findstring 86,$(CPU_ARCH))) |
michael@0 | 203 | CPU_ARCH = x386 |
michael@0 | 204 | endif |
michael@0 | 205 | endif |
michael@0 | 206 | endif |
michael@0 | 207 | # |
michael@0 | 208 | # If uname -s returns "MINGW32_NT-*", we assume that we are using |
michael@0 | 209 | # the uname.exe in the MSYS toolkit. |
michael@0 | 210 | # |
michael@0 | 211 | ifeq (MINGW32_NT,$(findstring MINGW32_NT,$(OS_ARCH))) |
michael@0 | 212 | OS_RELEASE := $(patsubst MINGW32_NT-%,%,$(OS_ARCH)) |
michael@0 | 213 | OS_ARCH = WINNT |
michael@0 | 214 | USE_MSYS = 1 |
michael@0 | 215 | ifndef CPU_ARCH |
michael@0 | 216 | CPU_ARCH := $(shell uname -m) |
michael@0 | 217 | # |
michael@0 | 218 | # MSYS's uname -m returns "i686" on a Pentium Pro machine. |
michael@0 | 219 | # |
michael@0 | 220 | ifneq (,$(findstring 86,$(CPU_ARCH))) |
michael@0 | 221 | CPU_ARCH = x386 |
michael@0 | 222 | endif |
michael@0 | 223 | endif |
michael@0 | 224 | endif |
michael@0 | 225 | |
michael@0 | 226 | ifeq ($(OS_TARGET),Android) |
michael@0 | 227 | # |
michael@0 | 228 | # this should be configurable from the user |
michael@0 | 229 | # |
michael@0 | 230 | OS_TEST := arm |
michael@0 | 231 | OS_ARCH = Android |
michael@0 | 232 | ifndef OS_TARGET_RELEASE |
michael@0 | 233 | OS_TARGET_RELEASE := 8 |
michael@0 | 234 | endif |
michael@0 | 235 | endif |
michael@0 | 236 | |
michael@0 | 237 | ifndef OS_TARGET |
michael@0 | 238 | ifeq ($(OS_ARCH), WINNT) |
michael@0 | 239 | OS_TARGET = WIN95 |
michael@0 | 240 | else |
michael@0 | 241 | OS_TARGET = $(OS_ARCH) |
michael@0 | 242 | endif |
michael@0 | 243 | endif |
michael@0 | 244 | |
michael@0 | 245 | ifeq ($(OS_TARGET), WIN95) |
michael@0 | 246 | OS_RELEASE = 4.0 |
michael@0 | 247 | endif |
michael@0 | 248 | |
michael@0 | 249 | ifdef OS_TARGET_RELEASE |
michael@0 | 250 | OS_RELEASE = $(OS_TARGET_RELEASE) |
michael@0 | 251 | endif |
michael@0 | 252 | |
michael@0 | 253 | # |
michael@0 | 254 | # This variable is used to get OS_CONFIG.mk. |
michael@0 | 255 | # |
michael@0 | 256 | |
michael@0 | 257 | OS_CONFIG = $(OS_TARGET)$(OS_RELEASE) |
michael@0 | 258 | |
michael@0 | 259 | # |
michael@0 | 260 | # OBJDIR_TAG depends on the predefined variable BUILD_OPT, |
michael@0 | 261 | # to distinguish between debug and release builds. |
michael@0 | 262 | # |
michael@0 | 263 | |
michael@0 | 264 | ifdef BUILD_OPT |
michael@0 | 265 | OBJDIR_TAG = $(64BIT_TAG)_OPT |
michael@0 | 266 | else |
michael@0 | 267 | ifdef BUILD_IDG |
michael@0 | 268 | OBJDIR_TAG = $(64BIT_TAG)_IDG |
michael@0 | 269 | else |
michael@0 | 270 | OBJDIR_TAG = $(64BIT_TAG)_DBG |
michael@0 | 271 | endif |
michael@0 | 272 | endif |
michael@0 | 273 | |
michael@0 | 274 | # |
michael@0 | 275 | # The following flags are defined in the individual $(OS_CONFIG).mk |
michael@0 | 276 | # files. |
michael@0 | 277 | # |
michael@0 | 278 | # CPU_TAG is defined if the CPU is not the most common CPU. |
michael@0 | 279 | # COMPILER_TAG is defined if the compiler is not the default compiler. |
michael@0 | 280 | # IMPL_STRATEGY may be defined too. |
michael@0 | 281 | # |
michael@0 | 282 | |
michael@0 | 283 | OBJDIR_NAME = $(OS_TARGET)$(OS_RELEASE)$(CPU_TAG)$(COMPILER_TAG)$(LIBC_TAG)$(IMPL_STRATEGY)$(OBJDIR_TAG).OBJ |
michael@0 | 284 | |
michael@0 | 285 | ifeq (,$(filter-out WIN%,$(OS_TARGET))) |
michael@0 | 286 | ifndef BUILD_OPT |
michael@0 | 287 | # |
michael@0 | 288 | # Define USE_DEBUG_RTL if you want to use the debug runtime library |
michael@0 | 289 | # (RTL) in the debug build |
michael@0 | 290 | # |
michael@0 | 291 | ifdef USE_DEBUG_RTL |
michael@0 | 292 | OBJDIR_NAME = $(OS_TARGET)$(OS_RELEASE)$(CPU_TAG)$(COMPILER_TAG)$(IMPL_STRATEGY)$(OBJDIR_TAG).OBJD |
michael@0 | 293 | endif |
michael@0 | 294 | endif |
michael@0 | 295 | endif |
michael@0 | 296 | |
michael@0 | 297 | MK_ARCH = included |