# # # delete "po/POTFILES.in" # # delete "po/POTFILES.skip" # # delete "po/remove-potcdate.sin" # # add_file "m4/mtn-gettext.m4" # content [d86e51b0bea3264152d2c3c3be140ce880c4c1f3] # # patch "Makefile.am" # from [24a49b6a2886c1adcfbf6ecda1183626cce5d15b] # to [d6351a733601012b0ef0558e244abbbb47064778] # # patch "configure.ac" # from [2caa1ffd67b28d0ba6fafcea138b7963a9db029d] # to [713299aeb8b21f4c66733e684a02ab9042ab6f62] # # patch "po/Makevars" # from [39ebd1daa879a3c8906b2b98d764f82a337c42e1] # to [21ea46d8804edc5eef509858140a75fb0e40623c] # ============================================================ --- m4/mtn-gettext.m4 d86e51b0bea3264152d2c3c3be140ce880c4c1f3 +++ m4/mtn-gettext.m4 d86e51b0bea3264152d2c3c3be140ce880c4c1f3 @@ -0,0 +1,230 @@ +# This is a custom set of probe macros for xgettext and the gettext +# library (either in libc or as -lintl [-liconv]). The differences +# from the standard version are as follows: +# +# - Library tests work correctly under AC_LANG([C++]). +# - Library tests have far fewer dependencies. +# - Does not require use of autopoint. +# - Does not use a Makefile in the po/ directory. +# (Instead, sets AM_CONDITIONALs; must be paired with appropriate +# Makefile.am logic.) +# - Does not support bundled libintl/libiconv. +# - Always checks for ngettext(). +# - Always checks for the --flag option to xgettext. +# - Never checks for support for format string macros. +# - If you give an explicit --enable-nls on the command line and the +# library functions are not available, configure will error out. +# - Does not use POTFILES.in. (Does use the LINGUAS file, as this is +# a sensible way of suppressing out-of-date translations.) + +AC_DEFUN([MTN_GNU_GETTEXT], [ +AC_ARG_VAR([LINGUAS], [List of languages to install message translations for, if available. (Default is to install everything available.)]) +AC_ARG_VAR([intl_CFLAGS], [override C compiler flags for GNU libintl]) +AC_ARG_VAR([intl_LIBS], [override linker flags for GNU libintl]) + +AC_ARG_ENABLE([nls], + [AS_HELP_STRING([--disable-nls], + [do not use user's native language for program messages])], + [USE_NLS=$enableval], + [USE_NLS=auto]) + +MTN_PROG_GNU_GETTEXT +MTN_LIB_GNU_GETTEXT +MTN_VARS_GNU_GETTEXT]) + +# Probe for gettext and related programs. +# This happens whether or not NLS is disabled, because it's needed for +# 'make dist'. +AC_DEFUN([MTN_PROG_GNU_GETTEXT], [ + dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. + dnl The second test excludes FreeBSD msgfmt. + AC_CACHE_CHECK([for GNU msgfmt], [ac_cv_path_gnu_msgfmt], + [AC_PATH_PROGS_FEATURE_CHECK([gnu_msgfmt], [msgfmt gmsgfmt], + [[if "$ac_path_gnu_msgfmt" --statistics /dev/null >/dev/null 2>&1; then + if "$ac_path_gnu_msgfmt" --statistics /dev/null 2>&1 >/dev/null | + grep usage >/dev/null; then + : # no good + else + ac_cv_path_gnu_msgfmt="$ac_path_gnu_msgfmt" + ac_path_gnu_msgfmt_found=: + fi + fi]], + [ac_cv_path_gnu_msgfmt="not found"])]) + AC_SUBST([MSGFMT], [$ac_cv_path_gnu_msgfmt]) + + AC_CACHE_CHECK([for GNU msgmerge], [ac_cv_path_gnu_msgmerge], + [AC_PATH_PROGS_FEATURE_CHECK([gnu_msgmerge], [msgmerge gmsgmerge], + [[if "$ac_path_gnu_msgmerge" --update -q /dev/null /dev/null \ + >/dev/null 2>&1; then + ac_cv_path_gnu_msgmerge="$ac_path_gnu_msgmerge" + ac_path_gnu_msgmerge_found=: + fi]], + [ac_cv_path_gnu_msgmerge="not found"])]) + AC_SUBST([MSGMERGE], [$ac_cv_path_gnu_msgmerge]) + + dnl The first test excludes Solaris xgettext and early GNU xgettext versions. + dnl The second test excludes FreeBSD xgettext. + AC_CACHE_CHECK([for GNU xgettext], [ac_cv_path_gnu_xgettext], + [AC_PATH_PROGS_FEATURE_CHECK([gnu_xgettext], [xgettext gxgettext], + [[if "$ac_path_gnu_xgettext" --omit-header --copyright-holder= \ + /dev/null >/dev/null 2>&1; then + if "$ac_path_gnu_xgettext" --omit-header --copyright-holder= \ + /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then + : # no good + else + ac_cv_path_gnu_xgettext="$ac_path_gnu_xgettext" + ac_path_gnu_xgettext_found=: + fi + fi]], + [ac_cv_path_gnu_xgettext="not found"])]) + AC_SUBST([XGETTEXT], [$ac_cv_path_gnu_xgettext]) + + dnl Remove leftover from FreeBSD xgettext call. + rm -f messages.po + + if test x"$XGETTEXT" != x"not found"; then + AC_CACHE_CHECK([whether $XGETTEXT supports --flag], + [ac_cv_prog_xgettext_flag_option], + [echo 'int main(void) { return 0; }' >> conftest.c + if "$XGETTEXT" --flag printf:1:c-format -o conftest.po conftest.c \ + >/dev/null 2>&1 + then ac_cv_prog_xgettext_flag_option=yes + else ac_cv_prog_xgettext_flag_option=no + fi]) + + # The variable names here are chosen for compatibility with + # intltool-update; see po/Makevars. + if test $ac_cv_prog_xgettext_flag_option = yes; then + XGETTEXT_OPTS='$(XGETTEXT_OPTIONS)' + else + XGETTEXT_OPTS='$(XGETTEXT_OPTIONS_NO_FLAG)' + fi + else + XGETTEXT_OPTS= + fi + AC_SUBST([XGETTEXT_OPTS]) + + if test x"$MSGFMT" = x"not found" || + test x"$MSGMERGE" = x"not found" || + test x"$XGETTEXT" = x"not found"; then + REBUILD_NLS=false + else + REBUILD_NLS=true + fi + AM_CONDITIONAL([REBUILD_NLS], [$REBUILD_NLS]) +]) + +# Probe for NLS functions in libc, then in libintl, and throw +# in libiconv if needed. These tests are skipped when --disable-nls is +# given. If --enable-nls was given explicitly, we bomb out if we can't +# find the libraries. +AC_DEFUN([MTN_LIB_GNU_GETTEXT], [ +if test x"$USE_NLS" != xno; then + dnl This is not the same test that gettext.m4 does, so we do not use + dnl the same cache variables. In particular it does not look for any + dnl _nl_* symbols. + AC_CACHE_CHECK([for libraries containing GNU gettext and ngettext], + [mtn_cv_lib_gnu_gettext_ngettext], + [# If the user specified the libraries we're supposed to use, test + # those and no others. + if test x"${intl_LIBS+set}" = xset; then + set fnord "${intl_LIBS}" + else + set fnord '' '-lintl' '-lintl -liconv' + fi + shift + + mtn_cv_lib_gnu_gettext_ngettext="not found" + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$save_CFLAGS $intl_CFLAGS" + for try in "$@"; do + LIBS="$save_LIBS $try" + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], [[ + const char *a = textdomain(""); + const char *b = bindtextdomain("", ""); + const char *c = gettext(""); + const char *d = ngettext("", "", 0); + return a && b && c && d; + ]])], + [mtn_cv_lib_gnu_gettext_ngettext="${try:-none required}" + break]) + done + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + ]) + + if test x"$mtn_cv_lib_gnu_gettext_ngettext" = x"not found"; then + if test x"$USE_NLS" = xyes; then + AC_MSG_FAILURE([no usable NLS libraries found]) + else + intl_LIBS="" + USE_NLS=no + fi + else + USE_NLS=yes + intl_LIBS="$mtn_cv_lib_gnu_gettext_ngettext" + if test x"$intl_LIBS" = x"none required"; then + intl_LIBS="" + fi + fi +fi +if test $USE_NLS = yes; then + AC_DEFINE(ENABLE_NLS, 1, + [Define to 1 if program messages should use the user's native language.]) +fi +AM_CONDITIONAL(USE_NLS, [test x$USE_NLS = xyes]) +]) + +# Logic to set Makefile variables that depend on what language translations +# are available. +AC_DEFUN([MTN_VARS_GNU_GETTEXT], [ + GOOD_LINGUAS= + if test -f "$srcdir/po/LINGUAS"; then + GOOD_LINGUAS=`sed -e '/^#/d' $srcdir/po/LINGUAS | tr "$as_nl" " "` + fi + + if test x"$LINGUAS" = x; then + INST_LINGUAS="$GOOD_LINGUAS" + else + INST_LINGUAS= + for candidate in $GOOD_LINGUAS; do + for desired in $LINGUAS; do + case "$desired" in "$candidate"*) + INST_LINGUAS="$INST_LINGUAS $candidate" + break ;; + esac + done + done + fi + AC_SUBST(INST_LINGUAS) +]) + +# pre autoconf 2.62 support; fallback code lifted directly from autoconf 2.62 +m4_ifndef([AC_PATH_PROGS_FEATURE_CHECK], [ +m4_define([_AC_PATH_PROGS_FEATURE_CHECK], +[if test -z "$$1"; then + ac_path_$1_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + _AS_PATH_WALK([$5], + [for ac_prog in $2; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_$1="$as_dir/$ac_prog$ac_exec_ext" + AS_EXECUTABLE_P(["$ac_path_$1"]) || continue +$3 + $ac_path_$1_found && break 3 + done + done])dnl + if test -z "$ac_cv_path_$1"; then + m4_default([$4], + [AC_MSG_ERROR([no acceptable m4_bpatsubst([$2], [ .*]) could be dnl +found in m4_default([$5], [\$PATH])])]) + fi +else + ac_cv_path_$1=$$1 +fi +]) +m4_define([AC_PATH_PROGS_FEATURE_CHECK], +[_$0([$1], [$2], [$3], m4_default([$4], [:]), [$5])dnl +]) +]) ============================================================ --- Makefile.am 24a49b6a2886c1adcfbf6ecda1183626cce5d15b +++ Makefile.am d6351a733601012b0ef0558e244abbbb47064778 @@ -1,4 +1,4 @@ -AUTOMAKE_OPTIONS=subdir-objects 1.7.1 +AUTOMAKE_OPTIONS=subdir-objects 1.7.1 -Wno-portability ACLOCAL_AMFLAGS = -I m4 CMD_SOURCES = \ @@ -194,6 +194,11 @@ html_DATA = monotone.html # flags +# sets DEFS for just this object +# the variable prevents this from overriding automake's unix/fs.o rule +UNIX=unix/ +$(UNIX)fs.$(OBJEXT) : DEFS += -DLOCALEDIR="\"$(localedir)\"" + if BUILD_PCH PCH_SOURCE = $(srcdir)/pch.hh @@ -219,7 +224,7 @@ endif || rm "./$(PCH_FILE).Tdep" endif -SUFFIXES = .gch +SUFFIXES = .gch .merged.po .gmo EXTERNAL_CPPFLAGS = $(pcre_CFLAGS) $(botan_CFLAGS) \ $(lua_CFLAGS) $(sqlite_CFLAGS) $(idn_CFLAGS) @@ -273,13 +278,6 @@ endif lib3rdparty_a_CPPFLAGS += -DNETXX_NO_INET6 endif -# i18n support - -SUBDIRS = po -datadir = @datadir@ -localedir = $(datadir)/locale -DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ - # extra files PDF_FIGURES= figures/branch-heads.pdf figures/cert.pdf \ @@ -344,6 +342,86 @@ $(top_builddir)/figures/%.ps: $(srcdir)/ # acroread -toPostScript -pairs $< $@ pdftops $< $@ + +# Message translation support +# INST_LINGUAS is set by configure, based on the po/LINGUAS file and +# the user's LINGUAS env. variable. Additional settings are in +# po/Makevars. +# +# Only the foo.po-update target will overwrite a file in the source +# po/ directory. + +include $(srcdir)/po/Makevars +ALL_POFILES := $(wildcard $(srcdir)/po/*.po) +ALL_LINGUAS := $(basename $(notdir $(ALL_POFILES))) +ALL_GMOFILES := $(addsuffix .gmo, $(ALL_LINGUAS)) +CLEAN_POFILES := $(ALL_GMOFILES) $(addsuffix .merged.po, $(ALL_LINGUAS)) \ + $(PACKAGE).pot + +EXTRA_DIST += $(ALL_POFILES) po/LINGUAS po/README + +if USE_NLS +# for installation +GMOFILES := $(addsuffix .gmo, $(INST_LINGUAS)) + +all-local: $(GMOFILES) + +install-data-local: all-local + @linguas='$(INST_LINGUAS)'; set -ex; for lang in $$linguas; do \ + dir=$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES; \ + $(MKDIR_P) $$dir; \ + $(INSTALL_DATA) $$lang.gmo $$dir/$(PACKAGE).mo; \ + done + +uninstall-local: + @linguas='$(INST_LINGUAS)'; set -ex; for lang in $$linguas; do \ + rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(PACKAGE).mo; \ + rmdir $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES || :; \ + rmdir $(DESTDIR)$(localedir)/$$lang || :; \ + done +endif + +if REBUILD_NLS +%.gmo: %.merged.po + $(MSGFMT) -c --statistics -o $@ $< + +%.merged.po: $(srcdir)/po/%.po $(PACKAGE).pot + $(MSGMERGE) $^ -o $@ + +# for translators' use +UPDATEPOFILES = $(addsuffix .po-update, $(ALL_LINGUAS)) + +%.po-update: $(srcdir)/po/%.po $(PACKAGE).pot + $(MSGMERGE) --update $^ + +update-po: $(UPDATEPOFILES) + +# for the template file +POTFILES = $(filter-out package_%, $(MOST_SOURCES)) \ + $(UNIX_PLATFORM_SOURCES) $(WIN32_PLATFORM_SOURCES) \ + monotone.cc std_hooks.lua + +$(PACKAGE).pot: $(POTFILES) + $(XGETTEXT) -o$@ -D$(top_srcdir) -cTRANSLATORS: \ + --package-name=$(PACKAGE) --package-version=$(VERSION) \ + --copyright-holder='$(COPYRIGHT_HOLDER)' \ + --msgid-bugs-address='$(MSGID_BUGS_ADDRESS)' \ + $(XGETTEXT_OPTS) \ + $(POTFILES) + +dist-hook: $(ALL_GMOFILES) + cp $^ $(distdir)/po + +else + +%.gmo: $(srcdir)/po/%.gmo + cp $< $@ + +dist-hook: + @echo "*** Cannot 'make dist' without xgettext" >&2; exit 1 + +endif + # build an OS X installer # requires sudo since packagemaker just looks at directory permissions. PKG_INST_ROOT = $(PWD)/$(top_builddir)/pkg_inst_root @@ -487,11 +565,11 @@ BUILT_SOURCES = $(PCH_FILE) $(PCH_BUILD) BUILT_SOURCES = $(PCH_FILE) $(PCH_BUILD) -CLEANFILES = $(BUILT_SOURCES) $(CLEAN_SOURCES) $(EPS_FIGURES) +CLEANFILES = $(BUILT_SOURCES) $(CLEAN_SOURCES) $(EPS_FIGURES) $(CLEAN_POFILES) -txt2c: txt2c.cc - $(CXX) $(CXXFLAGS) -o $@ $< - chmod 0755 address@hidden(EXEEXT) +# override compiler for txt2c +txt2c$(EXEEXT): txt2c.cc + $(CXX_FOR_BUILD) $(CXXFLAGS) -o $@ $< # FIXME: should use stamp files. %.cc: %.sql txt2c ============================================================ --- configure.ac 2caa1ffd67b28d0ba6fafcea138b7963a9db029d +++ configure.ac 713299aeb8b21f4c66733e684a02ab9042ab6f62 @@ -6,7 +6,7 @@ AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([1.9 tar-ustar std-options]) AC_CONFIG_SRCDIR([app_state.cc]) AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_FILES([Makefile po/Makefile.in util/mtnopt]) +AC_CONFIG_FILES([Makefile util/mtnopt]) AC_LANG([C++]) # Operating system categorization. Don't add more entries to this @@ -14,53 +14,47 @@ AC_MSG_CHECKING([category of operating s AC_CANONICAL_HOST AC_MSG_CHECKING([category of operating system]) -case "$host" in +WIN32_PLATFORM=false +os_err_t="int" +case "$host" in *-mingw32 | *-pc-pw32 | *-pc-mks | *-winnt ) AC_MSG_RESULT([Windows]) - - AM_CONDITIONAL(WIN32_PLATFORM, true) - AC_DEFINE(os_err_t, unsigned int, - [Define as the best type to hold an OS error code.]) + WIN32_PLATFORM="true" + os_err_t="unsigned int" ;; *-ibm-aix* ) AC_MSG_RESULT([AIX]) - - AM_CONDITIONAL(WIN32_PLATFORM, false) - AC_DEFINE(os_err_t, int, - [Define as the best type to hold an OS error code.]) LDFLAGS="$LDFLAGS -Wl,-bexpfull" ;; * ) AC_MSG_RESULT([Unix]) - - AM_CONDITIONAL(WIN32_PLATFORM, false) - AC_DEFINE(os_err_t, int, - [Define as the best type to hold an OS error code.]) ;; esac +AM_CONDITIONAL(WIN32_PLATFORM, $WIN32_PLATFORM) +AC_DEFINE_UNQUOTED(os_err_t, $os_err_t, + [Define as the best type to hold an OS error code.]) + # Checks for programs. AC_PROG_CXX AC_PROG_CXX_WARNINGS AC_PROG_CXX_PCH -AC_PROG_RANLIB +dnl needed for 'txt2c' +dnl There ought to be an AC_PROG_CXX_FOR_BUILD, but there isn't. +AC_ARG_VAR([CXX_FOR_BUILD], + [C++ compiler command for programs to run on build machine]) +if test $cross_compiling = yes; then + CXX_FOR_BUILD='c++' +else + CXX_FOR_BUILD="$CXX" +fi -dnl Note: the gettext checks do not work if AC_LANG(C++) is in effect, -dnl due to the C++ compiler objecting to the very sloppy code that is -dnl used to generate link-time references to gettext functions. This -dnl is the only remaining use of the C compiler in the entire package. -dnl Note 2: if you *don't* put AM_ICONV in here then AM_GNU_GETTEXT -dnl thinks it needs to stick -liconv in LIBS, even when iconv is in libc! +AC_PROG_RANLIB -AC_LANG([C]) -AM_ICONV -AM_GNU_GETTEXT([external], [need-ngettext]) -AM_GNU_GETTEXT_VERSION(0.11.5) -AC_PROG_XGETTEXT_FLAG_OPTION -AC_LANG([C++]) +MTN_GNU_GETTEXT # Do library checks as early as possible so we bail out quickly if # one is missing. @@ -106,22 +100,22 @@ AC_CHECK_TYPE([off_t], AC_CHECK_TYPE([off_t], [], [AC_DEFINE([off_t], [long int], - [Define to `long int' if does not define.])], [#include ]) AC_CHECK_TYPE([pid_t], [], [AC_DEFINE([pid_t], [int], - [Define to `int' if does not define.])], [#include ]) AC_CHECK_MEMBERS([struct stat.st_ctim.tv_nsec, - struct stat.st_mtim.tv_nsec, - struct stat.st_ctimespec.tv_nsec, - struct stat.st_mtimespec.tv_nsec, - struct stat.st_ctimensec, - struct stat.st_mtimensec], - [], [], [#include ]) + struct stat.st_mtim.tv_nsec, + struct stat.st_ctimespec.tv_nsec, + struct stat.st_mtimespec.tv_nsec, + struct stat.st_ctimensec, + struct stat.st_mtimensec], + [], [], [#include ]) AC_CHECK_MEMBERS([struct dirent.d_type], [], [], [#include ]) # Checks for library functions. @@ -129,6 +123,6 @@ AC_CHECK_FUNCS([__cxa_current_exception_ # complicated check for it. AC_CHECK_FUNCS([__cxa_current_exception_type __cxa_demangle dirfd \ - fstatat mkdtemp mmap putenv setenv strptime unsetenv]) + fstatat mkdtemp mmap putenv setenv strptime unsetenv]) AC_OUTPUT ============================================================ --- po/Makevars 39ebd1daa879a3c8906b2b98d764f82a337c42e1 +++ po/Makevars 21ea46d8804edc5eef509858140a75fb0e40623c @@ -1,12 +1,5 @@ -# Makefile variables for PO directory in any package using GNU gettext. +# xgettext configuration for Monotone. -# Usually the message domain is the same as the package name. -DOMAIN = $(PACKAGE) - -# These two variables depend on the location of this directory. -subdir = po -top_builddir = .. - # These options get passed to xgettext. Note that some of the options # are given twice, once in each variable. In fact, our configure # script defines XGETTEXT_OPTIONS=$(XGETTEXT_OPTIONS_NO_FLAG) if it @@ -33,7 +26,7 @@ COPYRIGHT_HOLDER = Graydon Hoare -# This is the email address or URL to which the translators shall report +# This is the email address or URL to which the translators should report # bugs in the untranslated strings: # - Strings which are not entire sentences, see the maintainer guidelines # in the GNU gettext documentation, section 'Preparing Strings'. @@ -48,7 +41,3 @@ MSGID_BUGS_ADDRESS = address@hidden # can write to without being subscribed, or the URL of a web page through # which the translators can contact you. MSGID_BUGS_ADDRESS = address@hidden - -# This is the list of locale categories, beyond LC_MESSAGES, for which the -# message catalogs shall be used. It is usually empty. -EXTRA_LOCALE_CATEGORIES =