build_config.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 src/chrome/LICENSE file.
  4. // This file adds defines about the platform we're currently building on.
  5. // Operating System:
  6. // OS_WIN / OS_MACOSX / OS_LINUX / OS_POSIX (MACOSX or LINUX)
  7. // Compiler:
  8. // COMPILER_MSVC / COMPILER_GCC
  9. // Processor:
  10. // ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)
  11. // ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
  12. #ifndef BUILD_BUILD_CONFIG_H_
  13. #define BUILD_BUILD_CONFIG_H_
  14. // A set of macros to use for platform detection.
  15. #if defined(__APPLE__)
  16. #define OS_MACOSX 1
  17. #elif defined(__linux__)
  18. #define OS_LINUX 1
  19. // Use TOOLKIT_GTK on linux if TOOLKIT_VIEWS isn't defined.
  20. #if !defined(TOOLKIT_VIEWS)
  21. #define TOOLKIT_GTK
  22. #endif
  23. #elif defined(_WIN32)
  24. #define OS_WIN 1
  25. #define TOOLKIT_VIEWS 1
  26. #elif defined(__FreeBSD__)
  27. #define OS_FREEBSD 1
  28. #define TOOLKIT_GTK
  29. #elif defined(__OpenBSD__)
  30. #define OS_OPENBSD 1
  31. #define TOOLKIT_GTK
  32. #elif defined(__sun)
  33. #define OS_SOLARIS 1
  34. #define TOOLKIT_GTK
  35. #else
  36. #error Please add support for your platform in build/build_config.h
  37. #endif
  38. // A flag derived from the above flags, used to cover GTK code in
  39. // both TOOLKIT_GTK and TOOLKIT_VIEWS.
  40. #if defined(TOOLKIT_GTK) || (defined(TOOLKIT_VIEWS) && !defined(OS_WIN))
  41. #define TOOLKIT_USES_GTK 1
  42. #endif
  43. #if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || \
  44. defined(OS_SOLARIS)
  45. #define USE_NSS 1 // Use NSS for crypto.
  46. #define USE_X11 1 // Use X for graphics.
  47. #endif
  48. // For access to standard POSIXish features, use OS_POSIX instead of a
  49. // more specific macro.
  50. #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \
  51. defined(OS_OPENBSD) || defined(OS_SOLARIS)
  52. #define OS_POSIX 1
  53. // Use base::DataPack for name/value pairs.
  54. #define USE_BASE_DATA_PACK 1
  55. #endif
  56. // Use tcmalloc
  57. #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(NO_TCMALLOC)
  58. #define USE_TCMALLOC 1
  59. #endif
  60. // Use heapchecker.
  61. #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(NO_HEAPCHECKER)
  62. #define USE_HEAPCHECKER 1
  63. #endif
  64. // Compiler detection.
  65. #if defined(__GNUC__)
  66. #define COMPILER_GCC 1
  67. #elif defined(_MSC_VER)
  68. #define COMPILER_MSVC 1
  69. #else
  70. #error Please add support for your compiler in build/build_config.h
  71. #endif
  72. // Processor architecture detection. For more info on what's defined, see:
  73. // http://msdn.microsoft.com/en-us/library/b0084kay.aspx
  74. // http://www.agner.org/optimize/calling_conventions.pdf
  75. // or with gcc, run: "echo | gcc -E -dM -"
  76. #if defined(_M_X64) || defined(__x86_64__)
  77. #define ARCH_CPU_X86_FAMILY 1
  78. #define ARCH_CPU_X86_64 1
  79. #define ARCH_CPU_64_BITS 1
  80. #elif defined(_M_IX86) || defined(__i386__)
  81. #define ARCH_CPU_X86_FAMILY 1
  82. #define ARCH_CPU_X86 1
  83. #define ARCH_CPU_32_BITS 1
  84. #elif defined(__ARMEL__)
  85. #define ARCH_CPU_ARM_FAMILY 1
  86. #define ARCH_CPU_ARMEL 1
  87. #define ARCH_CPU_32_BITS 1
  88. #define WCHAR_T_IS_UNSIGNED 1
  89. #else
  90. #error Please add support for your architecture in build/build_config.h
  91. #endif
  92. // Type detection for wchar_t.
  93. #if defined(OS_WIN)
  94. #define WCHAR_T_IS_UTF16
  95. #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
  96. defined(__WCHAR_MAX__) && \
  97. (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
  98. #define WCHAR_T_IS_UTF32
  99. #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
  100. defined(__WCHAR_MAX__) && \
  101. (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
  102. // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
  103. // compile in this mode (in particular, Chrome doesn't). This is intended for
  104. // other projects using base who manage their own dependencies and make sure
  105. // short wchar works for them.
  106. #define WCHAR_T_IS_UTF16
  107. #else
  108. #error Please add support for your compiler in build/build_config.h
  109. #endif
  110. #endif // BUILD_BUILD_CONFIG_H_