######################################################################### # Makefile.common # # This file, to be included from every document's local Makefile, provides # the basic targets used by the Fedora Docs Project. To see a list, # type "make help". ######################################################################### ######################################################################### # PDF generation is still fragile and probably won't work on your document. # Yet. ######################################################################### ######################################################################### # STYLE GUIDE (Or, How To Keep Tommy From Raising A Single Eyebrow At You) # 1) Lines are 80 characters, max. # 2) Tabs are 8 characters, exactly. # 3) All targets must use the "::" form to allow multiple instances of # the target. # 4) Keep a modular Makefile. For example, do NOT group all the "clean:" # rules into one place. Using the "::" form lets us keep all the # targets and rules for one object (file, template, whatever) close # together. This makes maintenance much, much easier. ######################################################################### # One key to writing good rules (the commands run to build a target) is # to write the shell commands so they could be cut'n pasted into a real # shell window. To do this, we have to find a common pidgen syntax that # works for both make(1) and the Bourne-type shells. # # Compared to even the most basic shell, the make(1) parser is very # limited. This is most visible when referencing shell variables or # make(1) macros. While a shell only needs delimiters to disambiguate # $FOObar from ${FOO}bar, make(1) needs the delimiters for any macro # name longer than one character. Combining the two rules, we get: # # 1) In a shell script, use the form ${FOO} to reference *EVERY* variable # instead of using $(FOO); most shells interpret the parens as a # directive to run the contents in a subshell. All shells correctly # handle the ${} braces form. # 2) In a make(1) rule, use the form ${FOO} instead of $(FOO) when # referencing macros. # 3) Reserve the form $(FOO), with parens, for enclosing real shell # commands such as $(shell /bin/pwd) ######################################################################### ######################################################################### # Note: all targets within this Makefile.common must be defined as # double-colon (::) targets so that additional steps can be added by # providing additional rules, also marked with double-colons, in the # document Makefile. ######################################################################### ######################################################################### # N.B., if you want to use built-in variables such as "$@" in a template # be sure to quote them as "$$@" since the template is evaluated once as # it is expanded ######################################################################### ######################################################################### # WARNING. This feature is deprecated and will shortly disappear. ######################################################################### # Allow client document to provide "Make.paths" file to locate our files # This is a "silent include", so if it's missing there is no problem. # This file, if present, must be in the DOCUMENT directory, not here in # docs-common. Even if this file is present, defining FTPDIR via the # command line will take precedence. sinclude Make.paths ######################################################################### ######################################################################### # Strange though it may seem, some shells do not provide a ${PWD} # environment variable for us. PWD :=$(shell /bin/pwd) ######################################################################### ######################################################################### # Supply default values for the boilerplate files _unless_ the user has # provided their own values. define find-common-dir for d in $(PWD)/docs-common $(PWD)/../docs-common $(PWD)/../../docs-common \ /usr/share/fedora/doc/docs-common ; do \ if [ -f $$d/Makefile.common ] ; then (cd "$$d" && /bin/pwd); break; fi; done endef FDPCOMMONDIR := $(shell $(find-common-dir)) # FDPDIR may no longer be required. FDPDIR ?= ${FDPCOMMONDIR}/.. FDPBIN ?= ${FDPCOMMONDIR}/bin XSLPDF ?= ${FDPCOMMONDIR}/xsl/main-pdf.xsl XSLHTML ?= ${FDPCOMMONDIR}/xsl/main-html.xsl XSLHTMLNOCHUNKS ?= ${FDPCOMMONDIR}/xsl/main-html-nochunks.xsl HTMLCSS ?= ${FDPCOMMONDIR}/css/fedora-draft.css DRAFT ?= yes PRI_LANG ?= en POTBASE ?= ${DOCBASE} RPMINFO ?= rpm-info.xml RPMPREP ?= yes RPMPOST ?= yes XMLTOTXTPOSTOPT ?= -p '-I iso-8859-15 -O UTF-8' XMLLINTOPT ?= --xinclude --postvalid --noent LEGALNOTICEBASE ?= legalnotice-opl ######################################################################### ######################################################################### # Use macros to locate our commonly-used programs XMLTO ?= xmlto XSLTPROC ?= xsltproc XSLTPROCOPTS ?= --path ${FDPCOMMONDIR}/common/entities:${FDPCOMMONDIR}/packaging XMLFORMAT ?= xmlformat XMLFOPTS ?= -f $(FDPCOMMONDIR)/bin/xmlformat-fdp.conf XMLLINT ?= xmllint XML2PO ?= xml2po # NEVER CHANGE ${XML2POFLAGS} TO "-k", EVER. THAT WOULD BE STUPID. XML2POFLAGS ?= -e MSGMERGE ?= msgmerge MSGFMT ?= msgfmt LN ?= ln MEINPROC ?= meinproc ######################################################################### ######################################################################### 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 .fo .ent .xml %.po: %.xml ${XML2PO} ${XML2POFLAGS} $< >$@ %.ent: %.xml ${XSLTPROC} ${XSLTPROCOPTS} -o $@.tmp \ --stringparam FDPCOMMONDIR "${FDPCOMMONDIR}/common" \ ${FDPCOMMONDIR}/common/entities/entities.xsl $< && \ move-if-change $@.tmp $@ ######################################################################### ######################################################################### # Use our very own "docs-common/bin/fdpsh" as the command interpreter # This automatically has ${FDPBIN} as first in the ${PATH} SHELL =${FDPBIN}/fdpsh ######################################################################### ######################################################################### ifndef RPMFLAGS RPMFLAGS?=--define "docbase $(DOCBASE)" \ --define "_topdir $(PWD)/rpm" \ --define "_srpmdir ${PWD}" \ --define "_rpmdir ${PWD}" \ --define "_sourcedir ${PWD}" \ --define "fdpdir /usr/share/fedora/doc" endif # Do not use specspo by default in case we want to use summary or desc RPMI18N ?= --i18ndomains %{nil} RPMFLAGS := ${RPMFLAGS} ${RPMI18N} ifneq "${RPMDEBUG}" "" RPMDFLAG = -vv endif ######################################################################### ######################################################################### # If ${OTHERS} does not exist, look for a po/LINGUAS file with a list # of locales. Using a po/LINGUAS file allows translators with access # to only the po/ folders to add their locales to the list without # seeking help from an XML editorial person. # The sed script ensures that comments are excised properly. OTHERS ?=$(shell test -f po/LINGUAS && /bin/sed 's/\#.*//' po/LINGUAS) ######################################################################### ######################################################################### # Set a provisional ${LANG} value. We'll dynamically change this as # needed. The "${PRI_LANG}" value is used because that is the original # language the doc. LANG =${PRI_LANG} LANGUAGES=${PRI_LANG} ${OTHERS} # ######################################################################### ######################################################################### 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 $(call DOCENT_template,${L}))) endif ######################################################################### ######################################################################### # 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}))) # Make sure rpm-info is part of the document PO template $(foreach L,${LANGUAGES},$(eval XMLFILES-${L}+=${L}/${RPMINFO})) # Append per-document dependencies $(foreach L, ${LANGUAGES}, $(eval XMLDEPFILES-${L}+=${DOC_ENTITIES_ENT-${L}})) $(foreach L, ${LANGUAGES}, $(eval XMLDEPFILES-${L}+=${L}/fdp-info.xml)) $(foreach L, ${LANGUAGES}, $(eval XMLDEPFILES-${L}+=${L}/${FDP_ENTITIES})) # ######################################################################### ######################################################################### TFMT="%-31s -- %s\n" TPOFMT="%-30s* -- %s\n" ######################################################################### ######################################################################### # PUT NO TARGETS BEFORE THIS ONE, not even in your base Makefile # In a properly-constructed Makefile, this will be the default target TARGETS=all clean distclean fdp-info html html-nochunks pdf po showvars \ tarball rpm rpm-common noarch srpm package-prep package-post \ src-tarball txt text targets help tag # FIXME: add the .PHONY attribute where the actual target is defined .PHONY: ${TARGETS} .PHONY: $(foreach LANG,${LANGUAGES},html-${LANG}) .PHONY: $(foreach LANG,${LANGUAGES},html-nochunks-${LANG}) .PHONY: $(foreach LANG,${LANGUAGES},pdf-${LANG}) all:: html html-nochunks tarball # pdf help:: @echo -e 'The following targets are available for use with the make(1)' @echo -e 'command. Targets with a * marker can be built for a specific' @echo -e 'locale only. To do this, append a locale suffix to the' @echo -e 'target name, as in "make html-ja".' @echo -e 'Valid locales are: ${OTHERS}' @printf ${TPOFMT} 'all' 'Builds html, html-nochunks, and tarball' @printf ${TFMT} 'help' 'Brief list of targets' @printf ${TFMT} 'help-verbose' 'Full list, try "make help-verbose|sort"' help-verbose:: help ${TARGETS}:: ######################################################################### # Ensure all 'clean' targets are invoked before 'distclean' targets distclean:: clean # ######################################################################### showvars:: @echo "XMLFILES=\"${XMLFILES-${PRI_LANG}}\"" @echo "XMLDEPFILES=\"${XMLDEPFILES-${PRI_LANG}}\"" @echo "FDPCOMMONDIR=\"${FDPCOMMONDIR}\"" help:: @printf ${TFMT} 'showvars' 'Displays convenient make(1) variables' ######################################################################### # Obtain the document version and release info for building RPM's SPECFILE := $(firstword $(wildcard *.spec)) ifneq "${SPECFILE}" "" # the name of the package ifeq "${NAME}" "" NAME := $(shell rpm ${RPMFLAGS} ${DISTRPMFLAGS} -q --qf "%{NAME}\n" \ --specfile ${SPECFILE} | head -1) endif # the version of the package ifeq "${VERSION}" "" VERSION := $(shell rpm ${RPMFLAGS} ${DISTRPMFLAGS} -q --qf "%{VERSION}\n" \ --specfile ${SPECFILE} | head -1) endif # the release of the package ifeq "${RELEASE}" "" RELEASE := $(shell rpm ${RPMFLAGS} ${DISTRPMFLAGS} -q --qf "%{RELEASE}\n" \ --specfile ${SPECFILE} | head -1) endif # CVS-safe version/release -- a package name like 4Suite screws things # up, so we have to remove the leaving digits from the name TAG_NAME := $(shell echo ${NAME} | sed -e s/\\\./_/g -e s/^[0-9]\\\+//g) TAG_VERSION := $(shell echo ${VERSION} | sed s/\\\./_/g) TAG_RELEASE := $(shell echo ${RELEASE} | sed s/\\\./_/g) # tag to export, defaulting to current tag in the spec file TAG ?= ${TAG_NAME}-${TAG_VERSION}-${TAG_RELEASE} # The rest of this rule is set outside the ifneq .PHONY: tag tag:: ${SPECFILE} @: else # ifneq "${SPECFILE}" "" # Only set tag here if not done already (i.e. SPECFILE doesn't exist) # Use the FDPSH function to get a current version. Keep in mind this # will prevent repetitive tagging without the user making use of # TAG_OPTS. I'd say that encourages people to Do The Right Thing by # changing version numbers where necessary. (PWF) VERSION ?= $(shell version doc) TAG_NAME ?= $(shell echo ${DOCBASE} | sed -e s/\\\./_/g -e s/^[0-9]\\\+//g) TAG_VERSION ?= $(shell version doc | sed s/\\\./_/g) TAG ?= ${TAG_NAME}-${TAG_VERSION} endif # the last revision date of the package, according to rpm-info REVDATE ?= $(shell date doc) tag:: cvs tag ${TAG_OPTS} -c ${TAG} @echo "Tagged with: ${TAG}" @echo showvars:: @echo "NAME=${NAME}" @echo "VERSION=${VERSION}" @echo "TAG_NAME=${TAG_NAME}" @echo "TAG_VERSION=${TAG_VERSION}" ifdef TAG_RELEASE # Only used if we have a specfile! @echo "RELEASE=$(RELEASE)" @echo "TAG_RELEASE=${TAG_RELEASE}" endif @echo "TAG=${TAG}" @echo "### (Tag vars do not necessarily reflect CVS status)" @echo "REVDATE=${REVDATE}" help:: @printf ${TFMT} 'tag' 'Tag this directory with the packaging NVR' ######################################################################### ######################################################################### # Rules to generate the "${LANG}/${DOC_ENTITIES}.ent" file, if used define DOC_ENTITIES_template ${1}/${DOC_ENTITIES}.xml:: ${1}/${FDP_ENTITIES} po/${1}.po ${PRI_LANG}/${DOC_ENTITIES}.xml ${XML2PO} ${XML2POFLAGS} -p po/${1}.po \ ${PRI_LANG}/${DOC_ENTITIES}.xml >$$@ clean:: ${RM} ${1}/${DOC_ENTITIES}.xml ${1}/${DOC_ENTITIES}.ent:: ${1}/${DOC_ENTITIES}.xml help-verbose:: @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-verbose:: @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/${POTBASE}.pot:: ${DOC_ENTITIES_XML-${PRI_LANG}} \ ${DOC_ENTITIES_ENT-${PRI_LANG}} \ ${PRI_LANG}/${FDP_ENTITIES} ${XMLFILES-${PRI_LANG}} [ -d po/CVS ] || (echo ADD po/ TO CVS >&2; exit 1) ${XML2PO} ${XML2POFLAGS} -o $@ ${XMLFILES-${PRI_LANG}} ${DOC_ENTITIES_XML-${PRI_LANG}} help-verbose:: @printf ${TFMT} 'po/${POTBASE}.pot' 'Writes one POT file for all XML' showvars:: @echo "POTBASE=${POTBASE}" .PHONY: pot pot:: po/${POTBASE}.pot help:: @printf ${TPOFMT} 'po' 'Writes one ${PRI_LANG} PO file for all XML' @printf ${TFMT} 'pot' 'Writes one POT file for all XML' ######################################################################### ######################################################################### define PO_template .PRECIOUS: po/${1}.po po/${1}.po:: po/${POTBASE}.pot $${DOC_ENTITITES_ENT-${1}} [ -d po/CVS ] || (echo ADD po/ TO CVS >&2; exit 1) if [ ! -f $$@ ]; then \ cp po/${POTBASE}.pot $$@; \ else \ ${MSGMERGE} -U -q $$@ po/${POTBASE}.pot; \ touch $$@; \ fi .PHONY: po-${1} po-${1}:: po/${1}.po postat-${1}:: @echo "${1}: $(shell $(MSGFMT) --stat po/${1}.po 2>&1 | \ sed 's@[^0-9]\+@/@g')" help-verbose:: @printf ${TFMT} 'po/${1}.po' 'Creates or updates locale ${1} .PO file' endef $(foreach L,${OTHERS},$(eval $(call PO_template,${L}))) .PHONY: po po:: $(foreach L,${OTHERS},po-${L}) postat:: $(foreach L,${OTHERS},postat-${L}) clean:: ${RM} .xml2po.mo ######################################################################## ######################################################################### # Define a template to generate the locale-specific XML files given the # original ${PRI_LANG} file and an updated po/${LANG}.po file. # We have to be funky and cd(1) into the ${LANG} directory so that # the "lang=foo" attribute that ${XML2PO} generates will be correct. # Hiss! Boo! define XML_template $(patsubst ${PRI_LANG}/%,${1}/%,${2}):: ${2} po/${1}.po mkdir -p ${1} cd po && ${XML2PO} ${XML2POFLAGS} -p ${1}.po ../${2} >../$$@ endef $(foreach L,${OTHERS}, \ $(foreach F,${XMLFILES-${PRI_LANG}}, \ $(eval $(call XML_template,${L},${F})))) clean:: cd po && ${RM} .xml2po.mo ${RM} messages.mo define XMLTARGET_template .PHONY: xml-${1} xml-${1}:: ${XMLDEPFILES-${1}} ${XMLFILES-${1}} distclean:: ${RM} -r ${1} help-verbose:: @printf ${TFMT} 'xml-${1}' 'Produces translated XML for locale ${1}' endef .PHONY: xml-${PRI_LANG} xml-${PRI_LANG}:: ${XMLFILES-${PRI_LANG}} $(foreach L,${OTHERS},$(eval $(call XMLTARGET_template,${L}))) .PHONY: xml xml-all xml xml-all:: $(foreach L,${LANGUAGES},xml-${L}) help:: @printf ${TPOFMT} 'xml' 'Creates all XML locale files, no validation' distclean:: $(foreach L,${OTHERS},${RM} -r ${L}) ######################################################################### ########### # # Get or build OMF. # # If the per-doc Makefile provides a ${OMFINFILES} list, we use those. # If it does not: # 1. look for ${PRI_LANG}/*.omf.in and use those; or, failing that, # 2. if ${BUILDOMF} is defined, make one using XSLT and rpm-info data. # # The template OMF files are expected to use @VARNAME@ notation to # allow replacement of their content dynamically at build time. They # should retain this notation during PO/POT conversion so that # translators never have to worry about that content. Substitution # only occurs during the packaging process. # # FIXME: There may not be a need to have the ${PRI_LANG} prefixing # each entry in ${OMFINFILES}. Might be a good idea to take that out. # if OMFINFILES is empty, try and get the file list. # If it's still empty, and BUILDOMF is set, use that to populate the list. # Otherwise it stays empty. After all, we may not want them at all. ifeq "${OMFINFILES}" "" OMFINFILES=$(foreach F,$(wildcard ${PRI_LANG}/*.omf.in),$(shell basename ${F})) ifeq "${OMFINFILES}" "" ifdef BUILDOMF OMFINFILES=${PKGNAME}.omf.in ${PRI_LANG}/${PKGNAME}.omf.in:: ${PRI_LANG}/${RPMINFO} ${XSLTPROC} --stringparam lang ${PRI_LANG} \ --stringparam docbase ${PKGNAME} \ ${FDPCOMMONDIR}/packaging/omf-in.xsl \ $< > $@ endif endif endif showvars:: @echo "OMFINFILES=\"${OMFINFILES}\"" define OMFVAR_template $(foreach F,${OMFINFILES},$(eval OMFINFILES-${1}+=${1}/${F})) $(foreach F,${OMFINFILES},$(eval OMFFILES-${1}+=$(patsubst %.in,${1}/%,${F}))) showvars-debug:: @echo "OMFFILES-${1}=\"${OMFFILES-${1}}\"" endef $(foreach L,${LANGUAGES},$(eval $(call OMFVAR_template,${L}))) define OMFIN_template .PHONY: omf-in-${1} omf-in-${1}:: ${OMFINFILES-${1}} # Treat .omf.in files just like XML... since they are! $(foreach F,${OMFINFILES},$(eval $(call XML_template,${1},${PRI_LANG}/${F}))) clean:: ${RM} ${OMFINFILES-${1}} endef $(foreach L,${OTHERS},$(eval $(call OMFIN_template,${L}))) .PHONY: omf-in omf-in:: $(foreach L,${LANGUAGES},${OMFINFILES-${L}}) help:: @printf ${TPOFMT} 'omf-in' 'Make all OMF input files' # To make the real OMF, just do a quick bit of sed processing. # The spacing in the second command is purposeful to ensure no extra # space appears in the sed command. # # Note the difference between @LANG@ and @LANGC@: the former is always # replaced by the locale name, whereas the latter is replaced by the # locale name *unless* the locale is en_US, in which case it is replaced # by "C", the fallback. %.omf: %.omf.in sed -e 's!@RELEASE@!${VERSION}!g' $< > $@ sed -i 's!@DATE@!${REVDATE}!g' $@ sed -i 's!@LANG@!$(patsubst %/$(shell basename $<),%,$<)!g' $@ sed -i 's!@LANGC@!$(if $(findstring en_US,$(patsubst \ %/$(shell basename $<),%,$<)),C,$(patsubst \ %/$(shell basename $<),%,$<))!g' $@ define OMF_template .PHONY: omf-${1} omf-${1}:: ${OMFFILES-${1}} clean:: ${RM} ${OMFFILES-${1}} endef $(foreach L,${LANGUAGES},$(eval $(call OMF_template,${L}))) .PHONY: omf omf:: $(foreach L,${LANGUAGES},${OMFFILES-${L}}) help:: @printf ${TPOFMT} 'omf' 'Make all OMF files for all locales' # End of OMF ############################### ######################################################################### # 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 # mkdir -p mydoc-en/stylesheet-images # cp ${FDPCOMMONDIR}/stylesheet-images/*.png mydoc-en/stylesheet-images/ # cp ${HTMLCSS} mydoc-en/fedora.css # cp ${HTMLCSSEXTRA} mydoc-en/watermark.png # cp ${FDPCOMMONDIR}/images/watermark.png mydoc-en/ # ${FDPCOMMONDIR}/bin/copy-figs -f '*.png' figs mydoc-en/ # but we do avoid copying EPS files since they are nonsense to the HTML world. # define HTML_template .PHONY: html-${1} html-$(1):: ${DOCBASE}-$(1)/index.html ${DOCBASE}-$(1)/index.html:: ${XMLFILES-${1}} ${XMLDEPFILES-${1}} LANG=$(1).UTF-8 ${XMLTO} html -x $(XSLHTML) ${XMLTOOPTS} \ -o $(DOCBASE)-$(1) $(1)/$(DOCBASE).xml mkdir -p $(DOCBASE)-$(1)/stylesheet-images/ cp ${FDPCOMMONDIR}/stylesheet-images/*.png \ $(DOCBASE)-$(1)/stylesheet-images cp ${HTMLCSS} $(DOCBASE)-$(1)/fedora.css ifneq "${DRAFT}" "no" cp ${FDPCOMMONDIR}/images/watermark-$(1).png \ $(DOCBASE)-$(1)/watermark.png endif [ ! -d figs ] || copy-figs -v -f '*.png' \ -l $(1) figs $(DOCBASE)-$(1) distclean:: ${RM} -r ${DOCBASE}-${1} help-verbose:: @printf ${TFMT} '${1}/index.html' 'Renders XML into locale ${1}' endef $(foreach L,${LANGUAGES},$(eval $(call HTML_template,${L}))) .PHONY: html html:: $(foreach L,${LANGUAGES},html-${L}) help:: @printf ${TPOFMT} 'html' 'Renders XML into chunked HTML' # ######################################################################### ######################################################################### # For each language in ${LANGUAGES}, generate a single HTML file define HTMLNOCHUNK_template .PHONY: html-nochunks-${1} html-nochunks-$(1):: ${DOCBASE}-$(1).html ${DOCBASE}-$(1).html:: ${XMLFILES-${1}} ${XMLDEPFILES-${1}} LANG=${1}.UTF-8 ${XMLTO} html-nochunks -x $(XSLHTMLNOCHUNKS) \ ${XMLTOOPTS} $(1)/$(DOCBASE).xml mv $(DOCBASE).html $(DOCBASE)-$(1).html mkdir -p stylesheet-images/ cp ${FDPCOMMONDIR}/stylesheet-images/*.png stylesheet-images/ cp ${HTMLCSS} fedora.css ifneq "${DRAFT}" "no" cp ${FDPCOMMONDIR}/images/watermark-$(1).png watermark.png endif distclean:: ${RM} ${DOCBASE}-${1}.html ${RM} -r stylesheet-images ${RM} fedora.css ${RM} watermark.png help-verbose:: @printf ${TFMT} '${DOCBASE}-${1}.html' 'Renders XML into locale ${1} HTML' endef $(foreach L,${LANGUAGES},$(eval $(call HTMLNOCHUNK_template,${L}))) .PHONY: html-nochunks html-nochunks:: $(foreach L,${LANGUAGES},html-nochunks-$(L)) help:: @printf ${TPOFMT} 'html-nochunks' 'Renders XML into locale ${1} HTML' # ######################################################################### ######################################################################### # For each language in ${LANGUAGES}, build a tarball of the HTML and # image files. Any ".eps" files are ignored. # define HTMLTAR_template .PHONY: tarball-${1} tarball-${1}:: ${DOCBASE}-${1}.tar.gz ${DOCBASE}-$(1).tar.gz:: ${DOCBASE}-$(1)/index.html tar -zc --exclude '*.eps' -f ${DOCBASE}-$(1).tar.gz ${DOCBASE}-$(1) distclean:: ${RM} ${DOCBASE}-${1}.tar.gz help-verbose:: @printf ${TFMT} '${DOCBASE}-${1}.tar.gz' 'Tar archive of HTML and images' endef $(foreach L,${LANGUAGES},$(eval $(call HTMLTAR_template,${L}))) .PHONY: tarball tarball:: $(foreach LANG,${LANGUAGES},$(DOCBASE)-$(LANG).tar.gz) help:: @printf ${TPOFMT} 'tarball' 'Tar archive of HTML and images' # ######################################################################### ######################################################################### # For each language in ${LANGUAGES}, generate an Adobe Portable Document # Format (PDF) file. define FO_template .PHONY: fo-${1} fo-${1}:: ${1}/${DOCBASE}.fo ${1}/${DOCBASE}.fo:: ${XMLFILES-${1}} ${XMLDEPFILES-${1}} LANG=${1}.UTF-8 xsltproc --xinclude \ --stringparam FDPCOMMONDIR ${FDPCOMMONDIR} \ --stringparam IMGROOT ${PWD} \ --stringparam RENDEREDBY fop-0.20.5 \ ${XSLPDF} ${1}/${DOCBASE}.xml | ${XMLLINT} --format -o $$@ - clean:: ${RM} ${1}/${DOCBASE}.fo help-verbose:: @printf ${TFMT} '${1}/${DOCBASE}.fo' 'XSL-FO file for locale ${1}' endef $(foreach L,${LANGUAGES},$(eval $(call FO_template,${L}))) .PHONY: fo fo-all fo fo-all:: $(foreach L,${LANGUAGES},fo-${L}) help:: @printf ${TPOFMT} 'fo' 'Generate .FO files for all languages' define PDF_template .PHONY: pdf-${1} pdf-$(1):: ${DOCBASE}-$(1).pdf ${DOCBASE}-${1}.pdf:: ${1}/${DOCBASE}.fo LANG=${1}.UTF-8 ${XMLTO} ${XMLTOOPTS} -o ${1} pdf $$< mv -f ${1}/${DOCBASE}.pdf $$@ distclean:: ${RM} ${DOCBASE}-${1}.pdf help-verbose:: @printf ${TFMT} '${DOCBASE}-${1}.pdf' 'Renders XML-FO into PDF file for locale ${1}' endef $(foreach L,${LANGUAGES},$(eval $(call PDF_template,${L}))) .PHONY: pdf pdf:: $(foreach LANG,${LANGUAGES},pdf-$(LANG)) help:: @printf ${TPOFMT} 'pdf' 'Renders XML-FO into PDF file' define TXT_template .PHONY: txt-${1} text-${1} txt-$(1) text-$(1):: ${DOCBASE}-$(1).txt ${DOCBASE}-$(1).txt:: ${XMLFILES-${1}} ${XMLDEPFILES-${1}} # Not pretty, but it's what we've got. test -f /usr/bin/w3m || ( echo 'Missing w3m package.' && exit 1 ) ${XMLLINT} ${XMLLINTOPT} $(1)/$(DOCBASE).xml > $(1)/$(DOCBASE).lint.xml ${XSLTPROC} $(FDPCOMMONDIR)/packaging/strip-for-txt.xsl \ $(1)/$(DOCBASE).lint.xml > $(1)/$(DOCBASE).stripped.xml rm $(1)/$(DOCBASE).lint.xml # THIS IS ONLY REMOVED FOR THE 9.0.1 BUILD, THANKS TO BROKEN XMLTO. # LANG=$(1).UTF-8 ${XMLTO} ${XMLTOOPTS} ${XMLTOTXTPOSTOPT} txt \ # $(1)/$(DOCBASE).stripped.xml LANG=${1}.UTF-8 ${XMLTO} ${XMLTOOPTS} html-nochunks \ ${1}/${DOCBASE}.stripped.xml LANG=${1}.UTF-8 w3m -dump ${DOCBASE}.stripped.html > \ ${DOCBASE}.stripped.txt mv $(DOCBASE).stripped.txt $(DOCBASE)-$(1).txt rm $(1)/$(DOCBASE).stripped.xml ${DOCBASE}.stripped.html clean:: ${RM} ${1}/${DOCBASE}.stripped.xml distclean:: ${RM} ${DOCBASE}-${1}.txt help-verbose:: @printf ${TFMT} '${DOCBASE}-${1}.txt' 'Renders XML into ASCII text for locale ${1}' endef $(foreach L,${LANGUAGES},$(eval $(call TXT_template,${L}))) .PHONY: txt text txt text:: $(foreach LANG,${LANGUAGES},txt-$(LANG)) help:: @printf ${TPOFMT} 'txt' 'Renders XML into ASCII text' @printf ${TPOFMT} 'text' 'Renders XML into ASCII text' # ######################################################################### ######################################################################### clean:: ${RM} *.tmp ######################################################################### ######################################################################### # showvars:: @echo "DOCBASE=\"$(DOCBASE)\"" @echo "PRI_LANG=\"$(PRI_LANG)\"" @echo "OTHERS=\"$(OTHERS)\"" # ######################################################################### ######################################################################### # Show differences between two file revisions. To use this tool: # $ make OLD=old.xml NEW=new.xml diff # The ${DIFFS} macro can select a different output format: # $ make DIFFS=-C OLD=old.xml NEW=new.xml diff OLD =define-me-old.xml NEW =define-me-new.xml DIFFS =-u diff:: xmldiff ${DIFFS} ${OLD} ${NEW} help:: @printf ${TFMT} 'diff' 'Compares XML files' # ######################################################################### ######################################################################### # The "${LANG}/rpm-info.xml" file contains the revision information for # the original DocBook source. We use it to generate the "fdp-info.xml" # file discussed in the next section. # define rpm-info_template ${1}/${RPMINFO}:: po/${1}.po ${PRI_LANG}/${RPMINFO} mkdir -p ${1} ${XML2PO} ${XML2POFLAGS} -p po/${1}.po \ ${PRI_LANG}/${RPMINFO} >$$@ clean:: ${RM} ${1}/${RPMINFO} help-verbose:: @printf ${TFMT} '${1}/${RPMINFO}' 'Make translated document revision info' endef # ${PRI_LANG}/${RPMINFO} must exist, only generate for OTHERS $(foreach L,${OTHERS},$(eval $(call rpm-info_template,${L}))) # ######################################################################### ######################################################################### # The "${LANG}/fdp-info.xml" file contains the or # stanza. It is automatically generated from data in the # "rpm-info.xml" file whenever that file changes. # define fdp-info_template $(1)/fdp-info.xml:: ${1}/$(RPMINFO) mkdir -p ${1} LANG=$(1).UTF-8 ${XSLTPROC} ${XSLTPROCOPTS} --stringparam lang $(1) \ --stringparam fdpcommondir $(FDPCOMMONDIR) \ --stringparam doctype $(shell \ doctype ${PRI_LANG}/$(DOCBASE).xml) \ --stringparam legalbase ${LEGALNOTICEBASE} \ ${FDPCOMMONDIR}/packaging/bookinfo.xsl \ ${1}/$(RPMINFO) | \ $(XMLFORMAT) $(XMLFOPTS) >$$@ clean:: ${RM} ${1}/fdp-info.xml help-verbose:: @printf ${TFMT} '${1}/fdp-info.xml' 'Locale ${1} packaging information' endef $(foreach L,${LANGUAGES},$(eval $(call fdp-info_template,${L}))) .PHONY: fdp-info fdp-info:: $(foreach LANG,${LANGUAGES},$(LANG)/fdp-info.xml) help:: @printf ${TPOFMT} 'fdp-info' 'Outputs XML document info' define khelp_template .PHONY: khelp-$(1) khelp-$(1):: ${XMLFILES-$(1)} ${XMLDEPFILES-$(1)} LANG=$(1).UTF-8 ${XMLLINT} --noent --xinclude $(1)/$(DOCBASE).xml \ 2>/dev/null >$(1)/$(DOCBASE).xml-parsed mkdir -p kde-$(1) ${MEINPROC} --output kde-$(1)/index.docbook \ --cache kde-$(1)/index.cache.bz2 \ $(1)/$(DOCBASE).xml-parsed ${RM} -f $(1)/$(DOCBASE).xml-parsed clean:: ${RM} -rf kde-$(1) endef $(foreach L,${LANGUAGES},$(eval $(call khelp_template,${L}))) .PHONY: khelp khelp:: $(foreach LANG,${LANGUAGES},khelp-$(LANG)) help:: @printf ${TPOFMT} 'khelp' 'Build all locale-specific khelpcenter files' # ######################################################################### ######################################################################### # Stuff after here is for RPM packaging ######################################################################### ######################################################################### # Make a new changelog entry for an existing rpm-info.xml file. # We cannot guarantee a correct relative location in , so # this target needs to be dropped. #clog:: ${PRI_LANG}/$(RPMINFO) # insert-changelog $(RPMINFO).tmp && \ # move-if-change $(RPMINFO).tmp ${PRI_LANG}/$(RPMINFO) # #help:: # @printf ${TFMT} 'clog' 'Adds changelog entry to rpm-info.xml file' # ######################################################################### # Make a new colophon entry for an existing rpm-info.xml file. # We cannot guarantee a correct relative location in , so # this target needs to be dropped. # colophon:: ${PRI_LANG}/${RPMINFO} # insert-colophon ${RPMINFO}.tmp && \ # move-if-change ${RPMINFO}.tmp ${PRI_LANG}/${RPMINFO} # #help:: # @printf ${TFMT} 'colophon' 'Adds colophon entry to rpm-info.xml file' ######################################################################### .PHONY: distclean-${1} ${DOCBASE}-${1}-distclean define DISTCLEAN_template distclean-${1} ${DOCBASE}-$(1)-distclean:: ${RM} *-$(1).omf ${RM} *-$(1).desktop endef $(foreach L,${LANGUAGES},$(eval $(call DISTCLEAN_template,${L}))) distclean:: $(foreach L,${LANGUAGES},${DOCBASE}-${L}-distclean) help:: @printf ${TPOFMT} 'distclean' 'Removes product files and temporary files' @printf ${TFMT} 'clean' 'Removes temporary files' ######################################################################### ######################################################################### clean:: ${RM} $(DOCBASE)-$(VERSION)*.src.tar.gz ${RM} -r $(DOCBASE)-$(VERSION)/ ${RM} fedora-doc-$(DOCBASE)*.{omf,desktop,spec} ${RM} *~ distclean:: ${RM} -r rpm ${RM} fedora-doc-$(DOCBASE)*.rpm ${RM} fedora-doc-$(DOCBASE)*.omf ${RM} fedora-doc-$(DOCBASE)*.desktop ${RM} fedora-doc-$(DOCBASE)*.spec ${RM} $(DOCBASE)*.src.tar.gz # ######################################################################### # Build project-wide entities. # define FDP_ENTITIES_template ${1}/$${FDP_ENTITIES}:: mkdir -p ${1} ( cd ${FDPCOMMONDIR}/common/entities ; $$(MAKE) entities-${1}.ent ) cp -u ${FDPCOMMONDIR}/common/entities/entities-${1}.ent $$@ clean:: ${RM} ${1}/$${FDP_ENTITIES} help-verbose:: @printf ${TFMT} '${1}/$${FDP_ENTITIES}' 'Link locale ${1} to FDP entities' endef $(foreach L,${LANGUAGES},$(eval $(call FDP_ENTITIES_template,${L}))) ######################################################################### ######################################################################### # 'LOCALE_template' issues rules and targets to symbolicly link the local # file 'locale-entities.xml' to the per-locale entity files located in # the "docs-common/common/entities/" directory. # define LOCALE_template .PHONY: set-locale-${1} set-locale-${1}:: ${XMLDEPFILES-${1}} clean:: ${RM} ${XMLDEPFILES-${1}} help-verbose:: @printf ${TFMT} 'set-locale-${1}' 'Link to locale ${1} FDP entities' endef $(foreach L,${PRI_LANG} ${OTHERS},$(eval $(call LOCALE_template,${L}))) # ######################################################################### ######################################################################### # 'VALIDATE_template' emits rules and targets to validate the XML for the # specified ${LANG} define VALIDATE_template .PHONY: validate-xml-${1} validate-xml-${1}:: ${XMLFILES-${1}} ${XMLDEPFILES-${1}} ${XMLLINT} --noout --xinclude --postvalid ${1}/${DOCBASE}.xml endef $(foreach L,${PRI_LANG} ${OTHERS},$(eval $(call VALIDATE_template,${L}))) .PHONY: validate-xml validate-xml: $(foreach L,${PRI_LANG} ${OTHERS},validate-xml-${L}) help:: @printf ${TPOFMT} 'validate-xml' 'Validate all XML' # ######################################################################### ######################################################################### # I'm going to bury this target deep at the bottom of the Makefile so # that maybe you won't see it ;-) This is a *VERY DANGEROUS* target # what will destroy *ALL* of your work, that of all the translators, # and probably cause dental cavities as well. You *DO NOT* want to # use this target, ever. The purpose of this target is to erase the # oh-so-carefully hand-crafted .POT and .PO translation files in addition # to all of the other generated product files. THIS IS THE ONLY TARGET # THAT WILL ERASE A .PO FILE! Unless you are working on the I18N part # of the FDP toolchain itself, you MUST NOT EVER use this target! It # voids all warranties! It will never show up on a "make help" list! mrproper: distclean ${RM} po/*.* # OK, you tried it anyway didn't you? To recover you must: # 1) NOT DO A CVS COMMIT; and # 2) Immediately do a "cvs update po" to repair the damage; and # 3) Send $25.00USD to the charity of your choice; or # 4) Just pretend you didn't use this target in the first place. ######################################################################### ######################################################################### # End of Makefile.common ######################################################################### # Local variables: # mode: makefile # End: