aclocal.m4 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. dnl Macros used to build the Wine configure script
  2. dnl
  3. dnl Copyright 2002 Alexandre Julliard
  4. dnl
  5. dnl This library is free software; you can redistribute it and/or
  6. dnl modify it under the terms of the GNU Lesser General Public
  7. dnl License as published by the Free Software Foundation; either
  8. dnl version 2.1 of the License, or (at your option) any later version.
  9. dnl
  10. dnl This library is distributed in the hope that it will be useful,
  11. dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. dnl Lesser General Public License for more details.
  14. dnl
  15. dnl You should have received a copy of the GNU Lesser General Public
  16. dnl License along with this library; if not, write to the Free Software
  17. dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  18. dnl
  19. dnl As a special exception to the GNU Lesser General Public License,
  20. dnl if you distribute this file as part of a program that contains a
  21. dnl configuration script generated by Autoconf, you may include it
  22. dnl under the same distribution terms that you use for the rest of
  23. dnl that program.
  24. dnl WINE_CHECK_HOST_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
  25. dnl
  26. dnl Like AC_CHECK_TOOL but without the broken fallback to non-prefixed name
  27. dnl
  28. AC_DEFUN([WINE_CHECK_HOST_TOOL],
  29. [AS_VAR_SET_IF([ac_tool_prefix],
  30. [AC_CHECK_PROG([$1],[${ac_tool_prefix}$2],[${ac_tool_prefix}$2],,[$4])])
  31. AS_VAR_IF([ac_cv_prog_$1],[],
  32. [AS_VAR_IF([cross_compiling],[yes],[],
  33. [AS_UNSET([ac_cv_prog_$1])
  34. AC_CHECK_PROG([$1],[$2],[$2],[$3],[$4])])],
  35. [AS_VAR_COPY([$1],[ac_cv_prog_$1])])])
  36. dnl WINE_HEADER_MAJOR()
  37. dnl
  38. dnl Same as AC_HEADER_MAJOR but fixed to handle the glibc 2.25 sys/types.h breakage
  39. dnl
  40. AC_DEFUN([WINE_HEADER_MAJOR],
  41. [AC_CHECK_HEADER(sys/mkdev.h,
  42. [AC_DEFINE(MAJOR_IN_MKDEV, 1,
  43. [Define to 1 if `major', `minor', and `makedev' are
  44. declared in <mkdev.h>.])])
  45. if test $ac_cv_header_sys_mkdev_h = no; then
  46. AC_CHECK_HEADER(sys/sysmacros.h,
  47. [AC_DEFINE(MAJOR_IN_SYSMACROS, 1,
  48. [Define to 1 if `major', `minor', and `makedev'
  49. are declared in <sysmacros.h>.])])
  50. fi])
  51. dnl **** Initialize the programs used by other checks ****
  52. dnl
  53. dnl Usage: WINE_PATH_SONAME_TOOLS
  54. dnl Usage: WINE_PATH_PKG_CONFIG
  55. dnl
  56. AC_DEFUN([WINE_PATH_SONAME_TOOLS],
  57. [AC_PATH_PROG(LDD,ldd,true,/sbin:/usr/sbin:$PATH)
  58. AC_CHECK_TOOL(OTOOL,otool,otool)
  59. AC_CHECK_TOOL(READELF,[readelf],true)])
  60. AC_DEFUN([WINE_PATH_PKG_CONFIG],
  61. [WINE_CHECK_HOST_TOOL(PKG_CONFIG,[pkg-config])])
  62. dnl **** Extract the soname of a library ****
  63. dnl
  64. dnl Usage: WINE_CHECK_SONAME(library, function, [action-if-found, [action-if-not-found, [other_libraries, [pattern]]]])
  65. dnl
  66. AC_DEFUN([WINE_CHECK_SONAME],
  67. [AC_REQUIRE([WINE_PATH_SONAME_TOOLS])dnl
  68. AS_VAR_PUSHDEF([ac_Lib],[ac_cv_lib_soname_$1])dnl
  69. m4_pushdef([ac_lib_pattern],m4_default([$6],[lib$1]))dnl
  70. AC_MSG_CHECKING([for -l$1])
  71. AC_CACHE_VAL(ac_Lib,
  72. [ac_check_soname_save_LIBS=$LIBS
  73. LIBS="-l$1 $5 $LIBS"
  74. AC_LINK_IFELSE([AC_LANG_CALL([], [$2])],
  75. [case "$LIBEXT" in
  76. dll) AS_VAR_SET(ac_Lib,[`$ac_cv_path_LDD conftest.exe | grep "$1" | sed -e "s/dll.*/dll/"';2,$d'`]) ;;
  77. dylib) AS_VAR_SET(ac_Lib,[`$OTOOL -L conftest$ac_exeext | grep "ac_lib_pattern\\.[[0-9A-Za-z.]]*dylib" | sed -e "s/^.*\/\(ac_lib_pattern\.[[0-9A-Za-z.]]*dylib\).*$/\1/"';2,$d'`]) ;;
  78. *) AS_VAR_SET(ac_Lib,[`$READELF -d conftest$ac_exeext | grep "NEEDED.*ac_lib_pattern\\.$LIBEXT" | sed -e "s/^.*\\m4_dquote(\\(ac_lib_pattern\\.$LIBEXT[[^ ]]*\\)\\).*$/\1/"';2,$d'`])
  79. AS_VAR_IF([ac_Lib],[],
  80. [AS_VAR_SET(ac_Lib,[`$LDD conftest$ac_exeext | grep "ac_lib_pattern\\.$LIBEXT" | sed -e "s/^.*\(ac_lib_pattern\.$LIBEXT[[^ ]]*\).*$/\1/"';2,$d'`])]) ;;
  81. esac],
  82. [AS_VAR_SET(ac_Lib,[])])
  83. LIBS=$ac_check_soname_save_LIBS])dnl
  84. AS_VAR_IF([ac_Lib],[],
  85. [AC_MSG_RESULT([not found])
  86. $4],
  87. [AC_MSG_RESULT(AS_VAR_GET(ac_Lib))
  88. AC_DEFINE_UNQUOTED(AS_TR_CPP(SONAME_LIB$1),["]AS_VAR_GET(ac_Lib)["],
  89. [Define to the soname of the lib$1 library.])
  90. $3])dnl
  91. m4_popdef([ac_lib_pattern])dnl
  92. AS_VAR_POPDEF([ac_Lib])])
  93. dnl **** Get flags from pkg-config or alternate xxx-config program ****
  94. dnl
  95. dnl Usage: WINE_PACKAGE_FLAGS(var,pkg-name,[default-lib,[cflags-alternate,libs-alternate,[checks]]])
  96. dnl
  97. AC_DEFUN([WINE_PACKAGE_FLAGS],
  98. [AC_REQUIRE([WINE_PATH_PKG_CONFIG])dnl
  99. AS_VAR_PUSHDEF([ac_cflags],[[$1]_CFLAGS])dnl
  100. AS_VAR_PUSHDEF([ac_libs],[[$1]_LIBS])dnl
  101. AC_ARG_VAR(ac_cflags, [C compiler flags for $2, overriding pkg-config])dnl
  102. AS_VAR_IF([ac_cflags],[],
  103. [AS_VAR_SET_IF([PKG_CONFIG],
  104. [ac_cflags=`$PKG_CONFIG --cflags [$2] 2>/dev/null`])])
  105. m4_ifval([$4],[test "$cross_compiling" = yes || ac_cflags=[$]{ac_cflags:-[$4]}])
  106. AC_ARG_VAR(ac_libs, [Linker flags for $2, overriding pkg-config])dnl
  107. AS_VAR_IF([ac_libs],[],
  108. [AS_VAR_SET_IF([PKG_CONFIG],
  109. [ac_libs=`$PKG_CONFIG --libs [$2] 2>/dev/null`])])
  110. m4_ifval([$5],[test "$cross_compiling" = yes || ac_libs=[$]{ac_libs:-[$5]}])
  111. m4_ifval([$3],[ac_libs=[$]{ac_libs:-"$3"}])
  112. AS_ECHO(["$as_me:${as_lineno-$LINENO}: $2 cflags: $ac_cflags"]) >&AS_MESSAGE_LOG_FD
  113. AS_ECHO(["$as_me:${as_lineno-$LINENO}: $2 libs: $ac_libs"]) >&AS_MESSAGE_LOG_FD
  114. ac_save_CPPFLAGS=$CPPFLAGS
  115. CPPFLAGS="$CPPFLAGS $ac_cflags"
  116. $6
  117. CPPFLAGS=$ac_save_CPPFLAGS
  118. AS_VAR_POPDEF([ac_libs])dnl
  119. AS_VAR_POPDEF([ac_cflags])])dnl
  120. dnl **** Link C code with an assembly file ****
  121. dnl
  122. dnl Usage: WINE_TRY_ASM_LINK(asm-code,includes,function,[action-if-found,[action-if-not-found]])
  123. dnl
  124. AC_DEFUN([WINE_TRY_ASM_LINK],
  125. [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]],[[asm($1); $3]])],[$4],[$5])])
  126. dnl **** Check if we can link an empty program with special CFLAGS ****
  127. dnl
  128. dnl Usage: WINE_TRY_CFLAGS(flags,[action-if-yes,[action-if-no]])
  129. dnl
  130. dnl The default action-if-yes is to append the flags to EXTRACFLAGS.
  131. dnl
  132. AC_DEFUN([WINE_TRY_CFLAGS],
  133. [AS_VAR_PUSHDEF([ac_var], ac_cv_cflags_[[$1]])dnl
  134. AC_CACHE_CHECK([whether the compiler supports $1], ac_var,
  135. [ac_wine_try_cflags_saved=$CFLAGS
  136. CFLAGS="$CFLAGS $1"
  137. AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(int argc, char **argv) { return 0; }]])],
  138. [AS_VAR_SET(ac_var,yes)], [AS_VAR_SET(ac_var,no)])
  139. CFLAGS=$ac_wine_try_cflags_saved])
  140. AS_VAR_IF([ac_var],[yes],[m4_default([$2], [EXTRACFLAGS="$EXTRACFLAGS $1"])], [$3])dnl
  141. AS_VAR_POPDEF([ac_var])])
  142. dnl **** Check if we can link an empty program with special CFLAGS ****
  143. dnl
  144. dnl Usage: WINE_TRY_CROSSCFLAGS(flags,[action-if-yes,[action-if-no]])
  145. dnl
  146. dnl The default action-if-yes is to append the flags to EXTRACROSSCFLAGS.
  147. dnl
  148. AC_DEFUN([WINE_TRY_CROSSCFLAGS],
  149. [AS_VAR_PUSHDEF([ac_var], ac_cv_crosscflags_[[$1]])dnl
  150. AC_CACHE_CHECK([whether the cross-compiler supports $1], ac_var,
  151. [ac_wine_try_cflags_saved=$CFLAGS
  152. ac_wine_try_cflags_saved_cc=$CC
  153. ac_wine_try_cflags_saved_exeext=$ac_exeext
  154. CFLAGS="$CFLAGS $EXTRACROSSCFLAGS -nostartfiles -nodefaultlibs $1"
  155. CC="$CROSSCC"
  156. ac_exeext=".exe"
  157. AC_LINK_IFELSE([AC_LANG_SOURCE([[int __cdecl mainCRTStartup(void) { return 0; }]])],
  158. [AS_VAR_SET(ac_var,yes)], [AS_VAR_SET(ac_var,no)])
  159. CFLAGS=$ac_wine_try_cflags_saved
  160. CC=$ac_wine_try_cflags_saved_cc
  161. ac_exeext=$ac_wine_try_cflags_saved_exeext])
  162. AS_VAR_IF([ac_var],[yes],[m4_default([$2], [EXTRACROSSCFLAGS="$EXTRACROSSCFLAGS $1"])], [$3])dnl
  163. AS_VAR_POPDEF([ac_var])])
  164. dnl **** Check if we can link an empty shared lib (no main) with special CFLAGS ****
  165. dnl
  166. dnl Usage: WINE_TRY_SHLIB_FLAGS(flags,[action-if-yes,[action-if-no]])
  167. dnl
  168. AC_DEFUN([WINE_TRY_SHLIB_FLAGS],
  169. [AS_VAR_PUSHDEF([ac_var], ac_cv_cflags_[[$1]])dnl
  170. ac_wine_try_cflags_saved=$CFLAGS
  171. CFLAGS="$CFLAGS $1"
  172. AC_LINK_IFELSE([AC_LANG_SOURCE([[void myfunc() {}]])],
  173. [AS_VAR_SET(ac_var,yes)], [AS_VAR_SET(ac_var,no)])
  174. CFLAGS=$ac_wine_try_cflags_saved
  175. AS_VAR_IF([ac_var],[yes], [$2], [$3])dnl
  176. AS_VAR_POPDEF([ac_var])])
  177. dnl **** Check whether we need to define a symbol on the compiler command line ****
  178. dnl
  179. dnl Usage: WINE_CHECK_DEFINE(name),[action-if-yes,[action-if-no]])
  180. dnl
  181. AC_DEFUN([WINE_CHECK_DEFINE],
  182. [AS_VAR_PUSHDEF([ac_var],[ac_cv_cpp_def_$1])dnl
  183. AC_CACHE_CHECK([whether we need to define $1],ac_var,
  184. AC_EGREP_CPP(yes,[#ifndef $1
  185. yes
  186. #endif],
  187. [AS_VAR_SET(ac_var,yes)],[AS_VAR_SET(ac_var,no)]))
  188. AS_VAR_IF([ac_var],[yes],
  189. [CFLAGS="$CFLAGS -D$1"
  190. LINTFLAGS="$LINTFLAGS -D$1"])dnl
  191. AS_VAR_POPDEF([ac_var])])
  192. dnl **** Check for functions with some extra libraries ****
  193. dnl
  194. dnl Usage: WINE_CHECK_LIB_FUNCS(funcs,libs,[action-if-found,[action-if-not-found]])
  195. dnl
  196. AC_DEFUN([WINE_CHECK_LIB_FUNCS],
  197. [ac_wine_check_funcs_save_LIBS="$LIBS"
  198. LIBS="$LIBS $2"
  199. AC_CHECK_FUNCS([$1],[$3],[$4])
  200. LIBS="$ac_wine_check_funcs_save_LIBS"])
  201. dnl **** Check for a mingw program, trying the various mingw prefixes ****
  202. dnl
  203. dnl Usage: WINE_CHECK_MINGW_PROG(variable,[value-if-not-found],[path])
  204. dnl
  205. AC_DEFUN([WINE_CHECK_MINGW_PROG],
  206. [case "$host_cpu" in
  207. aarch64*)
  208. ac_prefix_list="aarch64-w64-mingw32-clang aarch64-w64-mingw32-gcc" ;;
  209. arm*)
  210. ac_prefix_list="armv7-w64-mingw32-clang armv7-w64-mingw32-gcc" ;;
  211. i[[3456789]]86*)
  212. ac_prefix_list="m4_foreach([ac_wine_prefix],[w64-mingw32, pc-mingw32, mingw32msvc, mingw32],
  213. m4_foreach([ac_wine_cpu],[i686,i586,i486,i386],[ac_wine_cpu-ac_wine_prefix-gcc ]))
  214. m4_foreach([ac_wine_cpu],[i686,i586,i486,i386],[ac_wine_cpu-w64-mingw32-clang ])
  215. mingw32-gcc" ;;
  216. x86_64)
  217. ac_prefix_list="m4_foreach([ac_wine_prefix],[pc-mingw32, w64-mingw32, mingw32msvc],
  218. m4_foreach([ac_wine_cpu],[x86_64,amd64],[ac_wine_cpu-ac_wine_prefix-gcc ]))
  219. m4_foreach([ac_wine_cpu],[x86_64,amd64],[ac_wine_cpu-w64-mingw32-clang ])" ;;
  220. *)
  221. ac_prefix_list="" ;;
  222. esac
  223. AC_CHECK_PROGS([$1],[$ac_prefix_list],[$2],[$3])])
  224. dnl **** Define helper functions for creating config.status files ****
  225. dnl
  226. dnl Usage: AC_REQUIRE([WINE_CONFIG_HELPERS])
  227. dnl
  228. AC_DEFUN([WINE_CONFIG_HELPERS],
  229. [wine_rules_file=conf$$rules.make
  230. rm -f $wine_rules_file
  231. AC_SUBST(SUBDIRS,"")
  232. AC_SUBST(DISABLED_SUBDIRS,"")
  233. AC_SUBST(CONFIGURE_TARGETS,"")
  234. wine_fn_append_file ()
  235. {
  236. AS_VAR_APPEND($[1]," \\$as_nl $[2]")
  237. }
  238. wine_fn_append_rule ()
  239. {
  240. AS_ECHO("$[1]") >>$wine_rules_file
  241. }
  242. wine_fn_config_makefile ()
  243. {
  244. wine_fn_append_file SUBDIRS $[1]
  245. AS_VAR_IF([$[2]],[no],[wine_fn_append_file DISABLED_SUBDIRS $[1]])
  246. }
  247. wine_fn_config_symlink ()
  248. {
  249. ac_links=$[@]
  250. wine_fn_append_rule \
  251. "$ac_links:
  252. @./config.status \$[@]"
  253. for f in $ac_links; do wine_fn_append_file CONFIGURE_TARGETS $f; done
  254. }])
  255. dnl **** Define helper function to append a rule to a makefile command list ****
  256. dnl
  257. dnl Usage: WINE_APPEND_RULE(rule)
  258. dnl
  259. AC_DEFUN([WINE_APPEND_RULE],[AC_REQUIRE([WINE_CONFIG_HELPERS])wine_fn_append_rule "$1"])
  260. dnl **** Create symlinks from config.status ****
  261. dnl
  262. dnl Usage: WINE_CONFIG_SYMLINK(target,src,enable)
  263. dnl
  264. AC_DEFUN([WINE_CONFIG_SYMLINK],[AC_REQUIRE([WINE_CONFIG_HELPERS])dnl
  265. m4_ifval([$3],[if test $3; then
  266. ])AC_CONFIG_LINKS([$1:$2])dnl
  267. wine_fn_config_symlink[ $1]m4_ifval([$3],[
  268. fi])[]dnl
  269. ])])
  270. dnl **** Create a makefile from config.status ****
  271. dnl
  272. dnl Usage: WINE_CONFIG_MAKEFILE(file,enable,condition)
  273. dnl
  274. AC_DEFUN([WINE_CONFIG_MAKEFILE],[AC_REQUIRE([WINE_CONFIG_HELPERS])dnl
  275. AS_VAR_PUSHDEF([ac_enable],m4_default([$2],[enable_]m4_bpatsubst([$1],[.*/\([^/]*\)$],[\1])))dnl
  276. m4_append_uniq([_AC_USER_OPTS],ac_enable,[
  277. ])dnl
  278. m4_ifval([$3],[$3 || ])wine_fn_config_makefile [$1] ac_enable[]dnl
  279. AS_VAR_POPDEF([ac_enable])])
  280. dnl **** Append a file to the .gitignore list ****
  281. dnl
  282. dnl Usage: WINE_IGNORE_FILE(file,enable)
  283. dnl
  284. AC_DEFUN([WINE_IGNORE_FILE],[AC_REQUIRE([WINE_CONFIG_HELPERS])dnl
  285. m4_ifval([$2],[test "x$[$2]" = xno || ])wine_fn_append_file CONFIGURE_TARGETS $1])
  286. dnl **** Add a message to the list displayed at the end ****
  287. dnl
  288. dnl Usage: WINE_NOTICE(notice)
  289. dnl Usage: WINE_WARNING(warning)
  290. dnl Usage: WINE_NOTICE_WITH(with_flag, test, notice, enable)
  291. dnl Usage: WINE_WARNING_WITH(with_flag, test, warning, enable)
  292. dnl Usage: WINE_ERROR_WITH(with_flag, test, error, enable)
  293. dnl Usage: WINE_PRINT_MESSAGES
  294. dnl
  295. AC_DEFUN([WINE_NOTICE],[AS_VAR_APPEND([wine_notices],["|$1"])])
  296. AC_DEFUN([WINE_WARNING],[AS_VAR_APPEND([wine_warnings],["|$1"])])
  297. AC_DEFUN([WINE_NOTICE_WITH],[AS_IF([$2],[case "x$with_$1" in
  298. x) WINE_NOTICE([$3]) ;;
  299. xno) ;;
  300. *) AC_MSG_ERROR([$3
  301. This is an error since --with-$1 was requested.]) ;;
  302. esac
  303. m4_ifval([$4],[$4=${$4:-no}])])])
  304. AC_DEFUN([WINE_WARNING_WITH],[AS_IF([$2],[case "x$with_$1" in
  305. x) WINE_WARNING([$3]) ;;
  306. xno) ;;
  307. *) AC_MSG_ERROR([$3
  308. This is an error since --with-$1 was requested.]) ;;
  309. esac
  310. m4_ifval([$4],[$4=${$4:-no}])])])
  311. AC_DEFUN([WINE_ERROR_WITH],[AS_IF([$2],[case "x$with_$1" in
  312. xno) ;;
  313. *) AC_MSG_ERROR([$3
  314. Use the --without-$1 option if you really want this.]) ;;
  315. esac
  316. m4_ifval([$4],[$4=${$4:-no}])])])
  317. AC_DEFUN([WINE_PRINT_MESSAGES],[ac_save_IFS="$IFS"
  318. if test "x$wine_notices" != x; then
  319. echo >&AS_MESSAGE_FD
  320. IFS="|"
  321. for msg in $wine_notices; do
  322. IFS="$ac_save_IFS"
  323. AS_VAR_IF([msg],[],,[AC_MSG_NOTICE([$msg])])
  324. done
  325. fi
  326. IFS="|"
  327. for msg in $wine_warnings; do
  328. IFS="$ac_save_IFS"
  329. AS_VAR_IF([msg],[],,[echo >&2
  330. AC_MSG_WARN([$msg])])
  331. done
  332. IFS="$ac_save_IFS"])
  333. dnl Local Variables:
  334. dnl compile-command: "autoreconf --warnings=all"
  335. dnl End: