#################################################################################
# Makefile for the Kubuntu Documentation
# Copyright (C) 2005-2006 Ubuntu Documentation Project (ubuntu-doc@lists.ubuntu.com)
#    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 of the License, 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
#    On Debian based systems a copy of the GPL can be found
#    at /usr/share/common-licenses/GPL
#
#################################################################################

MAKECMD=make

# XSL Processors
XSLTPROC=/usr/bin/xsltproc

current_distro=$(shell test -e /etc/debian_version && echo "debian")

# NWalsh Docbook XSL's
ifeq ($(current_distro), debian)
# Ubuntu
NWDBXSL=/usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl

# Debian and Ubuntu also need an explicit location for the XML catalog files
#export XML_CATALOG_FILES = /usr/share/xml/docbook/schema/dtd/4.3/catalog.xml
#else
# SuSE
#NWDBXSL=/usr/share/xml/docbook/stylesheet/nwalsh/current/html/docbook.xsl
endif

# Stylesheets for building HTML and PDF
KUBUNTUXSL=libs/kubuntu-chunk.xsl
PDFSTYLE=../libs/pdf/ubuntu-pdf.xsl
LULUSTYLE=../libs/pdf/ubuntu-pdf-lulu.xsl

# Makes an Image list text file
MKIMGLST=../libs/imagelist.xsl

# Collected and Write Status
wOS=../libs/writeOwnerStatus.xsl

BUILDDIR=../build/

# Base kde directories for output from processor
KBASE=$(BUILDDIR)kubuntu/

PDFBASE=$(BUILDDIR)pdf/kubuntu/

LULUBASE=../build/lulu/kubuntu/

KRNBASE=$(BUILDDIR)kubuntu/release-notes/

KAKBASE=$(BUILDDIR)kubuntu/about-kubuntu/

SERVERBASE=$(BUILDDIR)kubuntu/serverguide/

PACKAGEBASE=$(BUILDDIR)kubuntu/packagingguide/

DESKTOPBASE=$(BUILDDIR)kubuntu/desktopguide/

