~ubuntu-branches/ubuntu/lucid/gco/lucid

« back to all changes in this revision

Viewing changes to macros/gnome-gettext.m4

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hocevar (Debian packages)
  • Date: 2006-08-31 12:35:42 UTC
  • mfrom: (3.1.2 edgy)
  • Revision ID: james.westby@ubuntu.com-20060831123542-mc4q70vmhci7jkx7
Tags: 0.5.0-6
Update package to the last python policy, courtesy of Pierre Habouzit
(Closes: #380807).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Macro to add for using GNU gettext.
2
 
# Ulrich Drepper <drepper@cygnus.com>, 1995.
3
 
#
4
 
# Modified to never use included libintl. 
5
 
# Owen Taylor <otaylor@redhat.com>, 12/15/1998
6
 
#
7
 
#
8
 
# This file can be copied and used freely without restrictions.  It can
9
 
# be used in projects which are not available under the GNU Public License
10
 
# but which still want to provide support for the GNU gettext functionality.
11
 
# Please note that the actual code is *not* freely available.
12
 
 
13
 
# serial 5
14
 
 
15
 
AC_DEFUN(AM_GNOME_WITH_NLS,
16
 
  [AC_MSG_CHECKING([whether NLS is requested])
17
 
    dnl Default is enabled NLS
18
 
    AC_ARG_ENABLE(nls,
19
 
      [  --disable-nls           do not use Native Language Support],
20
 
      USE_NLS=$enableval, USE_NLS=yes)
21
 
    AC_MSG_RESULT($USE_NLS)
22
 
    AC_SUBST(USE_NLS)
23
 
 
24
 
    USE_INCLUDED_LIBINTL=no
25
 
 
26
 
    dnl If we use NLS figure out what method
27
 
    if test "$USE_NLS" = "yes"; then
28
 
      AC_DEFINE(ENABLE_NLS)
29
 
#      AC_MSG_CHECKING([whether included gettext is requested])
30
 
#      AC_ARG_WITH(included-gettext,
31
 
#        [  --with-included-gettext use the GNU gettext library included here],
32
 
#        nls_cv_force_use_gnu_gettext=$withval,
33
 
#        nls_cv_force_use_gnu_gettext=no)
34
 
#      AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
35
 
      nls_cv_force_use_gnu_gettext="no"
36
 
 
37
 
      nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
38
 
      if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
39
 
        dnl User does not insist on using GNU NLS library.  Figure out what
40
 
        dnl to use.  If gettext or catgets are available (in this order) we
41
 
        dnl use this.  Else we have to fall back to GNU NLS library.
42
 
        dnl catgets is only used if permitted by option --with-catgets.
43
 
        nls_cv_header_intl=
44
 
        nls_cv_header_libgt=
45
 
        CATOBJEXT=NONE
46
 
 
47
 
        AC_CHECK_HEADER(libintl.h,
48
 
          [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
49
 
            [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
50
 
               gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
51
 
 
52
 
           if test "$gt_cv_func_gettext_libc" != "yes"; then
53
 
             AC_CHECK_LIB(intl, bindtextdomain,
54
 
               [AC_CACHE_CHECK([for gettext in libintl],
55
 
                 gt_cv_func_gettext_libintl,
56
 
                 [AC_CHECK_LIB(intl, gettext,
57
 
                  gt_cv_func_gettext_libintl=yes,
58
 
                  gt_cv_func_gettext_libintl=no)],
59
 
                 gt_cv_func_gettext_libintl=no)])
60
 
           fi
61
 
 
62
 
           if test "$gt_cv_func_gettext_libc" = "yes" \
63
 
              || test "$gt_cv_func_gettext_libintl" = "yes"; then
64
 
              AC_DEFINE(HAVE_GETTEXT)
65
 
              AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
66
 
                [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
67
 
              if test "$MSGFMT" != "no"; then
68
 
                AC_CHECK_FUNCS(dcgettext)
69
 
                AC_CHECK_FUNCS(dgettext)
70
 
                AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
71
 
                AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
72
 
                  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
73
 
                AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
74
 
                               return _nl_msg_cat_cntr],
75
 
                  [CATOBJEXT=.gmo
76
 
                   DATADIRNAME=share],
77
 
                  [CATOBJEXT=.mo
78
 
                   DATADIRNAME=lib])
79
 
                INSTOBJEXT=.mo
80
 
              else
81
 
                echo "You must install msgfmt (part of gettext)."
82
 
              fi
83
 
            fi
84
 
 
85
 
            # Added by Martin Baulig 12/15/98 for libc5 systems
86
 
            if test "$gt_cv_func_gettext_libc" != "yes" \
87
 
               && test "$gt_cv_func_gettext_libintl" = "yes"; then
88
 
               INTLLIBS=-lintl
89
 
               LIBS=`echo $LIBS | sed -e 's/-lintl//'`
90
 
            fi
91
 
        ])
92
 
 
93
 
        if test "$CATOBJEXT" = "NONE"; then
94
 
          AC_MSG_CHECKING([whether catgets can be used])
95
 
          AC_ARG_WITH(catgets,
96
 
            [  --with-catgets          use catgets functions if available],
97
 
            nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
98
 
          AC_MSG_RESULT($nls_cv_use_catgets)
99
 
 
100
 
          if test "$nls_cv_use_catgets" = "yes"; then
101
 
            dnl No gettext in C library.  Try catgets next.
102
 
            AC_CHECK_LIB(i, main)
103
 
            AC_CHECK_FUNC(catgets,
104
 
              [AC_DEFINE(HAVE_CATGETS)
105
 
               INTLOBJS="\$(CATOBJS)"
106
 
               AC_PATH_PROG(GENCAT, gencat, no)dnl
107
 
#              if test "$GENCAT" != "no"; then
108
 
#                AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
109
 
#                if test "$GMSGFMT" = "no"; then
110
 
#                  AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
111
 
#                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
112
 
#                fi
113
 
#                AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
114
 
#                  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
115
 
#                USE_INCLUDED_LIBINTL=yes
116
 
#                CATOBJEXT=.cat
117
 
#                INSTOBJEXT=.cat
118
 
#                DATADIRNAME=lib
119
 
#                INTLDEPS='$(top_builddir)/intl/libintl.a'
120
 
#                INTLLIBS=$INTLDEPS
121
 
#                LIBS=`echo $LIBS | sed -e 's/-lintl//'`
122
 
#                nls_cv_header_intl=intl/libintl.h
123
 
#                nls_cv_header_libgt=intl/libgettext.h
124
 
#              fi
125
 
            ])
126
 
          fi
127
 
        fi
128
 
 
129
 
        if test "$CATOBJEXT" = "NONE"; then
130
 
          dnl Neither gettext nor catgets in included in the C library.
131
 
          dnl Fall back on GNU gettext library.
132
 
          nls_cv_use_gnu_gettext=yes
133
 
        fi
134
 
      fi
135
 
 
136
 
      if test "$nls_cv_use_gnu_gettext" != "yes"; then
137
 
        AC_DEFINE(ENABLE_NLS)
138
 
      else
139
 
         # Unset this variable since we use the non-zero value as a flag.
140
 
         CATOBJEXT=
141
 
#        dnl Mark actions used to generate GNU NLS library.
142
 
#        INTLOBJS="\$(GETTOBJS)"
143
 
#        AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
144
 
#         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
145
 
#        AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
146
 
#        AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
147
 
#         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
148
 
#        AC_SUBST(MSGFMT)
149
 
#       USE_INCLUDED_LIBINTL=yes
150
 
#        CATOBJEXT=.gmo
151
 
#        INSTOBJEXT=.mo
152
 
#        DATADIRNAME=share
153
 
#       INTLDEPS='$(top_builddir)/intl/libintl.a'
154
 
#       INTLLIBS=$INTLDEPS
155
 
#       LIBS=`echo $LIBS | sed -e 's/-lintl//'`
156
 
#        nls_cv_header_intl=intl/libintl.h
157
 
#        nls_cv_header_libgt=intl/libgettext.h
158
 
      fi
159
 
 
160
 
      dnl Test whether we really found GNU xgettext.
161
 
      if test "$XGETTEXT" != ":"; then
162
 
        dnl If it is no GNU xgettext we define it as : so that the
163
 
        dnl Makefiles still can work.
164
 
        if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
165
 
          : ;
166
 
        else
167
 
          AC_MSG_RESULT(
168
 
            [found xgettext program is not GNU xgettext; ignore it])
169
 
          XGETTEXT=":"
170
 
        fi
171
 
      fi
172
 
 
173
 
      # We need to process the po/ directory.
174
 
      POSUB=po
175
 
    else
176
 
      DATADIRNAME=share
177
 
      nls_cv_header_intl=intl/libintl.h
178
 
      nls_cv_header_libgt=intl/libgettext.h
179
 
    fi
180
 
    AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
181
 
    AC_OUTPUT_COMMANDS(
182
 
     [case "$CONFIG_FILES" in *po/Makefile.in*)
183
 
        sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
184
 
      esac])
185
 
 
186
 
 
187
 
#    # If this is used in GNU gettext we have to set USE_NLS to `yes'
188
 
#    # because some of the sources are only built for this goal.
189
 
#    if test "$PACKAGE" = gettext; then
190
 
#      USE_NLS=yes
191
 
#      USE_INCLUDED_LIBINTL=yes
192
 
#    fi
193
 
 
194
 
    dnl These rules are solely for the distribution goal.  While doing this
195
 
    dnl we only have to keep exactly one list of the available catalogs
196
 
    dnl in configure.in.
197
 
    for lang in $ALL_LINGUAS; do
198
 
      GMOFILES="$GMOFILES $lang.gmo"
199
 
      POFILES="$POFILES $lang.po"
200
 
    done
201
 
 
202
 
    dnl Make all variables we use known to autoconf.
203
 
    AC_SUBST(USE_INCLUDED_LIBINTL)
204
 
    AC_SUBST(CATALOGS)
205
 
    AC_SUBST(CATOBJEXT)
206
 
    AC_SUBST(DATADIRNAME)
207
 
    AC_SUBST(GMOFILES)
208
 
    AC_SUBST(INSTOBJEXT)
209
 
    AC_SUBST(INTLDEPS)
210
 
    AC_SUBST(INTLLIBS)
211
 
    AC_SUBST(INTLOBJS)
212
 
    AC_SUBST(POFILES)
213
 
    AC_SUBST(POSUB)
214
 
  ])
215
 
 
216
 
AC_DEFUN(AM_GNOME_GETTEXT,
217
 
  [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
218
 
   AC_REQUIRE([AC_PROG_CC])dnl
219
 
   AC_REQUIRE([AC_PROG_RANLIB])dnl
220
 
   AC_REQUIRE([AC_ISC_POSIX])dnl
221
 
   AC_REQUIRE([AC_HEADER_STDC])dnl
222
 
   AC_REQUIRE([AC_C_CONST])dnl
223
 
   AC_REQUIRE([AC_C_INLINE])dnl
224
 
   AC_REQUIRE([AC_TYPE_OFF_T])dnl
225
 
   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
226
 
   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
227
 
   AC_REQUIRE([AC_FUNC_MMAP])dnl
228
 
 
229
 
   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
230
 
unistd.h sys/param.h])
231
 
   AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
232
 
strdup __argz_count __argz_stringify __argz_next])
233
 
 
234
 
   if test "${ac_cv_func_stpcpy+set}" != "set"; then
