acinclude.m4 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. AC_DEFUN(AC_HEADER_IOSTREAM,
  2. [AC_CHECK_HEADERS(iostream,[have_iostream=yes],[have_iostream=no])])
  3. AC_DEFUN(AC_IOS_BINARY,
  4. [AC_CACHE_CHECK([for ios::binary],
  5. ac_cv_ios_binary,
  6. [
  7. if test $have_iostream = yes; then
  8. AC_TRY_COMPILE([
  9. #include <iostream>
  10. ],[
  11. int x; x = ios::binary;
  12. ], ac_cv_ios_binary=yes, ac_cv_ios_binary=no)
  13. else
  14. AC_TRY_COMPILE([
  15. #include <iostream.h>
  16. ],[
  17. int x; x = ios::binary;
  18. ], ac_cv_ios_binary=yes, ac_cv_ios_binary=no)
  19. fi
  20. ])
  21. if test $ac_cv_ios_binary = yes; then
  22. AC_DEFINE(HAVE_IOS_BINARY)
  23. fi
  24. ])
  25. AC_DEFUN(AC_NAMESPACE,
  26. [AC_CACHE_CHECK([for compiler namespace support],
  27. ac_cv_namespace,
  28. [AC_TRY_COMPILE(
  29. [namespace std { };
  30. using namespace std;],
  31. [],
  32. ac_cv_namespace=yes, ac_cv_namespace=no)])
  33. if test $ac_cv_namespace = yes; then
  34. AC_DEFINE(HAVE_NAMESPACE)
  35. fi
  36. ])
  37. dnl A handy function to see if a library is in a particular directory.
  38. dnl AC_CHECK_LIB_LOC(directory, library, function, action-if-found, action-if-not-found, other-libraries)
  39. dnl
  40. AC_DEFUN(AC_CHECK_LIB_LOC,
  41. [AC_MSG_CHECKING([for lib$2 in $1])
  42. ac_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
  43. AC_CACHE_VAL(ac_cv_lib_loc_$ac_lib_var,
  44. [ac_save_LIBS="$LIBS"
  45. LIBS="-L$1 -l$2 $6 $LIBS"
  46. AC_TRY_LINK(dnl
  47. ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
  48. extern "C"
  49. #endif
  50. ])dnl
  51. [/* We use char because int might match the return type of a gcc2
  52. builtin and then its argument prototype would still apply. */
  53. char $3();
  54. ],
  55. [$3()],
  56. eval "ac_cv_lib_loc_$ac_lib_var=yes",
  57. eval "ac_cv_lib_loc_$ac_lib_var=no")
  58. LIBS="$ac_save_LIBS"
  59. ])dnl
  60. if eval "test \"`echo '$ac_cv_lib_loc_'$ac_lib_var`\" = yes"; then
  61. AC_MSG_RESULT(yes)
  62. ifelse([$4], ,
  63. [LIBS="-L$1 -l$2 $LIBS"
  64. ], [$4])
  65. else
  66. AC_MSG_RESULT(no)
  67. ifelse([$5], , , [$5
  68. ])dnl
  69. fi
  70. ])
  71. dnl A handy function to search a number of possible locations for a library.
  72. dnl AC_SEARCH_LIB(search-dirs, library, function, package, other-libraries)
  73. dnl
  74. dnl Sets $package_LIB to the directory containing the library, or to the
  75. dnl empty string if the library cannot be found.
  76. AC_DEFUN(AC_SEARCH_LIB, [
  77. ac_found_lib=""
  78. for ac_check_dir in $1; do
  79. if test "$ac_found_lib" = ""; then
  80. AC_CHECK_LIB_LOC($ac_check_dir, $2, $3, [ ac_found_lib="$ac_check_dir"; ],, $5)
  81. fi
  82. done
  83. $4_LIB="$ac_found_lib"
  84. ])
  85. dnl A handy function to see if a header file is in a particular directory.
  86. dnl AC_CHECK_HEADER_LOC(directory, header, action-if-found, action-if-not-found)
  87. dnl
  88. AC_DEFUN(AC_CHECK_HEADER_LOC, [
  89. AC_MSG_CHECKING([for $2 in $1])
  90. ac_include_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
  91. AC_CACHE_VAL(ac_cv_include_loc_$ac_include_var, [
  92. ac_save_CPPFLAGS="$CPPFLAGS"
  93. CPPFLAGS="-I$1 $CPPFLAGS"
  94. AC_TRY_CPP([#include <$2>], ac_ch_found_it="yes", ac_ch_found_it="no")
  95. if test "$ac_ch_found_it" = "yes"; then
  96. AC_MSG_RESULT(yes)
  97. ifelse([$3], , :, [$3])
  98. else
  99. AC_MSG_RESULT(no)
  100. ifelse([$4], , , [$4])
  101. fi
  102. CPPFLAGS="$ac_save_CPPFLAGS"
  103. ])
  104. ])
  105. dnl A handy function to search a number of possible locations for a header
  106. dnl file.
  107. dnl
  108. dnl AC_SEARCH_HEADER(search-dirs, header, package)
  109. dnl
  110. dnl Sets $package_INCLUDE to the directory containing the header, or to
  111. dnl the empty string if the header cannot be found.
  112. AC_DEFUN(AC_SEARCH_HEADER, [
  113. ac_found_header=""
  114. for ac_check_dir in $1; do
  115. if test "$ac_found_header" = ""; then
  116. AC_CHECK_HEADER_LOC($ac_check_dir, $2, [ ac_found_header="$ac_check_dir";])
  117. fi
  118. done
  119. $3_INCLUDE="$ac_found_header"
  120. ])
  121. dnl A handy function to scan for a third-party package, consisting of at
  122. dnl least a library and an include file. A few assumptions are made about
  123. dnl the relationships between lib and include directories.
  124. dnl
  125. dnl AC_SEARCH_PACKAGE(search-dirs, package-names, header, library, function, package, other-libraries)
  126. dnl
  127. dnl search-dirs is the whitespace-separated list of directory prefixes to
  128. dnl check.
  129. dnl package-names is a whitespace-separated list of possible names the
  130. dnl package may have been installed under.
  131. dnl
  132. dnl For each combination of ${search-dir} and ${package-name}, the following
  133. dnl directories are searched:
  134. dnl
  135. dnl ${search-dir}
  136. dnl ${search-dir}/lib
  137. dnl ${search-dir}/${package-name}
  138. dnl ${search-dir}/${package-name}/lib
  139. dnl ${search-dir}/lib/${package-name}
  140. dnl
  141. dnl And similarly for include.
  142. dnl
  143. dnl Sets the variables $package_INCLUDE and $package_LIB to the directories
  144. dnl containing the header file and library, respectively. If both pieces
  145. dnl are located, also sets the variable $package_PKG to "yes"; otherwise,
  146. dnl sets the variable $package_PKG to "no".
  147. dnl
  148. AC_DEFUN(AC_SEARCH_PACKAGE, [
  149. $6_LIB=""
  150. $6_INCLUDE=""
  151. $6_PKG="no"
  152. dnl Look for the library.
  153. for ac_sp_dir in $1; do
  154. if test "[$]$6_LIB" = ""; then
  155. AC_SEARCH_LIB("$ac_sp_dir" "$ac_sp_dir/lib", $4, $5, $6, $7)
  156. for ac_sp_pkg in $2; do
  157. if test "[$]$6_LIB" = ""; then
  158. AC_SEARCH_LIB("$ac_sp_dir/$ac_sp_pkg" "$ac_sp_dir/$ac_sp_pkg/lib" \
  159. "$ac_sp_dir/lib/$ac_sp_pkg", $4, $5, $6, $7)
  160. fi
  161. done
  162. fi
  163. done
  164. dnl Now look for the header file. Don't bother looking if the library
  165. dnl wasn't found.
  166. if test "[$]$6_LIB" != ""; then
  167. dnl First look in the obvious directory corresponding to the lib dir.
  168. ac_sp_testinc=`echo [$]$6_LIB | sed 's:/lib:/include:'`
  169. AC_SEARCH_HEADER("$ac_sp_testinc", $3, $6)
  170. dnl If it wasn't found there, cast about.
  171. if test "[$]$6_INCLUDE" = ""; then
  172. for ac_sp_dir in $1; do
  173. if test "[$]$6_INCLUDE" = ""; then
  174. AC_SEARCH_HEADER("$ac_sp_dir" "$ac_sp_dir/include", $3, $6)
  175. for ac_sp_pkg in $2; do
  176. if test "[$]$6_INCLUDE" = ""; then
  177. AC_SEARCH_HEADER("$ac_sp_dir/$ac_sp_pkg" \
  178. "$ac_sp_dir/$ac_sp_pkg/include" \
  179. "$ac_sp_dir/include/$ac_sp_pkg", $3, $6)
  180. fi
  181. done
  182. fi
  183. done
  184. fi
  185. dnl If we got both a header and a library, set the PKG variable.
  186. if test "[$]$6_INCLUDE" != ""; then
  187. $6_PKG="yes"
  188. fi
  189. fi
  190. ])
  191. # Configure paths for GTK--
  192. # Erik Andersen 30 May 1998
  193. # Modified by Tero Pulkkinen (added the compiler checks... I hope they work..)
  194. dnl Test for GTKMM, and define GTKMM_CFLAGS and GTKMM_LIBS
  195. dnl to be used as follows:
  196. dnl AM_PATH_GTKMM([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  197. dnl
  198. AC_DEFUN(AM_PATH_GTKMM,
  199. [dnl
  200. dnl Get the cflags and libraries from the gtkmm-config script
  201. dnl
  202. AC_ARG_WITH(gtkmm-prefix,[ --with-gtkmm-prefix=PREFIX
  203. Prefix where GTK-- is installed (optional)],
  204. gtkmm_config_prefix="$withval", gtkmm_config_prefix="")
  205. AC_ARG_WITH(gtkmm-exec-prefix,[ --with-gtkmm-exec-prefix=PREFIX
  206. Exec prefix where GTK-- is installed (optional)],
  207. gtkmm_config_exec_prefix="$withval", gtkmm_config_exec_prefix="")
  208. AC_ARG_ENABLE(gtkmmtest, [ --disable-gtkmmtest Do not try to compile and run a test GTK-- program],
  209. , enable_gtkmmtest=yes)
  210. if test x$gtkmm_config_exec_prefix != x ; then
  211. gtkmm_config_args="$gtkmm_config_args --exec-prefix=$gtkmm_config_exec_prefix"
  212. if test x${GTKMM_CONFIG+set} != xset ; then
  213. GTKMM_CONFIG=$gtkmm_config_exec_prefix/bin/gtkmm-config
  214. fi
  215. fi
  216. if test x$gtkmm_config_prefix != x ; then
  217. gtkmm_config_args="$gtkmm_config_args --prefix=$gtkmm_config_prefix"
  218. if test x${GTKMM_CONFIG+set} != xset ; then
  219. GTKMM_CONFIG=$gtkmm_config_prefix/bin/gtkmm-config
  220. fi
  221. fi
  222. AC_PATH_PROG(GTKMM_CONFIG, gtkmm-config, no)
  223. min_gtkmm_version=ifelse([$1], ,0.10.0,$1)
  224. AC_MSG_CHECKING(for GTK-- - version >= $min_gtkmm_version)
  225. no_gtkmm=""
  226. if test "$GTKMM_CONFIG" = "no" ; then
  227. no_gtkmm=yes
  228. else
  229. AC_LANG_SAVE
  230. AC_LANG_CPLUSPLUS
  231. GTKMM_CFLAGS=`$GTKMM_CONFIG $gtkmm_config_args --cflags`
  232. GTKMM_LIBS=`$GTKMM_CONFIG $gtkmm_config_args --libs`
  233. gtkmm_config_major_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \
  234. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  235. gtkmm_config_minor_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \
  236. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  237. gtkmm_config_micro_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \
  238. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  239. if test "x$enable_gtkmmtest" = "xyes" ; then
  240. ac_save_CXXFLAGS="$CXXFLAGS"
  241. ac_save_LIBS="$LIBS"
  242. CXXFLAGS="$CXXFLAGS $GTKMM_CFLAGS"
  243. LIBS="$LIBS $GTKMM_LIBS"
  244. dnl
  245. dnl Now check if the installed GTK-- is sufficiently new. (Also sanity
  246. dnl checks the results of gtkmm-config to some extent
  247. dnl
  248. rm -f conf.gtkmmtest
  249. AC_TRY_RUN([
  250. #include <gtk--.h>
  251. #include <stdio.h>
  252. #include <stdlib.h>
  253. int
  254. main ()
  255. {
  256. int major, minor, micro;
  257. char *tmp_version;
  258. system ("touch conf.gtkmmtest");
  259. /* HP/UX 0 (%@#!) writes to sscanf strings */
  260. tmp_version = g_strdup("$min_gtkmm_version");
  261. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  262. printf("%s, bad version string\n", "$min_gtkmm_version");
  263. exit(1);
  264. }
  265. if ((gtkmm_major_version != $gtkmm_config_major_version) ||
  266. (gtkmm_minor_version != $gtkmm_config_minor_version) ||
  267. (gtkmm_micro_version != $gtkmm_config_micro_version))
  268. {
  269. printf("\n*** 'gtkmm-config --version' returned %d.%d.%d, but GTK-- (%d.%d.%d)\n",
  270. $gtkmm_config_major_version, $gtkmm_config_minor_version, $gtkmm_config_micro_version,
  271. gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
  272. printf ("*** was found! If gtkmm-config was correct, then it is best\n");
  273. printf ("*** to remove the old version of GTK--. You may also be able to fix the error\n");
  274. printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
  275. printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
  276. printf("*** required on your system.\n");
  277. printf("*** If gtkmm-config was wrong, set the environment variable GTKMM_CONFIG\n");
  278. printf("*** to point to the correct copy of gtkmm-config, and remove the file config.cache\n");
  279. printf("*** before re-running configure\n");
  280. }
  281. /* GTK-- does not have the GTKMM_*_VERSION constants */
  282. /*
  283. else if ((gtkmm_major_version != GTKMM_MAJOR_VERSION) ||
  284. (gtkmm_minor_version != GTKMM_MINOR_VERSION) ||
  285. (gtkmm_micro_version != GTKMM_MICRO_VERSION))
  286. {
  287. printf("*** GTK-- header files (version %d.%d.%d) do not match\n",
  288. GTKMM_MAJOR_VERSION, GTKMM_MINOR_VERSION, GTKMM_MICRO_VERSION);
  289. printf("*** library (version %d.%d.%d)\n",
  290. gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
  291. }
  292. */
  293. else
  294. {
  295. if ((gtkmm_major_version > major) ||
  296. ((gtkmm_major_version == major) && (gtkmm_minor_version > minor)) ||
  297. ((gtkmm_major_version == major) && (gtkmm_minor_version == minor) && (gtkmm_micro_version >= micro)))
  298. {
  299. return 0;
  300. }
  301. else
  302. {
  303. printf("\n*** An old version of GTK-- (%d.%d.%d) was found.\n",
  304. gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
  305. printf("*** You need a version of GTK-- newer than %d.%d.%d. The latest version of\n",
  306. major, minor, micro);
  307. printf("*** GTK-- is always available from ftp://ftp.gtk.org.\n");
  308. printf("***\n");
  309. printf("*** If you have already installed a sufficiently new version, this error\n");
  310. printf("*** probably means that the wrong copy of the gtkmm-config shell script is\n");
  311. printf("*** being found. The easiest way to fix this is to remove the old version\n");
  312. printf("*** of GTK--, but you can also set the GTKMM_CONFIG environment to point to the\n");
  313. printf("*** correct copy of gtkmm-config. (In this case, you will have to\n");
  314. printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
  315. printf("*** so that the correct libraries are found at run-time))\n");
  316. }
  317. }
  318. return 1;
  319. }
  320. ],, no_gtkmm=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  321. CXXFLAGS="$ac_save_CXXFLAGS"
  322. LIBS="$ac_save_LIBS"
  323. fi
  324. fi
  325. if test "x$no_gtkmm" = x ; then
  326. AC_MSG_RESULT(yes)
  327. ifelse([$2], , :, [$2])
  328. else
  329. AC_MSG_RESULT(no)
  330. if test "$GTKMM_CONFIG" = "no" ; then
  331. echo "*** The gtkmm-config script installed by GTK-- could not be found"
  332. echo "*** If GTK-- was installed in PREFIX, make sure PREFIX/bin is in"
  333. echo "*** your path, or set the GTKMM_CONFIG environment variable to the"
  334. echo "*** full path to gtkmm-config."
  335. echo "*** The gtkmm-config script was not available in GTK-- versions"
  336. echo "*** prior to 0.9.12. Perhaps you need to update your installed"
  337. echo "*** version to 0.9.12 or later"
  338. else
  339. if test -f conf.gtkmmtest ; then
  340. :
  341. else
  342. echo "*** Could not run GTK-- test program, checking why..."
  343. CXXFLAGS="$CFLAGS $GTKMM_CXXFLAGS"
  344. LIBS="$LIBS $GTKMM_LIBS"
  345. AC_TRY_LINK([
  346. #include <gtk--.h>
  347. #include <stdio.h>
  348. ], [ return ((gtkmm_major_version) || (gtkmm_minor_version) || (gtkmm_micro_version)); ],
  349. [ echo "*** The test program compiled, but did not run. This usually means"
  350. echo "*** that the run-time linker is not finding GTK-- or finding the wrong"
  351. echo "*** version of GTK--. If it is not finding GTK--, you'll need to set your"
  352. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  353. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  354. echo "*** is required on your system"
  355. echo "***"
  356. echo "*** If you have an old version installed, it is best to remove it, although"
  357. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
  358. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  359. echo "*** exact error that occured. This usually means GTK-- was incorrectly installed"
  360. echo "*** or that you have moved GTK-- since it was installed. In the latter case, you"
  361. echo "*** may want to edit the gtkmm-config script: $GTKMM_CONFIG" ])
  362. CXXFLAGS="$ac_save_CXXFLAGS"
  363. LIBS="$ac_save_LIBS"
  364. fi
  365. fi
  366. GTKMM_CFLAGS=""
  367. GTKMM_LIBS=""
  368. ifelse([$3], , :, [$3])
  369. AC_LANG_RESTORE
  370. fi
  371. AC_SUBST(GTKMM_CFLAGS)
  372. AC_SUBST(GTKMM_LIBS)
  373. rm -f conf.gtkmmtest
  374. ])