aclocal.m4 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. test -z "$ac_cflags" || ac_cflags=`echo " $ac_cflags" | sed 's/ -I\([[^/]]\)/ -I\$(top_builddir)\/\1/g'`
  119. test -z "$ac_libs" || ac_libs=`echo " $ac_libs" | sed 's/ -L\([[^/]]\)/ -L\$(top_builddir)\/\1/g'`
  120. AS_VAR_POPDEF([ac_libs])dnl
  121. AS_VAR_POPDEF([ac_cflags])])dnl
  122. dnl **** Link C code with an assembly file ****
  123. dnl
  124. dnl Usage: WINE_TRY_ASM_LINK(asm-code,includes,function,[action-if-found,[action-if-not-found]])
  125. dnl
  126. AC_DEFUN([WINE_TRY_ASM_LINK],
  127. [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]],[[asm($1); $3]])],[$4],[$5])])
  128. dnl **** Check if we can link an empty program with special CFLAGS ****
  129. dnl
  130. dnl Usage: WINE_TRY_CFLAGS(flags,[action-if-yes,[action-if-no]])
  131. dnl
  132. dnl The default action-if-yes is to append the flags to EXTRACFLAGS.
  133. dnl
  134. AC_DEFUN([WINE_TRY_CFLAGS],
  135. [AS_VAR_PUSHDEF([ac_var], ac_cv_cflags_[[$1]])dnl
  136. AC_CACHE_CHECK([whether the compiler supports $1], ac_var,
  137. [ac_wine_try_cflags_saved=$CFLAGS
  138. CFLAGS="$CFLAGS $1"
  139. AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(int argc, char **argv) { return 0; }]])],
  140. [AS_VAR_SET(ac_var,yes)], [AS_VAR_SET(ac_var,no)])
  141. CFLAGS=$ac_wine_try_cflags_saved])
  142. AS_VAR_IF([ac_var],[yes],[m4_default([$2], [EXTRACFLAGS="$EXTRACFLAGS $1"])], [$3])dnl
  143. AS_VAR_POPDEF([ac_var])])
  144. dnl **** Check if we can link an empty program with special CFLAGS ****
  145. dnl
  146. dnl Usage: WINE_TRY_CROSSCFLAGS(flags,[action-if-yes,[action-if-no]])
  147. dnl
  148. dnl The default action-if-yes is to append the flags to EXTRACROSSCFLAGS.
  149. dnl
  150. AC_DEFUN([WINE_TRY_CROSSCFLAGS],
  151. [AS_VAR_PUSHDEF([ac_var], ac_cv_crosscflags_[[$1]])dnl
  152. AC_CACHE_CHECK([whether the cross-compiler supports $1], ac_var,
  153. [ac_wine_try_cflags_saved=$CFLAGS
  154. ac_wine_try_cflags_saved_cc=$CC
  155. ac_wine_try_cflags_saved_exeext=$ac_exeext
  156. CFLAGS="$CFLAGS $EXTRACROSSCFLAGS -nostartfiles -nodefaultlibs $1"
  157. CC="$CROSSCC"
  158. ac_exeext=".exe"
  159. AC_LINK_IFELSE([AC_LANG_SOURCE([[void __stdcall __delayLoadHelper2(void *descr, void *addr) {} int __cdecl mainCRTStartup(void) { return 0; }]])],
  160. [AS_VAR_SET(ac_var,yes)], [AS_VAR_SET(ac_var,no)])
  161. CFLAGS=$ac_wine_try_cflags_saved
  162. CC=$ac_wine_try_cflags_saved_cc
  163. ac_exeext=$ac_wine_try_cflags_saved_exeext])
  164. AS_VAR_IF([ac_var],[yes],[m4_default([$2], [EXTRACROSSCFLAGS="$EXTRACROSSCFLAGS $1"])], [$3])dnl
  165. AS_VAR_POPDEF([ac_var])])
  166. dnl **** Check if we can link an empty shared lib (no main) with special CFLAGS ****
  167. dnl
  168. dnl Usage: WINE_TRY_SHLIB_FLAGS(flags,[action-if-yes,[action-if-no]])
  169. dnl
  170. AC_DEFUN([WINE_TRY_SHLIB_FLAGS],
  171. [AS_VAR_PUSHDEF([ac_var], ac_cv_cflags_[[$1]])dnl
  172. ac_wine_try_cflags_saved=$CFLAGS
  173. CFLAGS="$CFLAGS $1"
  174. AC_LINK_IFELSE([AC_LANG_SOURCE([[void myfunc() {}]])],
  175. [AS_VAR_SET(ac_var,yes)], [AS_VAR_SET(ac_var,no)])
  176. CFLAGS=$ac_wine_try_cflags_saved
  177. AS_VAR_IF([ac_var],[yes], [$2], [$3])dnl
  178. AS_VAR_POPDEF([ac_var])])
  179. dnl **** Check whether we need to define a symbol on the compiler command line ****
  180. dnl
  181. dnl Usage: WINE_CHECK_DEFINE(name),[action-if-yes,[action-if-no]])
  182. dnl
  183. AC_DEFUN([WINE_CHECK_DEFINE],
  184. [AS_VAR_PUSHDEF([ac_var],[ac_cv_cpp_def_$1])dnl
  185. AC_CACHE_CHECK([whether we need to define $1],ac_var,
  186. AC_EGREP_CPP(yes,[#ifndef $1
  187. yes
  188. #endif],
  189. [AS_VAR_SET(ac_var,yes)],[AS_VAR_SET(ac_var,no)]))
  190. AS_VAR_IF([ac_var],[yes],
  191. [CFLAGS="$CFLAGS -D$1"
  192. LINTFLAGS="$LINTFLAGS -D$1"])dnl
  193. AS_VAR_POPDEF([ac_var])])
  194. dnl **** Check for functions with some extra libraries ****
  195. dnl
  196. dnl Usage: WINE_CHECK_LIB_FUNCS(funcs,libs,[action-if-found,[action-if-not-found]])
  197. dnl
  198. AC_DEFUN([WINE_CHECK_LIB_FUNCS],
  199. [ac_wine_check_funcs_save_LIBS="$LIBS"
  200. LIBS="$LIBS $2"
  201. AC_CHECK_FUNCS([$1],[$3],[$4])
  202. LIBS="$ac_wine_check_funcs_save_LIBS"])
  203. dnl **** Check for a mingw program, trying the various mingw prefixes ****
  204. dnl
  205. dnl Usage: WINE_CHECK_MINGW_PROG(variable,[value-if-not-found],[path])
  206. dnl
  207. AC_DEFUN([WINE_CHECK_MINGW_PROG],
  208. [case "$host_cpu" in
  209. aarch64*)
  210. ac_prefix_list="aarch64-w64-mingw32-clang aarch64-w64-mingw32-gcc" ;;
  211. arm*)
  212. ac_prefix_list="armv7-w64-mingw32-clang armv7-w64-mingw32-gcc" ;;
  213. i[[3456789]]86*)
  214. ac_prefix_list="m4_foreach([ac_wine_prefix],[w64-mingw32, pc-mingw32, mingw32msvc, mingw32],
  215. m4_foreach([ac_wine_cpu],[i686,i586,i486,i386],[ac_wine_cpu-ac_wine_prefix-gcc ]))
  216. m4_foreach([ac_wine_cpu],[i686,i586,i486,i386],[ac_wine_cpu-w64-mingw32-clang ])
  217. mingw32-gcc" ;;
  218. x86_64)
  219. ac_prefix_list="m4_foreach([ac_wine_prefix],[pc-mingw32, w64-mingw32, mingw32msvc],
  220. m4_foreach([ac_wine_cpu],[x86_64,amd64],[ac_wine_cpu-ac_wine_prefix-gcc ]))
  221. m4_foreach([ac_wine_cpu],[x86_64,amd64],[ac_wine_cpu-w64-mingw32-clang ])" ;;
  222. *)
  223. ac_prefix_list="" ;;
  224. esac
  225. AC_CHECK_PROGS([$1],[$ac_prefix_list],[$2],[$3])])
  226. dnl **** Define helper functions for creating config.status files ****
  227. dnl
  228. dnl Usage: AC_REQUIRE([WINE_CONFIG_HELPERS])
  229. dnl
  230. AC_DEFUN([WINE_CONFIG_HELPERS],
  231. [wine_rules_file=conf$$rules.make
  232. rm -f $wine_rules_file
  233. AC_SUBST(SUBDIRS,"")
  234. AC_SUBST(DISABLED_SUBDIRS,"")
  235. AC_SUBST(CONFIGURE_TARGETS,"")
  236. wine_fn_append_file ()
  237. {
  238. AS_VAR_APPEND($[1]," \\$as_nl $[2]")
  239. }
  240. wine_fn_append_rule ()
  241. {
  242. AS_ECHO("$[1]") >>$wine_rules_file
  243. }
  244. wine_fn_config_makefile ()
  245. {
  246. wine_fn_append_file SUBDIRS $[1]
  247. AS_VAR_IF([$[2]],[no],[wine_fn_append_file DISABLED_SUBDIRS $[1]])
  248. }
  249. wine_fn_config_symlink ()
  250. {
  251. ac_links=$[@]
  252. wine_fn_append_rule \
  253. "$ac_links:
  254. @./config.status \$[@]"
  255. for f in $ac_links; do wine_fn_append_file CONFIGURE_TARGETS $f; done
  256. }])
  257. dnl **** Define helper function to append a rule to a makefile command list ****
  258. dnl
  259. dnl Usage: WINE_APPEND_RULE(rule)
  260. dnl
  261. AC_DEFUN([WINE_APPEND_RULE],[AC_REQUIRE([WINE_CONFIG_HELPERS])wine_fn_append_rule "$1"])
  262. dnl **** Create symlinks from config.status ****
  263. dnl
  264. dnl Usage: WINE_CONFIG_SYMLINK(target,src,enable)
  265. dnl
  266. AC_DEFUN([WINE_CONFIG_SYMLINK],[AC_REQUIRE([WINE_CONFIG_HELPERS])dnl
  267. m4_ifval([$3],[if test $3; then
  268. ])AC_CONFIG_LINKS([$1:$2])dnl
  269. wine_fn_config_symlink[ $1]m4_ifval([$3],[
  270. fi])[]dnl
  271. ])])
  272. dnl **** Create a makefile from config.status ****
  273. dnl
  274. dnl Usage: WINE_CONFIG_MAKEFILE(file,enable,condition)
  275. dnl
  276. AC_DEFUN([WINE_CONFIG_MAKEFILE],[AC_REQUIRE([WINE_CONFIG_HELPERS])dnl
  277. AS_VAR_PUSHDEF([ac_enable],m4_default([$2],[enable_]m4_bpatsubst([$1],[.*/\([^/]*\)$],[\1])))dnl
  278. m4_append_uniq([_AC_USER_OPTS],ac_enable,[
  279. ])dnl
  280. m4_ifval([$3],[$3 || ])wine_fn_config_makefile [$1] ac_enable[]dnl
  281. AS_VAR_POPDEF([ac_enable])])
  282. dnl **** Append a file to the .gitignore list ****
  283. dnl
  284. dnl Usage: WINE_IGNORE_FILE(file,enable)
  285. dnl
  286. AC_DEFUN([WINE_IGNORE_FILE],[AC_REQUIRE([WINE_CONFIG_HELPERS])dnl
  287. m4_ifval([$2],[test "x$[$2]" = xno || ])wine_fn_append_file CONFIGURE_TARGETS $1])
  288. dnl **** Add a message to the list displayed at the end ****
  289. dnl
  290. dnl Usage: WINE_NOTICE(notice)
  291. dnl Usage: WINE_WARNING(warning)
  292. dnl Usage: WINE_NOTICE_WITH(with_flag, test, notice, enable)
  293. dnl Usage: WINE_WARNING_WITH(with_flag, test, warning, enable)
  294. dnl Usage: WINE_ERROR_WITH(with_flag, test, error, enable)
  295. dnl Usage: WINE_PRINT_MESSAGES
  296. dnl
  297. AC_DEFUN([WINE_NOTICE],[AS_VAR_APPEND([wine_notices],["|$1"])])
  298. AC_DEFUN([WINE_WARNING],[AS_VAR_APPEND([wine_warnings],["|$1"])])
  299. AC_DEFUN([WINE_NOTICE_WITH],[AS_IF([$2],[case "x$with_$1" in
  300. x) WINE_NOTICE([$3]) ;;
  301. xno) ;;
  302. *) AC_MSG_ERROR([$3
  303. This is an error since --with-$1 was requested.]) ;;
  304. esac
  305. m4_ifval([$4],[$4=${$4:-no}])])])
  306. AC_DEFUN([WINE_WARNING_WITH],[AS_IF([$2],[case "x$with_$1" in
  307. x) WINE_WARNING([$3]) ;;
  308. xno) ;;
  309. *) AC_MSG_ERROR([$3
  310. This is an error since --with-$1 was requested.]) ;;
  311. esac
  312. m4_ifval([$4],[$4=${$4:-no}])])])
  313. AC_DEFUN([WINE_ERROR_WITH],[AS_IF([$2],[case "x$with_$1" in
  314. xno) ;;
  315. *) AC_MSG_ERROR([$3
  316. Use the --without-$1 option if you really want this.]) ;;
  317. esac
  318. m4_ifval([$4],[$4=${$4:-no}])])])
  319. AC_DEFUN([WINE_PRINT_MESSAGES],[ac_save_IFS="$IFS"
  320. if test "x$wine_notices" != x; then
  321. echo >&AS_MESSAGE_FD
  322. IFS="|"
  323. for msg in $wine_notices; do
  324. IFS="$ac_save_IFS"
  325. AS_VAR_IF([msg],[],,[AC_MSG_NOTICE([$msg])])
  326. done
  327. fi
  328. IFS="|"
  329. for msg in $wine_warnings; do
  330. IFS="$ac_save_IFS"
  331. AS_VAR_IF([msg],[],,[echo >&2
  332. AC_MSG_WARN([$msg])])
  333. done
  334. IFS="$ac_save_IFS"])
  335. dnl Local Variables:
  336. dnl compile-command: "autoreconf --warnings=all"
  337. dnl End: