Blame po/Makefile

Packit 6c4009
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
Packit 6c4009
# This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
# The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
# modify it under the terms of the GNU Lesser General Public
Packit 6c4009
# License as published by the Free Software Foundation; either
Packit 6c4009
# version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
# The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
# Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
# You should have received a copy of the GNU Lesser General Public
Packit 6c4009
# License along with the GNU C Library; if not, see
Packit 6c4009
# <http://www.gnu.org/licenses/>.
Packit 6c4009
Packit 6c4009
# Makefile for installing libc message catalogs.
Packit 6c4009
Packit 6c4009
subdir := po
Packit 6c4009
Packit 6c4009
include ../Makeconfig
Packit 6c4009
Packit 6c4009
# Add names of the languages with broken .po files here.
Packit 6c4009
BROKEN_LINGUAS =
Packit 6c4009
Packit 6c4009
# List of languages for which we have message catalogs of translations.
Packit 6c4009
ALL_LINGUAS := $(filter-out $(BROKEN_LINGUAS),$(basename $(wildcard *.po)))
Packit 6c4009
Packit 6c4009
# You can override this in configparms or the make command line to limit
Packit 6c4009
# the languages which get installed.
Packit 6c4009
ifdef LINGUAS
Packit 6c4009
LINGUAS := $(filter $(addsuffix %,$(LINGUAS)),$(ALL_LINGUAS))
Packit 6c4009
else
Packit 6c4009
LINGUAS = $(ALL_LINGUAS)
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
# Text domain name to install under; must match ../locale/SYS_libc.c string.
Packit 6c4009
domainname = libc
Packit 6c4009
Packit 6c4009
# Pattern for where message catalog object for language % gets installed.
Packit 6c4009
mo-installed = $(inst_localedir)/%/LC_MESSAGES/$(domainname).mo
Packit 6c4009
Packit 6c4009
# Files to install: a $(domainname).mo file for each language.
Packit 6c4009
install-others = $(LINGUAS:%=$(mo-installed))
Packit 6c4009
Packit 6c4009
generated += $(ALL_LINGUAS:%=%.mo)
Packit 6c4009
Packit 6c4009
Packit 6c4009
include ../Rules
Packit 6c4009
Packit 6c4009
# Generate the translation template from all the source files.
Packit 6c4009
libc.pot: pot.header libc.pot.files
Packit 6c4009
	@rm -f $@.new
Packit 6c4009
	set `date -R`; disp="$$6"; \
Packit 6c4009
	sed -e 's/VERSION/$(version)/' \
Packit 6c4009
	    -e "s/DATE/`date +'%Y-%m-%d %H:%M'$$disp`/" \
Packit 6c4009
	    -e "s/CHARSET/UTF-8/" \
Packit 6c4009
	    $< > $@.new
Packit 6c4009
	egrep -v '\.ksh$$' $(word 2,$^) > $(objdir)/tmp-libc.pot-files
Packit 6c4009
	cd ..; $(XGETTEXT) --keyword=_ --keyword=N_ \
Packit 6c4009
			   --add-comments=TRANS --flag=error:3:c-format \
Packit 6c4009
			   --flag=f_print:2:c-format \
Packit 6c4009
			   --sort-by-file --omit-header -E -n -d - \
Packit 6c4009
			   -f $(objdir)/tmp-libc.pot-files >> po/$@.new
Packit 6c4009
	egrep '\.ksh$$' $(word 2,$^) > $(objdir)/tmp-libc.pot-files
Packit 6c4009
	cd ..; $(XGETTEXT) --add-comments=TRANS --language=Shell \
Packit 6c4009
			   --sort-by-file --omit-header -E -n -o po/$@.new -j \
Packit 6c4009
			   -f $(objdir)/tmp-libc.pot-files po/$@.new
Packit 6c4009
	rm $(objdir)/tmp-libc.pot-files
Packit 6c4009
	mv -f $@.new $@
Packit 6c4009
Packit 6c4009
po-sed-cmd = \
Packit 6c4009
  '/\/tst-/d;$(foreach S,[ch] cxx sh ksh bash,$(subst .,\.,/.$S\(.in\)*$$/p;))'
Packit 6c4009
Packit 6c4009
# Omit tst-* files, and get only files with the given suffixes.
Packit 6c4009
libc.pot.files: FORCE
Packit 6c4009
	$(..)scripts/list-sources.sh .. | sed -n $(po-sed-cmd) > $@.new
Packit 6c4009
	mv -f $@.new $@
Packit 6c4009
Packit 6c4009
.SUFFIXES: .mo .po .pot
Packit 6c4009
Packit 6c4009
# Compile the binary message object files from the portable object source
Packit 6c4009
# files of translations for each language.
Packit 6c4009
$(objpfx)%.mo: %.po
Packit 6c4009
	$(make-target-directory)
Packit 6c4009
	$(MSGFMT) -o $@ $<
Packit 6c4009
Packit 6c4009
# Install the message object files as libc.po in the language directory.
Packit 6c4009
$(mo-installed): $(objpfx)%.mo $(+force); $(do-install) || exit 0
Packit 6c4009

Packit 6c4009
# Update translations from the translation project.
Packit 6c4009
TRANSLATIONS_URL = https://translationproject.org/latest/libc
Packit 6c4009
WGET = wget
Packit 6c4009
Packit 6c4009
update-translations:
Packit 6c4009
	$(WGET) -qO- $(TRANSLATIONS_URL) | sed -n 's|.*href="\([^"]\+po\)".*|\1|p' | \
Packit 6c4009
	  while read f; do \
Packit 6c4009
	    $(WGET) -O $(objdir)/$$f-tmp $(TRANSLATIONS_URL)/$$f && \
Packit 6c4009
	    mv -f $(objdir)/$$f-tmp $$f; \
Packit 6c4009
	  done