aclocal.m4 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. # aclocal.m4 - Local additions to Autoconf macros.
  2. # Copyright (C) 1995 - 2006 Michael Riepe
  3. #
  4. # This library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Library General Public
  6. # License as published by the Free Software Foundation; either
  7. # version 2 of the License, or (at your option) any later version.
  8. #
  9. # This library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # Library General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Library General Public
  15. # License along with this library; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  17. # @(#) $Id: aclocal.m4,v 1.28 2008/05/23 08:17:56 michael Exp $
  18. AC_PREREQ(2.13)
  19. dnl mr_PACKAGE(package-name)
  20. AC_DEFUN(mr_PACKAGE, [changequote(<<, >>)dnl
  21. changequote([, ])dnl
  22. PACKAGE=$1
  23. VERSION=`cat $srcdir/VERSION`
  24. AC_SUBST(PACKAGE)
  25. AC_SUBST(VERSION)
  26. AC_ARG_ENABLE(maintainer-mode,
  27. [ --enable-maintainer-mode
  28. enable maintainer-specific make rules (default: auto)],
  29. [mr_enable_maintainer_mode="$enableval"],
  30. [case :${I_AM_THE_MAINTAINER_OF}: in
  31. *:$1:*) mr_enable_maintainer_mode=yes;;
  32. *) mr_enable_maintainer_mode=no;;
  33. esac])
  34. if test x"$mr_enable_maintainer_mode" = x"yes"; then
  35. MAINT=
  36. else
  37. MAINT='maintainer-only-'
  38. fi
  39. AC_SUBST(MAINT)
  40. ])
  41. AC_DEFUN(mr_ENABLE_NLS, [
  42. AC_PROVIDE([$0])
  43. # Needed for `make dist' even if NLS is disabled.
  44. GMOFILES=
  45. MSGFILES=
  46. POFILES=
  47. for mr_lang in $ALL_LINGUAS; do
  48. GMOFILES="$GMOFILES $mr_lang.gmo"
  49. MSGFILES="$MSGFILES $mr_lang.msg"
  50. POFILES="$POFILES $mr_lang.po"
  51. done
  52. AC_SUBST(GMOFILES)
  53. AC_SUBST(MSGFILES)
  54. AC_SUBST(POFILES)
  55. AC_MSG_CHECKING([whether NLS is requested])
  56. AC_ARG_ENABLE(nls,
  57. [ --enable-nls use Native Language Support (default: yes)],
  58. [mr_enable_nls="$enableval"],
  59. [mr_enable_nls=yes])
  60. AC_MSG_RESULT($mr_enable_nls)
  61. CATOBJEXT=
  62. INSTOBJEXT=
  63. localedir=
  64. if test "$mr_enable_nls" = yes; then
  65. mr_PATH=`echo ":$PATH" | sed -e 's,:[^:]*openwin[^:]*,,g' -e 's,^:,,'`
  66. AC_CACHE_CHECK([for dgettext],
  67. mr_cv_func_dgettext, [
  68. AC_TRY_LINK([#include <libintl.h>],
  69. [char *s = dgettext("", ""); return 0],
  70. [mr_cv_func_dgettext=yes],
  71. [mr_cv_func_dgettext=no])
  72. ])
  73. if test "$mr_cv_func_dgettext" = yes; then
  74. AC_PATH_PROG(MSGFMT, msgfmt, no, $mr_PATH)
  75. if test "$MSGFMT" != no; then
  76. AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT, $mr_PATH)
  77. AC_PATH_PROG(XGETTEXT, xgettext, xgettext, $mr_PATH)
  78. AC_PATH_PROG(MSGMERGE, msgmerge, msgmerge, $mr_PATH)
  79. AC_CACHE_CHECK([for GNU gettext],
  80. mr_cv_gnu_gettext, [
  81. AC_TRY_LINK([],
  82. [extern int _nl_msg_cat_cntr; return _nl_msg_cat_cntr],
  83. [mr_cv_gnu_gettext=yes],
  84. [mr_cv_gnu_gettext=no])
  85. ])
  86. if test "$mr_cv_gnu_gettext" = yes; then
  87. AC_CACHE_CHECK([for losing catgets-based GNU gettext],
  88. mr_cv_catgets_based_gettext, [
  89. AC_TRY_LINK([],
  90. [extern int _msg_tbl_length; return _msg_tbl_length],
  91. [mr_cv_catgets_based_gettext=yes],
  92. [mr_cv_catgets_based_gettext=no])
  93. ])
  94. if test "$mr_cv_catgets_based_gettext" = yes; then
  95. # This loses completely. Turn it off and use catgets.
  96. LIBS=`echo $LIBS | sed 's,-lintl,,g'`
  97. mr_cv_func_dgettext=no
  98. else
  99. # Is there a better test for this case?
  100. AC_CACHE_CHECK([for pure GNU gettext],
  101. mr_cv_pure_gnu_gettext, [
  102. AC_TRY_LINK([],
  103. [extern int gettext(); return gettext()],
  104. [mr_cv_pure_gnu_gettext=yes],
  105. [mr_cv_pure_gnu_gettext=no])
  106. ])
  107. if test "$mr_cv_pure_gnu_gettext" = yes; then
  108. CATOBJEXT=.gmo
  109. localedir='$(prefix)/share/locale'
  110. else
  111. CATOBJEXT=.mo
  112. localedir='$(prefix)/lib/locale'
  113. fi
  114. INSTOBJEXT=.mo
  115. fi
  116. else
  117. # System provided gettext
  118. CATOBJEXT=.mo
  119. INSTOBJEXT=.mo
  120. localedir='$(prefix)/lib/locale'
  121. fi
  122. else
  123. # Gettext but no msgfmt. Try catgets.
  124. mr_cv_func_dgettext=no
  125. fi
  126. fi
  127. if test "$mr_cv_func_dgettext" = yes; then
  128. AC_DEFINE(HAVE_DGETTEXT)
  129. else
  130. AC_CACHE_CHECK([for catgets], mr_cv_func_catgets, [
  131. AC_TRY_LINK([#include <nl_types.h>],
  132. [catgets(catopen("",0),0,0,"");return 0;],
  133. [mr_cv_func_catgets=yes],
  134. [mr_cv_func_catgets=no])
  135. ])
  136. if test "$mr_cv_func_catgets" = yes; then
  137. AC_PATH_PROG(GENCAT, gencat, no, $mr_PATH)
  138. if test "$GENCAT" != no; then
  139. AC_DEFINE(HAVE_CATGETS)
  140. AC_PATH_PROG(GMSGFMT, [gmsgfmt msgfmt], msgfmt, $mr_PATH)
  141. AC_PATH_PROG(XGETTEXT, xgettext, xgettext, $mr_PATH)
  142. CATOBJEXT=.cat
  143. INSTOBJEXT=.cat
  144. localedir='$(prefix)/lib/locale'
  145. fi
  146. else
  147. AC_MSG_WARN([no NLS support, disabled])
  148. mr_enable_nls=no
  149. fi
  150. fi
  151. fi
  152. AC_SUBST(CATOBJEXT)
  153. AC_SUBST(INSTOBJEXT)
  154. AC_SUBST(localedir)
  155. POSUB=
  156. CATALOGS=
  157. if test "$mr_enable_nls" = yes; then
  158. AC_MSG_CHECKING([for catalogs to be installed])
  159. mr_linguas=
  160. for mr_lang in ${LINGUAS=$ALL_LINGUAS}; do
  161. case " $ALL_LINGUAS " in
  162. *" $mr_lang "*)
  163. mr_linguas="$mr_linguas$mr_lang "
  164. CATALOGS="$CATALOGS $mr_lang$CATOBJEXT"
  165. ;;
  166. esac
  167. done
  168. AC_MSG_RESULT($mr_linguas)
  169. POSUB=po
  170. fi
  171. AC_SUBST(CATALOGS)
  172. AC_SUBST(POSUB)
  173. ])
  174. AC_DEFUN(mr_TARGET_ELF, [
  175. AC_PROVIDE([$0])
  176. AC_CACHE_CHECK([for native ELF system],
  177. mr_cv_target_elf,
  178. [AC_TRY_RUN(changequote(<<, >>)dnl
  179. <<#include <stdio.h>
  180. int
  181. main(int argc, char **argv) {
  182. char buf[BUFSIZ];
  183. FILE *fp;
  184. int n;
  185. if ((fp = fopen(*argv, "r")) == NULL) {
  186. exit(1);
  187. }
  188. n = fread(buf, 1, sizeof(buf), fp);
  189. if (n >= 52
  190. && buf[0] == '\177'
  191. && buf[1] == 'E'
  192. && buf[2] == 'L'
  193. && buf[3] == 'F') {
  194. exit(0);
  195. }
  196. exit(1);
  197. }>>, changequote([, ])dnl
  198. mr_cv_target_elf=yes,
  199. mr_cv_target_elf=no,
  200. mr_cv_target_elf=no)])])
  201. AC_DEFUN(mr_ENABLE_SHARED, [
  202. AC_PROVIDE([$0])
  203. PICFLAGS=
  204. SHLIB_SFX=
  205. SHLINK_SFX=
  206. SONAME_SFX=
  207. LINK_SHLIB=
  208. INSTALL_SHLIB=
  209. DEPSHLIBS=
  210. AC_MSG_CHECKING([whether to build a shared library])
  211. AC_ARG_ENABLE(shared,
  212. [ --enable-shared build shared library (default: yes)],
  213. [mr_enable_shared="$enableval"],
  214. [mr_enable_shared=yes])
  215. AC_MSG_RESULT($mr_enable_shared)
  216. if test "$mr_enable_shared" = yes; then
  217. AC_MSG_CHECKING([whether GNU naming conventions are requested])
  218. AC_ARG_ENABLE(gnu-names,
  219. [ --enable-gnu-names use GNU library naming conventions (default: no)],
  220. [mr_enable_gnu_names="$enableval"],
  221. [mr_enable_gnu_names=no])
  222. AC_MSG_RESULT($mr_enable_gnu_names)
  223. AC_REQUIRE([AC_CANONICAL_HOST])
  224. AC_REQUIRE([AC_PROG_CC])
  225. AC_PATH_PROG(LD, ld, ld)
  226. case "$host" in
  227. *-linux*|*-gnu*|*bsd*|*BSD*)
  228. if test "$GCC" = yes; then
  229. mr_TARGET_ELF
  230. if test "$mr_cv_target_elf" = yes; then
  231. PICFLAGS='-fPIC -DPIC'
  232. if test "$mr_enable_gnu_names" = yes
  233. then SHLIB_SFX='-$(VERSION).so'
  234. else SHLIB_SFX='.so.$(VERSION)'
  235. fi
  236. SHLINK_SFX='.so'
  237. SONAME_SFX='.so.$(MAJOR)'
  238. LINK_SHLIB='$(CC) -shared -Wl,-soname,$(SONAME)'
  239. INSTALL_SHLIB='$(INSTALL_PROGRAM)'
  240. DEPSHLIBS='-lc'
  241. else
  242. AC_MSG_WARN([shared libraries not supported for $host])
  243. mr_enable_shared=no
  244. fi
  245. elif ${CC} -V 2>&1 | grep 'Intel(R) C++ Compiler' >/dev/null 2>&1; then
  246. AC_MSG_WARN([Use --disable-shared if $CC fails to build the shared library])
  247. PICFLAGS='-fPIC -DPIC'
  248. if test "$mr_enable_gnu_names" = yes
  249. then SHLIB_SFX='-$(VERSION).so'
  250. else SHLIB_SFX='.so.$(VERSION)'
  251. fi
  252. SHLINK_SFX='.so'
  253. SONAME_SFX='.so.$(MAJOR)'
  254. LINK_SHLIB='$(CC) -shared -Wl,-soname,$(SONAME)'
  255. INSTALL_SHLIB='$(INSTALL_PROGRAM)'
  256. DEPSHLIBS='-lc'
  257. else
  258. AC_MSG_WARN([GNU CC required for building shared libraries])
  259. mr_enable_shared=no
  260. fi
  261. ;;
  262. i386-pc-nto-qnx*)
  263. mr_TARGET_ELF
  264. if test "$mr_cv_target_elf" = yes; then
  265. PICFLAGS='-fPIC -DPIC'
  266. if test "$mr_enable_gnu_names" = yes
  267. then SHLIB_SFX='-$(VERSION).so'
  268. else SHLIB_SFX='.so.$(VERSION)'
  269. fi
  270. SHLINK_SFX='.so'
  271. SONAME_SFX='.so.$(MAJOR)'
  272. LINK_SHLIB='$(CC) -shared -Wl,-soname,$(SONAME)'
  273. INSTALL_SHLIB='$(INSTALL_PROGRAM)'
  274. DEPSHLIBS='-lc'
  275. else
  276. AC_MSG_WARN([shared libraries not supported for $host])
  277. mr_enable_shared=no
  278. fi
  279. ;;
  280. sparc-sun-solaris2*)
  281. if test "$GCC" = yes; then
  282. PICFLAGS='-fPIC -DPIC'
  283. else
  284. PICFLAGS='-K PIC -DPIC'
  285. fi
  286. if test "$mr_enable_gnu_names" = yes
  287. then SHLIB_SFX='-$(MAJOR).so'
  288. else SHLIB_SFX='.so.$(MAJOR)'
  289. fi
  290. SONAME_SFX='.so.$(MAJOR)'
  291. SHLINK_SFX='.so'
  292. LINK_SHLIB='$(LD) -G -z text -h $(SONAME)'
  293. INSTALL_SHLIB='$(INSTALL_PROGRAM)'
  294. ;;
  295. *)
  296. AC_MSG_WARN([shared libraries not supported for $host])
  297. mr_enable_shared=no
  298. ;;
  299. esac
  300. else
  301. mr_enable_shared=no
  302. fi
  303. AC_SUBST(PICFLAGS)
  304. AC_SUBST(SHLIB_SFX)
  305. AC_SUBST(SHLINK_SFX)
  306. AC_SUBST(SONAME_SFX)
  307. AC_SUBST(LINK_SHLIB)
  308. AC_SUBST(INSTALL_SHLIB)
  309. AC_SUBST(DEPSHLIBS)
  310. DO_SHLIB="$mr_enable_shared"
  311. AC_SUBST(DO_SHLIB)
  312. ])
  313. AC_DEFUN(mr_ENABLE_DEBUG, [
  314. AC_PROVIDE([$0])
  315. AC_ARG_ENABLE(debug,
  316. [ --enable-debug include extra debugging code (default: no)],
  317. [mr_enable_debug="$enableval"],
  318. [mr_enable_debug=no])
  319. if test "$mr_enable_debug" = yes; then
  320. AC_DEFINE(ENABLE_DEBUG)
  321. fi
  322. ])
  323. # vi: set ts=8 sw=2 :