235
 
     AC_CHECK_FUNCS(stpcpy)
236
 
   fi
237
 
   if test "${ac_cv_func_stpcpy}" = "yes"; then
238
 
     AC_DEFINE(HAVE_STPCPY)
239
 
   fi
240
 
 
241
 
   AM_LC_MESSAGES
242
 
   AM_GNOME_WITH_NLS
243
 
 
244
 
   if test "x$CATOBJEXT" != "x"; then
245
 
     if test "x$ALL_LINGUAS" = "x"; then
246
 
       LINGUAS=
247
 
     else
248
 
       AC_MSG_CHECKING(for catalogs to be installed)
249
 
       NEW_LINGUAS=
250
 
       if test "x$LINGUAS" = "x"; then
251
 
           LINGUAS=$ALL_LINGUAS
252
 
       fi
253
 
       for lang in $LINGUAS; do
254
 
         case "$ALL_LINGUAS" in
255
 
          *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
256
 
         esac
257
 
       done
258
 
       LINGUAS=$NEW_LINGUAS
259
 
       AC_MSG_RESULT($LINGUAS)
260
 
     fi
261
 
 
262
 
     dnl Construct list of names of catalog files to be constructed.
263
 
     if test -n "$LINGUAS"; then
264
 
       for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
265
 
     fi
