######################################################################### # Makefile.common # # This file, to be included from every document's local Makefile, provides # the basic targets used by the Fedora Docs Project: # all -- Default target, builds HTML document only # ${DOCNAME}/index.html -- Builds HTML version of document # html -- See "${DOCNAME}/index.html" # html-nochunks -- See "${DOCNAME}.html"; single HTML file # ${DOCNAME}.tar.gz -- Packages HTML document into a tar archive # tarball -- See "${DOCNAME}.tar.gz" # clean -- Deletes all generated files and directories # distclean -- See "clean" # ${DOCNAME}.pdf -- Builds PDF version of document # pdf -- See "${DOCNAME}.pdf" ######################################################################### # PDF generation is still fragile and probably won't work on your document. # Yet. ######################################################################### # 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. ######################################################################### # 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 ######################################################################### # Supply default values for the boilerplate files _unless_ the user has # provided their own values. ifeq (${FDPDIR},) FDPDIR = $(PWD)/.. endif ifeq (${FDPBIN},) FDPBIN = ${FDPDIR}/docs-common/bin endif ifeq (${XSLPDF},) XSLPDF = ${FDPDIR}/docs-common/xsl/main-pdf.xsl endif ifeq (${XSLHTML},) XSLHTML = ${FDPDIR}/docs-common/xsl/main-html.xsl endif ifeq (${XSLHTMLNOCHUNKS},) XSLHTMLNOCHUNKS = ${FDPDIR}/docs-common/xsl/main-html-nochunks.xsl endif ifeq (${HTMLCSS},) HTMLCSS = ${FDPDIR}/docs-common/css/fedora-draft.css endif ifeq (${HTMLCSSEXTRA},) HTMLCSSEXTRA = ${FDPDIR}/docs-common/images/watermark-${LANG}.png endif ifeq (${RPMINFO},) RPMINFO = ${PWD}/rpm-info.xml endif ######################################################################### # Define a macro to locate xmlto(1) so we can choose a specific version # by "make XMLTO=/path/to/xmlto", if we so desire. XMLTO =xmlto # Let's also do this for xsltproc(1). XSLTPROC=xsltproc XMLFORMAT=$(FDPDIR)/docs-common/bin/xmlformat XMLFOPTS=-f $(FDPDIR)/docs-common/bin/xmlformat-fdp.conf ######################################################################### # 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 tarball pdf html html-nochunks clean distclean showvars fdp-info .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 ${TARGETS}:: ######################################################################### # 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 ${FDPDIR}/docs-common/stylesheet-images/*.png mydoc-en/stylesheet-images/ # cp ${HTMLCSS} mydoc-en/fedora.css # cp ${HTMLCSSEXTRA} mydoc-en/watermark.png # cp ${FDPDIR}/docs-common/images/watermark.png mydoc-en/ # ${FDPDIR}/docs-common/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 html-$(1) ${DOCBASE}-$(1)/index.html:: ${DOCBASE}-$(1).xml $$(XMLEXTRAFILES-$(1)) fdp-info-$(1).xml LANG=$(1).UTF-8 ${XMLTO} html -x $(XSLHTML) -o $(DOCBASE)-$(1) $(DOCBASE)-$(1).xml mkdir -p $(DOCBASE)-$(1)/stylesheet-images/ cp ${FDPDIR}/docs-common/stylesheet-images/*.png $(DOCBASE)-$(1)/stylesheet-images cp ${HTMLCSS} $(DOCBASE)-$(1)/fedora.css [ -z "${HTMLCSSEXTRA}" ] || \ cp ${HTMLCSSEXTRA} $(DOCBASE)-$(1)/watermark.png [ ! -d figs ] || ${FDPBIN}/copy-figs -v -f '*.png' \ -l ${LANG} figs $(DOCBASE)-$(1) endef # $(foreach LANG,${LANGUAGES},$(eval $(call HTML_template,${LANG}))) html:: $(foreach LANG,${LANGUAGES},$(DOCBASE)-${LANG}/index.html) html:: $(foreach LANG,${LANGUAGES},html-${LANG}) # ######################################################################### # For each language in ${LANGUAGES}, generate a single HTML file define HTMLNOCHUNK_template html-nochunks-$(1) ${DOCBASE}-$(1).html:: ${DOCBASE}-$(1).xml $$(XMLEXTRAFILES-$(1)) fdp-info-$(1).xml ${XMLTO} html-nochunks -x $(XSLHTMLNOCHUNKS) $(DOCBASE)-$(1).xml mkdir -p stylesheet-images/ cp ${FDPDIR}/docs-common/stylesheet-images/*.png stylesheet-images/ cp ${HTMLCSS} fedora.css [ -z "${HTMLCSSEXTRA}" ] || \ cp ${HTMLCSSEXTRA} watermark.png endef # $(foreach LANG,${LANGUAGES},$(eval $(call HTMLNOCHUNK_template,${LANG}))) html-nochunks:: $(foreach LANG,${LANGUAGES},$(DOCBASE)-$(LANG).html) html-nochunks:: $(foreach LANG,${LANGUAGES},html-nochunks-$(LANG)) # ######################################################################### # For each language in ${LANGUAGES}, build a tarball of the HTML files. # define TAR_template ${DOCBASE}-$(1).tar.gz:: ${DOCBASE}-$(1)/index.html tar -zc --exclude '*.eps' -f ${DOCBASE}-$(1).tar.gz ${DOCBASE}-$(1) endef # tarball:: $(foreach LANG,${LANGUAGES},$(DOCBASE)-$(LANG).tar.gz) $(foreach LANG,${LANGUAGES},$(eval $(call TAR_template,${LANG}))) # ######################################################################### # For each language in ${LANGUAGES}, generate an Adobe Portable Document # Format (PDF) file. define PDF_template pdf-$(1) ${DOCBASE}-$(1).pdf:: ${DOCBASE}-$(1).xml $$(XMLEXTRAFILES-$(1)) ${XMLTO} pdf -x $(XSLPDF) $(DOCBASE)-$(1).xml endef # $(foreach LANG,${LANGUAGES},$(eval $(call PDF_template,${LANG}))) pdf:: $(foreach LANG,${LANGUAGES},$(DOCBASE)-$(LANG).pdf) pdf:: $(foreach LANG,${LANGUAGES},pdf-$(LANG).pdf) # ######################################################################### # For each language in ${LANGUAGES}, clean up! define CLEAN_template ${DOCBASE}-$(1)-clean:: ${RM} fdp-info-$(1).xml ${RM} fedora.css watermark-${LANG}.png watermark.png endef # $(foreach LANG,${LANGUAGES},$(eval $(call CLEAN_template,${LANG}))) # clean:: $(foreach LANG,${LANGUAGES},${DOCBASE}-${LANG}-clean) ######################################################################### define DISTCLEAN_template ${DOCBASE}-$(1)-distclean:: ${DOCBASE}-$(1)-clean ${RM} -r ${DOCBASE}-$(1) ${RM} -r ${DOCBASE}-$(1).html stylesheet-images ${RM} -r ${DOCBASE}-$(1).pdf ${RM} -r ${DOCBASE}-$(1).tar.gz endef # $(foreach LANG,${LANGUAGES},$(eval $(call DISTCLEAN_template,${LANG}))) # distclean:: $(foreach LANG,${LANGUAGES},${DOCBASE}-${LANG}-distclean) ######################################################################### # showvars:: @echo "DOCBASE=\"$(DOCBASE)\"" @echo "LANGUAGES=\"$(LANGUAGES)\"" # ######################################################################### # 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:: ${FDPBIN}/xmldiff ${DIFFS} ${OLD} ${NEW} # ######################################################################### # The "fdp-info-${LANG}.xml" file contains the or # stanza. It is automatically generated from data in the # "rpm-info.xml" file. # define fdp-info_template fdp-info-$(1).xml:: $(RPMINFO) ${XSLTPROC} --stringparam lang $(1) \ --stringparam doctype $(shell \ ${FDPDIR}/docs-common/packaging/doctype \ $(DOCBASE)-$(1).xml \ ) ${FDPDIR}/docs-common/packaging/bookinfo.xsl \ $(RPMINFO) | \ $(XMLFORMAT) $(XMLFOPTS) > fdp-info-$(1).xml endef # $(foreach LANG,${LANGUAGES},$(eval $(call fdp-info_template,${LANG}))) # fdp-info:: $(foreach LANG,${LANGUAGES},fdp-info-$(LANG).xml) # ######################################################################### # Make a new changelog entry for an existing rpm-info.xml file. clog:: $(RPMINFO) @${FDPBIN}/fdpsh -c insert-changelog $(RPMINFO).clog mv -b $(RPMINFO).clog $(RPMINFO) # ######################################################################### # Make a new colophon entry for an existing rpm-info.xml file. colophon:: $(RPMINFO) @${FDPBIN}/fdpsh -c insert-colophon $(RPMINFO).worker mv -b $(RPMINFO).worker $(RPMINFO) # ######################################################################### # End of Makefile.common #########################################################################