aclocal.m4 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. AC_DEFUN([LOC_CHECK_USE],[
  2. AC_MSG_CHECKING(whether to use $2)
  3. AC_MSG_RESULT("$with_$1")
  4. case "$with_$1" in
  5. "no") $3= ;;
  6. "yes") $3="1" ;;
  7. *) AC_MSG_ERROR([*** You must answer yes or no.]) ;;
  8. esac
  9. ])
  10. AC_DEFUN([LOC_CHECK_INC_PATH],[
  11. AC_MSG_CHECKING(for location of $2 includes)
  12. case "$with_$1_includes" in
  13. y | ye | yes | n | no)
  14. AC_MSG_ERROR([*** You must supply a directory to --with-$1-includes.])
  15. ;;
  16. esac
  17. AC_MSG_RESULT($with_$1_includes)
  18. if test -n "$with_$1_includes" ; then
  19. for dir in $with_$1_includes; do
  20. if test -d "$dir"; then
  21. $3="$$3 -I$dir"
  22. else
  23. AC_MSG_ERROR([*** $2 includes directory $dir does not exist.])
  24. fi
  25. done
  26. fi
  27. ])
  28. AC_DEFUN([LOC_CHECK_LIB_PATH],[
  29. AC_MSG_CHECKING(for location of $2 library)
  30. case "$with_$1_libs" in
  31. y | ye | yes | n | no)
  32. AC_MSG_ERROR([*** You must supply a directory to --with-$1-libs.])
  33. ;;
  34. esac
  35. AC_MSG_RESULT($with_$1_libs)
  36. if test -n "$with_$1_libs"; then
  37. for dir in $with_$1_libs; do
  38. if test -d "$dir"; then
  39. $3="$$3 -L$dir"
  40. else
  41. AC_MSG_ERROR([*** $2 library directory $dir does not exist.])
  42. fi
  43. done
  44. fi
  45. ])
  46. AC_DEFUN([LOC_CHECK_FRAMEWORK_PATH],[
  47. AC_MSG_CHECKING(for location of $2 framework)
  48. case "$with_$1_framework" in
  49. y | ye | yes | n | no)
  50. AC_MSG_ERROR([*** You must supply a directory to --with-$1-framework.])
  51. ;;
  52. esac
  53. AC_MSG_RESULT($with_$1_framework)
  54. if test -n "$with_$1_framework"; then
  55. if test -d $with_$1_framework; then
  56. $3="$$3 -F$with_$1_framework"
  57. else
  58. AC_MSG_ERROR([*** $2 framework directory $dir does not exist.])
  59. fi
  60. fi
  61. ])
  62. AC_DEFUN([LOC_CHECK_SHARE_PATH],[
  63. AC_MSG_CHECKING(for location of $2 data files)
  64. case "$with_$1_share" in
  65. y | ye | yes | n | no)
  66. AC_MSG_ERROR([*** You must supply a directory to --with-$1-share.])
  67. ;;
  68. esac
  69. AC_MSG_RESULT($with_$1_share)
  70. if test -n "$with_$1_share" ; then
  71. if test -d "$with_$1_share"; then
  72. $3="$with_$1_share"
  73. else
  74. AC_MSG_ERROR([*** $2 data directory $dir does not exist.])
  75. fi
  76. fi
  77. ])
  78. AC_DEFUN([LOC_CHECK_LDFLAGS],[
  79. AC_MSG_CHECKING(for $2 linking flags)
  80. case "$with_$1_ldflags" in
  81. y | ye | yes | n | no)
  82. AC_MSG_ERROR([*** You must supply a directory to --with-$1-ldflags.])
  83. ;;
  84. esac
  85. AC_MSG_RESULT($with_$1_ldflags)
  86. $3="$$3 $with_$1_ldflags"
  87. ])
  88. AC_DEFUN([LOC_CHECK_INCLUDES],[
  89. ac_save_cppflags="$CPPFLAGS"
  90. CPPFLAGS="$3 $CPPFLAGS"
  91. AC_CHECK_HEADERS($1, [], ifelse($4,[],[
  92. AC_MSG_ERROR([*** Unable to locate $2 includes.])
  93. ], $4))
  94. CPPFLAGS=$ac_save_cppflags
  95. ])
  96. dnl $1 = library
  97. dnl $2 = header
  98. dnl $3 = function call
  99. dnl $4 = descriptive name
  100. dnl $5 = LDFLAGS initialiser
  101. dnl $6 = result variable
  102. dnl $7 = mandatory dependencies (not added to $5)
  103. dnl $8 = mandatory dependencies (added to $5)
  104. dnl $9 = ACTION-IF-NOT-FOUND
  105. define(LOC_CHECK_LINK,[
  106. ac_save_ldflags="$LDFLAGS"
  107. ac_save_libs="$LIBS"
  108. AC_MSG_CHECKING(for $4 library)
  109. LDFLAGS="$5 $LDFLAGS"
  110. LIBS="-l$1 $7 $8"
  111. AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]], [[$3]])],[
  112. AC_MSG_RESULT(found)
  113. $6="$$6 -l$1 $8"
  114. ],[
  115. ifelse($9,[],[
  116. AC_MSG_ERROR([*** Unable to locate $4 library.])
  117. ],$9)
  118. ])
  119. LIBS=${ac_save_libs}
  120. LDFLAGS=${ac_save_ldflags}
  121. ])
  122. dnl autoconf undefines "shift", so use "builtin([shift], ...)"
  123. define(LOC_SHIFT1,[builtin([shift],$*)])
  124. define(LOC_SHIFT2,[LOC_SHIFT1(LOC_SHIFT1($*))])
  125. define(LOC_SHIFT4,[LOC_SHIFT2(LOC_SHIFT2($*))])
  126. define(LOC_SHIFT8,[LOC_SHIFT4(LOC_SHIFT4($*))])
  127. define(LOC_SHIFT9,[LOC_SHIFT1(LOC_SHIFT8($*))])
  128. dnl $1 = library
  129. dnl $2 = function
  130. dnl $3 = descriptive name
  131. dnl $4 = LDFLAGS initialiser
  132. dnl $5 = result variable
  133. dnl $6 = mandatory dependencies (not added to $5)
  134. dnl $7 = mandatory dependencies (added to $5)
  135. dnl $8 = ACTION-IF-NOT-FOUND
  136. dnl $9+ = optional dependencies
  137. define(LOC_CHECK_LIBS_0,[
  138. AC_CHECK_LIB($1, $2, $5="$$5 -l$1 $7",[
  139. [$8]
  140. ],$6 $7)
  141. ])
  142. define(LOC_CHECK_LIBS_1,[
  143. ifelse($9,[],
  144. LOC_CHECK_LIBS_0($1,$2,,,$5,$6,$7,$8),
  145. [
  146. LOC_CHECK_LIBS_1($1,$2,,,$5,$6,$7,
  147. LOC_CHECK_LIBS_1($1,$2,,,$5,$6,$7 $9,$8,LOC_SHIFT9($*)),
  148. LOC_SHIFT9($*))
  149. ]
  150. )
  151. ])
  152. define(LOC_CHECK_LIBS,[
  153. ac_save_ldflags="$LDFLAGS"
  154. LDFLAGS="$4 $LDFLAGS"
  155. LOC_CHECK_LIBS_1($1,$2,,,$5,$6,$7,
  156. LDFLAGS=${ac_save_ldflags}
  157. ifelse($8,[],[
  158. AC_MSG_ERROR([*** Unable to locate $3 library.])
  159. ],$8),LOC_SHIFT8($*))
  160. LDFLAGS=${ac_save_ldflags}
  161. ])
  162. dnl $1 = function
  163. dnl $2 = descriptive name
  164. dnl $3 = result variable
  165. dnl $4 = LIBS initialiser (added to $3)
  166. dnl $5 = LDFLAGS initialiser (not added to $3)
  167. dnl $6 = LIBS initialiser (not added to $3)
  168. dnl $7 = ACTION-IF-FOUND
  169. dnl $8 = ACTION-IF-NOT-FOUND
  170. define(LOC_CHECK_FUNC,[
  171. ac_save_libs="$LIBS"
  172. ac_save_ldflags="$LDFLAGS"
  173. LIBS="$4 $6 $LIBS"
  174. LDFLAGS="$5 $LDFLAGS"
  175. AC_CHECK_FUNC($1,[
  176. ifelse($7,[],[
  177. $3="$$3 $4"
  178. ],$7)
  179. ],[
  180. ifelse($8,[],[
  181. ifelse($2,[],
  182. [AC_MSG_ERROR([*** Unable to locate $1.])],
  183. [AC_MSG_ERROR([*** Unable to locate $2.])]
  184. )
  185. ],$8)
  186. ])
  187. LIBS=${ac_save_libs}
  188. LDFLAGS=${ac_save_ldflags}
  189. ])
  190. AC_DEFUN([LOC_CHECK_VERSION_STRING],[
  191. AC_MSG_CHECKING($3 version)
  192. ac_save_cppflags="$CPPFLAGS"
  193. CPPFLAGS="$5 $CPPFLAGS"
  194. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  195. #include <stdio.h>
  196. #include <$1>
  197. int main(void) {
  198. FILE *fp = fopen("conftestdata","w");
  199. fputs($2, fp);
  200. return 0;
  201. }
  202. ]])],[ $4=`cat conftestdata`
  203. AC_MSG_RESULT($$4)],[ AC_MSG_ERROR([*** Could not determine $3 version.]) ],[ $4=$6
  204. AC_MSG_RESULT([unknown (cross-compiling)]) ])
  205. CPPFLAGS=$ac_save_cppflags
  206. ])
  207. AC_DEFUN([LOC_CHECK_SHARE],[
  208. AC_CHECK_FILE($3/$1, [], ifelse($4,[],[
  209. AC_MSG_ERROR([*** Unable to locate $2 data files.])
  210. ], $4))
  211. ])
  212. AC_DEFUN([LOC_CHECK_VERSION_INT],[
  213. AC_MSG_CHECKING($3 version)
  214. ac_save_cppflags="$CPPFLAGS"
  215. CPPFLAGS="$5 $CPPFLAGS"
  216. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  217. #include <stdio.h>
  218. #include <$1>
  219. int main(void) {
  220. FILE *fp = fopen("conftestdata","w");
  221. fprintf(fp, "%d", $2);
  222. return 0;
  223. }
  224. ]])],[ $4=`cat conftestdata`
  225. AC_MSG_RESULT($$4)],[ AC_MSG_ERROR([*** Could not determine $3 version.]) ],[ $4=$6
  226. AC_MSG_RESULT([unknown (cross-compiling)]) ])
  227. CPPFLAGS=$ac_save_cppflags
  228. ])
  229. dnl autoconf undefines "eval", so use "builtin([eval], ...)"
  230. AC_DEFUN([LOC_PAD],[$1[]ifelse(builtin([eval],len($1) > 23),1,[
  231. ],m4_substr([ ],len($1)))])
  232. AC_DEFUN([LOC_ARG_WITH],[
  233. AC_ARG_WITH($1,
  234. LOC_PAD([ --with-$1])[support $2 functionality (default: ]ifelse([$3],,yes,[$3])[)],,
  235. [with_]patsubst([$1], -, _)[=]ifelse([$3],,yes,[$3]))
  236. ])
  237. AC_DEFUN([LOC_ARG_WITH_INC],[
  238. AC_ARG_WITH($1-includes,
  239. LOC_PAD([ --with-$1-includes=DIRS])[$2 include files are in DIRS])
  240. ])
  241. AC_DEFUN([LOC_ARG_WITH_LIB],[
  242. AC_ARG_WITH($1-libs,
  243. LOC_PAD([ --with-$1-libs=DIRS])[$2 library files are in DIRS])
  244. ])
  245. AC_DEFUN([LOC_ARG_WITH_LDFLAGS],[
  246. AC_ARG_WITH($1-ldflags,
  247. LOC_PAD([ --with-$1-ldflags=FLAGS])[$2 needs FLAGS when linking])
  248. ])
  249. AC_DEFUN([LOC_ARG_WITH_SHARE],[
  250. AC_ARG_WITH($1-share,
  251. LOC_PAD([ --with-$1-share=DIR])[$2 data files are in DIR])
  252. ])
  253. AC_DEFUN([LOC_ARG_WITH_FRAMEWORK],[
  254. AC_ARG_WITH($1-framework,
  255. LOC_PAD([ --with-$1-framework=DIR])[$2 framework is in DIR])
  256. ])
  257. AC_DEFUN([LOC_OPTIONAL],[
  258. AC_MSG_CHECKING(whether to build $1)
  259. if test -n "$USE_$2" ; then
  260. AC_MSG_RESULT(yes)
  261. BUILD_$3="$4"
  262. else
  263. AC_MSG_RESULT(no)
  264. BUILD_$3=
  265. fi
  266. AC_SUBST(BUILD_$3)
  267. ])
  268. dnl checks for complete floating-point support (infinity, NaN)
  269. define(LOC_FP_TEST,[
  270. #include <float.h>
  271. int main(void) {
  272. double one = 1.0;
  273. double zero = 0.0;
  274. if (one/zero > DBL_MAX) /* infinity */
  275. if (zero/zero != zero/zero) /* NaN */
  276. return 0;
  277. return 1;
  278. }
  279. ])
  280. AC_DEFUN([LOC_CHECK_FP_INF_NAN],[
  281. AC_MSG_CHECKING([for full floating-point support]$1)
  282. AC_RUN_IFELSE([AC_LANG_SOURCE([LOC_FP_TEST])],[ AC_MSG_RESULT(yes)
  283. $2],[ AC_MSG_RESULT(no)
  284. $3],[ AC_MSG_RESULT([unknown (cross-compiling)])
  285. $4
  286. ])
  287. ])
  288. dnl check whether the compiler supports the -mieee switch
  289. AC_DEFUN([LOC_CHECK_CC_MIEEE],[
  290. AC_MSG_CHECKING(whether "cc -mieee" works)
  291. ac_save_cflags=${CFLAGS}
  292. CFLAGS="$CFLAGS -mieee"
  293. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[ AC_MSG_RESULT(yes)
  294. IEEEFLAG="-mieee"],[ AC_MSG_RESULT(no)])
  295. CFLAGS=${ac_save_cflags}
  296. ])
  297. AC_DEFUN([LOC_MSG],[
  298. echo "$1"
  299. ])
  300. AC_DEFUN([LOC_PAD_26],[m4_substr([ ],len($1))])
  301. AC_DEFUN([LOC_YES_NO],[if test -n "${$1}" ; then echo yes ; else echo no ; fi])
  302. AC_DEFUN([LOC_MSG_USE],[
  303. [echo " $1:]LOC_PAD_26($1)`LOC_YES_NO($2)`"])
  304. AC_DEFUN(LOC_EXEEXT,[
  305. [case $host_os in
  306. *cygwin* ) CYGWIN=yes;;
  307. esac
  308. ]
  309. [case $host_os in
  310. *mingw32* ) MINGW32=yes;;
  311. esac
  312. ]
  313. AC_MSG_CHECKING([for executable suffix])
  314. AC_CACHE_VAL(ac_cv_exeext,
  315. [if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
  316. ac_cv_exeext=.exe
  317. else
  318. ac_cv_exeext=no
  319. fi])
  320. EXEEXT=""
  321. test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
  322. AC_MSG_RESULT(${ac_cv_exeext})
  323. dnl Setting ac_exeext will implicitly change the ac_link command.
  324. ac_exeext=$EXEEXT
  325. AC_SUBST(EXEEXT)])
  326. #------------------------------------------------------------------------
  327. # SC_ENABLE_SHARED --
  328. #
  329. # Allows the building of shared libraries
  330. #
  331. # Arguments:
  332. # none
  333. #
  334. # Results:
  335. #
  336. # Adds the following arguments to configure:
  337. # --enable-shared=yes|no
  338. #
  339. # Defines the following vars:
  340. # STATIC_BUILD Used for building import/export libraries
  341. # on Windows.
  342. #
  343. # Sets the following vars:
  344. # SHARED_BUILD Value of 1 or 0
  345. #------------------------------------------------------------------------
  346. AC_DEFUN([SC_ENABLE_SHARED], [
  347. AC_MSG_CHECKING([how to build libraries])
  348. AC_ARG_ENABLE(shared,
  349. [ --enable-shared build and link with shared libraries [--enable-shared]],
  350. [shared_ok=$enableval], [shared_ok=yes])
  351. if test "${enable_shared+set}" = set; then
  352. enableval="$enable_shared"
  353. shared_ok=$enableval
  354. else
  355. shared_ok=yes
  356. fi
  357. if test "$shared_ok" = "yes" ; then
  358. AC_MSG_RESULT([shared])
  359. SHARED_BUILD=1
  360. GRASS_LIBRARY_TYPE='shlib'
  361. else
  362. AC_MSG_RESULT([static])
  363. SHARED_BUILD=0
  364. AC_DEFINE(STATIC_BUILD, 1, [define for Windows static build])
  365. GRASS_LIBRARY_TYPE='stlib'
  366. fi
  367. AC_SUBST(GRASS_LIBRARY_TYPE)
  368. ])
  369. #--------------------------------------------------------------------
  370. # SC_CONFIG_CFLAGS
  371. #
  372. # Try to determine the proper flags to pass to the compiler
  373. # for building shared libraries and other such nonsense.
  374. #
  375. # Arguments:
  376. # none
  377. #
  378. # Results:
  379. #
  380. # Defines and substitutes the following vars:
  381. #
  382. # LDFLAGS - Flags to pass to the compiler when linking object
  383. # files into an executable application binary such
  384. # as tclsh.
  385. # LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
  386. # that tell the run-time dynamic linker where to look
  387. # for shared libraries such as libtcl.so. Depends on
  388. # the variable LIB_RUNTIME_DIR in the Makefile. Could
  389. # be the same as CC_SEARCH_FLAGS if ${CC} is used to link.
  390. # CC_SEARCH_FLAGS-Flags to pass to ${CC}, such as "-Wl,-rpath,/usr/local/tcl/lib",
  391. # that tell the run-time dynamic linker where to look
  392. # for shared libraries such as libtcl.so. Depends on
  393. # the variable LIB_RUNTIME_DIR in the Makefile.
  394. # STLIB_LD - Base command to use for combining object files
  395. # into a static library.
  396. # SHLIB_CFLAGS - Flags to pass to cc when compiling the components
  397. # of a shared library (may request position-independent
  398. # code, among other things).
  399. # SHLIB_LD - Base command to use for combining object files
  400. # into a shared library.
  401. # SHLIB_LD_FLAGS -Flags to pass when building a shared library. This
  402. # differes from the SHLIB_CFLAGS as it is not used
  403. # when building object files or executables.
  404. # SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
  405. # creating shared libraries. This symbol typically
  406. # goes at the end of the "ld" commands that build
  407. # shared libraries. The value of the symbol is
  408. # "${LIBS}" if all of the dependent libraries should
  409. # be specified when creating a shared library. If
  410. # dependent libraries should not be specified (as on
  411. # SunOS 4.x, where they cause the link to fail, or in
  412. # general if Tcl and Tk aren't themselves shared
  413. # libraries), then this symbol has an empty string
  414. # as its value.
  415. # SHLIB_SUFFIX - Suffix to use for the names of dynamically loadable
  416. # extensions. An empty string means we don't know how
  417. # to use shared libraries on this platform.
  418. #
  419. #--------------------------------------------------------------------
  420. AC_DEFUN([SC_CONFIG_CFLAGS], [
  421. SHLIB_CFLAGS=""
  422. SHLIB_LD_FLAGS=""
  423. SHLIB_SUFFIX=""
  424. SHLIB_LD=""
  425. STLIB_LD='${AR} cr'
  426. STLIB_SUFFIX='.a'
  427. GRASS_TRIM_DOTS='`echo ${LIB_VER} | tr -d .`'
  428. GRASS_LIB_VERSIONS_OK=ok
  429. LDFLAGS=""
  430. LD_SEARCH_FLAGS=""
  431. LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
  432. case $host in
  433. *-linux-* | *-gnu* | *-kfreebsd*-gnu)
  434. SHLIB_CFLAGS="-fPIC"
  435. SHLIB_LD_FLAGS="-Wl,-soname,\$(notdir \$[@])"
  436. SHLIB_SUFFIX=".so"
  437. SHLIB_LD="${CC} -shared"
  438. LDFLAGS="-Wl,--export-dynamic"
  439. LD_SEARCH_FLAGS='-Wl,-rpath-link,${LIB_RUNTIME_DIR}'
  440. LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
  441. ;;
  442. *-pc-cygwin)
  443. SHLIB_SUFFIX=".dll"
  444. SHLIB_LD="${CC} -shared"
  445. LDFLAGS="-Wl,--export-dynamic"
  446. LD_LIBRARY_PATH_VAR="PATH"
  447. ;;
  448. *-pc-mingw32 | *-w64-mingw32 | *-pc-msys)
  449. SHLIB_SUFFIX=".dll"
  450. SHLIB_LD="${CC} -shared"
  451. LDFLAGS="-Wl,--export-dynamic,--enable-runtime-pseudo-reloc"
  452. LD_LIBRARY_PATH_VAR="PATH"
  453. ;;
  454. *-apple-darwin*)
  455. SHLIB_CFLAGS="-fno-common"
  456. SHLIB_SUFFIX=".dylib"
  457. SHLIB_LD="${CC} -dynamiclib -compatibility_version \${GRASS_VERSION_MAJOR}.\${GRASS_VERSION_MINOR} -current_version \${GRASS_VERSION_MAJOR}.\${GRASS_VERSION_MINOR} -install_name @rpath/lib\${LIB_NAME}\${SHLIB_SUFFIX}"
  458. LDFLAGS="-Wl,-rpath,${INSTDIR}/lib,-rpath,\${GISBASE}/lib"
  459. LD_LIBRARY_PATH_VAR="LD_RUN_PATH"
  460. ;;
  461. *-sun-solaris*)
  462. # Note: If _REENTRANT isn't defined, then Solaris
  463. # won't define thread-safe library routines.
  464. AC_DEFINE(_REENTRANT, 1, [define _REENTRANT flag (for SunOS)])
  465. AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [enable threading extensions on Solaris])
  466. # Note: need the LIBS below, otherwise Tk won't find Tcl's
  467. # symbols when dynamically loaded into tclsh.
  468. if test "$GCC" = "yes" ; then
  469. SHLIB_CFLAGS="-fPIC"
  470. SHLIB_LD="$CC -shared"
  471. LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
  472. else
  473. SHLIB_CFLAGS="-KPIC"
  474. SHLIB_LD="/usr/ccs/bin/ld -G -z text"
  475. LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
  476. fi
  477. SHLIB_SUFFIX=".so"
  478. LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
  479. ;;
  480. *-solaris2*)
  481. # Note: Solaris is as of 2010 Oracle Solaris, not Sun Solaris
  482. # Oracle Solaris derives from Solaris 2
  483. # derives from SunOS 5
  484. # derives from UNIX System V Release 4
  485. # Note: If _REENTRANT isn't defined, then Solaris
  486. # won't define thread-safe library routines.
  487. AC_DEFINE(_REENTRANT, 1, [define _REENTRANT flag (for SunOS)])
  488. AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [enable threading extensions on Solaris])
  489. # Note: need the LIBS below, otherwise Tk won't find Tcl's
  490. # symbols when dynamically loaded into tclsh.
  491. if test "$GCC" = "yes" ; then
  492. SHLIB_CFLAGS="-fPIC"
  493. SHLIB_LD="$CC -shared"
  494. LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
  495. else
  496. SHLIB_CFLAGS="-KPIC"
  497. SHLIB_LD="/usr/ccs/bin/ld -G -z text"
  498. LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
  499. fi
  500. SHLIB_SUFFIX=".so"
  501. LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
  502. ;;
  503. *-freebsd*)
  504. # NOTE: only FreeBSD 4+ is supported
  505. # FreeBSD 3.* and greater have ELF.
  506. SHLIB_CFLAGS="-fPIC"
  507. #SHLIB_LD="ld -Bshareable -x"
  508. SHLIB_LD="${CC} -shared"
  509. SHLIB_LD_FLAGS="-Wl,-soname,\$(notdir \$[@])"
  510. SHLIB_SUFFIX=".so"
  511. LDFLAGS="-Wl,--export-dynamic"
  512. #LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
  513. LD_SEARCH_FLAGS='-Wl,-rpath-link,${LIB_RUNTIME_DIR}'
  514. # TODO: add optional pthread support with any combination of:
  515. # CFLAGS="$CFLAGS -pthread"
  516. # LDFLAGS="$LDFLAGS -lpthread"
  517. # AC_DEFINE(_REENTRANT, 1, [define _REENTRANT flag (for SunOS)])
  518. # AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [enable threading extensions on Solaris])
  519. ;;
  520. *-netbsd*)
  521. # NetBSD has ELF.
  522. SHLIB_CFLAGS="-fPIC"
  523. SHLIB_LD="${CC} -shared"
  524. SHLIB_LD_LIBS="${LIBS}"
  525. LDFLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR} -export-dynamic'
  526. SHLIB_LD_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR} -export-dynamic'
  527. LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR} -L${LIB_RUNTIME_DIR}'
  528. # some older NetBSD versions do not handle version numbers with dots.
  529. #STLIB_SUFFIX='${GRASS_TRIM_DOTS}.a'
  530. #SHLIB_SUFFIX='${GRASS_TRIM_DOTS}.so'
  531. #GRASS_LIB_VERSIONS_OK=nodots
  532. # NetBSD 6 does handle version numbers with dots.
  533. STLIB_SUFFIX=".a"
  534. SHLIB_SUFFIX=".so"
  535. # TODO: add optional pthread support with any combination of:
  536. # CFLAGS="$CFLAGS -pthread"
  537. # LDFLAGS="$LDFLAGS -lpthread"
  538. # AC_DEFINE(_REENTRANT, 1, [define _REENTRANT flag (for SunOS)])
  539. # AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [enable threading extensions on Solaris])
  540. ;;
  541. *aix*)
  542. # NOTE: do we need to support aix < 6 ?
  543. LIBS="$LIBS -lc"
  544. SHLIB_CFLAGS=""
  545. LDFLAGS=""
  546. if test "$GCC" = "yes" ; then
  547. SHLIB_CFLAGS="-fPIC"
  548. SHLIB_LD="$CC -shared"
  549. LD_SEARCH_FLAGS='-Wl,-bsvr4,-R,${LIB_RUNTIME_DIR}'
  550. else
  551. # assume xlc
  552. SHLIB_CFLAGS="-qmkshrobj"
  553. SHLIB_LD="$CC -shared"
  554. LD_SEARCH_FLAGS='-Wl,-bsvr4,-R,${LIB_RUNTIME_DIR}'
  555. fi
  556. SHLIB_SUFFIX=".so"
  557. LD_LIBRARY_PATH_VAR="LIBPATH"
  558. GRASS_NEEDS_EXP_FILE=1
  559. GRASS_EXPORT_FILE_SUFFIX='${LIB_VER}.exp'
  560. ;;
  561. *)
  562. AC_MSG_ERROR([***Unknown platform: $host***])
  563. ;;
  564. esac
  565. AC_SUBST(LDFLAGS)
  566. AC_SUBST(LD_SEARCH_FLAGS)
  567. AC_SUBST(LD_LIBRARY_PATH_VAR)
  568. AC_SUBST(SHLIB_LD)
  569. AC_SUBST(SHLIB_LD_FLAGS)
  570. AC_SUBST(SHLIB_CFLAGS)
  571. AC_SUBST(SHLIB_SUFFIX)
  572. AC_SUBST(STLIB_LD)
  573. AC_SUBST(STLIB_SUFFIX)
  574. ])
  575. dnl XXXX Begin Stolen from cdrtools-2.01
  576. dnl XXXX by Joerg Schilling <schilling fokus fraunhofer de> et al. XXXXXXXXX
  577. dnl XXXXXXXXX Begin Stolen (but modified) from GNU tar XXXXXXXXXXXXXXXXXXXXX
  578. dnl Changes:
  579. dnl One line has been changed to: [ac_save_CC="${CC-cc}" to default to "'cc"
  580. dnl AC_SYS_LARGEFILE_MACRO_VALUE test moved from AC_FUNC_FSEEKO into AC_SYS_LARGEFILE
  581. dnl Do not call AC_FUNC_FSEEKO because it does not check whether fseeko() is
  582. dnl available on non Large File mode. There are additional tests for fseeko()/ftello()
  583. dnl inside the AC_HAVE_LARGEFILES test.
  584. dnl largefile_cc_opt definition added
  585. #serial 18
  586. dnl By default, many hosts won't let programs access large files;
  587. dnl one must use special compiler options to get large-file access to work.
  588. dnl For more details about this brain damage please see:
  589. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  590. dnl Written by Paul Eggert <eggert@twinsun.com>.
  591. dnl Internal subroutine of AC_SYS_LARGEFILE.
  592. dnl AC_SYS_LARGEFILE_TEST_INCLUDES
  593. AC_DEFUN([AC_SYS_LARGEFILE_TEST_INCLUDES],
  594. [[#include <sys/types.h>
  595. /* Check that off_t can represent 2**63 - 1 correctly.
  596. We can't simply "#define LARGE_OFF_T 9223372036854775807",
  597. since some C++ compilers masquerading as C compilers
  598. incorrectly reject 9223372036854775807. */
  599. # define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
  600. int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
  601. && LARGE_OFF_T % 2147483647 == 1)
  602. ? 1 : -1];
  603. ]])
  604. dnl Internal subroutine of AC_SYS_LARGEFILE.
  605. dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY)
  606. AC_DEFUN([AC_SYS_LARGEFILE_MACRO_VALUE],
  607. [AC_CACHE_CHECK([for $1 value needed for large files], $3,
  608. [$3=no
  609. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$5]], [[$6]])],[],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define $1 $2
  610. $5
  611. ]], [[$6]])],[$3=$2],[])])])
  612. if test "[$]$3" != no; then
  613. AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
  614. if test "$LFS_CFLAGS" ; then
  615. LFS_CFLAGS="$LFS_CFLAGS -D$1=[$]$3"
  616. else
  617. LFS_CFLAGS="-D$1=[$]$3"
  618. fi
  619. fi])
  620. AC_DEFUN([AC_SYS_LARGEFILE],
  621. [AC_ARG_ENABLE(largefile,
  622. [ --disable-largefile omit support for large files (LFS)])
  623. LFS_CFLAGS=
  624. if test "$enable_largefile" != no; then
  625. ac_save_cflags=$CFLAGS
  626. if test "`which getconf 2>&5`" ; then
  627. LFS_CFLAGS=`getconf LFS_CFLAGS 2>&5`
  628. CFLAGS="$LFS_CFLAGS $ac_save_cflags"
  629. fi
  630. AC_CACHE_CHECK([for special C compiler options needed for large files],
  631. ac_cv_sys_largefile_CC,
  632. [ac_cv_sys_largefile_CC=no
  633. largefile_cc_opt=""
  634. if test "$GCC" != yes; then
  635. # IRIX 6.2 and later do not support large files by default,
  636. # so use the C compiler's -n32 option if that helps.
  637. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_SYS_LARGEFILE_TEST_INCLUDES], [[]])],[],[ac_save_CC="${CC-cc}"
  638. CC="$CC -n32"
  639. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_SYS_LARGEFILE_TEST_INCLUDES], [[]])],[ac_cv_sys_largefile_CC=' -n32'],[])
  640. CC="$ac_save_CC"])
  641. fi])
  642. if test "$ac_cv_sys_largefile_CC" != no; then
  643. CC="$CC$ac_cv_sys_largefile_CC"
  644. largefile_cc_opt="$ac_cv_sys_largefile_CC"
  645. if test "$LFS_CFLAGS" ; then
  646. LFS_CFLAGS="$LFS_CFLAGS $ac_cv_sys_largefile_CC"
  647. else
  648. LFS_CFLAGS="$ac_cv_sys_largefile_CC"
  649. CFLAGS="$LFS_CFLAGS $ac_save_cflags"
  650. fi
  651. fi
  652. AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
  653. ac_cv_sys_file_offset_bits,
  654. [Number of bits in a file offset, on hosts where this is settable.],
  655. AC_SYS_LARGEFILE_TEST_INCLUDES)
  656. AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
  657. ac_cv_sys_large_files,
  658. [Define for large files, on AIX-style hosts.],
  659. AC_SYS_LARGEFILE_TEST_INCLUDES)
  660. AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
  661. ac_cv_sys_largefile_source,
  662. [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
  663. [#include <stdio.h>], [return !fseeko;])
  664. CFLAGS=$ac_save_cflags
  665. fi
  666. ])
  667. AC_DEFUN([AC_FUNC_FSEEKO],
  668. [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
  669. ac_cv_sys_largefile_source,
  670. [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
  671. [#include <stdio.h>], [return !fseeko;])
  672. # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
  673. # in glibc 2.1.3, but that breaks too many other things.
  674. # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
  675. AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko,
  676. [ac_cv_func_fseeko=no
  677. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[return fseeko && fseeko (stdin, 0, 0);]])],[ac_cv_func_fseeko=yes],[])])
  678. if test $ac_cv_func_fseeko != no; then
  679. AC_DEFINE(HAVE_FSEEKO, 1,
  680. [Define if fseeko (and presumably ftello) exists and is declared.])
  681. fi])
  682. dnl XXXXXXXXXXXXXXXXXX End Stolen (but modified) from GNU tar XXXXXXXXXXXXXX
  683. AC_DEFUN([AC_HAVE_LARGEFILES],
  684. [AC_CACHE_CHECK([if system supports Large Files at all], ac_cv_largefiles,
  685. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
  686. #include <sys/types.h>]], [[
  687. /*
  688. * Check that off_t can represent 2**63 - 1 correctly.
  689. * We can't simply "#define LARGE_OFF_T 9223372036854775807",
  690. * since some C++ compilers masquerading as C compilers
  691. * incorrectly reject 9223372036854775807.
  692. *
  693. * For MinGW, off64_t should be used and __MSVCRT_VERSION__ >= 0x0601
  694. * (msvcrt.dll version 6.10 or higher) is needed for _fstat64 and _stat64.
  695. */
  696. #ifdef __MINGW32__
  697. # define LARGE_OFF_T (((off64_t) 1 << 62) - 1 + ((off64_t) 1 << 62))
  698. #else
  699. # define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
  700. #endif
  701. int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
  702. && LARGE_OFF_T % 2147483647 == 1)
  703. ? 1 : -1];
  704. #ifdef __MINGW32__
  705. return !fseeko64;
  706. return !ftello64;
  707. #else
  708. return !fseeko;
  709. return !ftello;
  710. #endif]])],[ac_cv_largefiles=yes],[ac_cv_largefiles=no])])
  711. if test $ac_cv_largefiles = yes; then
  712. AC_DEFINE(HAVE_LARGEFILES, 1, [define if we have LFS])
  713. USE_LARGEFILES=1
  714. else
  715. USE_LARGEFILES=
  716. LFS_CFLAGS=
  717. fi
  718. AC_SUBST(USE_LARGEFILES)
  719. AC_SUBST(LFS_CFLAGS)
  720. ])
  721. dnl Checks for whether fseeko() is available in non large file mode
  722. dnl and whether there is a prototype for fseeko()
  723. dnl Defines HAVE_FSEEKO on success.
  724. AC_DEFUN([AC_SMALL_FSEEKO],
  725. [AC_CACHE_CHECK([for fseeko()], ac_cv_func_fseeko,
  726. [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[return !fseeko;]])],[ac_cv_func_fseeko=yes],[ac_cv_func_fseeko=no])])
  727. if test $ac_cv_func_fseeko = yes; then
  728. AC_DEFINE(HAVE_FSEEKO, 1, [define if fseeko() exists])
  729. fi])
  730. dnl Checks for whether ftello() is available in non large file mode
  731. dnl and whether there is a prototype for ftello()
  732. dnl Defines HAVE_FTELLO on success.
  733. AC_DEFUN([AC_SMALL_FTELLO],
  734. [AC_CACHE_CHECK([for ftello()], ac_cv_func_ftello,
  735. [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[return !ftello;]])],[ac_cv_func_ftello=yes],[ac_cv_func_ftello=no])])
  736. if test $ac_cv_func_ftello = yes; then
  737. AC_DEFINE(HAVE_FTELLO, 1, [define if ftello() exists])
  738. fi])
  739. dnl XXXXXXXXXXX End Stolen from cdrtools-2.01 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX