|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
|
2 // Use of this source code is governed by a BSD-style license that can be |
|
3 // found in the LICENSE file. |
|
4 |
|
5 // This file adds defines about the platform we're currently building on. |
|
6 // Operating System: |
|
7 // OS_WIN / OS_MACOSX / OS_LINUX / OS_POSIX (MACOSX or LINUX) |
|
8 // 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 |
|
14 #ifndef BUILD_BUILD_CONFIG_H_ |
|
15 #define BUILD_BUILD_CONFIG_H_ |
|
16 |
|
17 #if defined(__APPLE__) |
|
18 #include <TargetConditionals.h> |
|
19 #endif |
|
20 |
|
21 // A set of macros to use for platform detection. |
|
22 #if defined(__APPLE__) |
|
23 #define OS_MACOSX 1 |
|
24 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
|
25 #define OS_IOS 1 |
|
26 #endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
|
27 #elif defined(ANDROID) |
|
28 #define OS_ANDROID 1 |
|
29 #elif defined(__native_client__) |
|
30 #define OS_NACL 1 |
|
31 #elif defined(__linux__) |
|
32 #define OS_LINUX 1 |
|
33 // Use TOOLKIT_GTK on linux if TOOLKIT_VIEWS isn't defined. |
|
34 #if !defined(TOOLKIT_VIEWS) |
|
35 #define TOOLKIT_GTK |
|
36 #endif |
|
37 #elif defined(_WIN32) |
|
38 #define OS_WIN 1 |
|
39 #define TOOLKIT_VIEWS 1 |
|
40 #elif defined(__DragonFly__) |
|
41 #define OS_DRAGONFLY 1 |
|
42 #define TOOLKIT_GTK |
|
43 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
|
44 #define OS_FREEBSD 1 |
|
45 #define TOOLKIT_GTK |
|
46 #elif defined(__NetBSD__) |
|
47 #define OS_NETBSD 1 |
|
48 #define TOOLKIT_GTK |
|
49 #elif defined(__OpenBSD__) |
|
50 #define OS_OPENBSD 1 |
|
51 #define TOOLKIT_GTK |
|
52 #elif defined(__sun) |
|
53 #define OS_SOLARIS 1 |
|
54 #define TOOLKIT_GTK |
|
55 #else |
|
56 #error Please add support for your platform in build/build_config.h |
|
57 #endif |
|
58 |
|
59 #if defined(USE_OPENSSL) && defined(USE_NSS) |
|
60 #error Cannot use both OpenSSL and NSS |
|
61 #endif |
|
62 |
|
63 // For access to standard BSD features, use OS_BSD instead of a |
|
64 // more specific macro. |
|
65 #if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) \ |
|
66 || defined(OS_NETBSD) || defined(OS_OPENBSD) |
|
67 #define OS_BSD 1 |
|
68 #endif |
|
69 |
|
70 // For access to standard POSIXish features, use OS_POSIX instead of a |
|
71 // more specific macro. |
|
72 #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_BSD) || \ |
|
73 defined(OS_SOLARIS) || defined(OS_ANDROID) || defined(OS_NACL) |
|
74 #define OS_POSIX 1 |
|
75 #endif |
|
76 |
|
77 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \ |
|
78 !defined(OS_NACL) |
|
79 #define USE_X11 1 // Use X for graphics. |
|
80 #endif |
|
81 |
|
82 // Use tcmalloc |
|
83 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(NO_TCMALLOC) |
|
84 #define USE_TCMALLOC 1 |
|
85 #endif |
|
86 |
|
87 // Compiler detection. |
|
88 #if defined(__GNUC__) |
|
89 #define COMPILER_GCC 1 |
|
90 #elif defined(_MSC_VER) |
|
91 #define COMPILER_MSVC 1 |
|
92 #else |
|
93 #error Please add support for your compiler in build/build_config.h |
|
94 #endif |
|
95 |
|
96 // Processor architecture detection. For more info on what's defined, see: |
|
97 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx |
|
98 // http://www.agner.org/optimize/calling_conventions.pdf |
|
99 // or with gcc, run: "echo | gcc -E -dM -" |
|
100 #if defined(_M_X64) || defined(__x86_64__) |
|
101 #define ARCH_CPU_X86_FAMILY 1 |
|
102 #define ARCH_CPU_X86_64 1 |
|
103 #define ARCH_CPU_64_BITS 1 |
|
104 #define ARCH_CPU_LITTLE_ENDIAN 1 |
|
105 #elif defined(_M_IX86) || defined(__i386__) |
|
106 #define ARCH_CPU_X86_FAMILY 1 |
|
107 #define ARCH_CPU_X86 1 |
|
108 #define ARCH_CPU_32_BITS 1 |
|
109 #define ARCH_CPU_LITTLE_ENDIAN 1 |
|
110 #elif defined(__ARMEL__) |
|
111 #define ARCH_CPU_ARM_FAMILY 1 |
|
112 #define ARCH_CPU_ARMEL 1 |
|
113 #define ARCH_CPU_32_BITS 1 |
|
114 #define ARCH_CPU_LITTLE_ENDIAN 1 |
|
115 #elif defined(__pnacl__) |
|
116 #define ARCH_CPU_32_BITS 1 |
|
117 #elif defined(__MIPSEL__) |
|
118 #define ARCH_CPU_MIPS_FAMILY 1 |
|
119 #define ARCH_CPU_MIPSEL 1 |
|
120 #define ARCH_CPU_32_BITS 1 |
|
121 #define ARCH_CPU_LITTLE_ENDIAN 1 |
|
122 #elif defined(__powerpc64__) |
|
123 #define ARCH_CPU_PPC_FAMILY 1 |
|
124 #define ARCH_CPU_PPC64 1 |
|
125 #define ARCH_CPU_64_BITS 1 |
|
126 #define ARCH_CPU_BIG_ENDIAN 1 |
|
127 #elif defined(__ppc__) || defined(__powerpc__) |
|
128 #define ARCH_CPU_PPC_FAMILY 1 |
|
129 #define ARCH_CPU_PPC 1 |
|
130 #define ARCH_CPU_32_BITS 1 |
|
131 #define ARCH_CPU_BIG_ENDIAN 1 |
|
132 #elif defined(__sparc64__) |
|
133 #define ARCH_CPU_SPARC_FAMILY 1 |
|
134 #define ARCH_CPU_SPARC 1 |
|
135 #define ARCH_CPU_64_BITS 1 |
|
136 #elif defined(__sparc__) |
|
137 #define ARCH_CPU_SPARC_FAMILY 1 |
|
138 #define ARCH_CPU_SPARC 1 |
|
139 #define ARCH_CPU_32_BITS 1 |
|
140 #elif defined(__mips__) |
|
141 #define ARCH_CPU_MIPS_FAMILY 1 |
|
142 #define ARCH_CPU_MIPS 1 |
|
143 #define ARCH_CPU_32_BITS 1 |
|
144 #elif defined(__hppa__) |
|
145 #define ARCH_CPU_HPPA 1 |
|
146 #define ARCH_CPU_32_BITS 1 |
|
147 #elif defined(__ia64__) |
|
148 #define ARCH_CPU_IA64 1 |
|
149 #define ARCH_CPU_64_BITS 1 |
|
150 #elif defined(__s390x__) |
|
151 #define ARCH_CPU_S390X 1 |
|
152 #define ARCH_CPU_64_BITS 1 |
|
153 #elif defined(__s390__) |
|
154 #define ARCH_CPU_S390 1 |
|
155 #define ARCH_CPU_32_BITS 1 |
|
156 #elif defined(__alpha__) |
|
157 #define ARCH_CPU_ALPHA 1 |
|
158 #define ARCH_CPU_64_BITS 1 |
|
159 #else |
|
160 #error Please add support for your architecture in build/build_config.h |
|
161 #endif |
|
162 |
|
163 // Type detection for wchar_t. |
|
164 #if defined(OS_WIN) |
|
165 #define WCHAR_T_IS_UTF16 |
|
166 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ |
|
167 defined(__WCHAR_MAX__) && \ |
|
168 (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) |
|
169 #define WCHAR_T_IS_UTF32 |
|
170 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ |
|
171 defined(__WCHAR_MAX__) && \ |
|
172 (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) |
|
173 // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to |
|
174 // compile in this mode (in particular, Chrome doesn't). This is intended for |
|
175 // other projects using base who manage their own dependencies and make sure |
|
176 // short wchar works for them. |
|
177 #define WCHAR_T_IS_UTF16 |
|
178 #else |
|
179 #error Please add support for your compiler in build/build_config.h |
|
180 #endif |
|
181 |
|
182 #if defined(__ARMEL__) && !defined(OS_IOS) |
|
183 #define WCHAR_T_IS_UNSIGNED 1 |
|
184 #elif defined(__MIPSEL__) |
|
185 #define WCHAR_T_IS_UNSIGNED 0 |
|
186 #endif |
|
187 |
|
188 #if defined(OS_ANDROID) |
|
189 // The compiler thinks std::string::const_iterator and "const char*" are |
|
190 // equivalent types. |
|
191 #define STD_STRING_ITERATOR_IS_CHAR_POINTER |
|
192 // The compiler thinks base::string16::const_iterator and "char16*" are |
|
193 // equivalent types. |
|
194 #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER |
|
195 #endif |
|
196 |
|
197 #endif // BUILD_BUILD_CONFIG_H_ |