summaryrefslogtreecommitdiffstats
path: root/Makefile.common
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile.common')
-rw-r--r--Makefile.common288
1 files changed, 172 insertions, 116 deletions
diff --git a/Makefile.common b/Makefile.common
index cce0031..5da90f0 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -104,11 +104,14 @@ XMLFOPTS=-f $(FDPDIR)/docs-common/bin/xmlformat-fdp.conf
XMLLINT =xmllint
XML2PO =xml2po
MSGMERGE=msgmerge
-PO2XML =po2xml
LN =ln
#########################################################################
#########################################################################
+FDP_ENTITIES=fdp-entities.ent
+#########################################################################
+
+#########################################################################
# Rules to produce .po files from .xml files. Get the tools to do this
# from the gnome-doc-utils RPM.
.SUFFIXES: .po .pot .ent .xml
@@ -154,21 +157,24 @@ LANGUAGES=${PRI_LANG} ${OTHERS}
#########################################################################
#########################################################################
-# Append per-document entities file if any
-$(foreach L,${LANGUAGES},$(eval $(call XMLFILES_template,${L})))
+define DOCENT_template
+DOC_ENTITIES_XML-${1}=${1}/${DOC_ENTITIES}.xml
+DOC_ENTITIES_ENT-${1}=${1}/${DOC_ENTITIES}.ent
+endef
+
ifneq "${DOC_ENTITIES}" ""
-$(foreach L, ${LANGUAGES}, $(eval XMLFILES-${L}+=${L}/${DOC_ENTITIES}.xml))
-$(foreach L, ${LANGUAGES}, $(eval XMLDEPFILES-${L}+=${L}/${DOC_ENTITIES}.ent))
+$(foreach L,${LANGUAGES},$(eval $(call DOCENT_template,${L})))
endif
-
-$(foreach L, ${LANGUAGES},$(eval $(call XMLFILENAME_template,${L})))
-#
#########################################################################
#########################################################################
-# Define ${XMLDEPFILES-${LANG}} to be the list of non-archived dependant
-# files needed in addition to ${XMLFILES-${LANG}}.
+# Explode the template from the doc-specific Makefile to get the
+# XML files the author knows about.
+$(foreach L,${LANGUAGES},$(eval $(call XMLFILES_template,${L})))
+# Append per-document dependancies
+$(foreach L, ${LANGUAGES}, $(eval XMLDEPFILES-${L}+=${DOC_ENTITIES_ENT-${L}}))
$(foreach L, ${LANGUAGES}, $(eval XMLDEPFILES-${L}+=${L}/fdp-info.xml))
+#
#########################################################################
#########################################################################
@@ -223,6 +229,148 @@ distclean:: clean
#########################################################################
#########################################################################
+# Rules to generate the "${LANG}/${DOC_ENTITIES}.ent" file, if used
+define DOC_ENTITIES_template
+
+po/${DOC_ENTITIES}.pot:: ${1}/${FDP_ENTITIES} ${PRI_LANG}/${DOC_ENTITIES}.xml
+ ${XML2PO} -o $$@ -k ${PRI_LANG}/${DOC_ENTITIES}.xml
+clean::
+ ${RM} po/${DOC_ENTITIES}.pot
+
+help::
+ @printf ${TFMT} 'po/${DOC_ENTITIES}.pot' 'Create .POT file for per-doc entities'
+
+po/${1}.po:: ${1}/${FDP_ENTITIES} po/${DOC_ENTITIES}.pot
+ if [ ! -f $$@ ]; then \
+ mkdir -p ${1}; \
+ cp -f po/${DOC_ENTITIES}.pot $$@; \
+ fi
+ ${MSGMERGE} -U -q $$@ po/${DOC_ENTITIES}.pot
+ touch $$@
+
+${1}/${DOC_ENTITIES}.xml:: ${1}/${FDP_ENTITIES} po/${1}.po ${PRI_LANG}/${DOC_ENTITIES}.xml
+ ${XML2PO} -p po/${1}.po ${PRI_LANG}/${DOC_ENTITIES}.xml >$$@
+
+clean::
+ ${RM} ${1}/${DOC_ENTITIES}.xml
+
+# ${1}/${DOC_ENTITIES}.ent:: ${1}/${DOC_ENTITIES}.xml
+
+help::
+ @printf ${TFMT} '${1}/${DOC_ENTITIES}.ent' 'Per-doc entities for locale "${1}"'
+ @printf ${TFMT} '${1}/${DOC_ENTITIES}.xml' 'Translated per-doc entities for locale "${1}"'
+endef
+
+ifneq "${DOC_ENTITIES}" ""
+${PRI_LANG}/${DOC_ENTITIES}.ent:: ${PRI_LANG}/${DOC_ENTITIES}.xml
+help::
+ @printf ${TFMT} '${PRI_LANG}/${DOC_ENTITIES}.ent' 'Per-doc entities for locale "${PRI_LANG}"'
+$(foreach L, ${OTHERS},$(eval $(call DOC_ENTITIES_template,${L})))
+
+showvars::
+ @echo "DOC_ENTITIES=${DOC_ENTITIES}"
+endif
+#
+#########################################################################
+
+#########################################################################
+po/${DOCBASE}.pot:: ${DOC_ENTITIES_ENT-${PRI_LANG}} \
+ ${PRI_LANG}/${FDP_ENTITIES} ${XMLFILES-${PRI_LANG}}
+ [ -d po/CVS ] || (echo ADD po/ TO CVS >&2; exit 1)
+ ${XML2PO} -k -o $@ ${XMLFILES-${PRI_LANG}}
+help::
+ @printf ${TFMT} 'po/${DOCBASE}.pot' 'Writes one PO file for all XML'
+
+.PHONY: pot
+pot:: po/${DOCBASE}.pot
+help::
+ @printf ${TFMT} 'po' 'Writes one ${PRI_LANG} PO file for all XML'
+#########################################################################
+
+#########################################################################
+define PO_template
+
+.PRECIOUS: po/${1}.po
+
+po/${1}.po:: po/${DOCBASE}.pot $${DOC_ENTITITES_ENT-${1}}
+ [ -d po/CVS ] || (echo ADD po/ TO CVS >&2; exit 1)
+ if [ ! -f $$@ ]; then \
+ cp po/${DOCBASE}.pot $$@; \
+ else \
+ ${MSGMERGE} -U -q $$@ po/${DOCBASE}.pot; \
+ touch $$@; \
+ fi
+
+.PHONY: po-${1}
+po-${1}:: po/${1}.po
+
+help::
+ @printf ${TFMT} 'po-${1}' 'Creates or updates locale ${1} .PO file'
+ @printf ${TFMT} 'po/${1}.po' 'Creates or updates locale ${1} .PO file'
+
+clean::
+ ${RM} .xml2po.mo
+
+endef
+
+$(foreach L,${OTHERS},$(eval $(call PO_template,${L})))
+
+.PHONY: po
+
+po:: $(foreach L,${OTHERS},po-${L})
+########################################################################
+
+#########################################################################
+# Define a template to generate the locale-specific XML files given the
+# original ${PRI_LANG} file and an updated po/${LANG}.po file.
+define XML_template
+$(patsubst ${PRI_LANG}/%,${1}/%,${2}):: ${2} po/${1}.po \
+ ${DOC_ENTITIES_ENT-${1}}
+ mkdir -p ${1}
+ ln -s -f ../${2} $$@.in
+ ${XML2PO} -e -p po/${1}.po $$@.in >$$@
+clean::
+ ${RM} $$@.in
+ endef
+
+$(foreach L,${OTHERS}, \
+ $(foreach F,${XMLFILES-${PRI_LANG}}, \
+ $(eval $(call XML_template,${L},${F}))))
+
+define XMLTARGET_template
+.PHONY: xml-${1}
+
+xml-${1}:: ${XMLDEPFILES-${1}} ${XMLFILES-${1}}
+
+distclean::
+ ${RM} -r ${1}
+
+help::
+ @printf ${TFMT} 'xml-${1}' 'Produces translated XML for locale ${1}'
+
+endef
+
+.PHONY: xml-${PRI_LANG}
+
+xml-${PRI_LANG}:: ${XMLFILES-${PRI_LANG}}
+
+help::
+ @printf ${TFMT} 'xml-${PRI_LANG}' 'Comfirms primary language XML files.'
+
+$(foreach L,${OTHERS},$(eval $(call XMLTARGET_template,${L})))
+
+.PHONY: xml-all
+
+xml-all:: $(foreach L,${LANGUAGES},xml-${L})
+
+help::
+ @printf ${TFMT} 'xml-all' 'Creates all XML locale files'
+
+distclean::
+ $(foreach L,${OTHERS},${RM} -r ${L})
+#########################################################################
+
+#########################################################################
# For each LANG in LANGUAGES, generate a target and rule similar to:
# mydoc-en/index.html:: mydoc-en.xml ${XMLEXTRAFILES}-en
# LANG=en.UTF-8 ${XMLTO} html -x $(XSLHTML) -o mydoc-en mydoc-en.xml
@@ -393,99 +541,6 @@ clean::
#########################################################################
#########################################################################
-po/${DOCBASE}.pot:: ${XMLFILES-${PRI_LANG}}
- [ -d po ] || (echo ADD po/ TO CVS >&2; exit 1)
- ${XML2PO} -k -o $@ $^
-
-help::
- @printf ${TFMT} 'po' 'Writes one ${PRI_LANG} PO file for all XML'
- @printf ${TFMT} 'po/${DOCBASE}.pot' 'Writes one PO file for all XML'
-
-.PHONY: pot
-
-pot:: po/${DOCBASE}.pot
-#########################################################################
-
-#########################################################################
-# Define a template to generate the locale-specific XML files given the
-# original ${PRI_LANG} file and an updated po/${LANG}.po file.
-define XML_template
-$(patsubst ${PRI_LANG}/%,${1}/%,${2}):: ${2} po/${1}.po
- mkdir -p ${1}
- ${XML2PO} -k -p po/${1}.po ${2} >$$@
-# ${PO2XML} ${2} po/${1}.po >$$@
- endef
-
-$(foreach L,${OTHERS}, \
- $(foreach F,${XMLFILES-${PRI_LANG}}, \
- $(eval $(call XML_template,${L},${F}))))
-
-define XMLTARGET_template
-.PHONY: xml-${1}
-
-xml-${1}:: ${XMLFILES-${1}}
-
-distclean::
- ${RM} -r ${1}
-
-help::
- @printf ${TFMT} 'xml-${1}' 'Produces translated XML for locale ${1}'
-
-endef
-
-.PHONY: xml-${PRI_LANG}
-
-xml-${PRI_LANG}:: ${XMLFILES-${PRI_LANG}}
-
-help::
- @printf ${TFMT} 'xml-${PRI_LANG}' 'Comfirms primary language XML files.'
-
-$(foreach L,${OTHERS},$(eval $(call XMLTARGET_template,${L})))
-
-.PHONY: xml-all
-
-xml-all:: $(foreach L,${LANGUAGES},xml-${L})
-
-help::
- @printf ${TFMT} 'xml-all' 'Creates all XML locale files'
-
-distclean::
- $(foreach L,${OTHERS},${RM} -r ${L})
-#########################################################################
-
-#########################################################################
-define PO_template
-
-.PRECIOUS: po/${1}.po
-
-po/${1}.po:: po/${DOCBASE}.pot
- [ -d po ] || (echo ADD po/ TO CVS >&2; exit 1)
- if [ ! -f $$@ ]; then \
- cp po/${DOCBASE}.pot $$@; \
- else \
- ${MSGMERGE} -U -q $$@ $$<; \
- fi
-
-.PHONY: po-${1}
-po-${1}:: po/${1}.po
-
-help::
- @printf ${TFMT} 'po-${1}' 'Creates or updates locale ${1} .PO file'
- @printf ${TFMT} 'po/${1}.po' 'Creates or updates locale ${1} .PO file'
-
-clean::
- ${RM} .xml2po.mo
-
-endef
-
-$(foreach L,${OTHERS},$(eval $(call PO_template,${L})))
-
-.PHONY: po
-
-po:: $(foreach L,${OTHERS},po-${L})
-#########################################################################
-
-#########################################################################
#
showvars::
@echo "DOCBASE=\"$(DOCBASE)\""
@@ -520,6 +575,7 @@ help::
#
define fdp-info_template
$(1)/fdp-info.xml:: $(RPMINFO)
+ mkdir -p ${1}
${XSLTPROC} --stringparam lang $(1) \
--stringparam fdpdir $(FDPDIR) \
--stringparam doctype $(shell \
@@ -758,17 +814,20 @@ showvars::
@echo "PWD=$(PWD)"
#########################################################################
-define DOC_ENTITIES_template
-${1}/${DOC_ENTITIES}.ent:: ${1}/${DOC_ENTITIES}.xml
-endef
-ifneq "${DOC_ENTITIES}" ""
-$(foreach L, ${PRI_LANG} ${OTHERS},$(eval $(call DOC_ENTITIES_template,${L})))
+define FDP_ENTITIES_template
+${1}/$${FDP_ENTITIES}:: ${FDPDIR}/docs-common/common/entities/entities-${1}.ent
+ mkdir -p ${1}
+ ln -s -f $$< $$@
-showvars::
- @echo "DOC_ENTITIES=${DOC_ENTITIES}"
-endif
+clean::
+ ${RM} ${1}/$${FDP_ENTITIES}
+
+help::
+ @printf ${TFMT} '${1}/$${FDP_ENTITIES}' 'Link locale ${1} to FDP entities'
+endef
+$(foreach L,${LANGUAGES},$(eval $(call FDP_ENTITIES_template,${L})))
#########################################################################
#########################################################################
@@ -776,16 +835,13 @@ endif
# file 'locale-entities.xml' to the per-locale entity files located in
# the "docs-common/common/entities/" directory.
#
-FDP_ENTITIES=fdp-entities.ent
define LOCALE_template
.PHONY: set-locale-${1}
-set-locale-${1}::
- ${LN} -f -s ${FDPDIR}/docs-common/common/entities/entities-${1}.ent \
- ${FDP_ENTITIES}
+set-locale-${1}:: ${1}/${FDP_ENTITIES}
clean::
- ${RM} ${FDP_ENTITIES}
+ ${RM} ${1}/${FDP_ENTITIES}
ifneq "${DOC_ENTITIES}" ""
${RM} ${1}/${DOC_ENTITIES}.ent
endif