gnome.m4 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. # gnome-common.m4
  2. #
  3. dnl GNOME_COMMON_INIT
  4. AC_DEFUN([GNOME_COMMON_INIT],
  5. [
  6. AC_CACHE_VAL(ac_cv_gnome_aclocal_dir,
  7. [ac_cv_gnome_aclocal_dir="$GNOME_COMMON_MACROS_DIR"])
  8. AC_CACHE_VAL(ac_cv_gnome_aclocal_flags,
  9. [ac_cv_gnome_aclocal_flags="$ACLOCAL_FLAGS"])
  10. GNOME_ACLOCAL_DIR="$ac_cv_gnome_aclocal_dir"
  11. GNOME_ACLOCAL_FLAGS="$ac_cv_gnome_aclocal_flags"
  12. AC_SUBST(GNOME_ACLOCAL_DIR)
  13. AC_SUBST(GNOME_ACLOCAL_FLAGS)
  14. ACLOCAL="$ACLOCAL $GNOME_ACLOCAL_FLAGS"
  15. AM_CONDITIONAL(INSIDE_GNOME_DOCU, false)
  16. ])
  17. AC_DEFUN([GNOME_GTKDOC_CHECK],
  18. [
  19. AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
  20. AM_CONDITIONAL(HAVE_GTK_DOC, $GTKDOC)
  21. AC_SUBST(HAVE_GTK_DOC)
  22. dnl Let people disable the gtk-doc stuff.
  23. AC_ARG_ENABLE(gtk-doc, [ --enable-gtk-doc Use gtk-doc to build documentation [default=auto]], enable_gtk_doc="$enableval", enable_gtk_doc=auto)
  24. if test x$enable_gtk_doc = xauto ; then
  25. if test x$GTKDOC = xtrue ; then
  26. enable_gtk_doc=yes
  27. else
  28. enable_gtk_doc=no
  29. fi
  30. fi
  31. dnl NOTE: We need to use a separate automake conditional for this
  32. dnl to make this work with the tarballs.
  33. AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
  34. ])
  35. AC_DEFUN([GNOME_DEBUG_CHECK],
  36. [
  37. AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging [default=no]], enable_debug="$enableval", enable_debug=no)
  38. if test x$enable_debug = xyes ; then
  39. AC_DEFINE(GNOME_ENABLE_DEBUG)
  40. fi
  41. ])
  42. # Define a conditional.
  43. AC_DEFUN([AM_CONDITIONAL],
  44. [AC_SUBST($1_TRUE)
  45. AC_SUBST($1_FALSE)
  46. if $2; then
  47. $1_TRUE=
  48. $1_FALSE='#'
  49. else
  50. $1_TRUE='#'
  51. $1_FALSE=
  52. fi])
  53. dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
  54. dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
  55. dnl also defines GSTUFF_PKG_ERRORS on error
  56. AC_DEFUN([PKG_CHECK_MODULES], [
  57. succeeded=no
  58. if test -z "$PKG_CONFIG"; then
  59. AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  60. fi
  61. if test "$PKG_CONFIG" = "no" ; then
  62. echo "*** The pkg-config script could not be found. Make sure it is"
  63. echo "*** in your path, or set the PKG_CONFIG environment variable"
  64. echo "*** to the full path to pkg-config."
  65. echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
  66. else
  67. PKG_CONFIG_MIN_VERSION=0.9.0
  68. if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
  69. AC_MSG_CHECKING(for $2)
  70. if $PKG_CONFIG --exists "$2" ; then
  71. AC_MSG_RESULT(yes)
  72. succeeded=yes
  73. AC_MSG_CHECKING($1_CFLAGS)
  74. $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
  75. AC_MSG_RESULT($$1_CFLAGS)
  76. AC_MSG_CHECKING($1_LIBS)
  77. $1_LIBS=`$PKG_CONFIG --libs "$2"`
  78. AC_MSG_RESULT($$1_LIBS)
  79. else
  80. $1_CFLAGS=""
  81. $1_LIBS=""
  82. ## If we have a custom action on failure, don't print errors, but
  83. ## do set a variable so people can do so.
  84. $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
  85. ifelse([$4], ,echo $$1_PKG_ERRORS,)
  86. fi
  87. AC_SUBST($1_CFLAGS)
  88. AC_SUBST($1_LIBS)
  89. else
  90. echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
  91. echo "*** See http://www.freedesktop.org/software/pkgconfig"
  92. fi
  93. fi
  94. if test $succeeded = yes; then
  95. ifelse([$3], , :, [$3])
  96. else
  97. ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
  98. fi
  99. ])
  100. # Macro to add for using GNU gettext.
  101. # Ulrich Drepper <drepper@cygnus.com>, 1995, 1996
  102. #
  103. # Modified to never use included libintl.
  104. # Owen Taylor <otaylor@redhat.com>, 12/15/1998
  105. #
  106. #
  107. # This file can be copied and used freely without restrictions. It can
  108. # be used in projects which are not available under the GNU Public License
  109. # but which still want to provide support for the GNU gettext functionality.
  110. # Please note that the actual code is *not* freely available.
  111. #
  112. #
  113. # If you make changes to this file, you MUST update the copy in
  114. # acinclude.m4. [ aclocal dies on duplicate macros, so if
  115. # we run 'aclocal -I macros/' then we'll run into problems
  116. # once we've installed glib-gettext.m4 :-( ]
  117. #
  118. AC_DEFUN([AM_GLIB_LC_MESSAGES],
  119. [if test $ac_cv_header_locale_h = yes; then
  120. AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
  121. [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
  122. am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
  123. if test $am_cv_val_LC_MESSAGES = yes; then
  124. AC_DEFINE(HAVE_LC_MESSAGES, 1,
  125. [Define if your <locale.h> file defines LC_MESSAGES.])
  126. fi
  127. fi])
  128. dnl AM_GLIB_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
  129. dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
  130. AC_DEFUN([AM_GLIB_PATH_PROG_WITH_TEST],
  131. [# Extract the first word of "$2", so it can be a program name with args.
  132. set dummy $2; ac_word=[$]2
  133. AC_MSG_CHECKING([for $ac_word])
  134. AC_CACHE_VAL(ac_cv_path_$1,
  135. [case "[$]$1" in
  136. /*)
  137. ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
  138. ;;
  139. *)
  140. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  141. for ac_dir in ifelse([$5], , $PATH, [$5]); do
  142. test -z "$ac_dir" && ac_dir=.
  143. if test -f $ac_dir/$ac_word; then
  144. if [$3]; then
  145. ac_cv_path_$1="$ac_dir/$ac_word"
  146. break
  147. fi
  148. fi
  149. done
  150. IFS="$ac_save_ifs"
  151. dnl If no 4th arg is given, leave the cache variable unset,
  152. dnl so AC_PATH_PROGS will keep looking.
  153. ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
  154. ])dnl
  155. ;;
  156. esac])dnl
  157. $1="$ac_cv_path_$1"
  158. if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
  159. AC_MSG_RESULT([$]$1)
  160. else
  161. AC_MSG_RESULT(no)
  162. fi
  163. AC_SUBST($1)dnl
  164. ])
  165. AC_DEFUN([AM_GLIB_WITH_NLS],
  166. dnl NLS is obligatory
  167. [USE_NLS=yes
  168. AC_SUBST(USE_NLS)
  169. dnl Figure out what method
  170. nls_cv_force_use_gnu_gettext="no"
  171. nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
  172. if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
  173. dnl User does not insist on using GNU NLS library. Figure out what
  174. dnl to use. If gettext or catgets are available (in this order) we
  175. dnl use this. Else we have to fall back to GNU NLS library.
  176. dnl catgets is only used if permitted by option --with-catgets.
  177. nls_cv_header_intl=
  178. nls_cv_header_libgt=
  179. CATOBJEXT=NONE
  180. XGETTEXT=:
  181. AC_CHECK_HEADER(libintl.h,
  182. [AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
  183. [AC_TRY_LINK([#include <libintl.h>], [return (int) dgettext ("","")],
  184. gt_cv_func_dgettext_libc=yes, gt_cv_func_dgettext_libc=no)])
  185. gt_cv_func_dgettext_libintl="no"
  186. libintl_extra_libs=""
  187. if test "$gt_cv_func_dgettext_libc" != "yes" ; then
  188. AC_CHECK_LIB(intl, bindtextdomain,
  189. [AC_CHECK_LIB(intl, dgettext,
  190. gt_cv_func_dgettext_libintl=yes)])
  191. if test "$gt_cv_func_dgettext_libc" != "yes" ; then
  192. AC_MSG_CHECKING([if -liconv is needed to use gettext])
  193. AC_MSG_RESULT([])
  194. AC_CHECK_LIB(intl, dcgettext,
  195. [gt_cv_func_dgettext_libintl=yes
  196. libintl_extra_libs=-liconv],
  197. :,-liconv)
  198. fi
  199. fi
  200. if test "$gt_cv_func_dgettext_libintl" = "yes"; then
  201. LIBS="$LIBS -lintl $libintl_extra_libs";
  202. fi
  203. if test "$gt_cv_func_dgettext_libc" = "yes" \
  204. || test "$gt_cv_func_dgettext_libintl" = "yes"; then
  205. AC_DEFINE(HAVE_GETTEXT,1,
  206. [Define if the GNU gettext() function is already present or preinstalled.])
  207. AM_GLIB_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
  208. [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
  209. if test "$MSGFMT" != "no"; then
  210. AC_CHECK_FUNCS(dcgettext)
  211. AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
  212. AM_GLIB_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
  213. [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
  214. AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
  215. return _nl_msg_cat_cntr],
  216. [CATOBJEXT=.gmo
  217. DATADIRNAME=share],
  218. [CATOBJEXT=.mo
  219. DATADIRNAME=lib])
  220. INSTOBJEXT=.mo
  221. fi
  222. fi
  223. # Added by Martin Baulig 12/15/98 for libc5 systems
  224. if test "$gt_cv_func_dgettext_libc" != "yes" \
  225. && test "$gt_cv_func_dgettext_libintl" = "yes"; then
  226. INTLLIBS="-lintl $libintl_extra_libs"
  227. LIBS=`echo $LIBS | sed -e 's/-lintl//'`
  228. fi
  229. ])
  230. if test "$CATOBJEXT" = "NONE"; then
  231. dnl Neither gettext nor catgets in included in the C library.
  232. dnl Fall back on GNU gettext library.
  233. nls_cv_use_gnu_gettext=yes
  234. fi
  235. fi
  236. if test "$nls_cv_use_gnu_gettext" != "yes"; then
  237. AC_DEFINE(ENABLE_NLS, 1,
  238. [always defined to indicate that i18n is enabled])
  239. else
  240. dnl Unset this variable since we use the non-zero value as a flag.
  241. CATOBJEXT=
  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 program is not GNU xgettext; ignore it])
  252. XGETTEXT=":"
  253. fi
  254. fi
  255. # We need to process the po/ directory.
  256. POSUB=po
  257. AC_OUTPUT_COMMANDS(
  258. [case "$CONFIG_FILES" in *po/Makefile.in*)
  259. sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
  260. esac])
  261. dnl These rules are solely for the distribution goal. While doing this
  262. dnl we only have to keep exactly one list of the available catalogs
  263. dnl in configure.in.
  264. for lang in $ALL_LINGUAS; do
  265. GMOFILES="$GMOFILES $lang.gmo"
  266. POFILES="$POFILES $lang.po"
  267. done
  268. dnl Make all variables we use known to autoconf.
  269. AC_SUBST(CATALOGS)
  270. AC_SUBST(CATOBJEXT)
  271. AC_SUBST(DATADIRNAME)
  272. AC_SUBST(GMOFILES)
  273. AC_SUBST(INSTOBJEXT)
  274. AC_SUBST(INTLDEPS)
  275. AC_SUBST(INTLLIBS)
  276. AC_SUBST(INTLOBJS)
  277. AC_SUBST(POFILES)
  278. AC_SUBST(POSUB)
  279. ])
  280. AC_DEFUN([AM_GLIB_GNU_GETTEXT],
  281. [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
  282. AC_REQUIRE([AC_PROG_CC])dnl
  283. AC_REQUIRE([AC_PROG_RANLIB])dnl
  284. AC_REQUIRE([AC_HEADER_STDC])dnl
  285. AC_REQUIRE([AC_C_CONST])dnl
  286. AC_REQUIRE([AC_C_INLINE])dnl
  287. AC_REQUIRE([AC_TYPE_OFF_T])dnl
  288. AC_REQUIRE([AC_TYPE_SIZE_T])dnl
  289. AC_REQUIRE([AC_FUNC_ALLOCA])dnl
  290. AC_REQUIRE([AC_FUNC_MMAP])dnl
  291. AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
  292. unistd.h sys/param.h])
  293. AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
  294. strdup __argz_count __argz_stringify __argz_next])
  295. AM_GLIB_LC_MESSAGES
  296. AM_GLIB_WITH_NLS
  297. if test "x$CATOBJEXT" != "x"; then
  298. if test "x$ALL_LINGUAS" = "x"; then
  299. LINGUAS=
  300. else
  301. AC_MSG_CHECKING(for catalogs to be installed)
  302. NEW_LINGUAS=
  303. for lang in ${LINGUAS=$ALL_LINGUAS}; do
  304. case "$ALL_LINGUAS" in
  305. *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
  306. esac
  307. done
  308. LINGUAS=$NEW_LINGUAS
  309. AC_MSG_RESULT($LINGUAS)
  310. fi
  311. dnl Construct list of names of catalog files to be constructed.
  312. if test -n "$LINGUAS"; then
  313. for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
  314. fi
  315. fi
  316. dnl Determine which catalog format we have (if any is needed)
  317. dnl For now we know about two different formats:
  318. dnl Linux libc-5 and the normal X/Open format
  319. test -d po || mkdir po
  320. if test "$CATOBJEXT" = ".cat"; then
  321. AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
  322. dnl Transform the SED scripts while copying because some dumb SEDs
  323. dnl cannot handle comments.
  324. sed -e '/^#/d' $srcdir/po/$msgformat-msg.sed > po/po2msg.sed
  325. fi
  326. dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
  327. dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
  328. dnl Try to locate is.
  329. MKINSTALLDIRS=
  330. if test -n "$ac_aux_dir"; then
  331. MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
  332. fi
  333. if test -z "$MKINSTALLDIRS"; then
  334. MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
  335. fi
  336. AC_SUBST(MKINSTALLDIRS)
  337. dnl Generate list of files to be processed by xgettext which will
  338. dnl be included in po/Makefile.
  339. test -d po || mkdir po
  340. if test "x$srcdir" != "x."; then
  341. if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
  342. posrcprefix="$srcdir/"
  343. else
  344. posrcprefix="../$srcdir/"
  345. fi
  346. else
  347. posrcprefix="../"
  348. fi
  349. rm -f po/POTFILES
  350. sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
  351. < $srcdir/po/POTFILES.in > po/POTFILES
  352. ])