libs.m4 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. # StarPU --- Runtime system for heterogeneous multicore architectures.
  2. #
  3. # Copyright (C) 2011-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. #
  5. # StarPU is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU Lesser General Public License as published by
  7. # the Free Software Foundation; either version 2.1 of the License, or (at
  8. # your option) any later version.
  9. #
  10. # StarPU is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. #
  14. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. #
  16. # STARPU_SEARCH_LIBS(NAME, FUNCTION, SEARCH-LIBS,
  17. # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
  18. # [OTHER-LIBRARIES])
  19. #
  20. # Like AC_SEARCH_LIBS, but puts -l flags into $1_LDFLAGS instead of LIBS, and
  21. # AC_SUBSTs it
  22. AC_DEFUN([STARPU_SEARCH_LIBS], [dnl
  23. _LIBS_SAV="$LIBS"
  24. LIBS=""
  25. AC_SEARCH_LIBS([$2], [$3], [$4], [$5], [$6])
  26. STARPU_$1_LDFLAGS="$STARPU_$1_LDFLAGS $LIBS"
  27. LIBS=$_LIBS_SAV
  28. AC_SUBST(STARPU_$1_LDFLAGS)
  29. ])dnl
  30. # STARPU_CHECK_LIB(NAME, LIBRARY, FUNCTION,
  31. # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
  32. # [OTHER-LIBRARIES])
  33. #
  34. # Like AC_CHECK_LIB, but puts -l flags into $1_LDFLAGS instead of LIBS, and
  35. # AC_SUBSTs it
  36. AC_DEFUN([STARPU_CHECK_LIB], [dnl
  37. _LIBS_SAV="$LIBS"
  38. LIBS=""
  39. AC_CHECK_LIB([$2], [$3], [$4], [$5], [$6])
  40. STARPU_$1_LDFLAGS="$STARPU_$1_LDFLAGS $LIBS"
  41. LIBS=$_LIBS_SAV
  42. AC_SUBST(STARPU_$1_LDFLAGS)
  43. ])dnl
  44. # STARPU_HAVE_LIBRARY(NAME, LIBRARY,
  45. # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
  46. # [OTHER-LIBRARIES])
  47. # Like AC_HAVE_LIBRARY, but puts -l flags into $1_LDFLAGS instead of LIBS, and
  48. # AC_SUBSTs it
  49. AC_DEFUN([STARPU_HAVE_LIBRARY], [dnl
  50. STARPU_CHECK_LIB([$1], [$2], main, [$3], [$4], [$5])
  51. ])dnl
  52. # STARPU_INIT_ZERO(INCLUDES, TYPE, INIT_MACRO)
  53. # Checks whether when TYPE is initialized with INIT_MACRO, the content is just
  54. # plain zeroes
  55. AC_DEFUN([STARPU_INIT_ZERO], [dnl
  56. AC_MSG_CHECKING(whether $3 just zeroes)
  57. AC_RUN_IFELSE([AC_LANG_PROGRAM(
  58. $1,
  59. [[$2 var = $3;
  60. char *p;
  61. for (p = (char*) &var; p < (char*) (&var+1); p++)
  62. if (*p != 0)
  63. return 1;
  64. return 0;
  65. ]],
  66. )],
  67. [AC_DEFINE([STARPU_$3_ZERO], [1], [Define to 1 if `$3' is just zeroes])
  68. AC_MSG_RESULT(yes)],
  69. [AC_MSG_RESULT(no)])
  70. ])dnl
  71. # IS_SUPPORTED_CFLAG(flag)
  72. # ------------------------
  73. # Check if the CFLAGS `flag' is supported by the compiler
  74. AC_DEFUN([IS_SUPPORTED_CFLAG],
  75. [
  76. AC_REQUIRE([AC_PROG_CC])
  77. AC_MSG_CHECKING([whether C compiler support $1])
  78. SAVED_CFLAGS="$CFLAGS"
  79. CFLAGS="$1"
  80. AC_LINK_IFELSE(
  81. AC_LANG_PROGRAM(
  82. [[]],
  83. [[AC_LANG_SOURCE([const char *hello = "Hello World";])]]
  84. ),
  85. [
  86. m4_default_nblank([$2], [GLOBAL_AM_CFLAGS="$GLOBAL_AM_CFLAGS $1"])
  87. AC_MSG_RESULT(yes)
  88. option_available=1
  89. ],
  90. [
  91. AC_MSG_RESULT(no)
  92. option_available=0
  93. ]
  94. )
  95. CFLAGS="$SAVED_CFLAGS"
  96. ])
  97. # IS_SUPPORTED_CXXFLAG(flag)
  98. # ------------------------
  99. # Check if the CXXFLAGS `flag' is supported by the compiler
  100. AC_DEFUN([IS_SUPPORTED_CXXFLAG],
  101. [
  102. AC_REQUIRE([AC_PROG_CXX])
  103. AC_LANG_PUSH([C++])
  104. AC_MSG_CHECKING([whether CXX compiler support $1])
  105. SAVED_CXXFLAGS="$CXXFLAGS"
  106. CXXFLAGS="$1"
  107. AC_LINK_IFELSE(
  108. AC_LANG_PROGRAM(
  109. [[]],
  110. [[AC_LANG_SOURCE([const char *hello = "Hello World";])]]
  111. ),
  112. [
  113. m4_default_nblank([$2], [GLOBAL_AM_CXXFLAGS="$GLOBAL_AM_CXXFLAGS $1"])
  114. AC_MSG_RESULT(yes)
  115. option_available=1
  116. ],
  117. [
  118. AC_MSG_RESULT(no)
  119. option_available=0
  120. ]
  121. )
  122. CXXFLAGS="$SAVED_CXXFLAGS"
  123. AC_LANG_POP([C++])
  124. ])
  125. # IS_SUPPORTED_FFLAG(flag)
  126. # ------------------------
  127. # Check if the FFLAGS `flag' is supported by the compiler
  128. AC_DEFUN([IS_SUPPORTED_FFLAG],
  129. [
  130. AC_LANG_PUSH([Fortran 77])
  131. AC_MSG_CHECKING([whether Fortran 77 compiler support $1])
  132. SAVED_FFLAGS="$FFLAGS"
  133. FFLAGS="$1"
  134. AC_LINK_IFELSE(
  135. AC_LANG_PROGRAM(
  136. [],
  137. [[AC_LANG_SOURCE([])]]
  138. ),
  139. [
  140. m4_default_nblank([$2], [GLOBAL_AM_FFLAGS="$GLOBAL_AM_FFLAGS $1"])
  141. AC_MSG_RESULT(yes)
  142. option_available=1
  143. ],
  144. [
  145. AC_MSG_RESULT(no)
  146. option_available=0
  147. ]
  148. )
  149. FFLAGS="$SAVED_FFLAGS"
  150. AC_LANG_POP([Fortran 77])
  151. ])
  152. # IS_SUPPORTED_FCFLAG(flag)
  153. # ------------------------
  154. # Check if the FCLAGS `flag' is supported by the compiler
  155. AC_DEFUN([IS_SUPPORTED_FCFLAG],
  156. [
  157. AC_LANG_PUSH([Fortran])
  158. AC_MSG_CHECKING([whether Fortran compiler support $1])
  159. SAVED_FCFLAGS="$FCFLAGS"
  160. FCFLAGS="$1"
  161. AC_LINK_IFELSE(
  162. AC_LANG_PROGRAM(
  163. [],
  164. [[AC_LANG_SOURCE([])]]
  165. ),
  166. [
  167. m4_default_nblank([$2], [GLOBAL_AM_FCFLAGS="$GLOBAL_AM_FCFLAGS $1"])
  168. AC_MSG_RESULT(yes)
  169. option_available=1
  170. ],
  171. [
  172. AC_MSG_RESULT(no)
  173. option_available=0
  174. ]
  175. )
  176. FCFLAGS="$SAVED_FCFLAGS"
  177. AC_LANG_POP([Fortran])
  178. ])
  179. # IS_SUPPORTED_FLAG(flag)
  180. # ------------------------
  181. # Check with C, C++, F77 and F90 that the `flag' is supported by the compiler
  182. AC_DEFUN([IS_SUPPORTED_FLAG],
  183. [
  184. IS_SUPPORTED_CFLAG($1)
  185. IS_SUPPORTED_CXXFLAG($1)
  186. IS_SUPPORTED_FFLAG($1)
  187. IS_SUPPORTED_FCFLAG($1)
  188. ])
  189. # AC_PYTHON_MODULE(modulename, [action-if-found], [action-if-not-found])
  190. # Check if the given python module is available
  191. AC_DEFUN([AC_PYTHON_MODULE],
  192. [
  193. echo "import $1" | $PYTHON - 2>/dev/null
  194. if test $? -ne 0 ; then
  195. $3
  196. else
  197. $2
  198. fi
  199. ])