acinclude.m4 15 KB

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