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