Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_04 / synfig-studio / config / 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 # serial 5
193
194 AC_DEFUN(AM_GLIB_WITH_NLS,
195   dnl NLS is obligatory
196   [USE_NLS=yes
197     AC_SUBST(USE_NLS)
198
199     dnl Figure out what method
200     nls_cv_force_use_gnu_gettext="no"
201
202     nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
203     if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
204       dnl User does not insist on using GNU NLS library.  Figure out what
205       dnl to use.  If gettext or catgets are available (in this order) we
206       dnl use this.  Else we have to fall back to GNU NLS library.
207       dnl catgets is only used if permitted by option --with-catgets.
208       nls_cv_header_intl=
209       nls_cv_header_libgt=
210       CATOBJEXT=NONE
211       XGETTEXT=:
212
213       AC_CHECK_HEADER(libintl.h,
214         [AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
215           [AC_TRY_LINK([#include <libintl.h>], [return (int) dgettext ("","")],
216             gt_cv_func_dgettext_libc=yes, gt_cv_func_dgettext_libc=no)])
217
218           gt_cv_func_dgettext_libintl="no"
219           libintl_extra_libs=""
220
221           if test "$gt_cv_func_dgettext_libc" != "yes" ; then
222             AC_CHECK_LIB(intl, bindtextdomain,
223               [AC_CHECK_LIB(intl, dgettext,
224                             gt_cv_func_dgettext_libintl=yes)])
225
226             if test "$gt_cv_func_dgettext_libc" != "yes" ; then
227               AC_MSG_CHECKING([if -liconv is needed to use gettext])
228               AC_MSG_RESULT([])
229               AC_CHECK_LIB(intl, dcgettext,
230                            [gt_cv_func_dgettext_libintl=yes
231                             libintl_extra_libs=-liconv],
232                            :,-liconv)
233             fi
234           fi
235
236           if test "$gt_cv_func_dgettext_libintl" = "yes"; then
237             LIBS="$LIBS -lintl $libintl_extra_libs";
238           fi
239
240           if test "$gt_cv_func_dgettext_libc" = "yes" \
241             || test "$gt_cv_func_dgettext_libintl" = "yes"; then
242             AC_DEFINE(HAVE_GETTEXT,1,
243               [Define if the GNU gettext() function is already present or preinstalled.])
244             AM_GLIB_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
245               [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
246             if test "$MSGFMT" != "no"; then
247               AC_CHECK_FUNCS(dcgettext)
248               AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
249               AM_GLIB_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
250                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
251               AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
252                              return _nl_msg_cat_cntr],
253                 [CATOBJEXT=.gmo
254                  DATADIRNAME=share],
255                 [CATOBJEXT=.mo
256                  DATADIRNAME=lib])
257               INSTOBJEXT=.mo
258             fi
259           fi
260
261           # Added by Martin Baulig 12/15/98 for libc5 systems
262           if test "$gt_cv_func_dgettext_libc" != "yes" \
263             && test "$gt_cv_func_dgettext_libintl" = "yes"; then
264             INTLLIBS="-lintl $libintl_extra_libs"
265             LIBS=`echo $LIBS | sed -e 's/-lintl//'`
266           fi
267       ])
268
269       if test "$CATOBJEXT" = "NONE"; then
270         dnl Neither gettext nor catgets in included in the C library.
271         dnl Fall back on GNU gettext library.
272         nls_cv_use_gnu_gettext=yes
273       fi
274     fi
275
276     if test "$nls_cv_use_gnu_gettext" != "yes"; then
277       AC_DEFINE(ENABLE_NLS, 1,
278         [always defined to indicate that i18n is enabled])
279     else
280       dnl Unset this variable since we use the non-zero value as a flag.
281       CATOBJEXT=
282     fi
283
284     dnl Test whether we really found GNU xgettext.
285     if test "$XGETTEXT" != ":"; then
286       dnl If it is no GNU xgettext we define it as : so that the
287       dnl Makefiles still can work.
288       if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
289         : ;
290       else
291         AC_MSG_RESULT(
292           [found xgettext program is not GNU xgettext; ignore it])
293         XGETTEXT=":"
294       fi
295     fi
296
297     # We need to process the po/ directory.
298     POSUB=po
299
300     AC_OUTPUT_COMMANDS(
301       [case "$CONFIG_FILES" in *po/Makefile.in*)
302         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
303       esac])
304
305     dnl These rules are solely for the distribution goal.  While doing this
306     dnl we only have to keep exactly one list of the available catalogs
307     dnl in configure.in.
308     for lang in $ALL_LINGUAS; do
309       GMOFILES="$GMOFILES $lang.gmo"
310       POFILES="$POFILES $lang.po"
311     done
312
313     dnl Make all variables we use known to autoconf.
314     AC_SUBST(CATALOGS)
315     AC_SUBST(CATOBJEXT)
316     AC_SUBST(DATADIRNAME)
317     AC_SUBST(GMOFILES)
318     AC_SUBST(INSTOBJEXT)
319     AC_SUBST(INTLDEPS)
320     AC_SUBST(INTLLIBS)
321     AC_SUBST(INTLOBJS)
322     AC_SUBST(POFILES)
323     AC_SUBST(POSUB)
324   ])
325
326 AC_DEFUN(AM_GLIB_GNU_GETTEXT,
327   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
328    AC_REQUIRE([AC_PROG_CC])dnl
329    AC_REQUIRE([AC_PROG_RANLIB])dnl
330    AC_REQUIRE([AC_HEADER_STDC])dnl
331    AC_REQUIRE([AC_C_CONST])dnl
332    AC_REQUIRE([AC_C_INLINE])dnl
333    AC_REQUIRE([AC_TYPE_OFF_T])dnl
334    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
335    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
336    AC_REQUIRE([AC_FUNC_MMAP])dnl
337
338    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
339 unistd.h sys/param.h])
340    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
341 strdup __argz_count __argz_stringify __argz_next])
342
343    AM_GLIB_LC_MESSAGES
344    AM_GLIB_WITH_NLS
345
346    if test "x$CATOBJEXT" != "x"; then
347      if test "x$ALL_LINGUAS" = "x"; then
348        LINGUAS=
349      else
350        AC_MSG_CHECKING(for catalogs to be installed)
351        NEW_LINGUAS=
352        for lang in ${LINGUAS=$ALL_LINGUAS}; do
353          case "$ALL_LINGUAS" in
354           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
355          esac
356        done
357        LINGUAS=$NEW_LINGUAS
358        AC_MSG_RESULT($LINGUAS)
359      fi
360
361      dnl Construct list of names of catalog files to be constructed.
362      if test -n "$LINGUAS"; then
363        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
364      fi
365    fi
366
367    dnl Determine which catalog format we have (if any is needed)
368    dnl For now we know about two different formats:
369    dnl   Linux libc-5 and the normal X/Open format
370    test -d po || mkdir po
371    if test "$CATOBJEXT" = ".cat"; then
372      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
373
374      dnl Transform the SED scripts while copying because some dumb SEDs
375      dnl cannot handle comments.
376      sed -e '/^#/d' $srcdir/po/$msgformat-msg.sed > po/po2msg.sed
377    fi
378
379    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
380    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
381    dnl Try to locate is.
382    MKINSTALLDIRS=
383    if test -n "$ac_aux_dir"; then
384      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
385    fi
386    if test -z "$MKINSTALLDIRS"; then
387      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
388    fi
389    AC_SUBST(MKINSTALLDIRS)
390
391    dnl Generate list of files to be processed by xgettext which will
392    dnl be included in po/Makefile.
393    test -d po || mkdir po
394    if test "x$srcdir" != "x."; then
395      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
396        posrcprefix="$srcdir/"
397      else
398        posrcprefix="../$srcdir/"
399      fi
400    else
401      posrcprefix="../"
402    fi
403    rm -f po/POTFILES
404    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
405         < $srcdir/po/POTFILES.in > po/POTFILES
406   ])
407