aclocal.m4 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  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_TRY_LINK([$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_TRY_RUN([
  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. ],
  203. [ $4=`cat conftestdata`
  204. AC_MSG_RESULT($$4)],
  205. [ AC_MSG_ERROR([*** Could not determine $3 version.]) ],
  206. [ $4=$6
  207. AC_MSG_RESULT([unknown (cross-compiling)]) ])
  208. CPPFLAGS=$ac_save_cppflags
  209. ])
  210. AC_DEFUN([LOC_CHECK_SHARE],[
  211. AC_CHECK_FILE($3/$1, [], ifelse($4,[],[
  212. AC_MSG_ERROR([*** Unable to locate $2 data files.])
  213. ], $4))
  214. ])
  215. AC_DEFUN([LOC_CHECK_VERSION_INT],[
  216. AC_MSG_CHECKING($3 version)
  217. ac_save_cppflags="$CPPFLAGS"
  218. CPPFLAGS="$5 $CPPFLAGS"
  219. AC_TRY_RUN([
  220. #include <stdio.h>
  221. #include <$1>
  222. int main(void) {
  223. FILE *fp = fopen("conftestdata","w");
  224. fprintf(fp, "%d", $2);
  225. return 0;
  226. }
  227. ],
  228. [ $4=`cat conftestdata`
  229. AC_MSG_RESULT($$4)],
  230. [ AC_MSG_ERROR([*** Could not determine $3 version.]) ],
  231. [ $4=$6
  232. AC_MSG_RESULT([unknown (cross-compiling)]) ])
  233. CPPFLAGS=$ac_save_cppflags
  234. ])
  235. dnl autoconf undefines "eval", so use "builtin([eval], ...)"
  236. AC_DEFUN([LOC_PAD],[$1[]ifelse(builtin([eval],len($1) > 23),1,[
  237. ],substr([ ],len($1)))])
  238. AC_DEFUN([LOC_ARG_WITH],[
  239. AC_ARG_WITH($1,
  240. LOC_PAD([ --with-$1])[support $2 functionality (default: ]ifelse([$3],,yes,[$3])[)],,
  241. [with_]patsubst([$1], -, _)[=]ifelse([$3],,yes,[$3]))
  242. ])
  243. AC_DEFUN([LOC_ARG_WITH_INC],[
  244. AC_ARG_WITH($1-includes,
  245. LOC_PAD([ --with-$1-includes=DIRS])[$2 include files are in DIRS])
  246. ])
  247. AC_DEFUN([LOC_ARG_WITH_LIB],[
  248. AC_ARG_WITH($1-libs,
  249. LOC_PAD([ --with-$1-libs=DIRS])[$2 library files are in DIRS])
  250. ])
  251. AC_DEFUN([LOC_ARG_WITH_LDFLAGS],[
  252. AC_ARG_WITH($1-ldflags,
  253. LOC_PAD([ --with-$1-ldflags=FLAGS])[$2 needs FLAGS when linking])
  254. ])
  255. AC_DEFUN([LOC_ARG_WITH_SHARE],[
  256. AC_ARG_WITH($1-share,
  257. LOC_PAD([ --with-$1-share=DIR])[$2 data files are in DIR])
  258. ])
  259. AC_DEFUN([LOC_ARG_WITH_FRAMEWORK],[
  260. AC_ARG_WITH($1-framework,
  261. LOC_PAD([ --with-$1-framework=DIR])[$2 framework is in DIR])
  262. ])
  263. AC_DEFUN([LOC_OPTIONAL],[
  264. AC_MSG_CHECKING(whether to build $1)
  265. if test -n "$USE_$2" ; then
  266. AC_MSG_RESULT(yes)
  267. BUILD_$3="$4"
  268. else
  269. AC_MSG_RESULT(no)
  270. BUILD_$3=
  271. fi
  272. AC_SUBST(BUILD_$3)
  273. ])
  274. dnl checks for complete floating-point support (infinity, NaN)
  275. define(LOC_FP_TEST,[
  276. #include <float.h>
  277. int main(void) {
  278. double one = 1.0;
  279. double zero = 0.0;
  280. if (one/zero > DBL_MAX) /* infinity */
  281. if (zero/zero != zero/zero) /* NaN */
  282. return 0;
  283. return 1;
  284. }
  285. ])
  286. AC_DEFUN([LOC_CHECK_FP_INF_NAN],[
  287. AC_MSG_CHECKING([for full floating-point support]$1)
  288. AC_TRY_RUN(LOC_FP_TEST,
  289. [ AC_MSG_RESULT(yes)
  290. $2],
  291. [ AC_MSG_RESULT(no)
  292. $3],
  293. [ AC_MSG_RESULT([unknown (cross-compiling)])
  294. $4]
  295. )
  296. ])
  297. dnl check whether the compiler supports the -mieee switch
  298. AC_DEFUN([LOC_CHECK_CC_MIEEE],[
  299. AC_MSG_CHECKING(whether "cc -mieee" works)
  300. ac_save_cflags=${CFLAGS}
  301. CFLAGS="$CFLAGS -mieee"
  302. AC_TRY_COMPILE(,,
  303. [ AC_MSG_RESULT(yes)
  304. IEEEFLAG="-mieee"],
  305. [ AC_MSG_RESULT(no)])
  306. CFLAGS=${ac_save_cflags}
  307. ])
  308. AC_DEFUN([LOC_MSG],[
  309. echo "$1"
  310. ])
  311. AC_DEFUN([LOC_PAD_26],[substr([ ],len($1))])
  312. AC_DEFUN([LOC_YES_NO],[if test -n "${$1}" ; then echo yes ; else echo no ; fi])
  313. AC_DEFUN([LOC_MSG_USE],[
  314. [echo " $1:]LOC_PAD_26($1)`LOC_YES_NO($2)`"])
  315. AC_DEFUN(LOC_EXEEXT,
  316. [AC_REQUIRE([AC_CYGWIN])
  317. AC_REQUIRE([AC_MINGW32])
  318. AC_MSG_CHECKING([for executable suffix])
  319. AC_CACHE_VAL(ac_cv_exeext,
  320. [if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
  321. ac_cv_exeext=.exe
  322. else
  323. ac_cv_exeext=no
  324. fi])
  325. EXEEXT=""
  326. test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
  327. AC_MSG_RESULT(${ac_cv_exeext})
  328. dnl Setting ac_exeext will implicitly change the ac_link command.
  329. ac_exeext=$EXEEXT
  330. AC_SUBST(EXEEXT)])
  331. #------------------------------------------------------------------------
  332. # SC_ENABLE_SHARED --
  333. #
  334. # Allows the building of shared libraries
  335. #
  336. # Arguments:
  337. # none
  338. #
  339. # Results:
  340. #
  341. # Adds the following arguments to configure:
  342. # --enable-shared=yes|no
  343. #
  344. # Defines the following vars:
  345. # STATIC_BUILD Used for building import/export libraries
  346. # on Windows.
  347. #
  348. # Sets the following vars:
  349. # SHARED_BUILD Value of 1 or 0
  350. #------------------------------------------------------------------------
  351. AC_DEFUN([SC_ENABLE_SHARED], [
  352. AC_MSG_CHECKING([how to build libraries])
  353. AC_ARG_ENABLE(shared,
  354. [ --enable-shared build and link with shared libraries [--enable-shared]],
  355. [shared_ok=$enableval], [shared_ok=yes])
  356. if test "${enable_shared+set}" = set; then
  357. enableval="$enable_shared"
  358. shared_ok=$enableval
  359. else
  360. shared_ok=yes
  361. fi
  362. if test "$shared_ok" = "yes" ; then
  363. AC_MSG_RESULT([shared])
  364. SHARED_BUILD=1
  365. GRASS_LIBRARY_TYPE='shlib'
  366. else
  367. AC_MSG_RESULT([static])
  368. SHARED_BUILD=0
  369. AC_DEFINE(STATIC_BUILD)
  370. GRASS_LIBRARY_TYPE='stlib'
  371. fi
  372. AC_SUBST(GRASS_LIBRARY_TYPE)
  373. ])
  374. #--------------------------------------------------------------------
  375. # SC_CONFIG_CFLAGS
  376. #
  377. # Try to determine the proper flags to pass to the compiler
  378. # for building shared libraries and other such nonsense.
  379. #
  380. # Arguments:
  381. # none
  382. #
  383. # Results:
  384. #
  385. # Defines and substitutes the following vars:
  386. #
  387. # LDFLAGS - Flags to pass to the compiler when linking object
  388. # files into an executable application binary such
  389. # as tclsh.
  390. # LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /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. Could
  394. # be the same as CC_SEARCH_FLAGS if ${CC} is used to link.
  395. # CC_SEARCH_FLAGS-Flags to pass to ${CC}, such as "-Wl,-rpath,/usr/local/tcl/lib",
  396. # that tell the run-time dynamic linker where to look
  397. # for shared libraries such as libtcl.so. Depends on
  398. # the variable LIB_RUNTIME_DIR in the Makefile.
  399. # STLIB_LD - Base command to use for combining object files
  400. # into a static library.
  401. # SHLIB_CFLAGS - Flags to pass to cc when compiling the components
  402. # of a shared library (may request position-independent
  403. # code, among other things).
  404. # SHLIB_LD - Base command to use for combining object files
  405. # into a shared library.
  406. # SHLIB_LD_FLAGS -Flags to pass when building a shared library. This
  407. # differes from the SHLIB_CFLAGS as it is not used
  408. # when building object files or executables.
  409. # SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
  410. # creating shared libraries. This symbol typically
  411. # goes at the end of the "ld" commands that build
  412. # shared libraries. The value of the symbol is
  413. # "${LIBS}" if all of the dependent libraries should
  414. # be specified when creating a shared library. If
  415. # dependent libraries should not be specified (as on
  416. # SunOS 4.x, where they cause the link to fail, or in
  417. # general if Tcl and Tk aren't themselves shared
  418. # libraries), then this symbol has an empty string
  419. # as its value.
  420. # SHLIB_SUFFIX - Suffix to use for the names of dynamically loadable
  421. # extensions. An empty string means we don't know how
  422. # to use shared libraries on this platform.
  423. #
  424. #--------------------------------------------------------------------
  425. AC_DEFUN([SC_CONFIG_CFLAGS], [
  426. SHLIB_CFLAGS=""
  427. SHLIB_LD_FLAGS=""
  428. SHLIB_SUFFIX=""
  429. SHLIB_LD=""
  430. STLIB_LD='${AR} cr'
  431. STLIB_SUFFIX='.a'
  432. GRASS_TRIM_DOTS='`echo ${LIB_VER} | tr -d .`'
  433. GRASS_LIB_VERSIONS_OK=ok
  434. LDFLAGS=""
  435. LD_SEARCH_FLAGS=""
  436. LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
  437. case $host in
  438. *-linux-* | *-gnu* | *-kfreebsd*-gnu)
  439. SHLIB_CFLAGS="-fPIC"
  440. SHLIB_LD_FLAGS="-Wl,-soname,\$(notdir \$[@])"
  441. SHLIB_SUFFIX=".so"
  442. SHLIB_LD="${CC} -shared"
  443. LDFLAGS="-Wl,--export-dynamic"
  444. LD_SEARCH_FLAGS='-Wl,-rpath-link,${LIB_RUNTIME_DIR}'
  445. LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
  446. ;;
  447. *-pc-cygwin)
  448. SHLIB_SUFFIX=".dll"
  449. SHLIB_LD="${CC} -shared"
  450. LDFLAGS="-Wl,--export-dynamic"
  451. LD_LIBRARY_PATH_VAR="PATH"
  452. ;;
  453. *-pc-mingw32 | *-w64-mingw32 | *-pc-msys)
  454. SHLIB_SUFFIX=".dll"
  455. SHLIB_LD="${CC} -shared"
  456. LDFLAGS="-Wl,--export-dynamic,--enable-runtime-pseudo-reloc"
  457. LD_LIBRARY_PATH_VAR="PATH"
  458. ;;
  459. *-apple-darwin*)
  460. SHLIB_CFLAGS="-fno-common"
  461. SHLIB_SUFFIX=".dylib"
  462. 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}"
  463. LDFLAGS="-Wl,-rpath,${INSTDIR}/lib,-rpath,\${GISBASE}/lib"
  464. LD_LIBRARY_PATH_VAR="LD_RUN_PATH"
  465. ;;
  466. *-sun-solaris*)
  467. # Note: If _REENTRANT isn't defined, then Solaris
  468. # won't define thread-safe library routines.
  469. AC_DEFINE(_REENTRANT)
  470. AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
  471. # Note: need the LIBS below, otherwise Tk won't find Tcl's
  472. # symbols when dynamically loaded into tclsh.
  473. if test "$GCC" = "yes" ; then
  474. SHLIB_CFLAGS="-fPIC"
  475. SHLIB_LD="$CC -shared"
  476. LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
  477. else
  478. SHLIB_CFLAGS="-KPIC"
  479. SHLIB_LD="/usr/ccs/bin/ld -G -z text"
  480. LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
  481. fi
  482. SHLIB_SUFFIX=".so"
  483. LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
  484. ;;
  485. *-solaris2*)
  486. # Note: Solaris is as of 2010 Oracle Solaris, not Sun Solaris
  487. # Oracle Solaris derives from Solaris 2
  488. # derives from SunOS 5
  489. # derives from UNIX System V Release 4
  490. # Note: If _REENTRANT isn't defined, then Solaris
  491. # won't define thread-safe library routines.
  492. AC_DEFINE(_REENTRANT)
  493. AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
  494. # Note: need the LIBS below, otherwise Tk won't find Tcl's
  495. # symbols when dynamically loaded into tclsh.
  496. if test "$GCC" = "yes" ; then
  497. SHLIB_CFLAGS="-fPIC"
  498. SHLIB_LD="$CC -shared"
  499. LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
  500. else
  501. SHLIB_CFLAGS="-KPIC"
  502. SHLIB_LD="/usr/ccs/bin/ld -G -z text"
  503. LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
  504. fi
  505. SHLIB_SUFFIX=".so"
  506. LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
  507. ;;
  508. *-freebsd*)
  509. # NOTE: only FreeBSD 4+ is supported
  510. # FreeBSD 3.* and greater have ELF.
  511. SHLIB_CFLAGS="-fPIC"
  512. #SHLIB_LD="ld -Bshareable -x"
  513. SHLIB_LD="${CC} -shared"
  514. SHLIB_LD_FLAGS="-Wl,-soname,\$(notdir \$[@])"
  515. SHLIB_SUFFIX=".so"
  516. LDFLAGS="-export-dynamic"
  517. #LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
  518. LD_SEARCH_FLAGS='-Wl,-rpath-link,${LIB_RUNTIME_DIR}'
  519. # TODO: add optional pthread support with any combination of:
  520. # CFLAGS="$CFLAGS -pthread"
  521. # LDFLAGS="$LDFLAGS -lpthread"
  522. # AC_DEFINE(_REENTRANT)
  523. # AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
  524. ;;
  525. *-netbsd*)
  526. # NetBSD has ELF.
  527. SHLIB_CFLAGS="-fPIC"
  528. SHLIB_LD="${CC} -shared"
  529. SHLIB_LD_LIBS="${LIBS}"
  530. LDFLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR} -export-dynamic'
  531. SHLIB_LD_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR} -export-dynamic'
  532. LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR} -L${LIB_RUNTIME_DIR}'
  533. # some older NetBSD versions do not handle version numbers with dots.
  534. #STLIB_SUFFIX='${GRASS_TRIM_DOTS}.a'
  535. #SHLIB_SUFFIX='${GRASS_TRIM_DOTS}.so'
  536. #GRASS_LIB_VERSIONS_OK=nodots
  537. # NetBSD 6 does handle version numbers with dots.
  538. STLIB_SUFFIX=".a"
  539. SHLIB_SUFFIX=".so"
  540. # TODO: add optional pthread support with any combination of:
  541. # CFLAGS="$CFLAGS -pthread"
  542. # LDFLAGS="$LDFLAGS -lpthread"
  543. # AC_DEFINE(_REENTRANT)
  544. # AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
  545. ;;
  546. *aix*)
  547. # NOTE: do we need to support aix < 6 ?
  548. LIBS="$LIBS -lc"
  549. SHLIB_CFLAGS=""
  550. LDFLAGS=""
  551. if test "$GCC" = "yes" ; then
  552. SHLIB_CFLAGS="-fPIC"
  553. SHLIB_LD="$CC -shared"
  554. LD_SEARCH_FLAGS='-Wl,-bsvr4,-R,${LIB_RUNTIME_DIR}'
  555. else
  556. # assume xlc
  557. SHLIB_CFLAGS="-qmkshrobj"
  558. SHLIB_LD="$CC -shared"
  559. LD_SEARCH_FLAGS='-Wl,-bsvr4,-R,${LIB_RUNTIME_DIR}'
  560. fi
  561. SHLIB_SUFFIX=".so"
  562. LD_LIBRARY_PATH_VAR="LIBPATH"
  563. GRASS_NEEDS_EXP_FILE=1
  564. GRASS_EXPORT_FILE_SUFFIX='${LIB_VER}.exp'
  565. ;;
  566. *)
  567. AC_MSG_ERROR([***Unknown platform: $host***])
  568. ;;
  569. esac
  570. AC_SUBST(LDFLAGS)
  571. AC_SUBST(LD_SEARCH_FLAGS)
  572. AC_SUBST(LD_LIBRARY_PATH_VAR)
  573. AC_SUBST(SHLIB_LD)
  574. AC_SUBST(SHLIB_LD_FLAGS)
  575. AC_SUBST(SHLIB_CFLAGS)
  576. AC_SUBST(SHLIB_SUFFIX)
  577. AC_SUBST(STLIB_LD)
  578. AC_SUBST(STLIB_SUFFIX)
  579. ])
  580. dnl XXXX Begin Stolen from cdrtools-2.01
  581. dnl XXXX by Joerg Schilling <schilling fokus fraunhofer de> et al. XXXXXXXXX
  582. dnl XXXXXXXXX Begin Stolen (but modified) from GNU tar XXXXXXXXXXXXXXXXXXXXX
  583. dnl Changes:
  584. dnl One line has been changed to: [ac_save_CC="${CC-cc}" to default to "'cc"
  585. dnl AC_SYS_LARGEFILE_MACRO_VALUE test moved from AC_FUNC_FSEEKO into AC_SYS_LARGEFILE
  586. dnl Do not call AC_FUNC_FSEEKO because it does not check whether fseeko() is
  587. dnl available on non Large File mode. There are additional tests for fseeko()/ftello()
  588. dnl inside the AC_HAVE_LARGEFILES test.
  589. dnl largefile_cc_opt definition added
  590. #serial 18
  591. dnl By default, many hosts won't let programs access large files;
  592. dnl one must use special compiler options to get large-file access to work.
  593. dnl For more details about this brain damage please see:
  594. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  595. dnl Written by Paul Eggert <eggert@twinsun.com>.
  596. dnl Internal subroutine of AC_SYS_LARGEFILE.
  597. dnl AC_SYS_LARGEFILE_TEST_INCLUDES
  598. AC_DEFUN([AC_SYS_LARGEFILE_TEST_INCLUDES],
  599. [[#include <sys/types.h>
  600. /* Check that off_t can represent 2**63 - 1 correctly.
  601. We can't simply "#define LARGE_OFF_T 9223372036854775807",
  602. since some C++ compilers masquerading as C compilers
  603. incorrectly reject 9223372036854775807. */
  604. # define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
  605. int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
  606. && LARGE_OFF_T % 2147483647 == 1)
  607. ? 1 : -1];
  608. ]])
  609. dnl Internal subroutine of AC_SYS_LARGEFILE.
  610. dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY)
  611. AC_DEFUN([AC_SYS_LARGEFILE_MACRO_VALUE],
  612. [AC_CACHE_CHECK([for $1 value needed for large files], $3,
  613. [$3=no
  614. AC_TRY_COMPILE([$5],
  615. [$6],
  616. ,
  617. [AC_TRY_COMPILE([#define $1 $2]
  618. [$5]
  619. ,
  620. [$6],
  621. [$3=$2])])])
  622. if test "[$]$3" != no; then
  623. AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
  624. if test "$LFS_CFLAGS" ; then
  625. LFS_CFLAGS="$LFS_CFLAGS -D$1=[$]$3"
  626. else
  627. LFS_CFLAGS="-D$1=[$]$3"
  628. fi
  629. fi])
  630. AC_DEFUN([AC_SYS_LARGEFILE],
  631. [AC_ARG_ENABLE(largefile,
  632. [ --disable-largefile omit support for large files (LFS)])
  633. LFS_CFLAGS=
  634. if test "$enable_largefile" != no; then
  635. ac_save_cflags=$CFLAGS
  636. if test "`which getconf 2>&5`" ; then
  637. LFS_CFLAGS=`getconf LFS_CFLAGS 2>&5`
  638. CFLAGS="$LFS_CFLAGS $ac_save_cflags"
  639. fi
  640. AC_CACHE_CHECK([for special C compiler options needed for large files],
  641. ac_cv_sys_largefile_CC,
  642. [ac_cv_sys_largefile_CC=no
  643. largefile_cc_opt=""
  644. if test "$GCC" != yes; then
  645. # IRIX 6.2 and later do not support large files by default,
  646. # so use the C compiler's -n32 option if that helps.
  647. AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
  648. [ac_save_CC="${CC-cc}"
  649. CC="$CC -n32"
  650. AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
  651. ac_cv_sys_largefile_CC=' -n32')
  652. CC="$ac_save_CC"])
  653. fi])
  654. if test "$ac_cv_sys_largefile_CC" != no; then
  655. CC="$CC$ac_cv_sys_largefile_CC"
  656. largefile_cc_opt="$ac_cv_sys_largefile_CC"
  657. if test "$LFS_CFLAGS" ; then
  658. LFS_CFLAGS="$LFS_CFLAGS $ac_cv_sys_largefile_CC"
  659. else
  660. LFS_CFLAGS="$ac_cv_sys_largefile_CC"
  661. CFLAGS="$LFS_CFLAGS $ac_save_cflags"
  662. fi
  663. fi
  664. AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
  665. ac_cv_sys_file_offset_bits,
  666. [Number of bits in a file offset, on hosts where this is settable.],
  667. AC_SYS_LARGEFILE_TEST_INCLUDES)
  668. AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
  669. ac_cv_sys_large_files,
  670. [Define for large files, on AIX-style hosts.],
  671. AC_SYS_LARGEFILE_TEST_INCLUDES)
  672. AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
  673. ac_cv_sys_largefile_source,
  674. [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
  675. [#include <stdio.h>], [return !fseeko;])
  676. CFLAGS=$ac_save_cflags
  677. fi
  678. ])
  679. AC_DEFUN([AC_FUNC_FSEEKO],
  680. [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
  681. ac_cv_sys_largefile_source,
  682. [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
  683. [#include <stdio.h>], [return !fseeko;])
  684. # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
  685. # in glibc 2.1.3, but that breaks too many other things.
  686. # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
  687. AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko,
  688. [ac_cv_func_fseeko=no
  689. AC_TRY_LINK([#include <stdio.h>],
  690. [return fseeko && fseeko (stdin, 0, 0);],
  691. [ac_cv_func_fseeko=yes])])
  692. if test $ac_cv_func_fseeko != no; then
  693. AC_DEFINE(HAVE_FSEEKO, 1,
  694. [Define if fseeko (and presumably ftello) exists and is declared.])
  695. fi])
  696. dnl XXXXXXXXXXXXXXXXXX End Stolen (but modified) from GNU tar XXXXXXXXXXXXXX
  697. AC_DEFUN([AC_HAVE_LARGEFILES],
  698. [AC_CACHE_CHECK([if system supports Large Files at all], ac_cv_largefiles,
  699. [AC_TRY_COMPILE([#include <stdio.h>
  700. #include <sys/types.h>],
  701. [
  702. /*
  703. * Check that off_t can represent 2**63 - 1 correctly.
  704. * We can't simply "#define LARGE_OFF_T 9223372036854775807",
  705. * since some C++ compilers masquerading as C compilers
  706. * incorrectly reject 9223372036854775807.
  707. *
  708. * For MinGW, off64_t should be used and __MSVCRT_VERSION__ >= 0x0601
  709. * (msvcrt.dll version 6.10 or higher) is needed for _fstat64 and _stat64.
  710. */
  711. #ifdef __MINGW32__
  712. # define LARGE_OFF_T (((off64_t) 1 << 62) - 1 + ((off64_t) 1 << 62))
  713. #else
  714. # define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
  715. #endif
  716. int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
  717. && LARGE_OFF_T % 2147483647 == 1)
  718. ? 1 : -1];
  719. #ifdef __MINGW32__
  720. return !fseeko64;
  721. return !ftello64;
  722. #else
  723. return !fseeko;
  724. return !ftello;
  725. #endif],
  726. [ac_cv_largefiles=yes],
  727. [ac_cv_largefiles=no])])
  728. if test $ac_cv_largefiles = yes; then
  729. AC_DEFINE(HAVE_LARGEFILES)
  730. USE_LARGEFILES=1
  731. else
  732. USE_LARGEFILES=
  733. LFS_CFLAGS=
  734. fi
  735. AC_SUBST(USE_LARGEFILES)
  736. AC_SUBST(LFS_CFLAGS)
  737. ])
  738. dnl Checks for whether fseeko() is available in non large file mode
  739. dnl and whether there is a prototype for fseeko()
  740. dnl Defines HAVE_FSEEKO on success.
  741. AC_DEFUN([AC_SMALL_FSEEKO],
  742. [AC_CACHE_CHECK([for fseeko()], ac_cv_func_fseeko,
  743. [AC_TRY_LINK([#include <stdio.h>],
  744. [return !fseeko;],
  745. [ac_cv_func_fseeko=yes],
  746. [ac_cv_func_fseeko=no])])
  747. if test $ac_cv_func_fseeko = yes; then
  748. AC_DEFINE(HAVE_FSEEKO)
  749. fi])
  750. dnl Checks for whether ftello() is available in non large file mode
  751. dnl and whether there is a prototype for ftello()
  752. dnl Defines HAVE_FTELLO on success.
  753. AC_DEFUN([AC_SMALL_FTELLO],
  754. [AC_CACHE_CHECK([for ftello()], ac_cv_func_ftello,
  755. [AC_TRY_LINK([#include <stdio.h>],
  756. [return !ftello;],
  757. [ac_cv_func_ftello=yes],
  758. [ac_cv_func_ftello=no])])
  759. if test $ac_cv_func_ftello = yes; then
  760. AC_DEFINE(HAVE_FTELLO)
  761. fi])
  762. dnl XXXXXXXXXXX End Stolen from cdrtools-2.01 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX