detect.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
  2. /* If you are missing that file, acquire a complete release at teeworlds.com. */
  3. #ifndef BASE_DETECT_H
  4. #define BASE_DETECT_H
  5. /*
  6. this file detected the family, platform and architecture
  7. to compile for.
  8. */
  9. /* platforms */
  10. /* windows Family */
  11. #if defined(WIN64) || defined(_WIN64)
  12. /* Hmm, is this IA64 or x86-64? */
  13. #define CONF_FAMILY_WINDOWS 1
  14. #define CONF_FAMILY_STRING "windows"
  15. #define CONF_PLATFORM_WIN64 1
  16. #define CONF_PLATFORM_STRING "win64"
  17. #elif defined(WIN32) || defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
  18. #define CONF_FAMILY_WINDOWS 1
  19. #define CONF_FAMILY_STRING "windows"
  20. #define CONF_PLATFORM_WIN32 1
  21. #define CONF_PLATFORM_STRING "win32"
  22. #endif
  23. /* unix family */
  24. #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
  25. #define CONF_FAMILY_UNIX 1
  26. #define CONF_FAMILY_STRING "unix"
  27. #define CONF_PLATFORM_FREEBSD 1
  28. #define CONF_PLATFORM_STRING "freebsd"
  29. #endif
  30. #if defined(__OpenBSD__)
  31. #define CONF_FAMILY_UNIX 1
  32. #define CONF_FAMILY_STRING "unix"
  33. #define CONF_PLATFORM_OPENBSD 1
  34. #define CONF_PLATFORM_STRING "openbsd"
  35. #endif
  36. #if defined(__LINUX__) || defined(__linux__)
  37. #define CONF_FAMILY_UNIX 1
  38. #define CONF_FAMILY_STRING "unix"
  39. #define CONF_PLATFORM_LINUX 1
  40. #define CONF_PLATFORM_STRING "linux"
  41. #endif
  42. #if defined(__GNU__) || defined(__gnu__)
  43. #define CONF_FAMILY_UNIX 1
  44. #define CONF_FAMILY_STRING "unix"
  45. #define CONF_PLATFORM_HURD 1
  46. #define CONF_PLATFORM_STRING "gnu"
  47. #endif
  48. #if defined(MACOSX) || defined(__APPLE__) || defined(__DARWIN__)
  49. #define CONF_FAMILY_UNIX 1
  50. #define CONF_FAMILY_STRING "unix"
  51. #define CONF_PLATFORM_MACOSX 1
  52. #define CONF_PLATFORM_STRING "macosx"
  53. #endif
  54. #if defined(__sun)
  55. #define CONF_FAMILY_UNIX 1
  56. #define CONF_FAMILY_STRING "unix"
  57. #define CONF_PLATFORM_SOLARIS 1
  58. #define CONF_PLATFORM_STRING "solaris"
  59. #endif
  60. /* beos family */
  61. #if defined(__BeOS) || defined(__BEOS__)
  62. #define CONF_FAMILY_BEOS 1
  63. #define CONF_FAMILY_STRING "beos"
  64. #define CONF_PLATFORM_BEOS 1
  65. #define CONF_PLATFORM_STRING "beos"
  66. #endif
  67. /* use gcc endianness definitions when available */
  68. #if defined(__GNUC__) && !defined(__APPLE__) && !defined(__MINGW32__) && !defined(__sun)
  69. #if defined(__FreeBSD__) || defined(__OpenBSD__)
  70. #include <sys/endian.h>
  71. #else
  72. #include <endian.h>
  73. #endif
  74. #if __BYTE_ORDER == __LITTLE_ENDIAN
  75. #define CONF_ARCH_ENDIAN_LITTLE 1
  76. #elif __BYTE_ORDER == __BIG_ENDIAN
  77. #define CONF_ARCH_ENDIAN_BIG 1
  78. #endif
  79. #endif
  80. /* architectures */
  81. #if defined(i386) || defined(__i386__) || defined(__x86__) || defined(CONF_PLATFORM_WIN32)
  82. #define CONF_ARCH_IA32 1
  83. #define CONF_ARCH_STRING "ia32"
  84. #if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
  85. #define CONF_ARCH_ENDIAN_LITTLE 1
  86. #endif
  87. #endif
  88. #if defined(__ia64__) || defined(_M_IA64)
  89. #define CONF_ARCH_IA64 1
  90. #define CONF_ARCH_STRING "ia64"
  91. #if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
  92. #define CONF_ARCH_ENDIAN_LITTLE 1
  93. #endif
  94. #endif
  95. #if defined(__amd64__) || defined(__x86_64__) || defined(_M_X64)
  96. #define CONF_ARCH_AMD64 1
  97. #define CONF_ARCH_STRING "amd64"
  98. #if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
  99. #define CONF_ARCH_ENDIAN_LITTLE 1
  100. #endif
  101. #endif
  102. #if defined(__powerpc__) || defined(__ppc__)
  103. #define CONF_ARCH_PPC 1
  104. #define CONF_ARCH_STRING "ppc"
  105. #if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
  106. #define CONF_ARCH_ENDIAN_BIG 1
  107. #endif
  108. #endif
  109. #if defined(__sparc__)
  110. #define CONF_ARCH_SPARC 1
  111. #define CONF_ARCH_STRING "sparc"
  112. #if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
  113. #define CONF_ARCH_ENDIAN_BIG 1
  114. #endif
  115. #endif
  116. #ifndef CONF_FAMILY_STRING
  117. #define CONF_FAMILY_STRING "unknown"
  118. #endif
  119. #ifndef CONF_PLATFORM_STRING
  120. #define CONF_PLATFORM_STRING "unknown"
  121. #endif
  122. #ifndef CONF_ARCH_STRING
  123. #define CONF_ARCH_STRING "unknown"
  124. #endif
  125. #endif