all: about desktop release-notes package server

	# copy style sheet to build directory
	mkdir -p $(KBASE)common/
	cp libs/kde-default.css $(KBASE)common/
	cp libs/kubuntu-default.css $(KBASE)common/
	cp /usr/share/doc/kde/HTML/en/common/*png $(KBASE)common/

# This is a reduced version of all, because we don't need the serverguide or packagingguide for the website (it's already in the ubuntu makefile)
website: about desktop release-notes

	# copy style sheet to build directory
	mkdir -p $(KBASE)common/
	cp libs/kde-default.css $(KBASE)common/
	cp libs/kubuntu-default.css $(KBASE)common/
	cp /usr/share/doc/kde/HTML/en/common/*png $(KBASE)common/

# This is here to select what to build for the .deb package.
# Frode M. Doeving <frode@lnix.net>
# Depends: debhelper devscripts cdbs
# Run prepdeb.sh do not run this make target
# Status: Available
kdeb: release-notes about server desktop package

#Status: AVAILABLE
# K About Kubuntu Document

about: ../build/kubuntu/about-kubuntu/C/index.html ../build/kubuntu/about-kubuntu/am/index.html ../build/kubuntu/about-kubuntu/ar/index.html ../build/kubuntu/about-kubuntu/bn/index.html ../build/kubuntu/about-kubuntu/cs/index.html ../build/kubuntu/about-kubuntu/da/index.html ../build/kubuntu/about-kubuntu/de/index.html ../build/kubuntu/about-kubuntu/en_AU/index.html ../build/kubuntu/about-kubuntu/en_CA/index.html ../build/kubuntu/about-kubuntu/es/index.html ../build/kubuntu/about-kubuntu/et/index.html ../build/kubuntu/about-kubuntu/fr/index.html ../build/kubuntu/about-kubuntu/gl/index.html ../build/kubuntu/about-kubuntu/hu/index.html ../build/kubuntu/about-kubuntu/id/index.html ../build/kubuntu/about-kubuntu/it/index.html ../build/kubuntu/about-kubuntu/ja/index.html ../build/kubuntu/about-kubuntu/ka/index.html ../build/kubuntu/about-kubuntu/ko/index.html ../build/kubuntu/about-kubuntu/lt/index.html ../build/kubuntu/about-kubuntu/nb/index.html ../build/kubuntu/about-kubuntu/oc/index.html ../build/kubuntu/about-kubuntu/pl/index.html ../build/kubuntu/about-kubuntu/pt/index.html ../build/kubuntu/about-kubuntu/pt_BR/index.html ../build/kubuntu/about-kubuntu/ro/index.html ../build/kubuntu/about-kubuntu/ru/index.html ../build/kubuntu/about-kubuntu/sk/index.html ../build/kubuntu/about-kubuntu/sl/index.html ../build/kubuntu/about-kubuntu/sv/index.html ../build/kubuntu/about-kubuntu/tl/index.html ../build/kubuntu/about-kubuntu/tr/index.html ../build/kubuntu/about-kubuntu/zh_CN/index.html ../build/kubuntu/about-kubuntu/zh_HK/index.html

	@echo "Building About Kubuntu Document"
	# copy style sheet to build directory
	mkdir -p $(KBASE)common/
	cp libs/kde-default.css $(KBASE)common/
	cp libs/kubuntu-default.css $(KBASE)common/
	cp /usr/share/doc/kde/HTML/en/common/*png $(KBASE)common/

../build/kubuntu/about-kubuntu/%/index.html: aboutkubuntu/%/about-kubuntu.xml
	xsltproc -o $@ $(KUBUNTUXSL) $<

#Status: AVAILABLE
# K Release Notes

release-notes: build/kubuntu/release-notes/C/releasenotes.html

build/kubuntu/release-notes/C/releasenotes.html: releasenotes/C/releasenotes.xml
	@echo "Building the Kubuntu Release Notes . . ."

	xsltproc -o $(KRNBASE)C/releasenotes.html $(KUBUNTUXSL) releasenotes/C/releasenotes.xml

	# copy style sheet to build directory
	mkdir -p $(KBASE)common/
	cp libs/kde-default.css $(KBASE)common/
	cp libs/kubuntu-default.css $(KBASE)common/
	cp /usr/share/doc/kde/HTML/en/common/*png $(KBASE)common/

	@echo "Complete. Find outputs at" $(KRNBASE)

# Server Guide

server: ../build/kubuntu/serverguide/C/index.html ../build/kubuntu/serverguide/bn/index.html ../build/kubuntu/serverguide/de/index.html ../build/kubuntu/serverguide/en_GB/index.html ../build/kubuntu/serverguide/es/index.html ../build/kubuntu/serverguide/et/index.html ../build/kubuntu/serverguide/fr/index.html ../build/kubuntu/serverguide/he/index.html ../build/kubuntu/serverguide/id/index.html ../build/kubuntu/serverguide/it/index.html ../build/kubuntu/serverguide/ko/index.html ../build/kubuntu/serverguide/lt/index.html ../build/kubuntu/serverguide/pl/index.html ../build/kubuntu/serverguide/pt/index.html ../build/kubuntu/serverguide/pt_BR/index.html ../build/kubuntu/serverguide/ro/index.html ../build/kubuntu/serverguide/sk/index.html ../build/kubuntu/serverguide/sv/index.html ../build/kubuntu/serverguide/tr/index.html ../build/kubuntu/serverguide/urd/index.html ../build/kubuntu/serverguide/zh_CN/index.html
	@echo "Building the Server Guide . . ."
	# copy style sheet to build directory
	mkdir -p $(KBASE)common/
	cp libs/kde-default.css $(KBASE)common/
	cp libs/kubuntu-default.css $(KBASE)common/
	cp /usr/share/doc/kde/HTML/en/common/*png $(KBASE)common/

../build/kubuntu/serverguide/%/index.html: ../generic/serverguide/%/serverguide.xml
	xsltproc --xinclude -o $@ $(KUBUNTUXSL) $<

# Desktop Guide

desktop: ../build/kubuntu/desktopguide/C/index.html ../build/kubuntu/desktopguide/bn/index.html ../build/kubuntu/desktopguide/cs/index.html ../build/kubuntu/desktopguide/de/index.html ../build/kubuntu/desktopguide/es/index.html ../build/kubuntu/desktopguide/fr/index.html ../build/kubuntu/desktopguide/hu/index.html ../build/kubuntu/desktopguide/id/index.html ../build/kubuntu/desktopguide/it/index.html ../build/kubuntu/desktopguide/ko/index.html ../build/kubuntu/desktopguide/pl/index.html ../build/kubuntu/desktopguide/pt/index.html ../build/kubuntu/desktopguide/pt_BR/index.html ../build/kubuntu/desktopguide/ru/index.html ../build/kubuntu/desktopguide/sk/index.html ../build/kubuntu/desktopguide/sl/index.html ../build/kubuntu/desktopguide/sv/index.html ../build/kubuntu/desktopguide/tl/index.html ../build/kubuntu/desktopguide/zh_CN/index.html ../build/kubuntu/desktopguide/zh_TW/index.html

	# copy sample files to build directory
	mkdir -p $(DESKTOPBASE)sample
	cp -r desktopguide/sample/* $(DESKTOPBASE)sample/

	# copy style sheet to build directory
	mkdir -p $(KBASE)common/
	cp libs/kde-default.css $(KBASE)common/
	cp libs/kubuntu-default.css $(KBASE)common/
	cp /usr/share/doc/kde/HTML/en/common/*png $(KBASE)common/

../build/kubuntu/desktopguide/%/index.html: desktopguide/%/desktopguide.xml
	xsltproc --xinclude -o $@ $(KUBUNTUXSL) $<

# Packaging Guide
package: ../build/kubuntu/packagingguide/C/index.html ../build/kubuntu/packagingguide/bn/index.html ../build/kubuntu/packagingguide/de/index.html ../build/kubuntu/packagingguide/es/index.html ../build/kubuntu/packagingguide/fr/index.html ../build/kubuntu/packagingguide/id/index.html ../build/kubuntu/packagingguide/it/index.html ../build/kubuntu/packagingguide/ka/index.html ../build/kubuntu/packagingguide/ko/index.html ../build/kubuntu/packagingguide/pt/index.html ../build/kubuntu/packagingguide/pt_BR/index.html ../build/kubuntu/packagingguide/ro/index.html  ../build/kubuntu/packagingguide/ru/index.html ../build/kubuntu/packagingguide/sk/index.html ../build/kubuntu/packagingguide/sv/index.html ../build/kubuntu/packagingguide/tl/index.html ../build/kubuntu/packagingguide/tr/index.html ../build/kubuntu/packagingguide/urd/index.html ../build/kubuntu/packagingguide/zh_CN/index.html
	@echo "Building the Packaging Guide . . ."
	# copy style sheet to build directory
	mkdir -p $(KBASE)common/
	cp libs/kde-default.css $(KBASE)common/
	cp libs/kubuntu-default.css $(KBASE)common/
	cp /usr/share/doc/kde/HTML/en/common/*png $(KBASE)common/

../build/kubuntu/packagingguide/%/index.html: ../generic/packagingguide/%/packagingguide.xml
	xsltproc --xinclude -o $@ $(KUBUNTUXSL) $<

# PDFs in A4 size

pdf: desktop-pdf

desktop-pdf: desktop-pdf-C desktop-pdf-bn desktop-pdf-cs desktop-pdf-es desktop-pdf-fr desktop-pdf-it desktop-pdf-ko desktop-pdf-pl desktop-pdf-pt_BR desktop-pdf-ru desktop-pdf-sk desktop-pdf-sv desktop-pdf-tl desktop-pdf-zh_CN desktop-pdf-zh_TW

desktop-pdf-C:

	xsltproc --xinclude -o $(PDFBASE)C/desktopguide.fo $(PDFSTYLE) desktopguide/C/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)C/desktopguide.fo -pdf $(PDFBASE)C/desktopguide.pdf
	rm $(PDFBASE)C/desktopguide.fo

desktop-pdf-bn:

	xsltproc --xinclude -o $(PDFBASE)bn/desktopguide.fo $(PDFSTYLE) desktopguide/bn/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)bn/desktopguide.fo -pdf $(PDFBASE)bn/desktopguide.pdf
	rm $(PDFBASE)bn/desktopguide.fo

desktop-pdf-cs:

	xsltproc --xinclude -o $(PDFBASE)cs/desktopguide.fo $(PDFSTYLE) desktopguide/cs/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)cs/desktopguide.fo -pdf $(PDFBASE)cs/desktopguide.pdf
	rm $(PDFBASE)cs/desktopguide.fo

desktop-pdf-es:

	xsltproc --xinclude -o $(PDFBASE)es/desktopguide.fo $(PDFSTYLE) desktopguide/es/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)es/desktopguide.fo -pdf $(PDFBASE)es/desktopguide.pdf
	rm $(PDFBASE)es/desktopguide.fo

desktop-pdf-fr:

	xsltproc --xinclude -o $(PDFBASE)fr/desktopguide.fo $(PDFSTYLE) desktopguide/fr/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)fr/desktopguide.fo -pdf $(PDFBASE)fr/desktopguide.pdf
	rm $(PDFBASE)fr/desktopguide.fo

desktop-pdf-it:

	xsltproc --xinclude -o $(PDFBASE)it/desktopguide.fo $(PDFSTYLE) desktopguide/it/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)it/desktopguide.fo -pdf $(PDFBASE)it/desktopguide.pdf
	rm $(PDFBASE)it/desktopguide.fo

desktop-pdf-ko:

	xsltproc --xinclude -o $(PDFBASE)ko/desktopguide.fo $(PDFSTYLE) desktopguide/ko/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)ko/desktopguide.fo -pdf $(PDFBASE)ko/desktopguide.pdf
	rm $(PDFBASE)ko/desktopguide.fo

desktop-pdf-pl:

	xsltproc --xinclude -o $(PDFBASE)pl/desktopguide.fo $(PDFSTYLE) desktopguide/pl/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)pl/desktopguide.fo -pdf $(PDFBASE)pl/desktopguide.pdf
	rm $(PDFBASE)pl/desktopguide.fo

desktop-pdf-pt_BR:

	xsltproc --xinclude -o $(PDFBASE)pt_BR/desktopguide.fo $(PDFSTYLE) desktopguide/pt_BR/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)pt_BR/desktopguide.fo -pdf $(PDFBASE)pt_BR/desktopguide.pdf
	rm $(PDFBASE)pt_BR/desktopguide.fo

desktop-pdf-ru:

	xsltproc --xinclude -o $(PDFBASE)ru/desktopguide.fo $(PDFSTYLE) desktopguide/ru/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)ru/desktopguide.fo -pdf $(PDFBASE)ru/desktopguide.pdf
	rm $(PDFBASE)ru/desktopguide.fo

desktop-pdf-sk:

	xsltproc --xinclude -o $(PDFBASE)sk/desktopguide.fo $(PDFSTYLE) desktopguide/sk/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)sk/desktopguide.fo -pdf $(PDFBASE)sk/desktopguide.pdf
	rm $(PDFBASE)sk/desktopguide.fo

desktop-pdf-sv:

	xsltproc --xinclude -o $(PDFBASE)sv/desktopguide.fo $(PDFSTYLE) desktopguide/sv/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)sv/desktopguide.fo -pdf $(PDFBASE)sv/desktopguide.pdf
	rm $(PDFBASE)sv/desktopguide.fo

desktop-pdf-tl:

	xsltproc --xinclude -o $(PDFBASE)tl/desktopguide.fo $(PDFSTYLE) desktopguide/tl/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)tl/desktopguide.fo -pdf $(PDFBASE)tl/desktopguide.pdf
	rm $(PDFBASE)tl/desktopguide.fo

desktop-pdf-zh_CN:

	xsltproc --xinclude -o $(PDFBASE)zh_CN/desktopguide.fo $(PDFSTYLE) desktopguide/zh_CN/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)zh_CN/desktopguide.fo -pdf $(PDFBASE)zh_CN/desktopguide.pdf
	rm $(PDFBASE)zh_CN/desktopguide.fo

desktop-pdf-zh_TW:

	xsltproc --xinclude -o $(PDFBASE)zh_TW/desktopguide.fo $(PDFSTYLE) desktopguide/zh_TW/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -fo $(PDFBASE)zh_TW/desktopguide.fo -pdf $(PDFBASE)zh_TW/desktopguide.pdf
	rm $(PDFBASE)zh_TW/desktopguide.fo

# PDFs for use with LULU

desktop-lulu:

	mkdir -p $(LULUBASE)C/images
	cp -r ../common/admon-lulu/*.png $(LULUBASE)C/images/
	xsltproc --xinclude -o $(LULUBASE)C/desktopguide.fo $(LULUSTYLE) desktopguide/C/desktopguide.xml
	fop -c ../libs/pdf/fop.xconf -c ../libs/pdf/userconfig.xml -fo $(LULUBASE)C/desktopguide.fo -pdf $(LULUBASE)C/desktopguide.pdf
	rm $(LULUBASE)C/desktopguide.fo
	rm -rf $(LULUBASE)C/images

# Cleanup

clean:
	rm -rf $(KBASE)

