acinclude.m4 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. dnl ---------------------------------------------------------------------------
  2. dnl
  3. dnl Macros for configure.in for wxWindows by Robert Roebling, Phil Blecker,
  4. dnl Vadim Zeitlin and Ron Lee
  5. dnl
  6. dnl This script is under the wxWindows licence.
  7. dnl ---------------------------------------------------------------------------
  8. dnl ===========================================================================
  9. dnl Objective-C(++) related macros
  10. dnl ===========================================================================
  11. m4_define([AC_WX_LANG_OBJECTIVEC],
  12. [AC_LANG(C)
  13. ac_ext=m
  14. ])
  15. m4_define([AC_WX_LANG_OBJECTIVECPLUSPLUS],
  16. [AC_LANG(C++)
  17. ac_ext=mm
  18. ])
  19. dnl ===========================================================================
  20. dnl macros to find a file in the list of include/lib paths
  21. dnl ===========================================================================
  22. dnl ---------------------------------------------------------------------------
  23. dnl call WX_PATH_FIND_INCLUDES(search path, header name), sets ac_find_includes
  24. dnl to the full name of the file that was found or leaves it empty if not found
  25. dnl ---------------------------------------------------------------------------
  26. AC_DEFUN([WX_PATH_FIND_INCLUDES],
  27. [
  28. ac_find_includes=
  29. for ac_dir in $1 /usr/include
  30. do
  31. if test -f "$ac_dir/$2"; then
  32. ac_find_includes=$ac_dir
  33. break
  34. fi
  35. done
  36. ])
  37. dnl ---------------------------------------------------------------------------
  38. dnl call WX_PATH_FIND_LIBRARIES(lib name, [optional extra search paths])
  39. dnl sets ac_find_libraries to the full name of the file that was found
  40. dnl or leaves it empty if not found
  41. dnl ---------------------------------------------------------------------------
  42. AC_DEFUN([WX_PATH_FIND_LIBRARIES],
  43. [
  44. ac_find_libraries=
  45. for ac_dir in $2 $SEARCH_LIB
  46. do
  47. for ac_extension in a so sl dylib dll.a; do
  48. if test -f "$ac_dir/lib$1.$ac_extension"; then
  49. ac_find_libraries=$ac_dir
  50. break 2
  51. fi
  52. done
  53. done
  54. ])
  55. dnl ---------------------------------------------------------------------------
  56. dnl return list of standard library paths
  57. dnl ---------------------------------------------------------------------------
  58. dnl return all default locations:
  59. dnl - /usr/lib: standard
  60. dnl - /usr/lib32: n32 ABI on IRIX
  61. dnl - /usr/lib64: n64 ABI on IRIX
  62. dnl - /usr/lib/64: 64 bit ABI on Solaris and Linux x86-64
  63. dnl
  64. dnl NB: if any of directories in the list is not a subdir of /usr, code setting
  65. dnl wx_cv_std_libpath needs to be updated
  66. AC_DEFUN([WX_STD_LIBPATH], [/usr/lib /usr/lib32 /usr/lib/64 /usr/lib64])
  67. dnl ---------------------------------------------------------------------------
  68. dnl Path to include, already defined
  69. dnl ---------------------------------------------------------------------------
  70. AC_DEFUN([WX_INCLUDE_PATH_EXIST],
  71. [
  72. dnl never add -I/usr/include to the CPPFLAGS
  73. if test "x$1" = "x/usr/include"; then
  74. ac_path_to_include=""
  75. else
  76. echo "$2" | grep "\-I$1" > /dev/null
  77. result=$?
  78. if test $result = 0; then
  79. ac_path_to_include=""
  80. else
  81. ac_path_to_include=" -I$1"
  82. fi
  83. fi
  84. ])
  85. dnl ---------------------------------------------------------------------------
  86. dnl Usage: WX_LINK_PATH_EXIST(path, libpath)
  87. dnl
  88. dnl Set ac_path_to_link to nothing if path is already in libpath, or to -Lpath
  89. dnl if it is not, so that libpath can be set to "$libpath$ac_path_to_link"
  90. dnl after calling this function
  91. dnl ---------------------------------------------------------------------------
  92. AC_DEFUN([WX_LINK_PATH_EXIST],
  93. [
  94. dnl never add -L/usr/libXXX explicitly to libpath
  95. if test "$1" = "default location"; then
  96. ac_path_to_link=""
  97. else
  98. echo "$2" | grep "\-L$1" > /dev/null
  99. result=$?
  100. if test $result = 0; then
  101. ac_path_to_link=""
  102. else
  103. ac_path_to_link=" -L$1"
  104. fi
  105. fi
  106. ])
  107. dnl ---------------------------------------------------------------------------
  108. dnl Usage: WX_FIND_LIB(lib-name, [lib-function to test], [extra search paths])
  109. dnl
  110. dnl Tests in a variety of ways for the presence of lib-name
  111. dnl
  112. dnl On success, returns any novel path found in ac_find_libraries; else "std"
  113. dnl and any cflags in ac_find_cflags
  114. dnl On failure, ac_find_libraries will be empty
  115. dnl ---------------------------------------------------------------------------
  116. AC_DEFUN([WX_FIND_LIB],
  117. [
  118. ac_find_libraries=
  119. dnl Try with pkg-config first. It requires its lib-name parameter lowercase
  120. fl_pkgname=`echo "$1" | tr [[:upper:]] [[:lower:]]`
  121. dnl suppress PKG_PROG_PKG_CONFIG output; we don't want to keep seeing it
  122. PKG_PROG_PKG_CONFIG() AS_MESSAGE_FD> /dev/null
  123. PKG_CHECK_MODULES([$1], [$fl_pkgname],
  124. [
  125. dnl Start by assuming there are no novel lib paths
  126. ac_find_libraries="std"
  127. dnl A simple copy of the internal vars $1_CFLAGS $1_LIBS doesn't work
  128. dnl inside the macro
  129. dnl
  130. dnl TODO: When we stop being autoconf 2.61 compatible, the next 2 lines
  131. dnl should become:
  132. dnl AS_VAR_COPY([ac_find_cflags], [$1_CFLAGS])
  133. dnl AS_VAR_COPY([fl_libs], [$1_LIBS])
  134. eval ac_find_cflags=\$$1_CFLAGS
  135. eval fl_libs=\$$1_LIBS
  136. dnl fl_libs may now contain -Lfoopath -lfoo (only non-standard paths are
  137. dnl added) We only want the path bit, not the lib names
  138. for fl_path in $fl_libs
  139. do
  140. if test `echo "$fl_path" | cut -c 1-2` = "-L"; then
  141. dnl there shouldn't be >1 novel path
  142. dnl return it without the -L, ready for WX_LINK_PATH_EXIST
  143. ac_find_libraries=`echo "$fl_path" | cut -c 3-`
  144. fi
  145. done
  146. ],
  147. [
  148. if test "x$ac_find_libraries" = "x"; then
  149. dnl Next with AC_CHECK_LIB, if a test function was provided
  150. if test "x$2" != "x"; then
  151. AC_CHECK_LIB([$1], [$2], [ac_find_libraries="std"])
  152. fi
  153. fi
  154. if test "x$ac_find_libraries" = "x"; then
  155. dnl Finally try the search path
  156. dnl Output a message again, as AC_CHECK_LIB will just have said "no"
  157. AC_MSG_CHECKING([elsewhere])
  158. dnl $3 will occasionally hold extra path(s) to search
  159. WX_PATH_FIND_LIBRARIES([$1], [$3])
  160. if test "x$ac_find_libraries" != "x"; then
  161. AC_MSG_RESULT([yes])
  162. else
  163. AC_MSG_RESULT([no])
  164. fi
  165. fi
  166. ])
  167. ])
  168. dnl ===========================================================================
  169. dnl C++ features test
  170. dnl ===========================================================================
  171. dnl ---------------------------------------------------------------------------
  172. dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
  173. dnl or only the old <iostream.h> one - it may be generally assumed that if
  174. dnl <iostream> exists, the other "new" headers (without .h) exist too.
  175. dnl
  176. dnl call WX_CPP_NEW_HEADERS(action-if-true, action-if-false)
  177. dnl ---------------------------------------------------------------------------
  178. AC_DEFUN([WX_CPP_NEW_HEADERS],
  179. [
  180. AC_LANG_SAVE
  181. AC_LANG_CPLUSPLUS
  182. AC_CHECK_HEADERS([iostream],,, [ ])
  183. if test "$ac_cv_header_iostream" = "yes" ; then
  184. ifelse([$1], , :, [$1])
  185. else
  186. ifelse([$2], , :, [$2])
  187. fi
  188. AC_LANG_RESTORE
  189. ])
  190. dnl ---------------------------------------------------------------------------
  191. dnl WX_CPP_EXPLICIT checks whether the C++ compiler support the explicit
  192. dnl keyword and defines HAVE_EXPLICIT if this is the case
  193. dnl ---------------------------------------------------------------------------
  194. AC_DEFUN([WX_CPP_EXPLICIT],
  195. [
  196. AC_CACHE_CHECK([if C++ compiler supports the explicit keyword],
  197. wx_cv_explicit,
  198. [
  199. AC_LANG_SAVE
  200. AC_LANG_CPLUSPLUS
  201. dnl do the test in 2 steps: first check that the compiler knows about the
  202. dnl explicit keyword at all and then verify that it really honours it
  203. AC_TRY_COMPILE(
  204. [
  205. class Foo { public: explicit Foo(int) {} };
  206. ],
  207. [
  208. return 0;
  209. ],
  210. [
  211. AC_TRY_COMPILE(
  212. [
  213. class Foo { public: explicit Foo(int) {} };
  214. static void TakeFoo(const Foo& foo) { }
  215. ],
  216. [
  217. TakeFoo(17);
  218. return 0;
  219. ],
  220. wx_cv_explicit=no,
  221. wx_cv_explicit=yes
  222. )
  223. ],
  224. wx_cv_explicit=no
  225. )
  226. AC_LANG_RESTORE
  227. ])
  228. if test "$wx_cv_explicit" = "yes"; then
  229. AC_DEFINE(HAVE_EXPLICIT)
  230. fi
  231. ])
  232. dnl ---------------------------------------------------------------------------
  233. dnl WX_CHECK_FUNCS(FUNCTIONS...,
  234. dnl [ACTION-IF-FOUND],
  235. dnl [ACTION-IF-NOT-FOUND],
  236. dnl [EXTRA-DEFINES-AND-INCLUDES],
  237. dnl [EXTRA-TEST-CODE])
  238. dnl
  239. dnl Checks that the functions listed in FUNCTIONS exist in the headers and the
  240. dnl libs. For each function, if it is found then defines 'HAVE_FUNCTION' and
  241. dnl executes ACTION-IF-FOUND, otherwise executes ACTION-IF-NOT-FOUND.
  242. dnl
  243. dnl The code from EXTRA-DEFINES-AND-INCLUDES is inserted into the test before
  244. dnl the default headers are included, and EXTRA-TEST-CODE is inserted into
  245. dnl the main() function after the default test for existence.
  246. dnl
  247. dnl Examples:
  248. dnl # the simple case
  249. dnl WX_CHECK_FUNCS(stat)
  250. dnl # use break to finish the loop early
  251. dnl WX_CHECK_FUNCS(mkstemp mktemp, break)
  252. dnl # extra defines
  253. dnl WX_CHECK_FUNCS(strtok_r, [], [], [#define _RREENTRANT])
  254. dnl # extra includes
  255. dnl WX_CHECK_FUNCS(swprintf, [], [], [#include <wchar.h>])
  256. dnl # checking the signature with extra test code
  257. dnl WX_CHECK_FUNCS(gettimeofday, [], [], [#include <sys/time.h>]
  258. dnl [struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz)])
  259. dnl ---------------------------------------------------------------------------
  260. AC_DEFUN([WX_CHECK_FUNCS],
  261. [
  262. for wx_func in $1
  263. do
  264. AC_CACHE_CHECK(
  265. [for $wx_func],
  266. [wx_cv_func_$wx_func],
  267. [
  268. AC_LINK_IFELSE(
  269. [
  270. AC_LANG_PROGRAM(
  271. [
  272. $4
  273. AC_INCLUDES_DEFAULT
  274. ],
  275. [
  276. #ifndef $wx_func
  277. &$wx_func;
  278. #endif
  279. $5
  280. ])
  281. ],
  282. [eval wx_cv_func_$wx_func=yes],
  283. [eval wx_cv_func_$wx_func=no])
  284. ])
  285. if eval test \$wx_cv_func_$wx_func = yes
  286. then
  287. AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$wx_func]))
  288. $2
  289. else
  290. :
  291. $3
  292. fi
  293. done
  294. ])
  295. dnl ---------------------------------------------------------------------------
  296. dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
  297. dnl ---------------------------------------------------------------------------
  298. AC_DEFUN([WX_C_BIGENDIAN],
  299. [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
  300. [ac_cv_c_bigendian=unknown
  301. # See if sys/param.h defines the BYTE_ORDER macro.
  302. AC_TRY_COMPILE([#include <sys/types.h>
  303. #include <sys/param.h>], [
  304. #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
  305. bogus endian macros
  306. #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
  307. AC_TRY_COMPILE([#include <sys/types.h>
  308. #include <sys/param.h>], [
  309. #if BYTE_ORDER != BIG_ENDIAN
  310. not big endian
  311. #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
  312. if test $ac_cv_c_bigendian = unknown; then
  313. AC_TRY_RUN([main () {
  314. /* Are we little or big endian? From Harbison&Steele. */
  315. union
  316. {
  317. long l;
  318. char c[sizeof (long)];
  319. } u;
  320. u.l = 1;
  321. exit (u.c[sizeof (long) - 1] == 1);
  322. }], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
  323. fi])
  324. if test $ac_cv_c_bigendian = unknown; then
  325. AC_MSG_WARN([Assuming little-endian target machine - this may be overridden by adding the line "ac_cv_c_bigendian=${ac_cv_c_bigendian='yes'}" to config.cache file])
  326. fi
  327. if test $ac_cv_c_bigendian = yes; then
  328. AC_DEFINE(WORDS_BIGENDIAN)
  329. fi
  330. ])
  331. dnl ---------------------------------------------------------------------------
  332. dnl override AC_ARG_ENABLE/WITH to handle options defaults
  333. dnl ---------------------------------------------------------------------------
  334. dnl this macro checks for a three-valued command line --with argument:
  335. dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
  336. dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
  337. dnl
  338. dnl the default value (used if the option is not specified at all) is the value
  339. dnl of wxUSE_ALL_FEATURES (which is "yes" by default but can be changed by
  340. dnl giving configure --disable-all-features option)
  341. AC_DEFUN([WX_ARG_SYS_WITH],
  342. [
  343. AC_MSG_CHECKING([for --with-$1])
  344. AC_ARG_WITH($1, [$2],
  345. [
  346. if test "$withval" = yes; then
  347. AS_TR_SH(wx_cv_use_$1)='$3=yes'
  348. elif test "$withval" = no; then
  349. AS_TR_SH(wx_cv_use_$1)='$3=no'
  350. elif test "$withval" = sys; then
  351. AS_TR_SH(wx_cv_use_$1)='$3=sys'
  352. elif test "$withval" = builtin; then
  353. AS_TR_SH(wx_cv_use_$1)='$3=builtin'
  354. else
  355. AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
  356. fi
  357. ],
  358. [
  359. AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$wxUSE_ALL_FEATURES}"
  360. ])
  361. eval "$AS_TR_SH(wx_cv_use_$1)"
  362. if test "$$3" = yes; then
  363. AC_MSG_RESULT(yes)
  364. elif test "$$3" = no; then
  365. AC_MSG_RESULT(no)
  366. elif test "$$3" = sys; then
  367. AC_MSG_RESULT([system version])
  368. elif test "$$3" = builtin; then
  369. AC_MSG_RESULT([builtin version])
  370. else
  371. AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
  372. fi
  373. ])
  374. dnl this macro simply checks for a command line argument
  375. dnl usage: WX_ARG_WITH(option, helpmessage, variable-name, [withstring])
  376. AC_DEFUN([WX_ARG_WITH],
  377. [
  378. withstring=$4
  379. defaultval=$wxUSE_ALL_FEATURES
  380. if test -z "$defaultval"; then
  381. if test x"$withstring" = xwithout; then
  382. defaultval=yes
  383. else
  384. defaultval=no
  385. fi
  386. fi
  387. AC_MSG_CHECKING([for --${withstring:-with}-$1])
  388. AC_ARG_WITH($1, [$2],
  389. [
  390. if test "$withval" = yes; then
  391. AS_TR_SH(wx_cv_use_$1)='$3=yes'
  392. else
  393. AS_TR_SH(wx_cv_use_$1)='$3=no'
  394. fi
  395. ],
  396. [
  397. AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$defaultval}"
  398. ])
  399. eval "$AS_TR_SH(wx_cv_use_$1)"
  400. if test x"$withstring" = xwithout; then
  401. if test $$3 = yes; then
  402. result=no
  403. else
  404. result=yes
  405. fi
  406. else
  407. result=$$3
  408. fi
  409. AC_MSG_RESULT($result)
  410. ])
  411. dnl same as WX_ARG_WITH but makes it clear that the option is enabled by default
  412. AC_DEFUN([WX_ARG_WITHOUT], [WX_ARG_WITH($1, [$2], $3, without)])
  413. dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
  414. dnl usage: WX_ARG_ENABLE(option, helpmessage, var, [enablestring], [default])
  415. dnl
  416. dnl enablestring can be omitted or a literal string "disable" and allows to
  417. dnl show "checking for --disable-foo" message when running configure instead of
  418. dnl the default "checking for --enable-foo" one whih is useful for the options
  419. dnl enabled by default
  420. dnl
  421. dnl the "default" argument can be omitted or contain the default value to use
  422. dnl for the option if it's unspecified
  423. AC_DEFUN([WX_ARG_ENABLE],
  424. [
  425. enablestring=$4
  426. defaultval=$5
  427. if test -z "$defaultval"; then
  428. if test x"$enablestring" = xdisable; then
  429. defaultval=yes
  430. else
  431. defaultval=no
  432. fi
  433. fi
  434. AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
  435. AC_ARG_ENABLE($1, [$2],
  436. [
  437. if test "$enableval" = yes; then
  438. AS_TR_SH(wx_cv_use_$1)='$3=yes'
  439. else
  440. AS_TR_SH(wx_cv_use_$1)='$3=no'
  441. fi
  442. ],
  443. [
  444. AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$defaultval}"
  445. ])
  446. eval "$AS_TR_SH(wx_cv_use_$1)"
  447. if test x"$enablestring" = xdisable; then
  448. if test $$3 = no; then
  449. result=yes
  450. else
  451. result=no
  452. fi
  453. else
  454. result=$$3
  455. fi
  456. AC_MSG_RESULT($result)
  457. ])
  458. dnl the same as WX_ARG_ENABLE but makes it more clear that the option is
  459. dnl enabled by default
  460. AC_DEFUN([WX_ARG_DISABLE], [WX_ARG_ENABLE($1, [$2], $3, disable)])
  461. dnl same as WX_ARG_ENABLE but defaults to wxUSE_ALL_FEATURES instead of "yes"
  462. AC_DEFUN([WX_ARG_FEATURE], [WX_ARG_ENABLE($1, [$2], $3,, $wxUSE_ALL_FEATURES)])
  463. dnl Like WX_ARG_ENABLE but accepts a parameter.
  464. dnl
  465. dnl Usage:
  466. dnl WX_ARG_ENABLE_PARAM(option, helpmessage, variable-name, enablestring)
  467. dnl
  468. dnl Example:
  469. dnl WX_ARG_ENABLE_PARAM(foo, [[ --enable-foo[=bar] use foo]], wxUSE_FOO)
  470. dnl
  471. dnl --enable-foo wxUSE_FOO=yes
  472. dnl --disable-foo wxUSE_FOO=no
  473. dnl --enable-foo=bar wxUSE_FOO=bar
  474. dnl <not given> wxUSE_FOO=$DEFAULT_wxUSE_FOO
  475. dnl
  476. AC_DEFUN([WX_ARG_ENABLE_PARAM],
  477. [
  478. enablestring=$4
  479. AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
  480. AC_ARG_ENABLE($1, [$2],
  481. [
  482. wx_cv_use_$1="$3='$enableval'"
  483. ],
  484. [
  485. wx_cv_use_$1='$3='$DEFAULT_$3
  486. ])
  487. eval "$wx_cv_use_$1"
  488. AC_MSG_RESULT([$$3])
  489. ])
  490. dnl ===========================================================================
  491. dnl Linker features test
  492. dnl ===========================================================================
  493. dnl ---------------------------------------------------------------------------
  494. dnl WX_VERSIONED_SYMBOLS checks whether the linker can create versioned
  495. dnl symbols. If it can, sets LDFLAGS_VERSIONING to $CXX flags needed to use
  496. dnl version script file named versionfile
  497. dnl
  498. dnl call WX_VERSIONED_SYMBOLS(versionfile)
  499. dnl ---------------------------------------------------------------------------
  500. AC_DEFUN([WX_VERSIONED_SYMBOLS],
  501. [
  502. case "${host}" in
  503. *-*-cygwin* | *-*-mingw* )
  504. dnl although ld does support version script option on these
  505. dnl platforms, it doesn't make much sense to use it under Win32
  506. dnl and, moreover, this breaks linking because of a bug in handling
  507. dnl paths in -Wl,--version-script,path option (if we ever do need
  508. dnl to use it for cygwin/mingw32, keep in mind that replacing last
  509. dnl comma with the equal sign works) so
  510. dnl simply disable it
  511. wx_cv_version_script=no
  512. ;;
  513. *)
  514. AC_CACHE_CHECK([if the linker accepts --version-script], wx_cv_version_script,
  515. [
  516. echo "VER_1 { *; };" >conftest.sym
  517. echo "int main() { return 0; }" >conftest.cpp
  518. if AC_TRY_COMMAND([
  519. $CXX -o conftest.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
  520. -Wl,--version-script,conftest.sym >/dev/null 2>conftest.stderr]) ; then
  521. if test -s conftest.stderr ; then
  522. wx_cv_version_script=no
  523. else
  524. wx_cv_version_script=yes
  525. fi
  526. else
  527. wx_cv_version_script=no
  528. fi
  529. dnl There's a problem in some old linkers with --version-script that
  530. dnl can cause linking to fail when you have objects with vtables in
  531. dnl libs 3 deep. This is known to happen in netbsd and openbsd with
  532. dnl ld 2.11.2.
  533. dnl
  534. dnl To test for this we need to make some shared libs and
  535. dnl unfortunately we can't be sure of the right way to do that. If the
  536. dnl first two compiles don't succeed then it looks like the test isn't
  537. dnl working and the result is ignored, but if OTOH the first two
  538. dnl succeed but the third does not then the bug has been detected and
  539. dnl the --version-script flag is dropped.
  540. if test $wx_cv_version_script = yes
  541. then
  542. echo "struct B { virtual ~B() { } }; \
  543. struct D : public B { }; \
  544. void F() { D d; }" > conftest.cpp
  545. if AC_TRY_COMMAND([
  546. $CXX -shared -fPIC -o conftest1.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
  547. -Wl,--version-script,conftest.sym >/dev/null 2>/dev/null]) &&
  548. AC_TRY_COMMAND([
  549. $CXX -shared -fPIC -o conftest2.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
  550. -Wl,--version-script,conftest.sym conftest1.output >/dev/null 2>/dev/null])
  551. then
  552. if AC_TRY_COMMAND([
  553. $CXX -shared -fPIC -o conftest3.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
  554. -Wl,--version-script,conftest.sym conftest2.output conftest1.output >/dev/null 2>/dev/null])
  555. then
  556. wx_cv_version_script=yes
  557. else
  558. wx_cv_version_script=no
  559. fi
  560. fi
  561. fi
  562. rm -f conftest.output conftest.stderr conftest.sym conftest.cpp
  563. rm -f conftest1.output conftest2.output conftest3.output
  564. ])
  565. if test $wx_cv_version_script = yes ; then
  566. LDFLAGS_VERSIONING="-Wl,--version-script,$1"
  567. fi
  568. ;;
  569. esac
  570. ])
  571. dnl ===========================================================================
  572. dnl "3rd party" macros included here because they are not widely available
  573. dnl ===========================================================================
  574. dnl ---------------------------------------------------------------------------
  575. dnl test for availability of iconv()
  576. dnl ---------------------------------------------------------------------------
  577. dnl From Bruno Haible.
  578. AC_DEFUN([AM_ICONV],
  579. [
  580. dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
  581. dnl those with the standalone portable GNU libiconv installed).
  582. AC_ARG_WITH([libiconv-prefix],
  583. [ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
  584. for dir in `echo "$withval" | tr : ' '`; do
  585. if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
  586. if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
  587. done
  588. ])
  589. AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
  590. am_cv_func_iconv="no, consider installing GNU libiconv"
  591. am_cv_lib_iconv=no
  592. AC_TRY_LINK([#include <stdlib.h>
  593. #include <iconv.h>],
  594. [iconv_t cd = iconv_open("","");
  595. iconv(cd,NULL,NULL,NULL,NULL);
  596. iconv_close(cd);],
  597. am_cv_func_iconv=yes)
  598. if test "$am_cv_func_iconv" != yes; then
  599. am_save_LIBS="$LIBS"
  600. LIBS="$LIBS -liconv"
  601. AC_TRY_LINK([#include <stdlib.h>
  602. #include <iconv.h>],
  603. [iconv_t cd = iconv_open("","");
  604. iconv(cd,NULL,NULL,NULL,NULL);
  605. iconv_close(cd);],
  606. am_cv_lib_iconv=yes
  607. am_cv_func_iconv=yes)
  608. LIBS="$am_save_LIBS"
  609. fi
  610. ])
  611. if test "$am_cv_func_iconv" = yes; then
  612. AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
  613. AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
  614. AC_TRY_COMPILE([
  615. #include <stdlib.h>
  616. #include <iconv.h>
  617. extern
  618. #ifdef __cplusplus
  619. "C"
  620. #endif
  621. #if defined(__STDC__) || defined(__cplusplus)
  622. size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
  623. #else
  624. size_t iconv();
  625. #endif
  626. ],
  627. [],
  628. wx_cv_func_iconv_const="no",
  629. wx_cv_func_iconv_const="yes"
  630. )
  631. )
  632. iconv_const=
  633. if test "x$wx_cv_func_iconv_const" = "xyes"; then
  634. iconv_const="const"
  635. fi
  636. AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
  637. [Define as const if the declaration of iconv() needs const.])
  638. fi
  639. LIBICONV=
  640. if test "$am_cv_lib_iconv" = yes; then
  641. LIBICONV="-liconv"
  642. fi
  643. AC_SUBST(LIBICONV)
  644. ])
  645. dnl ---------------------------------------------------------------------------
  646. dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
  647. dnl ---------------------------------------------------------------------------
  648. dnl WX_SYS_LARGEFILE_TEST
  649. dnl
  650. dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
  651. dnl arithmetic properly but this failed miserably with gcc under Linux
  652. dnl whereas the system still supports 64 bit files, so now simply check
  653. dnl that off_t is big enough
  654. define(WX_SYS_LARGEFILE_TEST,
  655. [typedef struct {
  656. unsigned int field: sizeof(off_t) == 8;
  657. } wxlf;
  658. ])
  659. dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
  660. define(WX_SYS_LARGEFILE_MACRO_VALUE,
  661. [
  662. AC_CACHE_CHECK([for $1 value needed for large files], [$3],
  663. [
  664. AC_TRY_COMPILE([#define $1 $2
  665. #include <sys/types.h>],
  666. WX_SYS_LARGEFILE_TEST,
  667. [$3=$2],
  668. [$3=no])
  669. ]
  670. )
  671. if test "$$3" != no; then
  672. wx_largefile=yes
  673. AC_DEFINE_UNQUOTED([$1], [$$3])
  674. fi
  675. ])
  676. dnl AC_SYS_LARGEFILE
  677. dnl ----------------
  678. dnl By default, many hosts won't let programs access large files;
  679. dnl one must use special compiler options to get large-file access to work.
  680. dnl For more details about this brain damage please see:
  681. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  682. AC_DEFUN([AC_SYS_LARGEFILE],
  683. [AC_ARG_ENABLE(largefile,
  684. [ --disable-largefile omit support for large files])
  685. if test "$enable_largefile" != no; then
  686. dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
  687. dnl _LARGE_FILES -- for AIX
  688. wx_largefile=no
  689. WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
  690. if test "x$wx_largefile" != "xyes"; then
  691. WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
  692. fi
  693. AC_MSG_CHECKING(if large file support is available)
  694. if test "x$wx_largefile" = "xyes"; then
  695. AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
  696. fi
  697. AC_MSG_RESULT($wx_largefile)
  698. fi
  699. ])