266
 
   fi
267
 
 
268
 
   dnl The reference to <locale.h> in the installed <libintl.h> file
269
 
   dnl must be resolved because we cannot expect the users of this
270
 
   dnl to define HAVE_LOCALE_H.
271
 
   if test $ac_cv_header_locale_h = yes; then
272
 
     INCLUDE_LOCALE_H="#include <locale.h>"
273
 
   else
274
 
     INCLUDE_LOCALE_H="\
275
 
/* The system does not provide the header <locale.h>.  Take care yourself.  */"
276
 
   fi
277
 
   AC_SUBST(INCLUDE_LOCALE_H)
278
 
 
279
 
   dnl Determine which catalog format we have (if any is needed)
280
 
   dnl For now we know about two different formats:
281
 
   dnl   Linux libc-5 and the normal X/Open format
282
 
   test -d intl || mkdir intl
283
 
   if test "$CATOBJEXT" = ".cat"; then
284
 
     AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
285
 
 
286
 
     dnl Transform the SED scripts while copying because some dumb SEDs
287
 
     dnl cannot handle comments.
288
 
     sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
289
 
   fi
290
 
   dnl po2tbl.sed is always needed.
291
 
   sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
292
 
     $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
293
 
 
294
 
   dnl In the intl/Makefile.in we have a special dependency which makes
