Home | History | Annotate | Download | only in build
      1 // Copyright (c) 2006-2008 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 // A set of macros to use for platform detection.
     18 #if defined(__APPLE__)
     19 #define OS_MACOSX 1
     20 #elif defined(__native_client__)
     21 #define OS_NACL 1
     22 #elif defined(__linux__)
     23 #define OS_LINUX 1
     24 // Use TOOLKIT_GTK on linux if TOOLKIT_VIEWS isn't defined.
     25 #if !defined(TOOLKIT_VIEWS)
     26 #define TOOLKIT_GTK
     27 #endif
     28 #elif defined(_WIN32)
     29 #define OS_WIN 1
     30 #define TOOLKIT_VIEWS 1
     31 #elif defined(__FreeBSD__)
     32 #define OS_FREEBSD 1
     33 #define TOOLKIT_GTK
     34 #elif defined(__OpenBSD__)
     35 #define OS_OPENBSD 1
     36 #define TOOLKIT_GTK
     37 #elif defined(__sun)
     38 #define OS_SOLARIS 1
     39 #define TOOLKIT_GTK
     40 #else
     41 #error Please add support for your platform in build/build_config.h
     42 #endif
     43 
     44 // A flag derived from the above flags, used to cover GTK code in
     45 // both TOOLKIT_GTK and TOOLKIT_VIEWS.
     46 #if defined(TOOLKIT_GTK) || (defined(TOOLKIT_VIEWS) && !defined(OS_WIN))
     47 #define TOOLKIT_USES_GTK 1
     48 #endif
     49 
     50 #if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || \
     51     defined(OS_SOLARIS)
     52 
     53 #if defined(ANDROID)
     54 #define USE_OPENSSL 1
     55 #define USE_SYSTEM_ZLIB 1
     56 #define USE_SYSTEM_SQLITE 1
     57 #define OS_ANDROID 1
     58 #endif
     59 
     60 #if !defined(USE_OPENSSL)
     61 #define USE_NSS 1  // Default to use NSS for crypto, unless OpenSSL is chosen.
     62 #endif
     63 #if !defined(ANDROID)
     64 #define USE_X11 1  // Use X for graphics.
     65 #else
     66 #undef USE_X11
     67 #endif
     68 #endif
     69 
     70 #if defined(USE_OPENSSL) && defined(USE_NSS)
     71 #error Cannot use both OpenSSL and NSS
     72 #endif
     73 
     74 // For access to standard POSIXish features, use OS_POSIX instead of a
     75 // more specific macro.
     76 #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \
     77     defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_NACL) || \
     78     defined(ANDROID)
     79 #define OS_POSIX 1
     80 // Use base::DataPack for name/value pairs.
     81 #define USE_BASE_DATA_PACK 1
     82 #endif
     83 
     84 // Use tcmalloc
     85 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(NO_TCMALLOC)
     86 #define USE_TCMALLOC 1
     87 #endif
     88 
     89 // Use heapchecker.
     90 #if defined(OS_LINUX) && !defined(NO_HEAPCHECKER)
     91 #define USE_HEAPCHECKER 1
     92 #endif
     93 
     94 // Compiler detection.
     95 #if defined(__GNUC__)
     96 #define COMPILER_GCC 1
     97 #elif defined(_MSC_VER)
     98 #define COMPILER_MSVC 1
     99 #else
    100 #error Please add support for your compiler in build/build_config.h
    101 #endif
    102 
    103 // Processor architecture detection.  For more info on what's defined, see:
    104 //   http://msdn.microsoft.com/en-us/library/b0084kay.aspx
    105 //   http://www.agner.org/optimize/calling_conventions.pdf
    106 //   or with gcc, run: "echo | gcc -E -dM -"
    107 #if defined(_M_X64) || defined(__x86_64__)
    108 #define ARCH_CPU_X86_FAMILY 1
    109 #define ARCH_CPU_X86_64 1
    110 #define ARCH_CPU_64_BITS 1
    111 #elif defined(_M_IX86) || defined(__i386__)
    112 #define ARCH_CPU_X86_FAMILY 1
    113 #define ARCH_CPU_X86 1
    114 #define ARCH_CPU_32_BITS 1
    115 #elif defined(__ARMEL__)
    116 #define ARCH_CPU_ARM_FAMILY 1
    117 #define ARCH_CPU_ARMEL 1
    118 #define ARCH_CPU_32_BITS 1
    119 #define WCHAR_T_IS_UNSIGNED 1
    120 #else
    121 #error Please add support for your architecture in build/build_config.h
    122 #endif
    123 
    124 // Type detection for wchar_t.
    125 #if defined(OS_WIN)
    126 #define WCHAR_T_IS_UTF16
    127 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
    128     defined(__WCHAR_MAX__) && \
    129     (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
    130 #define WCHAR_T_IS_UTF32
    131 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
    132     defined(__WCHAR_MAX__) && \
    133     (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
    134 // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
    135 // compile in this mode (in particular, Chrome doesn't). This is intended for
    136 // other projects using base who manage their own dependencies and make sure
    137 // short wchar works for them.
    138 #define WCHAR_T_IS_UTF16
    139 #else
    140 #error Please add support for your compiler in build/build_config.h
    141 #endif
    142 
    143 #if defined(OS_CHROMEOS)
    144 // Single define to trigger whether CrOS fonts have BCI on.
    145 // In that case font sizes/deltas should be adjusted.
    146 //define CROS_FONTS_USING_BCI
    147 #endif
    148 
    149 #if defined(OS_ANDROID)
    150 // The compiler thinks std::string::const_iterator and "const char*" are
    151 // equivalent types.
    152 #define STD_STRING_ITERATOR_IS_CHAR_POINTER
    153 // The compiler thinks base::string16::const_iterator and "char16*" are
    154 // equivalent types.
    155 #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
    156 #endif
    157 
    158 #endif  // BUILD_BUILD_CONFIG_H_
    159