blob: b48db72743d612bf2894e6a605f533f8d71379b1 [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:
sehr@chromium.orga6ec66f2014-06-05 00:39:58 +09007// OS_WIN / OS_MACOSX / OS_LINUX / OS_POSIX (MACOSX or LINUX) / OS_NACL
deanm@google.comd3d79a72008-08-05 20:56:30 +09008// Compiler:
9// COMPILER_MSVC / COMPILER_GCC
10// Processor:
11// ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)
12// ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
13
mmentovai@google.com3d555b82008-08-05 06:16:50 +090014#ifndef BUILD_BUILD_CONFIG_H_
15#define BUILD_BUILD_CONFIG_H_
16
stuartmorgan@chromium.org791de942012-06-30 07:12:20 +090017#if defined(__APPLE__)
18#include <TargetConditionals.h>
19#endif
20
mmentovai@google.com3d555b82008-08-05 06:16:50 +090021// A set of macros to use for platform detection.
sehr@chromium.orga6ec66f2014-06-05 00:39:58 +090022#if defined(__native_client__)
23// __native_client__ must be first, so that other OS_ defines are not set.
24#define OS_NACL 1
25#elif defined(ANDROID)
torne@chromium.orga00ac9d2013-04-04 20:51:27 +090026#define OS_ANDROID 1
27#elif defined(__APPLE__)
mmentovai@google.com3d555b82008-08-05 06:16:50 +090028#define OS_MACOSX 1
bbudge@chromium.org3ed0c362012-07-05 00:23:39 +090029#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
stuartmorgan@chromium.org791de942012-06-30 07:12:20 +090030#define OS_IOS 1
bbudge@chromium.org3ed0c362012-07-05 00:23:39 +090031#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
deanm@google.com5b70cbe2008-08-14 20:21:28 +090032#elif defined(__linux__)
mmentovai@google.com3d555b82008-08-05 06:16:50 +090033#define OS_LINUX 1
mostynb@opera.comb98da342014-04-19 08:40:16 +090034// include a system header to pull in features.h for glibc/uclibc macros.
35#include <unistd.h>
mostynb@opera.com889d3752013-05-23 21:00:10 +090036#if defined(__GLIBC__) && !defined(__UCLIBC__)
37// we really are using glibc, not uClibc pretending to be glibc
mostynb@opera.come1df6662014-04-08 08:51:45 +090038#define LIBC_GLIBC 1
mostynb@opera.com889d3752013-05-23 21:00:10 +090039#endif
maruel@chromium.org837a67f2009-02-10 00:42:08 +090040#elif defined(_WIN32)
mmentovai@google.com9a0fc8a2008-08-05 06:32:57 +090041#define OS_WIN 1
sky@chromium.org95936bd2009-05-14 08:21:45 +090042#define TOOLKIT_VIEWS 1
benl@chromium.org6b6b2162009-09-08 01:39:46 +090043#elif defined(__FreeBSD__)
44#define OS_FREEBSD 1
evan@chromium.org21252b12009-12-12 05:04:06 +090045#elif defined(__OpenBSD__)
46#define OS_OPENBSD 1
evan@chromium.org089339c2010-04-01 09:35:15 +090047#elif defined(__sun)
evan@chromium.orgd0e6b852010-02-19 01:11:37 +090048#define OS_SOLARIS 1
ctruta@blackberry.com57a7a052014-02-06 21:27:37 +090049#elif defined(__QNXNTO__)
50#define OS_QNX 1
mmentovai@google.com3d555b82008-08-05 06:16:50 +090051#else
52#error Please add support for your platform in build/build_config.h
53#endif
54
joth@chromium.org0dd35272010-10-22 22:12:34 +090055#if defined(USE_OPENSSL) && defined(USE_NSS)
56#error Cannot use both OpenSSL and NSS
57#endif
58
robert.nagy@gmail.com5f343eb2011-11-15 09:06:16 +090059// For access to standard BSD features, use OS_BSD instead of a
60// more specific macro.
61#if defined(OS_FREEBSD) || defined(OS_OPENBSD)
62#define OS_BSD 1
63#endif
64
benl@chromium.org6b6b2162009-09-08 01:39:46 +090065// For access to standard POSIXish features, use OS_POSIX instead of a
66// more specific macro.
michaelbai@google.combd0b2452011-06-28 04:13:10 +090067#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \
68 defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \
ctruta@blackberry.com57a7a052014-02-06 21:27:37 +090069 defined(OS_NACL) || defined(OS_QNX)
mmentovai@google.com3d555b82008-08-05 06:16:50 +090070#define OS_POSIX 1
benl@chromium.org6b6b2162009-09-08 01:39:46 +090071#endif
72
sgk@chromium.org1be49d82009-09-23 01:16:39 +090073// Use tcmalloc
bulach@chromium.org3b5d3592013-05-23 00:17:03 +090074#if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \
75 !defined(NO_TCMALLOC)
sgk@chromium.org1be49d82009-09-23 01:16:39 +090076#define USE_TCMALLOC 1
77#endif
78
mmentovai@google.com3d555b82008-08-05 06:16:50 +090079// Compiler detection.
80#if defined(__GNUC__)
deanm@google.comd3d79a72008-08-05 20:56:30 +090081#define COMPILER_GCC 1
mmentovai@google.com3d555b82008-08-05 06:16:50 +090082#elif defined(_MSC_VER)
deanm@google.comd3d79a72008-08-05 20:56:30 +090083#define COMPILER_MSVC 1
84#else
85#error Please add support for your compiler in build/build_config.h
86#endif
87
88// Processor architecture detection. For more info on what's defined, see:
89// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
90// http://www.agner.org/optimize/calling_conventions.pdf
thestig@chromium.org569de142009-05-02 02:57:09 +090091// or with gcc, run: "echo | gcc -E -dM -"
deanm@google.comd3d79a72008-08-05 20:56:30 +090092#if defined(_M_X64) || defined(__x86_64__)
93#define ARCH_CPU_X86_FAMILY 1
94#define ARCH_CPU_X86_64 1
95#define ARCH_CPU_64_BITS 1
hclam@chromium.orga94887c2011-06-25 05:46:06 +090096#define ARCH_CPU_LITTLE_ENDIAN 1
deanm@google.comd3d79a72008-08-05 20:56:30 +090097#elif defined(_M_IX86) || defined(__i386__)
98#define ARCH_CPU_X86_FAMILY 1
99#define ARCH_CPU_X86 1
100#define ARCH_CPU_32_BITS 1
hclam@chromium.orga94887c2011-06-25 05:46:06 +0900101#define ARCH_CPU_LITTLE_ENDIAN 1
thestig@chromium.org569de142009-05-02 02:57:09 +0900102#elif defined(__ARMEL__)
103#define ARCH_CPU_ARM_FAMILY 1
104#define ARCH_CPU_ARMEL 1
105#define ARCH_CPU_32_BITS 1
hclam@chromium.orga94887c2011-06-25 05:46:06 +0900106#define ARCH_CPU_LITTLE_ENDIAN 1
primiano@chromium.org7c3e5552014-04-01 07:10:30 +0900107#elif defined(__aarch64__)
sdefresne@chromium.org97a13e92014-02-06 11:51:01 +0900108#define ARCH_CPU_ARM_FAMILY 1
109#define ARCH_CPU_ARM64 1
110#define ARCH_CPU_64_BITS 1
111#define ARCH_CPU_LITTLE_ENDIAN 1
sehr@google.com15566f92011-08-27 04:03:20 +0900112#elif defined(__pnacl__)
113#define ARCH_CPU_32_BITS 1
sergeyu@chromium.org0a596042013-12-03 11:33:06 +0900114#define ARCH_CPU_LITTLE_ENDIAN 1
petarj@mips.comd3a3e762012-06-18 11:47:05 +0900115#elif defined(__MIPSEL__)
Gordana.Cmiljanovic@imgtec.comab304232014-08-15 02:14:05 +0900116#if defined(__LP64__)
117#define ARCH_CPU_MIPS64_FAMILY 1
118#define ARCH_CPU_MIPS64EL 1
119#define ARCH_CPU_64_BITS 1
120#define ARCH_CPU_LITTLE_ENDIAN 1
121#else
petarj@mips.comd3a3e762012-06-18 11:47:05 +0900122#define ARCH_CPU_MIPS_FAMILY 1
123#define ARCH_CPU_MIPSEL 1
124#define ARCH_CPU_32_BITS 1
125#define ARCH_CPU_LITTLE_ENDIAN 1
Gordana.Cmiljanovic@imgtec.comab304232014-08-15 02:14:05 +0900126#endif
deanm@google.comd3d79a72008-08-05 20:56:30 +0900127#else
128#error Please add support for your architecture in build/build_config.h
mmentovai@google.com3d555b82008-08-05 06:16:50 +0900129#endif
130
brettw@google.come3c034a2008-08-08 03:31:40 +0900131// Type detection for wchar_t.
132#if defined(OS_WIN)
133#define WCHAR_T_IS_UTF16
134#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
thestig@chromium.org569de142009-05-02 02:57:09 +0900135 defined(__WCHAR_MAX__) && \
136 (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
brettw@google.come3c034a2008-08-08 03:31:40 +0900137#define WCHAR_T_IS_UTF32
brettw@chromium.orgfd7a76b2009-10-23 03:04:17 +0900138#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
139 defined(__WCHAR_MAX__) && \
140 (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
141// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
142// compile in this mode (in particular, Chrome doesn't). This is intended for
143// other projects using base who manage their own dependencies and make sure
144// short wchar works for them.
145#define WCHAR_T_IS_UTF16
brettw@google.come3c034a2008-08-08 03:31:40 +0900146#else
147#error Please add support for your compiler in build/build_config.h
148#endif
149
michaelbai@google.combd0b2452011-06-28 04:13:10 +0900150#if defined(OS_ANDROID)
151// The compiler thinks std::string::const_iterator and "const char*" are
152// equivalent types.
153#define STD_STRING_ITERATOR_IS_CHAR_POINTER
154// The compiler thinks base::string16::const_iterator and "char16*" are
155// equivalent types.
156#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
157#endif
158
mmentovai@google.com3d555b82008-08-05 06:16:50 +0900159#endif // BUILD_BUILD_CONFIG_H_