#
# Debian ProLiant Guide Makefile
#
#  Copyright (C) 2004 Matt Taggart <taggart@debian.org>
#  Copyright (C) 2001-2003 Dann Frazier <dannf@hp.com>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
#  Function: Create documentation from SGML source.
#
#  If you get errors when running make, and you are fortunate enough to be
#  building on a Debian box, do the following to get all the proper tools 
#  installed:
# 
#    "apt-get install jadetex docbook-utils sgmltools-lite"
#
#  It may also be prefereable to do a "make USE_SGMLTOOLS=1 <target>" if you are on Debian.
#


NAME	        = Debian-ProLiant-Guide
BOOK            = $(NAME).xml

all:    html ps pdf dvi rtf txt

html:	$(NAME).html
dvi:	$(NAME).dvi
pdf:    $(NAME).pdf
ps:	$(NAME).ps
rtf:	$(NAME).rtf
txt: 	$(NAME).txt

$(NAME).html:	$(BOOK)
	docbook2html -u $(BOOK)

$(NAME).dvi: $(BOOK)
	docbook2dvi $(BOOK)

$(NAME).pdf: $(BOOK)
	# sgmltools makes better pdfs (e.g., page numbers, less cruft on
	# the cover), but using docbook-utils is more portable across distros
ifeq ($(USE_SGMLTOOLS),1)
	# workaround for broken something or other (tetex-bin, i think)
	# see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=130504
	cp --parents \
	  /usr/share/sgml/docbook/stylesheet/dsssl/modular/images/note.pdf .
	cp --parents \
	  /usr/share/sgml/docbook/stylesheet/dsssl/modular/images/warning.pdf .
	sgmltools -b pdf $(BOOK)
else
	docbook2pdf $(BOOK)
endif

$(NAME).ps: $(BOOK)
	docbook2ps $(BOOK)

$(NAME).rtf: $(BOOK)
	docbook2rtf $(BOOK)

$(NAME).txt: $(BOOK)
	docbook2txt $(BOOK)

clean:
	find . -name "*~" -exec rm -f {} \;
	find . -name "#*#" -exec rm -f {} \;
	rm -f $(NAME).aux $(NAME).dvi $(NAME).log $(NAME).out $(NAME).pdf \
	   $(NAME).ps $(NAME).rtf $(NAME).tex $(NAME).txt $(NAME).html
	rm -rf ./usr/

.PHONY: html ps pdf dvi rtf txt
