2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 #######################################################################
7 # Master "Core Components" macros for getting the OS architecture #
8 # defines these symbols:
10 # OS_ARCH (from uname -r)
11 # OS_TEST (from uname -m)
12 # OS_RELEASE (from uname -v and/or -r)
13 # OS_TARGET User defined, or set to OS_ARCH
14 # CPU_ARCH (from unmame -m or -p, ONLY on WINNT)
15 # OS_CONFIG OS_TARGET + OS_RELEASE
18 #######################################################################
21 # Macros for getting the OS architecture
30 OS_ARCH := $(subst /,_,$(shell uname -s))
33 # Attempt to differentiate between sparc and x86 Solaris
36 OS_TEST := $(shell uname -m)
37 ifeq ($(OS_TEST),i86pc)
38 OS_RELEASE := $(shell uname -r)_$(OS_TEST)
40 OS_RELEASE := $(shell uname -r)
44 # Force the IRIX64 machines to use IRIX.
47 ifeq ($(OS_ARCH),IRIX64)
52 # Force the older BSD/OS versions to use the new arch name.
55 ifeq ($(OS_ARCH),BSD_386)
60 # Catch Deterim if SVR4 is NCR or UNIXWARE
63 ifeq ($(OS_ARCH),UNIX_SV)
64 ifneq ($(findstring NCR, $(shell grep NCR /etc/bcheckrc | head -1 )),)
67 # Make UnixWare something human readable
71 # Get the OS release number, not 4.2
72 OS_RELEASE := $(shell uname -v)
75 ifeq ($(OS_ARCH),UNIX_System_V)
80 OS_RELEASE := $(shell uname -v).$(shell uname -r)
84 # Distinguish between OSF1 V4.0B and V4.0D
87 ifeq ($(OS_ARCH)$(OS_RELEASE),OSF1V4.0)
88 OS_VERSION := $(shell uname -v)
89 ifeq ($(OS_VERSION),564)
92 ifeq ($(OS_VERSION),878)
98 # SINIX changes name to ReliantUNIX with 5.43
101 ifeq ($(OS_ARCH),ReliantUNIX-N)
102 OS_ARCH = ReliantUNIX
106 ifeq ($(OS_ARCH),SINIX-N)
107 OS_ARCH = ReliantUNIX
112 # Handle FreeBSD 2.2-STABLE, Linux 2.0.30-osfmach3, and
113 # IRIX 6.5-ALPHA-1289139620.
116 ifeq (,$(filter-out Linux FreeBSD IRIX,$(OS_ARCH)))
117 OS_RELEASE := $(shell echo $(OS_RELEASE) | sed 's/-.*//')
120 ifeq ($(OS_ARCH),Linux)
121 OS_RELEASE := $(subst ., ,$(OS_RELEASE))
122 ifneq ($(words $(OS_RELEASE)),1)
123 OS_RELEASE := $(word 1,$(OS_RELEASE)).$(word 2,$(OS_RELEASE))
130 ifeq ($(OS_ARCH),OS_2)
132 OS_RELEASE := $(shell uname -v)
135 #######################################################################
136 # Master "Core Components" macros for getting the OS target #
137 #######################################################################
140 # Note: OS_TARGET should be specified on the command line for gmake.
141 # When OS_TARGET=WIN95 is specified, then a Windows 95 target is built.
142 # The difference between the Win95 target and the WinNT target is that
143 # the WinNT target uses Windows NT specific features not available
144 # in Windows 95. The Win95 target will run on Windows NT, but (supposedly)
145 # at lesser performance (the Win95 target uses threads; the WinNT target
148 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
153 # The following hack allows one to build on a WIN95 machine (as if
154 # s/he were cross-compiling on a WINNT host for a WIN95 target).
155 # It also accomodates for MKS's and Cygwin's uname.exe.
157 ifeq ($(OS_ARCH),WIN95)
161 ifeq ($(OS_ARCH),Windows_95)
165 ifeq ($(OS_ARCH),CYGWIN_95-4.0)
166 OS_ARCH = CYGWIN_NT-4.0
169 ifeq ($(OS_ARCH),CYGWIN_98-4.10)
170 OS_ARCH = CYGWIN_NT-4.0
173 ifeq ($(OS_ARCH),CYGWIN_ME-4.90)
174 OS_ARCH = CYGWIN_NT-4.0
179 # On WIN32, we also define the variable CPU_ARCH, if it isn't already.
182 ifeq ($(OS_ARCH), WINNT)
183 CPU_ARCH := $(shell uname -p)
184 ifeq ($(CPU_ARCH),I386)
190 # If uname -s returns "Windows_NT", we assume that we are using
191 # the uname.exe in MKS toolkit.
193 # The -r option of MKS uname only returns the major version number.
194 # So we need to use its -v option to get the minor version number.
195 # Moreover, it doesn't have the -p option, so we need to use uname -m.
197 ifeq ($(OS_ARCH), Windows_NT)
199 OS_MINOR_RELEASE := $(shell uname -v)
201 OS_MINOR_RELEASE := $(patsubst 0%,%,$(OS_MINOR_RELEASE))
202 OS_RELEASE := $(OS_RELEASE).$(OS_MINOR_RELEASE)
204 CPU_ARCH := $(shell uname -m)
206 # MKS's uname -m returns "586" on a Pentium machine.
208 ifneq (,$(findstring 86,$(CPU_ARCH)))
214 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
215 # the uname.exe in the Cygwin tools.
217 ifeq (CYGWIN_NT,$(findstring CYGWIN_NT,$(OS_ARCH)))
218 OS_RELEASE := $(patsubst CYGWIN_NT-%,%,$(OS_ARCH))
221 ifeq (WOW64,$(findstring WOW64,$(OS_RELEASE)))
222 OS_RELEASE := $(patsubst %-WOW64,%,$(OS_RELEASE))
224 CPU_ARCH := $(shell uname -m)
226 # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
228 ifneq (,$(findstring 86,$(CPU_ARCH)))
234 # If uname -s returns "MINGW32_NT-5.1", we assume that we are using
235 # the uname.exe in the MSYS toolkit.
237 ifeq (MINGW32_NT,$(findstring MINGW32_NT,$(OS_ARCH)))
238 OS_RELEASE := $(patsubst MINGW32_NT-%,%,$(OS_ARCH))
242 CPU_ARCH := $(shell uname -m)
244 # MSYS's uname -m returns "i686" on a Pentium Pro machine.
246 ifneq (,$(findstring 86,$(CPU_ARCH)))
252 ifeq ($(OS_TARGET),Android)
254 # this should be configurable from the user
258 ifndef OS_TARGET_RELEASE
259 OS_TARGET_RELEASE := 8
264 OS_TARGET = $(OS_ARCH)
267 ifeq ($(OS_TARGET), WIN95)
271 ifdef OS_TARGET_RELEASE
272 OS_RELEASE = $(OS_TARGET_RELEASE)
276 # This variable is used to get OS_CONFIG.mk.
279 OS_CONFIG = $(OS_TARGET)$(OS_RELEASE)
282 # OBJDIR_TAG depends on the predefined variable BUILD_OPT,
283 # to distinguish between debug and release builds.
287 OBJDIR_TAG = $(64BIT_TAG)_OPT
290 OBJDIR_TAG = $(64BIT_TAG)_IDG
292 OBJDIR_TAG = $(64BIT_TAG)_DBG
297 # The following flags are defined in the individual $(OS_CONFIG).mk
300 # CPU_TAG is defined if the CPU is not the most common CPU.
301 # COMPILER_TAG is defined if the compiler is not the default compiler.
302 # IMPL_STRATEGY may be defined too.
305 OBJDIR_NAME = $(OS_TARGET)$(OS_RELEASE)$(CPU_TAG)$(COMPILER_TAG)$(LIBC_TAG)$(IMPL_STRATEGY)$(OBJDIR_TAG).OBJ
307 ifeq (,$(filter-out WIN%,$(OS_TARGET)))
310 # Define USE_DEBUG_RTL if you want to use the debug runtime library
311 # (RTL) in the debug build
314 OBJDIR_NAME = $(OS_TARGET)$(OS_RELEASE)$(CPU_TAG)$(COMPILER_TAG)$(IMPL_STRATEGY)$(OBJDIR_TAG).OBJD