acinclude.m4 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. ## ----------------------------------------- ##
  2. ## Find how to suppress newlines with echo. ##
  3. ## ----------------------------------------- ##
  4. # Once this macro is called, you may output with no echo in a Makefile or
  5. # script using: echo @ECHO_N@ "STRING_TO_OUTPUT@ECHO_C@".
  6. AC_DEFUN(fp_PROG_ECHO,
  7. [AC_MSG_CHECKING(how to suppress newlines using echo)
  8. AC_CACHE_VAL(fp_cv_prog_echo_nonl,
  9. [if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
  10. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
  11. fp_cv_prog_echo_nonl=no
  12. else
  13. fp_cv_prog_echo_nonl=option
  14. fi
  15. else
  16. fp_cv_prog_echo_nonl=escape
  17. fi
  18. ])
  19. AC_MSG_RESULT($fp_cv_prog_echo_nonl)
  20. case $fp_cv_prog_echo_nonl in
  21. no) ECHO_N= ECHO_C= ;;
  22. option) ECHO_N=-n ECHO_C= ;;
  23. escape) ECHO_N= ECHO_C='\c' ;;
  24. esac
  25. AC_SUBST(ECHO_N)dnl
  26. AC_SUBST(ECHO_C)dnl
  27. ])
  28. ## ------------------------------------------- ##
  29. ## Check if --with-included-malloc was given. ##
  30. ## From Franc,ois Pinard ##
  31. ## ------------------------------------------- ##
  32. # In 1992, Michael Bushnell (now Thomas Bushnell <[email protected]>)
  33. # devised a test for avoiding HP/UX malloc and using GNU malloc instead.
  34. # Bruno Haible <[email protected]> recycled this
  35. # test for CLISP Common LISP and extended it to cover broken mallocs from
  36. # Sun and SGI. I (<[email protected]>) reworked it a little so
  37. # it is independent of config.guess, and overridable by the installer.
  38. # On IRIX 5.2, libc malloc is broken, but the -lmalloc one was usable.
  39. # So in my packages, I once unconditionally used -lmalloc if it existed.
  40. # This does not do anymore, because the -lmalloc malloc is broken on
  41. # Solaris 2.4 to 2.5.1 (alignment is 4 bytes instead of 8 bytes, as
  42. # reported by John Wells <[email protected]>).
  43. # Bruno also notes: "HP-UX has two different malloc() implementations.
  44. # Both are broken. When used with CLISP, the one in the default libc.a
  45. # leads to a SIGSEGV, the one in libmalloc.a leads to a SIGBUS. The SunOS
  46. # 4.1.1 malloc() breaks when used by CLISP's generational GC. The IRIX
  47. # 5.2 malloc() breaks when used by CLISP's generational GC."
  48. # If the installer does not give a preference, we use the included GNU
  49. # malloc if we have the slightest doubt that malloc could be broken, this
  50. # includes cross compilation, and *all* HP/UX, SunOS or IRIX systems.
  51. # It is crude indeed, but I just do not have enough information for truly
  52. # benchmarking malloc in all cases, but want safe packages nevertheless.
  53. AC_DEFUN(fp_WITH_INCLUDED_MALLOC,
  54. [AC_MSG_CHECKING(if included GNU malloc is wanted)
  55. AC_ARG_WITH(included-malloc,
  56. [ --with-included-malloc use the GNU malloc which is included here], ,
  57. [if test $cross_compiling = yes; then
  58. withval=yes
  59. else
  60. case `uname -s 2> /dev/null` in
  61. HP-UX | SunOS | IRIX* ) withval=yes ;;
  62. *) withval=no ;;
  63. esac
  64. fi])
  65. test "$withval" = yes && LIBOBJS="$LIBOBJS gmalloc.o"
  66. AC_MSG_RESULT($withval)
  67. ])
  68. ## -------------------- ##
  69. ## Macros from Ulrich. ##
  70. ## -------------------- ##
  71. # Search path for a program which passes the given test.
  72. # Ulrich Drepper <[email protected]>, 1996.
  73. # serial 1
  74. dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
  75. dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
  76. AC_DEFUN(AM_PATH_PROG_WITH_TEST,
  77. [# Extract the first word of "$2", so it can be a program name with args.
  78. set dummy $2; ac_word=[$]2
  79. AC_MSG_CHECKING([for $ac_word])
  80. AC_CACHE_VAL(ac_cv_path_$1,
  81. [case "[$]$1" in
  82. /*)
  83. ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
  84. ;;
  85. *)
  86. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  87. for ac_dir in ifelse([$5], , $PATH, [$5]); do
  88. test -z "$ac_dir" && ac_dir=.
  89. if test -f $ac_dir/$ac_word; then
  90. if [$3]; then
  91. ac_cv_path_$1="$ac_dir/$ac_word"
  92. break
  93. fi
  94. fi
  95. done
  96. IFS="$ac_save_ifs"
  97. dnl If no 4th arg is given, leave the cache variable unset,
  98. dnl so AC_PATH_PROGS will keep looking.
  99. ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
  100. ])dnl
  101. ;;
  102. esac])dnl
  103. $1="$ac_cv_path_$1"
  104. if test -n "[$]$1"; then
  105. AC_MSG_RESULT([$]$1)
  106. else
  107. AC_MSG_RESULT(no)
  108. fi
  109. AC_SUBST($1)dnl
  110. ])
  111. # Check whether LC_MESSAGES is available in <locale.h>.
  112. # Ulrich Drepper <[email protected]>, 1995.
  113. # serial 1
  114. AC_DEFUN(AM_LC_MESSAGES,
  115. [if test $ac_cv_header_locale_h = yes; then
  116. AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
  117. [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
  118. am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
  119. if test $am_cv_val_LC_MESSAGES = yes; then
  120. AC_DEFINE(HAVE_LC_MESSAGES)
  121. fi
  122. fi])
  123. # Macro to add for using GNU gettext.
  124. # Ulrich Drepper <[email protected]>, 1995.
  125. # serial 1
  126. AC_DEFUN(AM_WITH_NLS,
  127. [AC_MSG_CHECKING([whether NLS is requested])
  128. dnl Default is enabled NLS
  129. AC_ARG_ENABLE(nls,
  130. [ --disable-nls do not use Native Language Support],
  131. USE_NLS=$enableval, USE_NLS=yes)
  132. AC_MSG_RESULT($USE_NLS)
  133. AC_SUBST(USE_NLS)
  134. USE_INCLUDED_LIBINTL=no
  135. dnl If we use NLS figure out what method
  136. if test "$USE_NLS" = "yes"; then
  137. AC_DEFINE(ENABLE_NLS)
  138. AC_MSG_CHECKING([whether included gettext is requested])
  139. AC_ARG_WITH(included-gettext,
  140. [ --with-included-gettext use the GNU gettext library included here],
  141. nls_cv_force_use_gnu_gettext=$withval,
  142. nls_cv_force_use_gnu_gettext=no)
  143. AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
  144. nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
  145. if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
  146. dnl User does not insist on using GNU NLS library. Figure out what
  147. dnl to use. If gettext or catgets are available (in this order) we
  148. dnl use this. Else we have to fall back to GNU NLS library.
  149. dnl catgets is only used if permitted by option --with-catgets.
  150. nls_cv_header_intl=
  151. nls_cv_header_libgt=
  152. CATOBJEXT=NONE
  153. AC_CHECK_HEADER(libintl.h,
  154. [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
  155. [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
  156. gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
  157. if test "$gt_cv_func_gettext_libc" != "yes"; then
  158. AC_CHECK_LIB(intl, bindtextdomain,
  159. [AC_CACHE_CHECK([for gettext in libintl],
  160. gt_cv_func_gettext_libintl,
  161. [AC_TRY_LINK([], [return (int) gettext ("")],
  162. gt_cv_func_gettext_libintl=yes,
  163. gt_cv_func_gettext_libintl=no)])])
  164. fi
  165. if test "$gt_cv_func_gettext_libc" = "yes" \
  166. || test "$gt_cv_func_gettext_libintl" = "yes"; then
  167. AC_DEFINE(HAVE_GETTEXT)
  168. AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
  169. [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
  170. if test "$MSGFMT" != "no"; then
  171. AC_CHECK_FUNCS(dcgettext)
  172. AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
  173. AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
  174. [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
  175. AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
  176. return _nl_msg_cat_cntr],
  177. [CATOBJEXT=.gmo
  178. DATADIRNAME=share],
  179. [CATOBJEXT=.mo
  180. DATADIRNAME=lib])
  181. INSTOBJEXT=.mo
  182. fi
  183. fi
  184. ])
  185. if test "$CATOBJEXT" = "NONE"; then
  186. AC_MSG_CHECKING([whether catgets can be used])
  187. AC_ARG_WITH(catgets,
  188. [ --with-catgets use catgets functions if available],
  189. nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
  190. AC_MSG_RESULT($nls_cv_use_catgets)
  191. if test "$nls_cv_use_catgets" = "yes"; then
  192. dnl No gettext in C library. Try catgets next.
  193. AC_CHECK_LIB(i, main)
  194. AC_CHECK_FUNC(catgets,
  195. [AC_DEFINE(HAVE_CATGETS)
  196. INTLOBJS="\$(CATOBJS)"
  197. AC_PATH_PROG(GENCAT, gencat, no)dnl
  198. if test "$GENCAT" != "no"; then
  199. AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
  200. if test "$GMSGFMT" = "no"; then
  201. AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
  202. [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
  203. fi
  204. AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
  205. [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
  206. USE_INCLUDED_LIBINTL=yes
  207. CATOBJEXT=.cat
  208. INSTOBJEXT=.cat
  209. DATADIRNAME=lib
  210. INTLDEPS="../intl/libintl.a"
  211. INTLLIBS=$INTLDEPS
  212. LIBS=`echo $LIBS | sed -e 's/-lintl//'`
  213. nls_cv_header_intl=intl/libintl.h
  214. nls_cv_header_libgt=intl/libgettext.h
  215. fi])
  216. fi
  217. fi
  218. if test "$CATOBJEXT" = "NONE"; then
  219. dnl Neither gettext nor catgets in included in the C library.
  220. dnl Fall back on GNU gettext library.
  221. nls_cv_use_gnu_gettext=yes
  222. fi
  223. fi
  224. if test "$nls_cv_use_gnu_gettext" = "yes"; then
  225. dnl Mark actions used to generate GNU NLS library.
  226. INTLOBJS="\$(GETTOBJS)"
  227. AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
  228. [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
  229. AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
  230. AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
  231. [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
  232. AC_SUBST(MSGFMT)
  233. USE_INCLUDED_LIBINTL=yes
  234. CATOBJEXT=.gmo
  235. INSTOBJEXT=.mo
  236. DATADIRNAME=share
  237. INTLDEPS="../intl/libintl.a"
  238. INTLLIBS=$INTLDEPS
  239. LIBS=`echo $LIBS | sed -e 's/-lintl//'`
  240. nls_cv_header_intl=intl/libintl.h
  241. nls_cv_header_libgt=intl/libgettext.h
  242. fi
  243. dnl Test whether we really found GNU xgettext.
  244. if test "$XGETTEXT" != ":"; then
  245. dnl If it is no GNU xgettext we define it as : so that the
  246. dnl Makefiles still can work.
  247. if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
  248. : ;
  249. else
  250. AC_MSG_RESULT(
  251. [found xgettext programs is not GNU xgettext; ignore it])
  252. XGETTEXT=":"
  253. fi
  254. fi
  255. # We need to process the po/ directory.
  256. POSUB=po
  257. else
  258. DATADIRNAME=share
  259. nls_cv_header_intl=intl/libintl.h
  260. nls_cv_header_libgt=intl/libgettext.h
  261. fi
  262. # If this is used in GNU gettext we have to set USE_NLS to `yes'
  263. # because some of the sources are only built for this goal.
  264. if test "$PACKAGE" = gettext; then
  265. USE_NLS=yes
  266. USE_INCLUDED_LIBINTL=yes
  267. fi
  268. dnl These rules are solely for the distribution goal. While doing this
  269. dnl we only have to keep exactly one list of the available catalogs
  270. dnl in configure.in.
  271. for lang in $ALL_LINGUAS; do
  272. GMOFILES="$GMOFILES $lang.gmo"
  273. POFILES="$POFILES $lang.po"
  274. done
  275. dnl Make all variables we use known to autoconf.
  276. AC_SUBST(USE_INCLUDED_LIBINTL)
  277. AC_SUBST(CATALOGS)
  278. AC_SUBST(CATOBJEXT)
  279. AC_SUBST(DATADIRNAME)
  280. AC_SUBST(GMOFILES)
  281. AC_SUBST(INSTOBJEXT)
  282. AC_SUBST(INTLDEPS)
  283. AC_SUBST(INTLLIBS)
  284. AC_SUBST(INTLOBJS)
  285. AC_SUBST(POFILES)
  286. AC_SUBST(POSUB)
  287. ])
  288. AC_DEFUN(AM_GNU_GETTEXT,
  289. [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
  290. AC_REQUIRE([AC_PROG_CC])dnl
  291. AC_REQUIRE([AC_ISC_POSIX])dnl
  292. AC_REQUIRE([AC_PROG_RANLIB])dnl
  293. AC_REQUIRE([AC_HEADER_STDC])dnl
  294. AC_REQUIRE([AC_C_CONST])dnl
  295. AC_REQUIRE([AC_C_INLINE])dnl
  296. AC_REQUIRE([AC_TYPE_OFF_T])dnl
  297. AC_REQUIRE([AC_TYPE_SIZE_T])dnl
  298. AC_REQUIRE([AC_FUNC_ALLOCA])dnl
  299. AC_REQUIRE([AC_FUNC_MMAP])dnl
  300. AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
  301. unistd.h values.h])
  302. AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
  303. __argz_count __argz_stringify __argz_next])
  304. if test "${ac_cv_func_stpcpy+set}" != "set"; then
  305. AC_CHECK_FUNCS(stpcpy)
  306. fi
  307. if test "${ac_cv_func_stpcpy}" = "yes"; then
  308. AC_DEFINE(HAVE_STPCPY)
  309. fi
  310. AM_LC_MESSAGES
  311. AM_WITH_NLS
  312. if test "x$CATOBJEXT" != "x"; then
  313. if test "x$ALL_LINGUAS" = "x"; then
  314. LINGUAS=
  315. else
  316. AC_MSG_CHECKING(for catalogs to be installed)
  317. NEW_LINGUAS=
  318. for lang in ${LINGUAS=$ALL_LINGUAS}; do
  319. case "$ALL_LINGUAS" in
  320. *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
  321. esac
  322. done
  323. LINGUAS=$NEW_LINGUAS
  324. AC_MSG_RESULT($LINGUAS)
  325. fi
  326. dnl Construct list of names of catalog files to be constructed.
  327. if test -n "$LINGUAS"; then
  328. for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
  329. fi
  330. fi
  331. dnl Determine which catalog format we have (if any is needed)
  332. dnl For now we know about two different formats:
  333. dnl Linux libc-5 and the normal X/Open format
  334. test -d intl || mkdir intl
  335. if test "$CATOBJEXT" = ".cat"; then
  336. AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
  337. dnl Transform the SED scripts while copying because some dumb SEDs
  338. dnl cannot handle comments.
  339. sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
  340. fi
  341. dnl po2tbl.sed is always needed.
  342. sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
  343. $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
  344. dnl In the intl/Makefile.in we have a special dependency which makes
  345. dnl only sense for gettext. We comment this out for non-gettext
  346. dnl packages.
  347. if test "$PACKAGE" = "gettext"; then
  348. GT_NO="#NO#"
  349. GT_YES=
  350. else
  351. GT_NO=
  352. GT_YES="#YES#"
  353. fi
  354. AC_SUBST(GT_NO)
  355. AC_SUBST(GT_YES)
  356. dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
  357. dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
  358. dnl Try to locate is.
  359. MKINSTALLDIRS=
  360. if test $ac_aux_dir; then
  361. MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
  362. fi
  363. if test -z $MKINSTALLDIRS; then
  364. MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
  365. fi
  366. AC_SUBST(MKINSTALLDIRS)
  367. dnl Generate list of files to be processed by xgettext which will
  368. dnl be included in po/Makefile.
  369. test -d po || mkdir po
  370. if test "x$srcdir" != "x."; then
  371. if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
  372. posrcprefix="$srcdir/"
  373. else
  374. posrcprefix="../$srcdir/"
  375. fi
  376. else
  377. posrcprefix="../"
  378. fi
  379. sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
  380. < $srcdir/po/POTFILES.in > po/POTFILES
  381. ])