Package: cdbs
Version: 0.4.49
Followup-For: Bug #433852

Have made a working implementation now, that comply with policy of
removing generated files on clean. based on file made by Sylvain Le Gall
but with major changes.

Hope this diesn't qualify as "experimental code" :)
/Carl
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2006 Sylvain Le Gall <gildor#debian.org>
# Copyright © 2007 Carl Fürstenberg <[EMAIL PROTECTED]>
# Description: Rules to manage manpages written in XML.
#
# 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 2, 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, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA. 

#PATH_RULES#

ifndef _cdbs_rules_docbook_xml_manpage
        _cdbs_rules_docbook_xml_manpage = 1

include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)

# docbook-xml manpages to build
DOCBOOKXML_MANPAGE_SOURCES := 

# add required build dependency for used tools 
CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), docbook-xml, docbook-xsl, 
libxml2-utils, xsltproc, xml-twig-tools

# xmllint
DOCBOOKXML_MANPAGE_XMLLINT = xmllint --nonet --nocdata --noent --noout 
--postvalid --xinclude $(1)

# xml_grep
DOCBOOKXML_MANPAGE_XML_GREP = xml_grep --text_only --cond $(1) $(2)

# xsltproc
DOCBOOKXML_MANPAGE_XSLTPROC = xsltproc --nonet --xinclude --param 
man.charmap.use.subset 0 -o $(dir $(1)) $(2) $(1)

# XSL stylesheet to transform docbook-xml to manpage
DOCBOOKXML_MANPAGE_XSLTPROC_XSL = 
/usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl

# file containing the list of generated files
DOCBOOKXML_MANPAGE_LIST := debian/docbook-xml-manpage-list

define ECHO_CALL
        echo $(1); \
        $(1);

endef

define DOCBOOKXML_MANPAGE_PROCESS
        $(call ECHO_CALL, $(call DOCBOOKXML_MANPAGE_XMLLINT, $(1))) \
        docbook_xml_manpage_title=`$(call DOCBOOKXML_MANPAGE_XML_GREP, 
'//refentrytitle', $(1)) | tr '[:upper:]' '[:lower:]'`; \
        docbook_xml_manpage_section=`$(call DOCBOOKXML_MANPAGE_XML_GREP, 
'//manvolnum', $(1));`; \
        
docbook_xml_manpage=$$docbook_xml_manpage_title.$$docbook_xml_manpage_section; \
        echo "generating $(addprefix $(dir $(1)),$$docbook_xml_manpage)"; \
        echo $(addprefix $(dir $(1)),$$docbook_xml_manpage) >> 
$(DOCBOOKXML_MANPAGE_LIST); \
        $(call ECHO_CALL, $(call DOCBOOKXML_MANPAGE_XSLTPROC, $(1), 
$(DOCBOOKXML_MANPAGE_XSLTPROC_XSL))) 

endef

clean::
        @if test -f $(DOCBOOKXML_MANPAGE_LIST); then \
                for i in `cat $(DOCBOOKXML_MANPAGE_LIST)`; do \
                $(RM) $$i;echo $(RM) $$i; \
                done; \
                fi
        -$(RM) $(DOCBOOKXML_MANPAGE_LIST);
        -$(RM) debian/docbook-xml-manpage-stamp;

post-patches:: debian/docbook-xml-manpage-stamp
debian/docbook-xml-manpage-stamp: 
        @$(foreach source,$(DOCBOOKXML_MANPAGE_SOURCES),$(call 
DOCBOOKXML_MANPAGE_PROCESS,$(source)))
        touch $@

endif

Reply via email to