doc/share/mk/doc.common.mk
Hiroki Sato 20bedcfcf2 Add refinements on mirrors.xml:
- add doc.common.mk, which defines variables, targets, and
   dependencies commonly used in www/ and doc/.

 - move www/<lang>/includes.xsl to the language independent
   directory and split into several files.

 - add transtable*.xsl and transtable.xml to support localized
   mirror names.

 - make doc/{en_US.ISO8859-1,ja_JP.eucJP}/books/handbook/ use
   mirrors.xml (mirrors and eresources).

 - make www/{en,ja}/index.xsl use mirrors.xml.

For details, please see doc/share/sgml/README.mirrors for the moment.

Reviewed by:	simon and Alex Dupre <sysadmin@alexdupre.com>
2003-11-24 18:26:35 +00:00

120 lines
3.4 KiB
Makefile

#
# $FreeBSD$
#
# This include file <doc.common.mk> provides targets and variables for
# documents commonly used in doc/ and www/ tree.
#
.if defined(DOC_PREFIX) && !empty(DOC_PREFIX)
WEB_PREFIX?= ${DOC_PREFIX}/../www
.elif defined(WEB_PREFIX) && !empty(WEB_PREFIX)
DOC_PREFIX?= ${WEB_PREFIX}/../doc
.else
.error "You must define either WEB_PREFIX or DOC_PREFIX!"
.endif
# ------------------------------------------------------------------------
#
# Work out the language and encoding used for this document.
#
# Liberal default of maximum of 10 directories below to find it.
#
DOC_PREFIX_NAME?= doc
WWW_PREFIX_NAME?= www
.if !defined(LANGCODE) || empty(LANGCODE)
# Calculate LANGCODE. Are we in doc/?
LANGCODE:= ${.CURDIR}
.for _ in 1 2 3 4 5 6 7 8 9 10
.if !(${LANGCODE:H:T} == ${DOC_PREFIX_NAME})
LANGCODE:= ${LANGCODE:H}
.endif
.endfor
LANGCODE:= ${LANGCODE:T}
.if (${LANGCODE} == .)
# Recalculate LANGCODE. We are in www/.
LANGCODE:= ${.CURDIR}
.for _ in 1 2 3 4 5 6 7 8 9 10
.if !(${LANGCODE:H:T} == ${WWW_PREFIX_NAME})
LANGCODE:= ${LANGCODE:H}
.endif
.endfor
# We have a short name such as `en' now.
# Recalculate from doc/.
WWW_LANGCODE:= ${LANGCODE:T}
LANGCODE:= ${LANGCODE:T}
.if (${LANGCODE} != .)
LANGCODE!= ${ECHO} ${DOC_PREFIX}/${WWW_LANGCODE}*
.for _ in 1 2 3 4 5 6 7 8 9 10
.if !(${LANGCODE:H:T} == ${DOC_PREFIX_NAME})
LANGCODE:= ${LANGCODE:H}
.endif
.endfor
LANGCODE:= ${LANGCODE:T}
.endif
.endif
.endif
# If we are in doc/, guess WWW_LANGCODE using LANGCODE.
.if !defined(WWW_LANGCODE) || empty(WWW_LANGCODE)
WWW_LANGCODE!= ${ECHO} ${WEB_PREFIX}/*
WWW2_LANGCODE!= ${ECHO} ${WWW_LANGCODE:T} |\
${SED} -e 's,.*\(${LANGCODE:R:C,(..)_.*,\1,}[^. ]*\).*,\1,'
.if ${WWW_LANGCODE:T} == ${WWW2_LANGCODE}
WWW_LANGCODE:= .
.else
WWW_LANGCODE:= ${WWW2_LANGCODE}
.endif
.undef WWW2_LANGCODE
.endif
# ------------------------------------------------------------------------
#
# advisories.xml dependency.
#
#XML_ADVISORIES= ${WEB_PREFIX}/share/sgml/advisories.xml
# use www/en version temporarily
XML_ADVISORIES= ${WEB_PREFIX}/en/security/advisories.xml
# ------------------------------------------------------------------------
#
# mirrors.xml dependency.
#
XML_MIRRORS_MASTER= ${DOC_PREFIX}/share/sgml/mirrors.xml
XML_MIRRORS= ${.OBJDIR}/${DOC_PREFIX:S,^${.CURDIR}/,,}/${LANGCODE}/share/sgml/mirrors.xml
XSL_MIRRORS_MASTER= ${DOC_PREFIX}/share/sgml/mirrors-master.xsl
.if exists(${DOC_PREFIX}/${LANGCODE}/share/sgml/mirrors-local.xsl)
XSL_MIRRORS= ${DOC_PREFIX}/${LANGCODE}/share/sgml/mirrors-local.xsl
.else
XSL_MIRRORS= ${DOC_PREFIX}/share/sgml/mirrors-local.xsl
.endif
XSL_TRANSTABLE_MASTER= ${DOC_PREFIX}/share/sgml/transtable-master.xsl
.if exists(${DOC_PREFIX}/${LANGCODE}/share/sgml/transtable-local.xsl)
XSL_TRANSTABLE= ${DOC_PREFIX}/${LANGCODE}/share/sgml/transtable-local.xsl
.else
XSL_TRANSTABLE= ${DOC_PREFIX}/share/sgml/transtable-local.xsl
.endif
.if exists(${DOC_PREFIX}/${LANGCODE}/share/sgml/transtable.xml)
XML_TRANSTABLE= ${DOC_PREFIX}/${LANGCODE}/share/sgml/transtable.xml
.else
XML_TRANSTABLE= ${DOC_PREFIX}/share/sgml/transtable.xml
.endif
${XSL_MIRRORS}: ${XSL_MIRRORS_MASTER}
${XML_MIRRORS}: ${XML_MIRRORS_MASTER} ${XSL_TRANSTABLE} ${XSL_TRANSTABLE_MASTER}
${MKDIR} -p ${@:H}
${XSLTPROC} ${XSLTPROCOPTS} -o $@ \
--param 'transtable.xml' "'${XML_TRANSTABLE}'" \
--param 'transtable-conv-element' "'country'" \
${XSL_TRANSTABLE} ${XML_MIRRORS_MASTER} || (${RM} -f $@ && exit 1)
CLEANFILES+= ${XML_MIRRORS}