295
 
   dnl only sense for gettext.  We comment this out for non-gettext
296
 
   dnl packages.
297
 
   if test "$PACKAGE" = "gettext"; then
298
 
     GT_NO="#NO#"
299
 
     GT_YES=
300
 
   else
301
 
     GT_NO=
302
 
     GT_YES="#YES#"
303
 
   fi
304
 
   AC_SUBST(GT_NO)
305
 
   AC_SUBST(GT_YES)
306
 
 
307
 
   dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
308
 
   dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
309
 
   dnl Try to locate is.
310
 
   MKINSTALLDIRS=
311
 
   if test -n "$ac_aux_dir"; then
312
 
     MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
313
 
   fi
314
 
   if test -z "$MKINSTALLDIRS"; then
315
 
     MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
316
 
   fi
317
 
   AC_SUBST(MKINSTALLDIRS)
318
 
 
319
 
   dnl *** For now the libtool support in intl/Makefile is not for real.
320
 
   l=
321
 
   AC_SUBST(l)
322
 
 
323
 
   dnl Generate list of files to be processed by xgettext which will
324
 
   dnl be included in po/Makefile.
325
 
   test -d po || mkdir po
326
 
   if test "x$srcdir" != "x."; then
327
 
     if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
328
 
       posrcprefix="$srcdir/"
329
 
     else
330
 
       posrcprefix="../$srcdir/"
331
 
     fi
332
 
   else
333
 
     posrcprefix="../"
334
 
   fi
335
 
   rm -f po/POTFILES
336
 
   sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
337
 
        < $srcdir/po/POTFILES.in > po/POTFILES
338
 
  ])
339