You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
3.5 KiB

  1. dnl Check for the __declspec(dllexport) construct support.
  2. AC_DEFUN([AX_DECLSPEC],
  3. [
  4. AH_TEMPLATE($1[]_IMPORT,
  5. [Defined if the compiler understands __declspec(dllimport)
  6. or __attribute__((visibility("default"))) or __global construct.])
  7. AH_TEMPLATE($1[]_EXPORT,
  8. [Defined if the compiler understands __declspec(dllimport)
  9. or __attribute__((visibility("default"))) or __global construct.])
  10. AH_TEMPLATE($1[]_PRIVATE,
  11. [Defined if the compiler understands __attribute__((visibility("hidden")))
  12. or __hidden construct.])
  13. AS_VAR_SET([continue_checks], [1])
  14. dnl This is for Solaris platforms with Solaris Studio.
  15. AC_CACHE_CHECK([for __global and __hidden], [ac_cv__global],
  16. [
  17. AC_COMPILE_IFELSE(
  18. [AC_LANG_PROGRAM(
  19. [[
  20. __global int x = 0;
  21. __global int foo ();
  22. int foo () { return 0; }
  23. __global int bar () { return x; }
  24. __hidden int baz () { return 1; }
  25. ]],
  26. [[]])],
  27. [ac_cv__global=yes],
  28. [ac_cv__global=no])
  29. ])
  30. AS_IF([test "x$ac_cv__global" = "xyes"],
  31. [AC_DEFINE($1[]_IMPORT, [__global])
  32. AC_DEFINE($1[]_EXPORT, [__global])
  33. AC_DEFINE($1[]_PRIVATE, [__hidden])
  34. AS_UNSET([continue_checks])])
  35. dnl This typically succeeds on Windows/MinGW/Cygwin.
  36. AS_VAR_SET_IF([continue_checks],
  37. [
  38. AC_CACHE_CHECK([for __declspec(dllexport) and __declspec(dllimport)],
  39. [ac_cv_declspec],
  40. [
  41. AC_COMPILE_IFELSE(
  42. [AC_LANG_PROGRAM(
  43. [[
  44. #if defined (__clang__) || defined (__HAIKU__)
  45. // Here the problem is that Clang only warns that it does not support
  46. // __declspec(dllexport) but still compiles the executable. GCC on Haiku OS
  47. // suffers from the same problem.
  48. # error Please fail.
  49. And extra please fail.
  50. #else
  51. __declspec(dllexport) int x = 0;
  52. __declspec(dllexport) int foo ();
  53. int foo () { return 0; }
  54. __declspec(dllexport) int bar () { return x; }
  55. #endif
  56. ]],
  57. [[]])],
  58. [ac_cv_declspec=yes],
  59. [ac_cv_declspec=no])
  60. ])
  61. AS_IF([test "x$ac_cv_declspec" = "xyes"],
  62. [AC_DEFINE($1[]_IMPORT, [__declspec(dllimport)])
  63. AC_DEFINE($1[]_EXPORT, [__declspec(dllexport)])
  64. AC_DEFINE($1[]_PRIVATE, [/* empty */])
  65. AS_UNSET([continue_checks])])
  66. ])
  67. dnl This typically succeeds on *NIX platforms with GCC or Clang.
  68. AS_VAR_SET_IF([continue_checks],
  69. [
  70. AC_CACHE_CHECK([for __attribute__((visibility("default")))dnl
  71. and __attribute__((visibility("hidden")))], [ac_cv__attribute__visibility],
  72. [
  73. AC_COMPILE_IFELSE(
  74. [AC_LANG_PROGRAM(
  75. [[
  76. #if defined (__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ <= 1))
  77. # error Please fail.
  78. And extra please fail.
  79. #else
  80. __attribute__((visibility("default"))) int x = 0;
  81. __attribute__((visibility("default"))) int foo ();
  82. int foo () { return 0; }
  83. __attribute__((visibility("default"))) int bar () { return x; }
  84. __attribute__((visibility("hidden"))) int baz () { return 1; }
  85. #endif
  86. ]],
  87. [[]])],
  88. [ac_cv__attribute__visibility=yes],
  89. [ac_cv__attribute__visibility=no])
  90. ])
  91. AS_IF([test "x$ac_cv__attribute__visibility" = "xyes"],
  92. [AC_DEFINE($1[]_IMPORT, [__attribute__ ((visibility("default")))])
  93. AC_DEFINE($1[]_EXPORT, [__attribute__ ((visibility("default")))])
  94. AC_DEFINE($1[]_PRIVATE, [__attribute__ ((visibility("hidden")))])
  95. AS_UNSET([continue_checks])])
  96. ])
  97. AS_IF([test "x$ac_cv__attribute__visibility" = "xno" dnl
  98. && test "x$ac_cv_declspec" = "xno" dnl
  99. && test "x$ax_cv__global" = "xno"],
  100. [AC_DEFINE($1[]_IMPORT, [/* empty */])
  101. AC_DEFINE($1[]_EXPORT, [/* empty */])
  102. AC_DEFINE($1[]_PRIVATE, [/* empty */])])
  103. AS_UNSET([continue_checks])
  104. ]) dnl AX_DECLSPEC