#
# Makefile
#
# Developed by Lubomir Host 'rajo' <rajo AT platon.sk>
# Copyright (c) 2003 Platon SDG
# Licensed under terms of GNU General Public License.
# All rights reserved.
#
# Changelog:
# 31/07/2003 - created
#

# $Platon: doc/soft-doc-sys/Makefile,v 1.4 2003/08/04 19:23:37 rajo Exp $ 

# Makefile for creating distribution of soft-doc-sys package
# Type 'make dist' for create tar-gziped archiv. 

PACKAGE = soft-doc-sys
VERSION = 1.1

unexport SUBDIRS
unexport SUBDIR_OBJECTS
unexport MAKEFILES
unexport CONFIGURE_SCRIPTS
export PACKAGE
export VERSION

# Directories {{{

srcdir       = .
distdir      = $(PACKAGE)-$(VERSION)
top_distdir  = $(distdir)
top_builddir = .

# }}} Directories

# Targets {{{

# if you have subdirectories with Makefiles,
# add names of directories here
SUBDIRS   =

PDF_OUTPUT = doc/en/pdf/Software-documentation-systems.pdf \
			 doc/sk/pdf/Systemy-softverovej-dokumentacie.pdf

HTML_OUTPUT = doc/en/html/index.html \
			  doc/sk/html/index.html

EN_SGML = en/developer-doc-systems.sgml \
		  en/index.sgml \
		  en/introduction.sgml \
		  en/other-doc-systems.sgml \
		  en/user-doc-systems.sgml

SK_SGML = sk/developer-doc-systems.sgml \
		  sk/index.sgml \
		  sk/introduction.sgml \
		  sk/other-doc-systems.sgml \
		  sk/user-doc-systems.sgml \

SLIDES = doc/slides/data.php \
		 doc/slides/slide.css \
		 doc/slides/slide.php

DISTFILES = Makefile \
			$(SOURCES) $(include_HEADERS) \
			en/ $(EN_SGML) \
			sk/ $(SK_SGML) \
			slides/ \
			slides/data.php \
			slides/slide.css \
			slides/slide.php \
			doc/ doc/slides/ \
			$(SLIDES) \
			doc/en/ doc/en/html/ doc/en/pdf/ \
			doc/sk/ doc/sk/html/ doc/sk/pdf/ \
			doc/en/html/* \
			doc/sk/html/* \
			$(PDF_OUTPUT)

# }}} Targets

# Programs {{{

TAR      = tar
ZIP      = zip
ZIP_ENV  = -r9
GZIP_ENV = --best
DOCBOOK2HTML = docbook2html
DOCBOOK2PDF  = docbook2pdf

# }}} Programs


all: Makefile directories html pdf $(SLIDES)

directories:
	mkdir -p doc/en/pdf
	mkdir -p doc/sk/pdf
	mkdir -p doc/slides

html: $(HTML_OUTPUT)

pdf: $(PDF_OUTPUT)

doc/en/pdf/%.pdf: $(EN_SGML)
	$(DOCBOOK2PDF) en/index.sgml && mv index.pdf "$@"

doc/sk/pdf/%.pdf: $(SK_SGML)
	SP_ENCODING=ISO-8859-2; \
			$(DOCBOOK2PDF) sk/index.sgml && mv index.pdf "$@"

doc/en/html/*:
doc/en/html/%.html: $(EN_SGML)
	$(DOCBOOK2HTML) -o doc/en/html en/index.sgml

doc/sk/html/*:
doc/sk/html/%.html: $(SK_SGML)
	$(DOCBOOK2HTML) -o doc/sk/html sk/index.sgml

doc/slides/%:
	ln -s "../../slides/$(*F)" "$@"

#
# False targets.
#
.PHONY: dummy

#
# A rule to do nothing
#
dummy:
	
clean: clean-subdirs
	-rm -f *.o core
	-rm -rf doc/ en/index.junk/ sk/index.junk/

#
# A rule to make subdirectories
#
subdir-list-all = $(sort $(patsubst %,_subdir_%,$(SUBDIRS)))
all-subdirs: dummy $(subdir-list-all)

ifdef SUBDIRS
$(subdir-list-all) : dummy
	$(MAKE) -C $(patsubst _subdir_%,%,$@)
endif

#
# A rule to make clean in subdirectories
#
subdir-list-clean = $(sort $(patsubst %,_subdir_clean_%,$(SUBDIRS)))
clean-subdirs: dummy $(subdir-list-clean)

ifdef SUBDIRS
$(subdir-list-clean) : dummy
	$(MAKE) -C $(patsubst _subdir_clean_%,%,$@) clean
endif

# Distribution targets {{{
dist: all distdir
	GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
#ZIP=$(ZIP_ENV) $(ZIP) $(distdir).zip $(distdir)
	-rm -rf $(distdir)

dist-all: distdir
	GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
#ZIP=$(ZIP_ENV) $(ZIP) $(distdir).zip $(distdir)
	-rm -rf $(distdir)

distdir: $(DISTFILES)
	-rm -rf $(distdir)
	mkdir $(distdir)
	@here=`cd $(top_builddir) && pwd`; \
	top_distdir=`cd $(distdir) && pwd`; \
	distdir=`cd $(distdir) && pwd`;
	@FILES=`echo "$(DISTFILES)" | awk 'BEGIN{RS=" "}{print}' | sort -u`; \
	for file in $$FILES; do \
	  d=$(srcdir); \
	  if test -d $$d/$$file; then \
	    mkdir $(distdir)/$$file; \
	  else \
	    test -f $(distdir)/$$file \
	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
	    || cp -p $$d/$$file $(distdir)/$$file || :; \
	  fi; \
	done

# }}}

# vim600: fdm=marker fdc=3

