3434# Define NO_EXPAT if you do not have expat installed. git-http-push is
3535# not built, and you cannot push using http:// and https:// transports.
3636#
37+ # Define NO_GETTEXT if you don't want to build with Git with gettext
38+ # support. Building it requires GNU libintl or another gettext
39+ # implementation, and additionally libintl-perl at runtime.
40+ #
41+ # Define NEEDS_LIBINTL if you haven't set NO_GETTEXT and your system
42+ # needs to be explicitly linked to -lintl. It's defined automatically
43+ # on platforms where we don't expect glibc (Linux, Hurd,
44+ # GNU/kFreeBSD), which includes libintl.
45+ #
46+ # Define HAVE_LIBCHARSET_H if you haven't set NO_GETTEXT and you can't
47+ # trust the langinfo.h's nl_langinfo(CODESET) function to return the
48+ # current character set. GNU and Solaris have a nl_langinfo(CODESET),
49+ # FreeBSD can use either, but MinGW and some others need to use
50+ # libcharset.h's locale_charset() instead.
51+ #
52+ # Define GNU_GETTEXT if you're using the GNU implementation of
53+ # libintl. We define this everywhere except on Solaris, which has its
54+ # own gettext implementation. If GNU_GETTEXT is set we'll use GNU
55+ # extensions like `msgfmt --check'.
56+ #
57+ # Define GETTEXT_POISON to turn all strings that use gettext into
58+ # gibberish. This option should only be used by the Git developers to
59+ # check that the Git gettext implementation itself is sane.
60+ #
3761# Define EXPATDIR=/foo/bar if your expat header and library files are in
3862# /foo/bar/include and /foo/bar/lib directories.
3963#
@@ -289,6 +313,7 @@ infodir = share/info
289313gitexecdir = libexec/git-core
290314sharedir = $(prefix ) /share
291315gitwebdir = $(sharedir ) /gitweb
316+ localedir = $(sharedir ) /locale
292317template_dir = share/git-core/templates
293318htmldir = share/doc/git-doc
294319ifeq ($(prefix ) ,/usr)
@@ -304,7 +329,7 @@ lib = lib
304329# DESTDIR=
305330pathsep = :
306331
307- export prefix bindir sharedir sysconfdir gitwebdir
332+ export prefix bindir sharedir sysconfdir gitwebdir localedir
308333
309334CC = gcc
310335AR = ar
@@ -319,6 +344,8 @@ TCLTK_PATH = wish
319344PTHREAD_LIBS = -lpthread
320345PTHREAD_CFLAGS =
321346GCOV = gcov
347+ XGETTEXT = xgettext
348+ MSGFMT = msgfmt
322349
323350export TCL_PATH TCLTK_PATH
324351
@@ -380,6 +407,7 @@ SCRIPT_SH += git-web--browse.sh
380407SCRIPT_LIB += git-mergetool--lib
381408SCRIPT_LIB += git-parse-remote
382409SCRIPT_LIB += git-sh-setup
410+ SCRIPT_LIB += git-sh-i18n
383411
384412SCRIPT_PERL += git-add--interactive.perl
385413SCRIPT_PERL += git-difftool.perl
@@ -557,6 +585,7 @@ LIB_H += userdiff.h
557585LIB_H += utf8.h
558586LIB_H += xdiff-interface.h
559587LIB_H += xdiff/xdiff.h
588+ LIB_H += gettext.h
560589
561590LIB_OBJS += abspath.o
562591LIB_OBJS += advice.o
@@ -598,6 +627,9 @@ LIB_OBJS += entry.o
598627LIB_OBJS += environment.o
599628LIB_OBJS += exec_cmd.o
600629LIB_OBJS += fsck.o
630+ ifndef NO_GETTEXT
631+ LIB_OBJS += gettext.o
632+ endif
601633LIB_OBJS += graph.o
602634LIB_OBJS += grep.o
603635LIB_OBJS += hash.o
@@ -774,6 +806,22 @@ EXTLIBS =
774806# Platform specific tweaks
775807#
776808
809+ # Platform specific defaults. Where we'd only like some feature on the
810+ # minority of systems, e.g. if linking to a library isn't needed
811+ # because its features are included in the GNU C library.
812+ ifndef NO_GETTEXT
813+ # Systems that use GNU gettext and glibc are the exception
814+ NEEDS_LIBINTL = YesPlease
815+
816+ # Systems that don't use GNU gettext are the exception. Only
817+ # Solaris has a mature non-GNU gettext implementation.
818+ GNU_GETTEXT = YesPlease
819+
820+ # Since we assume a GNU gettext by default we also assume a
821+ # GNU-like langinfo.h by default
822+ HAVE_LIBCHARSET_H =
823+ endif
824+
777825# We choose to avoid "if .. else if .. else .. endif endif"
778826# because maintaining the nesting to match is a pain. If
779827# we had "elif" things would have been much nicer...
@@ -789,11 +837,13 @@ ifeq ($(uname_S),Linux)
789837 NO_STRLCPY = YesPlease
790838 NO_MKSTEMPS = YesPlease
791839 HAVE_PATHS_H = YesPlease
840+ NEEDS_LIBINTL =
792841endif
793842ifeq ($(uname_S ) ,GNU/kFreeBSD)
794843 NO_STRLCPY = YesPlease
795844 NO_MKSTEMPS = YesPlease
796845 HAVE_PATHS_H = YesPlease
846+ NEEDS_LIBINTL =
797847endif
798848ifeq ($(uname_S ) ,UnixWare)
799849 CC = cc
@@ -860,6 +910,9 @@ ifeq ($(uname_S),SunOS)
860910 NO_MKSTEMPS = YesPlease
861911 NO_REGEX = YesPlease
862912 NO_FNMATCH_CASEFOLD = YesPlease
913+ ifndef NO_GETTEXT
914+ GNU_GETTEXT =
915+ endif
863916 ifeq ($(uname_R),5.6)
864917 SOCKLEN_T = int
865918 NO_HSTRERROR = YesPlease
@@ -986,6 +1039,7 @@ ifeq ($(uname_S),GNU)
9861039 NO_STRLCPY=YesPlease
9871040 NO_MKSTEMPS = YesPlease
9881041 HAVE_PATHS_H = YesPlease
1042+ NEEDS_LIBINTL =
9891043endif
9901044ifeq ($(uname_S ) ,IRIX)
9911045 NO_SETENV = YesPlease
@@ -1180,6 +1234,9 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
11801234 EXTLIBS += /mingw/lib/libz.a
11811235 NO_R_TO_GCC_LINKER = YesPlease
11821236 INTERNAL_QSORT = YesPlease
1237+ ifndef NO_GETTEXT
1238+ HAVE_LIBCHARSET_H = YesPlease
1239+ endif
11831240else
11841241 NO_CURL = YesPlease
11851242endif
@@ -1540,6 +1597,22 @@ ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
15401597 export GIT_TEST_CMP_USE_COPIED_CONTEXT
15411598endif
15421599
1600+ ifdef NO_GETTEXT
1601+ COMPAT_CFLAGS += -DNO_GETTEXT
1602+ endif
1603+
1604+ ifdef NEEDS_LIBINTL
1605+ EXTLIBS += -lintl
1606+ endif
1607+
1608+ ifdef GNU_GETTEXT
1609+ MSGFMT += --check
1610+ endif
1611+
1612+ ifdef GETTEXT_POISON
1613+ COMPAT_CFLAGS += -DGETTEXT_POISON
1614+ endif
1615+
15431616ifeq ($(TCLTK_PATH ) ,)
15441617NO_TCLTK =NoThanks
15451618endif
@@ -1570,6 +1643,7 @@ ifndef V
15701643 QUIET_GEN = @echo ' ' GEN $@;
15711644 QUIET_LNCP = @echo ' ' LN/CP $@;
15721645 QUIET_GCOV = @echo ' ' GCOV $@;
1646+ QUIET_MSGFMT = @echo ' ' MSGFMT $@;
15731647 QUIET_SUBDIR0 = +@subdir=
15741648 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
15751649 $(MAKE) $(PRINT_DIR) -C $$subdir
@@ -1599,7 +1673,9 @@ template_dir_SQ = $(subst ','\'',$(template_dir))
15991673htmldir_SQ = $(subst ','\'',$(htmldir ) )
16001674prefix_SQ = $(subst ','\'',$(prefix ) )
16011675gitwebdir_SQ = $(subst ','\'',$(gitwebdir ) )
1676+ sharedir_SQ = $(subst ','\'',$(sharedir ) )
16021677
1678+ LOCALEDIR_SQ = $(subst ','\'',$(localedir ) )
16031679SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH ) )
16041680PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH ) )
16051681PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH ) )
@@ -1649,7 +1725,7 @@ ifndef NO_TCLTK
16491725 $(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
16501726endif
16511727ifndef NO_PERL
1652- $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
1728+ $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' localedir='$(localedir_SQ)' all
16531729endif
16541730ifndef NO_PYTHON
16551731 $(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
@@ -1695,6 +1771,7 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
16951771 -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
16961772 -e 's|@@DIFF@@|$(DIFF_SQ)|' \
16971773 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1774+ -e 's|@@LOCALEDIR@@|$(LOCALEDIR_SQ)|g' \
16981775 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
16991776 -e $(BROKEN_PATH_FIX) \
17001777 $@.sh >$@+
@@ -1970,6 +2047,10 @@ attr.s attr.o: EXTRA_CPPFLAGS = -DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"'
19702047
19712048http.s http.o : EXTRA_CPPFLAGS = -DGIT_HTTP_USER_AGENT='"git/$(GIT_VERSION ) "'
19722049
2050+ ifdef HAVE_LIBCHARSET_H
2051+ gettext.s gettext.o : EXTRA_CPPFLAGS = -DHAVE_LIBCHARSET_H
2052+ endif
2053+
19732054ifdef NO_EXPAT
19742055http-walker.s http-walker.o : EXTRA_CPPFLAGS = -DNO_EXPAT
19752056endif
@@ -2043,6 +2124,41 @@ cscope:
20432124 $(RM ) cscope*
20442125 $(FIND ) . -name ' *.[hcS]' -print | xargs cscope -b
20452126
2127+ XGETTEXT_OPTIONS = \
2128+ --add-comments \
2129+ --msgid-bugs-address="Git Mailing List <git@vger.kernel.org>" \
2130+ --from-code=UTF-8 \
2131+ --output=po/git.pot
2132+
2133+ XGETTEXT_OPTIONS_C = $(XGETTEXT_OPTIONS ) --keyword=_ --keyword=N_ --language=C
2134+ XGETTEXT_OPTIONS_SH = $(XGETTEXT_OPTIONS ) --language=Shell
2135+ XGETTEXT_OPTIONS_PERL = $(XGETTEXT_OPTIONS ) --keyword=__ --language=Perl
2136+
2137+ LOCALIZED_C = $(C_OBJ:o=c )
2138+ LOCALIZED_SH = $(SCRIPT_SH )
2139+ LOCALIZED_PERL = $(SCRIPT_PERL )
2140+
2141+ ifdef XGETTEXT_INCLUDE_TESTS
2142+ LOCALIZED_C += t/t0200/test.c
2143+ LOCALIZED_SH += t/t0200/test.sh
2144+ LOCALIZED_PERL += t/t0200/test.perl
2145+ endif
2146+
2147+ pot :
2148+ $(XGETTEXT ) $(XGETTEXT_OPTIONS_C ) $(LOCALIZED_C )
2149+ $(XGETTEXT ) $(XGETTEXT_OPTIONS_SH ) --join-existing $(LOCALIZED_SH )
2150+ $(XGETTEXT ) $(XGETTEXT_OPTIONS_PERL ) --join-existing $(LOCALIZED_PERL )
2151+
2152+ POFILES := $(wildcard po/* .po)
2153+ MOFILES := $(patsubst po/% .po,share/locale/% /LC_MESSAGES/git.mo,$(POFILES ) )
2154+ MODIRS := $(patsubst po/% .po,share/locale/% /LC_MESSAGES/,$(POFILES ) )
2155+ ifndef NO_GETTEXT
2156+ all :: $(MOFILES )
2157+ endif
2158+ share/locale/% /LC_MESSAGES/git.mo : po/% .po
2159+ @mkdir -p $(dir $@ )
2160+ $(QUIET_MSGFMT )$(MSGFMT ) -o $@ $<
2161+
20462162# ## Detect prefix changes
20472163TRACK_CFLAGS = $(CC ) :$(subst ','\'',$(ALL_CFLAGS ) ) :\
20482164 $(bindir_SQ ) :$(gitexecdir_SQ ) :$(template_dir_SQ ) :$(prefix_SQ )
@@ -2072,6 +2188,8 @@ endif
20722188ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
20732189 @echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
20742190endif
2191+ @echo NO_GETTEXT=\''$(subst ','\'',$(subst ','\'',$(NO_GETTEXT)))'\' >>$@
2192+ @echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@
20752193
20762194# ## Detect Tck/Tk interpreter path changes
20772195ifndef NO_TCLTK
@@ -2169,6 +2287,11 @@ install: all
21692287 $(INSTALL ) $(ALL_PROGRAMS ) ' $(DESTDIR_SQ)$(gitexec_instdir_SQ)'
21702288 $(INSTALL ) -m 644 $(SCRIPT_LIB ) ' $(DESTDIR_SQ)$(gitexec_instdir_SQ)'
21712289 $(INSTALL ) $(install_bindir_programs ) ' $(DESTDIR_SQ)$(bindir_SQ)'
2290+ ifndef NO_GETTEXT
2291+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sharedir_SQ)/locale'
2292+ (cd share && tar cf - locale) | \
2293+ (cd '$(DESTDIR_SQ)$(sharedir_SQ)' && umask 022 && tar xof -)
2294+ endif
21722295 $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
21732296ifndef NO_PERL
21742297 $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
@@ -2326,6 +2449,10 @@ ifndef NO_TCLTK
23262449 $(MAKE) -C git-gui clean
23272450endif
23282451 $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
2452+ ifndef NO_GETTEXT
2453+ $(RM) po/git.pot
2454+ $(RM) -r share/
2455+ endif
23292456
23302457.PHONY : all install clean strip
23312458.PHONY : shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
0 commit comments