aclocal.m4 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  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 \${INST_DIR}/lib/lib\${LIB_NAME}\${SHLIB_SUFFIX}"
  463. LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
  464. ;;
  465. *-sun-solaris*)
  466. # Note: If _REENTRANT isn't defined, then Solaris
  467. # won't define thread-safe library routines.
  468. AC_DEFINE(_REENTRANT)
  469. AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
  470. # Note: need the LIBS below, otherwise Tk won't find Tcl's
  471. # symbols when dynamically loaded into tclsh.
  472. if test "$GCC" = "yes" ; then
  473. SHLIB_CFLAGS="-fPIC"
  474. SHLIB_LD="$CC -shared"
  475. LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
  476. else
  477. SHLIB_CFLAGS="-KPIC"
  478. SHLIB_LD="/usr/ccs/bin/ld -G -z text"
  479. LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
  480. fi
  481. SHLIB_SUFFIX=".so"
  482. LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
  483. ;;
  484. *-solaris2*)
  485. # Note: Solaris is as of 2010 Oracle Solaris, not Sun Solaris
  486. # Oracle Solaris derives from Solaris 2
  487. # derives from SunOS 5
  488. # derives from UNIX System V Release 4
  489. # Note: If _REENTRANT isn't defined, then Solaris
  490. # won't define thread-safe library routines.
  491. AC_DEFINE(_REENTRANT)
  492. AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
  493. # Note: need the LIBS below, otherwise Tk won't find Tcl's
  494. # symbols when dynamically loaded into tclsh.
  495. if test "$GCC" = "yes" ; then
  496. SHLIB_CFLAGS="-fPIC"
  497. SHLIB_LD="$CC -shared"
  498. LD_SEARCH_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
  499. else
  500. SHLIB_CFLAGS="-KPIC"
  501. SHLIB_LD="/usr/ccs/bin/ld -G -z text"
  502. LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
  503. fi
  504. SHLIB_SUFFIX=".so"
  505. LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
  506. ;;
  507. *-freebsd*)
  508. # NOTE: only FreeBSD 4+ is supported
  509. # FreeBSD 3.* and greater have ELF.
  510. SHLIB_CFLAGS="-fPIC"
  511. #SHLIB_LD="ld -Bshareable -x"
  512. SHLIB_LD="${CC} -shared"
  513. SHLIB_SUFFIX=".so"
  514. LDFLAGS="-export-dynamic"
  515. #LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
  516. LD_SEARCH_FLAGS='-Wl,-rpath-link,${LIB_RUNTIME_DIR}'
  517. # TODO: add optional pthread support with any combination of:
  518. # CFLAGS="$CFLAGS -pthread"
  519. # LDFLAGS="$LDFLAGS -lpthread"
  520. # AC_DEFINE(_REENTRANT)
  521. # AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
  522. ;;
  523. *-netbsd*)
  524. # NetBSD has ELF.
  525. SHLIB_CFLAGS="-fPIC"
  526. SHLIB_LD="${CC} -shared"
  527. SHLIB_LD_LIBS="${LIBS}"
  528. LDFLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR} -export-dynamic'
  529. SHLIB_LD_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR} -export-dynamic'
  530. LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR} -L${LIB_RUNTIME_DIR}'
  531. # some older NetBSD versions do not handle version numbers with dots.
  532. #STLIB_SUFFIX='${GRASS_TRIM_DOTS}.a'
  533. #SHLIB_SUFFIX='${GRASS_TRIM_DOTS}.so'
  534. #GRASS_LIB_VERSIONS_OK=nodots
  535. # NetBSD 6 does handle version numbers with dots.
  536. STLIB_SUFFIX=".a"
  537. SHLIB_SUFFIX=".so"
  538. # TODO: add optional pthread support with any combination of:
  539. # CFLAGS="$CFLAGS -pthread"
  540. # LDFLAGS="$LDFLAGS -lpthread"
  541. # AC_DEFINE(_REENTRANT)
  542. # AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
  543. ;;
  544. *aix*)
  545. # NOTE: do we need to support aix < 6 ?
  546. LIBS="$LIBS -lc"
  547. SHLIB_CFLAGS=""
  548. LDFLAGS=""
  549. if test "$GCC" = "yes" ; then
  550. SHLIB_CFLAGS="-fPIC"
  551. SHLIB_LD="$CC -shared"
  552. LD_SEARCH_FLAGS='-Wl,-bsvr4,-R,${LIB_RUNTIME_DIR}'
  553. else
  554. # assume xlc
  555. SHLIB_CFLAGS="-qmkshrobj"
  556. SHLIB_LD="$CC -shared"
  557. LD_SEARCH_FLAGS='-Wl,-bsvr4,-R,${LIB_RUNTIME_DIR}'
  558. fi
  559. SHLIB_SUFFIX=".so"
  560. LD_LIBRARY_PATH_VAR="LIBPATH"
  561. GRASS_NEEDS_EXP_FILE=1
  562. GRASS_EXPORT_FILE_SUFFIX='${LIB_VER}.exp'
  563. ;;
  564. *)
  565. AC_MSG_ERROR([***Unknown platform: $host***])
  566. ;;
  567. esac
  568. AC_SUBST(LDFLAGS)
  569. AC_SUBST(LD_SEARCH_FLAGS)
  570. AC_SUBST(LD_LIBRARY_PATH_VAR)
  571. AC_SUBST(SHLIB_LD)
  572. AC_SUBST(SHLIB_LD_FLAGS)
  573. AC_SUBST(SHLIB_CFLAGS)
  574. AC_SUBST(SHLIB_SUFFIX)
  575. AC_SUBST(STLIB_LD)
  576. AC_SUBST(STLIB_SUFFIX)
  577. ])
  578. dnl XXXX Begin Stolen from cdrtools-2.01
  579. dnl XXXX by Joerg Schilling <schilling fokus fraunhofer de> et al. XXXXXXXXX
  580. dnl XXXXXXXXX Begin Stolen (but modified) from GNU tar XXXXXXXXXXXXXXXXXXXXX
  581. dnl Changes:
  582. dnl One line has been changed to: [ac_save_CC="${CC-cc}" to default to "'cc"
  583. dnl AC_SYS_LARGEFILE_MACRO_VALUE test moved from AC_FUNC_FSEEKO into AC_SYS_LARGEFILE
  584. dnl Do not call AC_FUNC_FSEEKO because it does not check whether fseeko() is
  585. dnl available on non Large File mode. There are additional tests for fseeko()/ftello()
  586. dnl inside the AC_HAVE_LARGEFILES test.
  587. dnl largefile_cc_opt definition added
  588. #serial 18
  589. dnl By default, many hosts won't let programs access large files;
  590. dnl one must use special compiler options to get large-file access to work.
  591. dnl For more details about this brain damage please see:
  592. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  593. dnl Written by Paul Eggert <eggert@twinsun.com>.
  594. dnl Internal subroutine of AC_SYS_LARGEFILE.
  595. dnl AC_SYS_LARGEFILE_TEST_INCLUDES
  596. AC_DEFUN([AC_SYS_LARGEFILE_TEST_INCLUDES],
  597. [[#include <sys/types.h>
  598. /* Check that off_t can represent 2**63 - 1 correctly.
  599. We can't simply "#define LARGE_OFF_T 9223372036854775807",
  600. since some C++ compilers masquerading as C compilers
  601. incorrectly reject 9223372036854775807. */
  602. # define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
  603. int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
  604. && LARGE_OFF_T % 2147483647 == 1)
  605. ? 1 : -1];
  606. ]])
  607. dnl Internal subroutine of AC_SYS_LARGEFILE.
  608. dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY)
  609. AC_DEFUN([AC_SYS_LARGEFILE_MACRO_VALUE],
  610. [AC_CACHE_CHECK([for $1 value needed for large files], $3,
  611. [$3=no
  612. AC_TRY_COMPILE([$5],
  613. [$6],
  614. ,
  615. [AC_TRY_COMPILE([#define $1 $2]
  616. [$5]
  617. ,
  618. [$6],
  619. [$3=$2])])])
  620. if test "[$]$3" != no; then
  621. AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
  622. if test "$LFS_CFLAGS" ; then
  623. LFS_CFLAGS="$LFS_CFLAGS -D$1=[$]$3"
  624. else
  625. LFS_CFLAGS="-D$1=[$]$3"
  626. fi
  627. fi])
  628. AC_DEFUN([AC_SYS_LARGEFILE],
  629. [AC_ARG_ENABLE(largefile,
  630. [ --disable-largefile omit support for large files (LFS)])
  631. LFS_CFLAGS=
  632. if test "$enable_largefile" != no; then
  633. ac_save_cflags=$CFLAGS
  634. if test "`which getconf 2>&5`" ; then
  635. LFS_CFLAGS=`getconf LFS_CFLAGS 2>&5`
  636. CFLAGS="$LFS_CFLAGS $ac_save_cflags"
  637. fi
  638. AC_CACHE_CHECK([for special C compiler options needed for large files],
  639. ac_cv_sys_largefile_CC,
  640. [ac_cv_sys_largefile_CC=no
  641. largefile_cc_opt=""
  642. if test "$GCC" != yes; then
  643. # IRIX 6.2 and later do not support large files by default,
  644. # so use the C compiler's -n32 option if that helps.
  645. AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
  646. [ac_save_CC="${CC-cc}"
  647. CC="$CC -n32"
  648. AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
  649. ac_cv_sys_largefile_CC=' -n32')
  650. CC="$ac_save_CC"])
  651. fi])
  652. if test "$ac_cv_sys_largefile_CC" != no; then
  653. CC="$CC$ac_cv_sys_largefile_CC"
  654. largefile_cc_opt="$ac_cv_sys_largefile_CC"
  655. if test "$LFS_CFLAGS" ; then
  656. LFS_CFLAGS="$LFS_CFLAGS $ac_cv_sys_largefile_CC"
  657. else
  658. LFS_CFLAGS="$ac_cv_sys_largefile_CC"
  659. CFLAGS="$LFS_CFLAGS $ac_save_cflags"
  660. fi
  661. fi
  662. AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
  663. ac_cv_sys_file_offset_bits,
  664. [Number of bits in a file offset, on hosts where this is settable.],
  665. AC_SYS_LARGEFILE_TEST_INCLUDES)
  666. AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
  667. ac_cv_sys_large_files,
  668. [Define for large files, on AIX-style hosts.],
  669. AC_SYS_LARGEFILE_TEST_INCLUDES)
  670. AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
  671. ac_cv_sys_largefile_source,
  672. [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
  673. [#include <stdio.h>], [return !fseeko;])
  674. CFLAGS=$ac_save_cflags
  675. fi
  676. ])
  677. AC_DEFUN([AC_FUNC_FSEEKO],
  678. [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
  679. ac_cv_sys_largefile_source,
  680. [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
  681. [#include <stdio.h>], [return !fseeko;])
  682. # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
  683. # in glibc 2.1.3, but that breaks too many other things.
  684. # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
  685. AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko,
  686. [ac_cv_func_fseeko=no
  687. AC_TRY_LINK([#include <stdio.h>],
  688. [return fseeko && fseeko (stdin, 0, 0);],
  689. [ac_cv_func_fseeko=yes])])
  690. if test $ac_cv_func_fseeko != no; then
  691. AC_DEFINE(HAVE_FSEEKO, 1,
  692. [Define if fseeko (and presumably ftello) exists and is declared.])
  693. fi])
  694. dnl XXXXXXXXXXXXXXXXXX End Stolen (but modified) from GNU tar XXXXXXXXXXXXXX
  695. AC_DEFUN([AC_HAVE_LARGEFILES],
  696. [AC_CACHE_CHECK([if system supports Large Files at all], ac_cv_largefiles,
  697. [AC_TRY_COMPILE([#include <stdio.h>
  698. #include <sys/types.h>],
  699. [
  700. /*
  701. * Check that off_t can represent 2**63 - 1 correctly.
  702. * We can't simply "#define LARGE_OFF_T 9223372036854775807",
  703. * since some C++ compilers masquerading as C compilers
  704. * incorrectly reject 9223372036854775807.
  705. *
  706. * For MinGW, off64_t should be used and __MSVCRT_VERSION__ >= 0x0601
  707. * (msvcrt.dll version 6.10 or higher) is needed for _fstat64 and _stat64.
  708. */
  709. #ifdef __MINGW32__
  710. # define LARGE_OFF_T (((off64_t) 1 << 62) - 1 + ((off64_t) 1 << 62))
  711. #else
  712. # define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
  713. #endif
  714. int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
  715. && LARGE_OFF_T % 2147483647 == 1)
  716. ? 1 : -1];
  717. #ifdef __MINGW32__
  718. return !fseeko64;
  719. return !ftello64;
  720. #else
  721. return !fseeko;
  722. return !ftello;
  723. #endif],
  724. [ac_cv_largefiles=yes],
  725. [ac_cv_largefiles=no])])
  726. if test $ac_cv_largefiles = yes; then
  727. AC_DEFINE(HAVE_LARGEFILES)
  728. USE_LARGEFILES=1
  729. else
  730. USE_LARGEFILES=
  731. LFS_CFLAGS=
  732. fi
  733. AC_SUBST(USE_LARGEFILES)
  734. AC_SUBST(LFS_CFLAGS)
  735. ])
  736. dnl Checks for whether fseeko() is available in non large file mode
  737. dnl and whether there is a prototype for fseeko()
  738. dnl Defines HAVE_FSEEKO on success.
  739. AC_DEFUN([AC_SMALL_FSEEKO],
  740. [AC_CACHE_CHECK([for fseeko()], ac_cv_func_fseeko,
  741. [AC_TRY_LINK([#include <stdio.h>],
  742. [return !fseeko;],
  743. [ac_cv_func_fseeko=yes],
  744. [ac_cv_func_fseeko=no])])
  745. if test $ac_cv_func_fseeko = yes; then
  746. AC_DEFINE(HAVE_FSEEKO)
  747. fi])
  748. dnl Checks for whether ftello() is available in non large file mode
  749. dnl and whether there is a prototype for ftello()
  750. dnl Defines HAVE_FTELLO on success.
  751. AC_DEFUN([AC_SMALL_FTELLO],
  752. [AC_CACHE_CHECK([for ftello()], ac_cv_func_ftello,
  753. [AC_TRY_LINK([#include <stdio.h>],
  754. [return !ftello;],
  755. [ac_cv_func_ftello=yes],
  756. [ac_cv_func_ftello=no])])
  757. if test $ac_cv_func_ftello = yes; then
  758. AC_DEFINE(HAVE_FTELLO)
  759. fi])
  760. dnl XXXXXXXXXXX End Stolen from cdrtools-2.01 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX