blob: d8c3db6ed781791bd8f37dc9cb28511fe5f553c4 [file] [log] [blame]
evan@chromium.org50dfbc42012-01-24 21:26:40 +09001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botf003cfe2008-08-24 09:55:55 +09002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
mmentovai@google.com3d555b82008-08-05 06:16:50 +09004
deanm@google.comd3d79a72008-08-05 20:56:30 +09005// This file adds defines about the platform we're currently building on.
6// Operating System:
hidehiko721e6042014-10-28 20:57:21 +09007// OS_WIN / OS_MACOSX / OS_LINUX / OS_POSIX (MACOSX or LINUX) /
8// OS_NACL (NACL_SFI or NACL_NONSFI) / OS_NACL_SFI / OS_NACL_NONSFI
deanm@google.comd3d79a72008-08-05 20:56:30 +09009// Compiler:
10// COMPILER_MSVC / COMPILER_GCC
11// Processor:
12// ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)
13// ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
14
mmentovai@google.com3d555b82008-08-05 06:16:50 +090015#ifndef BUILD_BUILD_CONFIG_H_
16#define BUILD_BUILD_CONFIG_H_
17
18// A set of macros to use for platform detection.
sehr@chromium.orga6ec66f2014-06-05 00:39:58 +090019#if defined(__native_client__)
20// __native_client__ must be first, so that other OS_ defines are not set.
21#define OS_NACL 1
hidehiko721e6042014-10-28 20:57:21 +090022// OS_NACL comes in two sandboxing technology flavors, SFI or Non-SFI.
23// PNaCl toolchain defines __native_client_nonsfi__ macro in Non-SFI build
24// mode, while it does not in SFI build mode.
25#if defined(__native_client_nonsfi__)
26#define OS_NACL_NONSFI
27#else
28#define OS_NACL_SFI
29#endif
sehr@chromium.orga6ec66f2014-06-05 00:39:58 +090030#elif defined(ANDROID)
torne@chromium.orga00ac9d2013-04-04 20:51:27 +090031#define OS_ANDROID 1
32#elif defined(__APPLE__)
torned759f342014-09-05 19:33:07 +090033// only include TargetConditions after testing ANDROID as some android builds
34// on mac don't have this header available and it's not needed unless the target
35// is really mac/ios.
36#include <TargetConditionals.h>
mmentovai@google.com3d555b82008-08-05 06:16:50 +090037#define OS_MACOSX 1
bbudge@chromium.org3ed0c362012-07-05 00:23:39 +090038#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
stuartmorgan@chromium.org791de942012-06-30 07:12:20 +090039#define OS_IOS 1
bbudge@chromium.org3ed0c362012-07-05 00:23:39 +090040#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
deanm@google.com5b70cbe2008-08-14 20:21:28 +090041#elif defined(__linux__)
mmentovai@google.com3d555b82008-08-05 06:16:50 +090042#define OS_LINUX 1
mostynb@opera.comb98da342014-04-19 08:40:16 +090043// include a system header to pull in features.h for glibc/uclibc macros.
44#include <unistd.h>
mostynb@opera.com889d3752013-05-23 21:00:10 +090045#if defined(__GLIBC__) && !defined(__UCLIBC__)
46// we really are using glibc, not uClibc pretending to be glibc
mostynb@opera.come1df6662014-04-08 08:51:45 +090047#define LIBC_GLIBC 1
mostynb@opera.com889d3752013-05-23 21:00:10 +090048#endif
maruel@chromium.org837a67f2009-02-10 00:42:08 +090049#elif defined(_WIN32)
mmentovai@google.com9a0fc8a2008-08-05 06:32:57 +090050#define OS_WIN 1
sky@chromium.org95936bd2009-05-14 08:21:45 +090051#define TOOLKIT_VIEWS 1
benl@chromium.org6b6b2162009-09-08 01:39:46 +090052#elif defined(__FreeBSD__)
53#define OS_FREEBSD 1
evan@chromium.org21252b12009-12-12 05:04:06 +090054#elif defined(__OpenBSD__)
55#define OS_OPENBSD 1
evan@chromium.org089339c2010-04-01 09:35:15 +090056#elif defined(__sun)
evan@chromium.orgd0e6b852010-02-19 01:11:37 +090057#define OS_SOLARIS 1
ctruta@blackberry.com57a7a052014-02-06 21:27:37 +090058#elif defined(__QNXNTO__)
59#define OS_QNX 1
mmentovai@google.com3d555b82008-08-05 06:16:50 +090060#else
61#error Please add support for your platform in build/build_config.h
62#endif
63
davidbendff95222015-04-22 11:36:41 +090064#if defined(USE_OPENSSL_CERTS) && defined(USE_NSS_CERTS)
65#error Cannot use both OpenSSL and NSS for certificates
joth@chromium.org0dd35272010-10-22 22:12:34 +090066#endif
67
robert.nagy@gmail.com5f343eb2011-11-15 09:06:16 +090068// For access to standard BSD features, use OS_BSD instead of a
69// more specific macro.
70#if defined(OS_FREEBSD) || defined(OS_OPENBSD)
71#define OS_BSD 1
72#endif
73
benl@chromium.org6b6b2162009-09-08 01:39:46 +090074// For access to standard POSIXish features, use OS_POSIX instead of a
75// more specific macro.
michaelbai@google.combd0b2452011-06-28 04:13:10 +090076#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \
77 defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \
ctruta@blackberry.com57a7a052014-02-06 21:27:37 +090078 defined(OS_NACL) || defined(OS_QNX)
mmentovai@google.com3d555b82008-08-05 06:16:50 +090079#define OS_POSIX 1
benl@chromium.org6b6b2162009-09-08 01:39:46 +090080#endif
81
sgk@chromium.org1be49d82009-09-23 01:16:39 +090082// Use tcmalloc
bulach@chromium.org3b5d3592013-05-23 00:17:03 +090083#if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \
84 !defined(NO_TCMALLOC)
sgk@chromium.org1be49d82009-09-23 01:16:39 +090085#define USE_TCMALLOC 1
86#endif
87
mmentovai@google.com3d555b82008-08-05 06:16:50 +090088// Compiler detection.
89#if defined(__GNUC__)
deanm@google.comd3d79a72008-08-05 20:56:30 +090090#define COMPILER_GCC 1
mmentovai@google.com3d555b82008-08-05 06:16:50 +090091#elif defined(_MSC_VER)
deanm@google.comd3d79a72008-08-05 20:56:30 +090092#define COMPILER_MSVC 1
93#else
94#error Please add support for your compiler in build/build_config.h
95#endif
96
97// Processor architecture detection. For more info on what's defined, see:
98// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
99// http://www.agner.org/optimize/calling_conventions.pdf
thestig@chromium.org569de142009-05-02 02:57:09 +0900100// or with gcc, run: "echo | gcc -E -dM -"
deanm@google.comd3d79a72008-08-05 20:56:30 +0900101#if defined(_M_X64) || defined(__x86_64__)
102#define ARCH_CPU_X86_FAMILY 1
103#define ARCH_CPU_X86_64 1
104#define ARCH_CPU_64_BITS 1
hclam@chromium.orga94887c2011-06-25 05:46:06 +0900105#define ARCH_CPU_LITTLE_ENDIAN 1
deanm@google.comd3d79a72008-08-05 20:56:30 +0900106#elif defined(_M_IX86) || defined(__i386__)
107#define ARCH_CPU_X86_FAMILY 1
108#define ARCH_CPU_X86 1
109#define ARCH_CPU_32_BITS 1
hclam@chromium.orga94887c2011-06-25 05:46:06 +0900110#define ARCH_CPU_LITTLE_ENDIAN 1
thestig@chromium.org569de142009-05-02 02:57:09 +0900111#elif defined(__ARMEL__)
112#define ARCH_CPU_ARM_FAMILY 1
113#define ARCH_CPU_ARMEL 1
114#define ARCH_CPU_32_BITS 1
hclam@chromium.orga94887c2011-06-25 05:46:06 +0900115#define ARCH_CPU_LITTLE_ENDIAN 1
primiano@chromium.org7c3e5552014-04-01 07:10:30 +0900116#elif defined(__aarch64__)
sdefresne@chromium.org97a13e92014-02-06 11:51:01 +0900117#define ARCH_CPU_ARM_FAMILY 1
118#define ARCH_CPU_ARM64 1
119#define ARCH_CPU_64_BITS 1
120#define ARCH_CPU_LITTLE_ENDIAN 1
sehr@google.com15566f92011-08-27 04:03:20 +0900121#elif defined(__pnacl__)
122#define ARCH_CPU_32_BITS 1
sergeyu@chromium.org0a596042013-12-03 11:33:06 +0900123#define ARCH_CPU_LITTLE_ENDIAN 1
petarj@mips.comd3a3e762012-06-18 11:47:05 +0900124#elif defined(__MIPSEL__)
Gordana.Cmiljanovic@imgtec.comab304232014-08-15 02:14:05 +0900125#if defined(__LP64__)
126#define ARCH_CPU_MIPS64_FAMILY 1
127#define ARCH_CPU_MIPS64EL 1
128#define ARCH_CPU_64_BITS 1
129#define ARCH_CPU_LITTLE_ENDIAN 1
130#else
petarj@mips.comd3a3e762012-06-18 11:47:05 +0900131#define ARCH_CPU_MIPS_FAMILY 1
132#define ARCH_CPU_MIPSEL 1
133#define ARCH_CPU_32_BITS 1
134#define ARCH_CPU_LITTLE_ENDIAN 1
Gordana.Cmiljanovic@imgtec.comab304232014-08-15 02:14:05 +0900135#endif
deanm@google.comd3d79a72008-08-05 20:56:30 +0900136#else
137#error Please add support for your architecture in build/build_config.h
mmentovai@google.com3d555b82008-08-05 06:16:50 +0900138#endif
139
brettw@google.come3c034a2008-08-08 03:31:40 +0900140// Type detection for wchar_t.
141#if defined(OS_WIN)
142#define WCHAR_T_IS_UTF16
143#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
thestig@chromium.org569de142009-05-02 02:57:09 +0900144 defined(__WCHAR_MAX__) && \
145 (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
brettw@google.come3c034a2008-08-08 03:31:40 +0900146#define WCHAR_T_IS_UTF32
brettw@chromium.orgfd7a76b2009-10-23 03:04:17 +0900147#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
148 defined(__WCHAR_MAX__) && \
149 (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
150// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
151// compile in this mode (in particular, Chrome doesn't). This is intended for
152// other projects using base who manage their own dependencies and make sure
153// short wchar works for them.
154#define WCHAR_T_IS_UTF16
brettw@google.come3c034a2008-08-08 03:31:40 +0900155#else
156#error Please add support for your compiler in build/build_config.h
157#endif
158
michaelbai@google.combd0b2452011-06-28 04:13:10 +0900159#if defined(OS_ANDROID)
160// The compiler thinks std::string::const_iterator and "const char*" are
161// equivalent types.
162#define STD_STRING_ITERATOR_IS_CHAR_POINTER
163// The compiler thinks base::string16::const_iterator and "char16*" are
164// equivalent types.
165#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
166#endif
167
mmentovai@google.com3d555b82008-08-05 06:16:50 +0900168#endif // BUILD_BUILD_CONFIG_H_