I18N: automatic determination of potfiles list
Zack Weinberg
zack@codesourcery.com
Mon Oct 29 21:46:00 GMT 2001
On Mon, Oct 29, 2001 at 09:17:09PM -0800, Zack Weinberg wrote:
> This patch causes us to calculate the list of files to be scanned for
> message translation on the fly.
Agh, there were stray bits from a previous version of the patch. This
is the correct diff for Makefile.in and po/EXCLUDES. Only one
adjustment to the changelog:
> (po-generated): New target; depend on c-parse.c
and tradcif.c.
zw
===================================================================
Index: Makefile.in
--- Makefile.in 2001/10/29 14:34:18 1.760
+++ Makefile.in 2001/10/30 05:46:02
@@ -49,11 +49,6 @@ SUBDIRS =@subdirs@
CONFIG_LANGUAGES = @all_languages@
LANGUAGES = c gcov$(exeext) $(CONFIG_LANGUAGES)
-# Languages should create dependencies of $(INTL_TARGETS) on generated
-# sources in Make-lang.in. Example:
-# $(INTL_TARGETS): $(srcdir)/cp/parse.c
-INTL_TARGETS = intl.all intl.install
-
# Selection of languages to be made during stage1 build.
# This is overridden by configure.
BOOT_LANGUAGES = c @all_boot_languages@
@@ -341,8 +336,7 @@ INTLDEPS = @INTLDEPS@
LIBICONV = @LIBICONV@
# List of internationalization subdirectories.
-POSUB = @POSUB@
-INTL_SUBDIRS = intl $(POSUB)
+INTL_SUBDIRS = intl
# Change this to a null string if obstacks are installed in the
# system library.
@@ -836,8 +830,9 @@ LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udi
#
# The only suffixes we want for implicit rules are .c and .o, so clear
# the list and add them. This speeds up GNU Make, and allows -r to work.
+# For i18n support, we also need .gmo, .po, .pox.
.SUFFIXES:
-.SUFFIXES: .c .o
+.SUFFIXES: .c .o .po .gmo
Makefile: $(srcdir)/Makefile.in config.status $(srcdir)/version.c \
$(xmake_file) $(tmake_file) $(LANG_MAKEFILES)
@@ -941,7 +936,7 @@ start.encap: native xgcc$(exeext) cpp$(e
rest.encap: $(STMP_FIXPROTO) $(LIBGCC) $(EXTRA_PARTS) lang.rest.encap
# This is what is made with the host's compiler
# whether making a cross compiler or not.
-native: config.status auto-host.h intl.all $(LANGUAGES) \
+native: config.status auto-host.h intl.all @POSUB@ $(LANGUAGES) \
$(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(USE_COLLECT2)
# Define the names for selecting languages in LANGUAGES.
@@ -1969,9 +1964,6 @@ intl.o: intl.c $(CONFIG_H) system.h intl
$(top_builddir)/intl/libintl.a: intl.all
-# Make sure all the headers are there for xgettext to scan.
-$(INTL_TARGETS): $(CONFIG_H) $(srcdir)/c-parse.c
-
intl.all intl.install intl.uninstall \
intl.mostlyclean intl.clean intl.distclean intl.maintainer-clean:
@for d in $(INTL_SUBDIRS); do \
@@ -1981,6 +1973,14 @@ intl.all intl.install intl.uninstall \
if [ $$? -eq 0 ] ; then true ; else exit 1 ; fi ; \
done
+# intl.all and intl.install need config.h to exist, and the files it includes.
+# (FIXME: intl/*.c shouldn't need to see insn-foo.h!)
+intl.all intl.install: config.h insn-flags.h insn-constants.h
+
+# Make-lang.in should add dependencies of po-generated on any generated
+# files which need to be scanned by gettext (usually Yacc-generated parsers).
+po-generated: c-parse.c tradcif.c
+
#
# Remake cpp and protoize.
@@ -2496,7 +2496,7 @@ install: $(INSTALL_TARGET) ; @true
# Install the driver last so that the window when things are
# broken is small.
install-normal: install-common $(INSTALL_HEADERS) $(INSTALL_LIBGCC) \
- $(INSTALL_CPP) install-man install-info intl.install \
+ $(INSTALL_CPP) install-man install-info intl.install install-@POSUB@ \
lang.install-normal install-driver
# Do nothing while making gcc with a cross-compiler. The person who
@@ -3337,3 +3337,65 @@ float.h-cross:
echo "#error float.h values not known for cross-compiler" >> t-float.h-cross
echo "#endif" >> t-float.h-cross
mv t-float.h-cross float.h-cross
+
+# Rules for generating translated message descriptions.
+# Disabled by autoconf if the tools are not available.
+
+XGETTEXT = @XGETTEXT@
+GMSGFMT = @GMSGFMT@
+MSGMERGE = msgmerge
+
+PACKAGE = @PACKAGE@
+CATALOGS = @CATALOGS@
+
+po: $(CATALOGS)
+
+# This notation should be acceptable to all Make implementations used
+# by people who are interested in updating .po files.
+update-po: $(CATALOGS:.gmo=.pox)
+
+# Update files in $(srcdir) atomically.
+.po.gmo:
+ $(GMSGFMT) --statistics $< -o $@
+ $(SHELL) $(srcdir)/move-if-change $@ $(srcdir)/$@
+
+# This rule does _not_ copy into $(srcdir). User must do this
+# by hand. (User is a translation maintainer and is expected to
+# go through the new .po by hand anyway.)
+.po.pox:
+ $(MSGMERGE) $< $(srcdir)/po/$(PACKAGE).pot -o $@
+
+# Dummy rule to deal with dependency produced by use of
+# "install-@POSUB@" above, when NLS is disabled.
+install-:
+
+install-po:
+ $(mkinstalldirs) $(DESTDIR)$(datadir)
+ for cat in $(CATALOGS); do \
+ cat=`basename $$cat`; \
+ lang=`echo $$cat | sed 's/\.gmo$$//'`; \
+ dir=$(localedir)/$$lang/LC_MESSAGES; \
+ $(mkinstalldirs) $(DESTDIR)$$dir; \
+ if test -r $$cat; then \
+ $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE).mo; \
+ echo "installing $$cat as $(DESTDIR)$$dir/$(PACKAGE).mo"; \
+ else \
+ $(INSTALL_DATA) $(srcdir)/$$cat $(DESTDIR)$$dir/$(PACKAGE).mo; \
+ echo "installing $(srcdir)/$$cat as" \
+ "$(DESTDIR)$$dir/$(PACKAGE).mo"; \
+ fi; \
+ done
+
+# Rule for regenerating the message template (gcc.pot).
+# Instead of forcing everyone to edit POTFILES.in, which proved impractical,
+# this rule has no dependencies and always regenerates gcc.pot. This is
+# relatively harmless since the .po files do not directly depend on it.
+# Note that exgettext has an awk script embedded in it which requires a
+# fairly modern (POSIX-compliant) awk.
+$(PACKAGE).pot: po/$(PACKAGE).pot
+po/$(PACKAGE).pot: force
+ $(MAKE) po-generated
+ AWK=$(AWK) $(SHELL) $(srcdir)/po/exgettext \
+ $(XGETTEXT) $(PACKAGE) $(srcdir)
+ $(SHELL) $(srcdir)/move-if-change $(PACKAGE).pot \
+ $(srcdir)/po/$(PACKAGE).pot
===================================================================
Index: po/EXCLUDES
--- po/EXCLUDES Tue May 5 13:32:27 1998
+++ po/EXCLUDES Mon Oct 29 21:46:02 2001
@@ -0,0 +1,64 @@
+# This file lists all the sources which should *not* be scanned for
+# strings to translate. Only the first word on each line is used; the
+# rest is ignored. Only files with an extension of .c or .h are
+# examined to begin with.
+
+# These files are part of libgcc, or target headers provided by gcc.
+config/rs6000/sol-c0.c
+config/float-c4x.h
+config/float-i128.h
+config/float-i32.h
+config/float-i386.h
+config/float-i64.h
+config/float-m68k.h
+config/float-sh.h
+config/float-sparc.h
+config/float-vax.h
+crtstuff.c
+frame.h
+gbl-ctors.h
+libgcc1.c
+libgcc1-test.c
+libgcc2.c
+libgcc2.h
+limitx.h
+limity.h
+longlong.h
+unwind-dw2-fde.c
+unwind-dw2-fde.h
+unwind-dw2.c
+unwind-pe.h
+unwind-sjlj.c
+unwind.h
+
+# These programs are meant to be executed only by GCC maintainers or
+# installers. Such files do not need to be translated, as these
+# people typically need to be able to read English anyway.
+enquire.c
+fix-header.c
+gen-protos.c
+genattr.c
+genattrtab.c
+gencheck.c
+gencodes.c
+genconfig.c
+genconstants.c
+genemit.c
+genextract.c
+genflags.c
+gengenrtl.c
+genopinit.c
+genoutput.c
+genpeep.c
+genpreds.c
+genrecog.c
+gensupport.c
+gensupport.h
+scan-decls.c
+scan.c
+scan.h
+
+# These files are not yet internationalized, because they contain
+# many strings that require a lot of analysis, and are little-used.
+mips-tdump.c
+mips-tfile.c
More information about the Gcc-patches
mailing list