6557348b28b4ec1271defd78ce758d6909e7a6c2
[platform/upstream/nss.git] / nss / coreconf / arch.mk
1 #
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/.
5
6 #######################################################################
7 # Master "Core Components" macros for getting the OS architecture     #
8 # defines these symbols:
9 # 64BIT_TAG
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
16 # OBJDIR_TAG
17 # OBJDIR_NAME
18 #######################################################################
19
20 #
21 # Macros for getting the OS architecture
22 #
23
24 ifeq ($(USE_64), 1)
25         64BIT_TAG=_64
26 else
27         64BIT_TAG=
28 endif
29
30 OS_ARCH := $(subst /,_,$(shell uname -s))
31
32 #
33 # Attempt to differentiate between sparc and x86 Solaris
34 #
35
36 OS_TEST := $(shell uname -m)
37 ifeq ($(OS_TEST),i86pc)
38     OS_RELEASE := $(shell uname -r)_$(OS_TEST)
39 else
40     OS_RELEASE := $(shell uname -r)
41 endif
42
43 #
44 # Force the IRIX64 machines to use IRIX.
45 #
46
47 ifeq ($(OS_ARCH),IRIX64)
48     OS_ARCH = IRIX
49 endif
50
51 #
52 # Force the older BSD/OS versions to use the new arch name.
53 #
54
55 ifeq ($(OS_ARCH),BSD_386)
56     OS_ARCH = BSD_OS
57 endif
58
59 #
60 # Catch Deterim if SVR4 is NCR or UNIXWARE
61 #
62
63 ifeq ($(OS_ARCH),UNIX_SV)
64     ifneq ($(findstring NCR, $(shell grep NCR /etc/bcheckrc | head -1 )),)
65         OS_ARCH = NCR
66     else
67         # Make UnixWare something human readable
68         OS_ARCH = UNIXWARE
69     endif
70
71     # Get the OS release number, not 4.2
72     OS_RELEASE := $(shell uname -v)
73 endif
74
75 ifeq ($(OS_ARCH),UNIX_System_V)
76     OS_ARCH     = NEC
77 endif
78
79 ifeq ($(OS_ARCH),AIX)
80     OS_RELEASE := $(shell uname -v).$(shell uname -r)
81 endif
82
83 #
84 # Distinguish between OSF1 V4.0B and V4.0D
85 #
86
87 ifeq ($(OS_ARCH)$(OS_RELEASE),OSF1V4.0)
88     OS_VERSION := $(shell uname -v)
89     ifeq ($(OS_VERSION),564)
90         OS_RELEASE := V4.0B
91     endif
92     ifeq ($(OS_VERSION),878)
93         OS_RELEASE := V4.0D
94     endif
95 endif
96
97 #
98 # SINIX changes name to ReliantUNIX with 5.43
99 #
100
101 ifeq ($(OS_ARCH),ReliantUNIX-N)
102     OS_ARCH    = ReliantUNIX
103     OS_RELEASE = 5.4
104 endif
105
106 ifeq ($(OS_ARCH),SINIX-N)
107     OS_ARCH    = ReliantUNIX
108     OS_RELEASE = 5.4
109 endif
110
111 #
112 # Handle FreeBSD 2.2-STABLE, Linux 2.0.30-osfmach3, and
113 # IRIX 6.5-ALPHA-1289139620.
114 #
115
116 ifeq (,$(filter-out Linux FreeBSD IRIX,$(OS_ARCH)))
117     OS_RELEASE := $(shell echo $(OS_RELEASE) | sed 's/-.*//')
118 endif
119
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))
124     endif
125 endif
126
127 #
128 # For OS/2
129 #
130 ifeq ($(OS_ARCH),OS_2)
131     OS_ARCH = OS2
132     OS_RELEASE := $(shell uname -v)
133 endif
134
135 #######################################################################
136 # Master "Core Components" macros for getting the OS target           #
137 #######################################################################
138
139 #
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
146 # uses fibers).
147 #
148 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
149 # cross-compilation.
150 #
151
152 #
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.
156 #
157 ifeq ($(OS_ARCH),WIN95)
158     OS_ARCH   = WINNT
159     OS_TARGET = WIN95
160 endif
161 ifeq ($(OS_ARCH),Windows_95)
162     OS_ARCH   = Windows_NT
163     OS_TARGET = WIN95
164 endif
165 ifeq ($(OS_ARCH),CYGWIN_95-4.0)
166         OS_ARCH   = CYGWIN_NT-4.0
167         OS_TARGET = WIN95
168 endif
169 ifeq ($(OS_ARCH),CYGWIN_98-4.10)
170         OS_ARCH   = CYGWIN_NT-4.0
171         OS_TARGET = WIN95
172 endif
173 ifeq ($(OS_ARCH),CYGWIN_ME-4.90)
174         OS_ARCH   = CYGWIN_NT-4.0
175         OS_TARGET = WIN95
176 endif
177
178 #
179 # On WIN32, we also define the variable CPU_ARCH, if it isn't already.
180 #
181 ifndef CPU_ARCH
182     ifeq ($(OS_ARCH), WINNT)
183         CPU_ARCH := $(shell uname -p)
184         ifeq ($(CPU_ARCH),I386)
185             CPU_ARCH = x386
186         endif
187     endif
188 endif
189
190 # If uname -s returns "Windows_NT", we assume that we are using
191 # the uname.exe in MKS toolkit.
192 #
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.
196 #
197 ifeq ($(OS_ARCH), Windows_NT)
198     OS_ARCH = WINNT
199     OS_MINOR_RELEASE := $(shell uname -v)
200     # strip leading 0
201     OS_MINOR_RELEASE := $(patsubst 0%,%,$(OS_MINOR_RELEASE))
202     OS_RELEASE := $(OS_RELEASE).$(OS_MINOR_RELEASE)
203     ifndef CPU_ARCH
204         CPU_ARCH := $(shell uname -m)
205         #
206         # MKS's uname -m returns "586" on a Pentium machine.
207         #
208         ifneq (,$(findstring 86,$(CPU_ARCH)))
209             CPU_ARCH = x386
210         endif
211     endif
212 endif
213 #
214 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
215 # the uname.exe in the Cygwin tools.
216 #
217 ifeq (CYGWIN_NT,$(findstring CYGWIN_NT,$(OS_ARCH)))
218     OS_RELEASE := $(patsubst CYGWIN_NT-%,%,$(OS_ARCH))
219     OS_ARCH = WINNT
220     ifndef CPU_ARCH
221     ifeq (WOW64,$(findstring WOW64,$(OS_RELEASE)))
222         OS_RELEASE := $(patsubst %-WOW64,%,$(OS_RELEASE))
223     endif    
224         CPU_ARCH := $(shell uname -m)
225         #
226         # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
227         #
228         ifneq (,$(findstring 86,$(CPU_ARCH)))
229             CPU_ARCH = x386
230         endif
231     endif
232 endif
233 #
234 # If uname -s returns "MINGW32_NT-5.1", we assume that we are using
235 # the uname.exe in the MSYS toolkit.
236 #
237 ifeq (MINGW32_NT,$(findstring MINGW32_NT,$(OS_ARCH)))
238     OS_RELEASE := $(patsubst MINGW32_NT-%,%,$(OS_ARCH))
239     OS_ARCH = WINNT
240     USE_MSYS = 1
241     ifndef CPU_ARCH
242         CPU_ARCH := $(shell uname -m)
243         #
244         # MSYS's uname -m returns "i686" on a Pentium Pro machine.
245         #
246         ifneq (,$(findstring 86,$(CPU_ARCH)))
247             CPU_ARCH = x386
248         endif
249     endif
250 endif
251
252 ifeq ($(OS_TARGET),Android)
253 #
254 # this should be  configurable from the user
255 #
256    OS_TEST := arm
257    OS_ARCH = Android
258    ifndef OS_TARGET_RELEASE
259         OS_TARGET_RELEASE := 8
260    endif
261 endif
262
263 ifndef OS_TARGET
264     OS_TARGET = $(OS_ARCH)
265 endif
266
267 ifeq ($(OS_TARGET), WIN95)
268     OS_RELEASE = 4.0
269 endif
270
271 ifdef OS_TARGET_RELEASE
272     OS_RELEASE = $(OS_TARGET_RELEASE)
273 endif
274
275 #
276 # This variable is used to get OS_CONFIG.mk.
277 #
278
279 OS_CONFIG = $(OS_TARGET)$(OS_RELEASE)
280
281 #
282 # OBJDIR_TAG depends on the predefined variable BUILD_OPT,
283 # to distinguish between debug and release builds.
284 #
285
286 ifdef BUILD_OPT
287     OBJDIR_TAG = $(64BIT_TAG)_OPT
288 else
289     ifdef BUILD_IDG
290         OBJDIR_TAG = $(64BIT_TAG)_IDG
291     else
292         OBJDIR_TAG = $(64BIT_TAG)_DBG
293     endif
294 endif
295
296 #
297 # The following flags are defined in the individual $(OS_CONFIG).mk
298 # files.
299 #
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.
303 #
304
305 OBJDIR_NAME = $(OS_TARGET)$(OS_RELEASE)$(CPU_TAG)$(COMPILER_TAG)$(LIBC_TAG)$(IMPL_STRATEGY)$(OBJDIR_TAG).OBJ
306
307 ifeq (,$(filter-out WIN%,$(OS_TARGET)))
308 ifndef BUILD_OPT
309 #
310 # Define USE_DEBUG_RTL if you want to use the debug runtime library
311 # (RTL) in the debug build
312 #
313 ifdef USE_DEBUG_RTL
314     OBJDIR_NAME = $(OS_TARGET)$(OS_RELEASE)$(CPU_TAG)$(COMPILER_TAG)$(IMPL_STRATEGY)$(OBJDIR_TAG).OBJD
315 endif
316 endif
317 endif
318
319 MK_ARCH = included