blob: 3ea3ddca4b833e8e8543ecf2396ad49b7d449fb5 [file] [log] [blame]
[email protected]cea4aec2012-01-24 12:26:401// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
[email protected]4867b182008-08-04 21:16:504
[email protected]ab8c0b02008-08-05 11:56:305// 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
[email protected]4867b182008-08-04 21:16:5014#ifndef BUILD_BUILD_CONFIG_H_
15#define BUILD_BUILD_CONFIG_H_
16
[email protected]1e013672012-06-29 22:12:2017#if defined(__APPLE__)
18#include <TargetConditionals.h>
19#endif
20
[email protected]4867b182008-08-04 21:16:5021// A set of macros to use for platform detection.
[email protected]c57a3702013-04-04 11:51:2722#if defined(ANDROID)
23#define OS_ANDROID 1
24#elif defined(__APPLE__)
[email protected]4867b182008-08-04 21:16:5025#define OS_MACOSX 1
[email protected]3777ee72012-07-04 15:23:3926#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
[email protected]1e013672012-06-29 22:12:2027#define OS_IOS 1
[email protected]3777ee72012-07-04 15:23:3928#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
[email protected]19ea84ca2010-11-12 08:37:0829#elif defined(__native_client__)
30#define OS_NACL 1
[email protected]1020d2f2008-08-14 11:21:2831#elif defined(__linux__)
[email protected]4867b182008-08-04 21:16:5032#define OS_LINUX 1
[email protected]0ae186f2009-05-07 23:41:2933// Use TOOLKIT_GTK on linux if TOOLKIT_VIEWS isn't defined.
[email protected]2fa2f2d82013-04-29 18:13:1234#if !defined(TOOLKIT_VIEWS) && defined(USE_X11)
[email protected]0ae186f2009-05-07 23:41:2935#define TOOLKIT_GTK
36#endif
[email protected]292633f02013-05-23 12:00:1037#if defined(__GLIBC__) && !defined(__UCLIBC__)
38// we really are using glibc, not uClibc pretending to be glibc
39#define LIBC_GLIBC
40#endif
[email protected]f61b898b2009-02-09 15:42:0841#elif defined(_WIN32)
[email protected]771b2fd2008-08-04 21:32:5742#define OS_WIN 1
[email protected]321792e2009-05-13 23:21:4543#define TOOLKIT_VIEWS 1
[email protected]fb66f9d2009-09-07 16:39:4644#elif defined(__FreeBSD__)
45#define OS_FREEBSD 1
46#define TOOLKIT_GTK
[email protected]c51e8d52009-12-11 20:04:0647#elif defined(__OpenBSD__)
48#define OS_OPENBSD 1
49#define TOOLKIT_GTK
[email protected]93f21e42010-04-01 00:35:1550#elif defined(__sun)
[email protected]b5c72b822010-02-18 16:11:3751#define OS_SOLARIS 1
52#define TOOLKIT_GTK
[email protected]4867b182008-08-04 21:16:5053#else
54#error Please add support for your platform in build/build_config.h
55#endif
56
[email protected]70372d42010-10-22 13:12:3457#if defined(USE_OPENSSL) && defined(USE_NSS)
58#error Cannot use both OpenSSL and NSS
59#endif
60
[email protected]e37e88a02011-11-15 00:06:1661// For access to standard BSD features, use OS_BSD instead of a
62// more specific macro.
63#if defined(OS_FREEBSD) || defined(OS_OPENBSD)
64#define OS_BSD 1
65#endif
66
[email protected]fb66f9d2009-09-07 16:39:4667// For access to standard POSIXish features, use OS_POSIX instead of a
68// more specific macro.
[email protected]be16cf22011-06-27 19:13:1069#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \
70 defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \
71 defined(OS_NACL)
[email protected]4867b182008-08-04 21:16:5072#define OS_POSIX 1
[email protected]fb66f9d2009-09-07 16:39:4673#endif
74
[email protected]833b88a2009-09-22 16:16:3975// Use tcmalloc
[email protected]3c8fe5482013-05-22 15:17:0376#if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \
77 !defined(NO_TCMALLOC)
[email protected]833b88a2009-09-22 16:16:3978#define USE_TCMALLOC 1
79#endif
80
[email protected]4867b182008-08-04 21:16:5081// Compiler detection.
82#if defined(__GNUC__)
[email protected]ab8c0b02008-08-05 11:56:3083#define COMPILER_GCC 1
[email protected]4867b182008-08-04 21:16:5084#elif defined(_MSC_VER)
[email protected]ab8c0b02008-08-05 11:56:3085#define COMPILER_MSVC 1
86#else
87#error Please add support for your compiler in build/build_config.h
88#endif
89
90// Processor architecture detection. For more info on what's defined, see:
91// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
92// http://www.agner.org/optimize/calling_conventions.pdf
[email protected]697776a2009-05-01 17:57:0993// or with gcc, run: "echo | gcc -E -dM -"
[email protected]ab8c0b02008-08-05 11:56:3094#if defined(_M_X64) || defined(__x86_64__)
95#define ARCH_CPU_X86_FAMILY 1
96#define ARCH_CPU_X86_64 1
97#define ARCH_CPU_64_BITS 1
[email protected]2377cdee2011-06-24 20:46:0698#define ARCH_CPU_LITTLE_ENDIAN 1
[email protected]ab8c0b02008-08-05 11:56:3099#elif defined(_M_IX86) || defined(__i386__)
100#define ARCH_CPU_X86_FAMILY 1
101#define ARCH_CPU_X86 1
102#define ARCH_CPU_32_BITS 1
[email protected]2377cdee2011-06-24 20:46:06103#define ARCH_CPU_LITTLE_ENDIAN 1
[email protected]697776a2009-05-01 17:57:09104#elif defined(__ARMEL__)
105#define ARCH_CPU_ARM_FAMILY 1
106#define ARCH_CPU_ARMEL 1
107#define ARCH_CPU_32_BITS 1
[email protected]2377cdee2011-06-24 20:46:06108#define ARCH_CPU_LITTLE_ENDIAN 1
[email protected]814127c2011-08-26 19:03:20109#elif defined(__pnacl__)
110#define ARCH_CPU_32_BITS 1
[email protected]f7d2fbd2012-06-18 02:47:05111#elif defined(__MIPSEL__)
112#define ARCH_CPU_MIPS_FAMILY 1
113#define ARCH_CPU_MIPSEL 1
114#define ARCH_CPU_32_BITS 1
115#define ARCH_CPU_LITTLE_ENDIAN 1
[email protected]ab8c0b02008-08-05 11:56:30116#else
117#error Please add support for your architecture in build/build_config.h
[email protected]4867b182008-08-04 21:16:50118#endif
119
[email protected]39be4242008-08-07 18:31:40120// Type detection for wchar_t.
121#if defined(OS_WIN)
122#define WCHAR_T_IS_UTF16
123#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
[email protected]697776a2009-05-01 17:57:09124 defined(__WCHAR_MAX__) && \
125 (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
[email protected]39be4242008-08-07 18:31:40126#define WCHAR_T_IS_UTF32
[email protected]d9a30d92009-10-22 18:04:17127#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
128 defined(__WCHAR_MAX__) && \
129 (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
130// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
131// compile in this mode (in particular, Chrome doesn't). This is intended for
132// other projects using base who manage their own dependencies and make sure
133// short wchar works for them.
134#define WCHAR_T_IS_UTF16
[email protected]39be4242008-08-07 18:31:40135#else
136#error Please add support for your compiler in build/build_config.h
137#endif
138
[email protected]1e013672012-06-29 22:12:20139#if defined(__ARMEL__) && !defined(OS_IOS)
140#define WCHAR_T_IS_UNSIGNED 1
141#elif defined(__MIPSEL__)
142#define WCHAR_T_IS_UNSIGNED 0
143#endif
144
[email protected]be16cf22011-06-27 19:13:10145#if defined(OS_ANDROID)
146// The compiler thinks std::string::const_iterator and "const char*" are
147// equivalent types.
148#define STD_STRING_ITERATOR_IS_CHAR_POINTER
149// The compiler thinks base::string16::const_iterator and "char16*" are
150// equivalent types.
151#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
152#endif
153
[email protected]4867b182008-08-04 21:16:50154#endif // BUILD_BUILD_CONFIG_H_