###############################################################################
#
# The CentOS HTML Makefile
# Copyright (C) 2019 Alain Reguera Delgado
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.
#
###############################################################################
#==============================================================================
# Configuration
#==============================================================================
package = centos-indexhtml
version = 8.0
lang = en-US
localedir = PO
prefix = .
#==============================================================================
# Requirements
#==============================================================================
all: $(package)/$(lang)/index.html
build: $(prefix)/$(package)-$(version).tar.gz
#==============================================================================
# Sources
#==============================================================================
$(prefix)/$(package)-$(version).tar.gz: \
$(package)/??-??/* \
$(package)/index.tpl.html \
$(package)/index.html \
$(localedir)/*.po \
common/css/* \
common/images/* \
common/fonts/*
rm -r $(package)-$(version) || mkdir $(package)-$(version)
cp -a $(package)/??-?? $(package)-$(version)
cp -a $(package)/index.html $(package)-$(version)
cp -a common $(package)-$(version)
if [[ $(package) == centos-indexhtml ]];then \
rm -v $(package)-$(version)/common/images/pb-*.png; \
fi
tar -czf $(prefix)/$(package)-$(version).tar.gz $(package)-$(version)
rm -r $(package)-$(version)
#======================================================================
# Localization
#======================================================================
$(localedir)/$(lang).pot: centos-*/index.tpl.html
xml2po -l $(lang) -o /tmp/$(lang).pot centos-*/index.tpl.html
if [[ ! -f $(localedir)/$(lang).pot ]];then \
msginit -i /tmp/$(lang).pot -o $(localedir)/$(lang).pot -l $(lang) --no-translator --width=80; \
else \
msgmerge -U $(localedir)/$(lang).pot /tmp/$(lang).pot; \
fi
rm /tmp/$(lang).pot
$(localedir)/$(lang).po: $(localedir)/$(lang).pot
if [[ ! -f $(localedir)/$(lang).po ]];then \
msginit -i $(localedir)/$(lang).pot -o $(localedir)/$(lang).po -l $(lang) --no-translator --width=80; \
else \
msgmerge -U $(localedir)/$(lang).po $(localedir)/$(lang).pot; \
fi
#======================================================================
# Content
#======================================================================
$(package)/$(lang)/index.html: $(localedir)/$(lang).po $(package)/index.tpl.html
xmllint -noout $(package)/index.tpl.html
xml2po -l $(lang) -p $(localedir)/$(lang).po -o $(package)/$(lang)/index.html $(package)/index.tpl.html
sed -i 's/<html lang="en-US">/<html lang="$(lang)">/' $(package)/$(lang)/index.html