# +----------------------------------------------------------------------+
# | PHP HTML Embedded Scripting Language Version 3.0                     |
# +----------------------------------------------------------------------+
# | Copyright (c) 1997,1998 PHP Development Team (See Credits file)      |
# +----------------------------------------------------------------------+
# | This program is free software; you can redistribute it and/or modify |
# | it under the terms of one of the following licenses:                 |
# |                                                                      |
# |  A) 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.                                               |
# |                                                                      |
# |  B) the PHP License as published by the PHP Development Team and     |
# |     included in the distribution in the file: LICENSE                |
# |                                                                      |
# | 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 both licenses referred to here.   |
# | If you did not, or have any questions about PHP licensing, please    |
# | contact core@php.net.                                                |
# +----------------------------------------------------------------------+
# | Authors: Stig Bakken <ssb@guardian.no>                               |
# +----------------------------------------------------------------------+

#
# $Id: Makefile.in,v 1.79 1998/05/17 22:03:19 sr Exp $
#

VPATH=@srcdir@
srcdir=@srcdir@

VERSION="@PHP_VERSION@"
HTML_STYLESHEET=$(srcdir)/html.dsl
PHPWEB_STYLESHEET=$(srcdir)/phpweb.dsl
HOWTO_STYLESHEET=$(srcdir)/howto.dsl
PRINT_STYLESHEET=/usr/lib/sgml/docbook/print/docbook.dsl

all: html

PREFACE=preface.sgml \
	bookinfo.sgml

APPENDICES=appendices/migration.sgml \
           appendices/escaping.sgml \
           appendices/regexp.sgml \
           appendices/http-stuff.sgml \
           appendices/history.sgml \
           appendices/debugger.sgml \
           appendices/phpdevel.sgml

CHAPTERS=chapters/copyright.sgml \
         chapters/intro.sgml \
         chapters/config.sgml \
         chapters/install.sgml \
         chapters/features.sgml \
         chapters/lang-syntax.sgml \
         chapters/lang-expr.sgml \
         chapters/lang-const.sgml

FUNCREF= \
	functions/array.sgml \
	functions/adabas.sgml \
	functions/bc.sgml \
	functions/datetime.sgml \
	functions/dbase.sgml \
	functions/dbm.sgml \
	functions/dl.sgml \
	functions/dir.sgml \
	functions/exec.sgml \
	functions/filepro.sgml \
	functions/filesystem.sgml \
	functions/http.sgml \
	functions/image.sgml \
	functions/imap.sgml \
	functions/ldap.sgml \
	functions/mail.sgml \
	functions/math.sgml \
	functions/misc.sgml \
	functions/msql.sgml \
	functions/mysql.sgml \
	functions/sybase.sgml \
	functions/network.sgml \
	functions/oracle.sgml \
	functions/pgsql.sgml \
	functions/info.sgml \
	functions/regex.sgml \
	functions/solid.sgml \
	functions/snmp.sgml \
	functions/strings.sgml \
	functions/uodbc.sgml \
	functions/url.sgml \
	functions/var.sgml \
	functions/zlib.sgml

FILES=$(PREFACE) $(APPENDICES) $(CHAPTERS) $(FUNCREF)
ONLINE_MANUAL=*.php3
DIST_FILES=manual.zip manual.tar.gz manual.rtf copyright.html bigmanual.html
MIRROR_TARGETS=manual.php3 $(DIST_FILES)

manual.sgml: .manual.sgml
.manual.sgml: $(FILES)
	touch .manual.sgml

html: manual.html
phpweb: manual.php3
rtf: manual.rtf
dvi: manual.dvi
ps print: manual.ps
howto: howto.html

mirror-files: $(MIRROR_TARGETS)

sync-no: mirror-files
	-rsync -vc $(ONLINE_MANUAL) ../../phpweb/manual/
	-rsync -vc $(DIST_FILES) ../../phpweb/distributions/

commit-no: sync-no
	(cd ../../phpweb/manual; \
	files=`cvs -qn update | grep '^?' | cut -c3-`; \
	test -n "$$files" && cvs add $$files; \
	cvs commit -m '$(MESSAGE)')
	(cd ../../phpweb/distributions; cvs commit -m '$(MESSAGE)')

status:
	$(srcdir)/checkdoc -s > $(srcdir)/status.txt
	$(srcdir)/checkdoc -m > $(srcdir)/missing.txt

makedoc: makedoc.cc
	g++ -o makedoc makedoc.cc

bigmanual.html: $(srcdir)/manual.sgml $(HTML_STYLESHEET)
	jade -V nochunks -d $(HTML_STYLESHEET) -t sgml $(srcdir)/manual.sgml > $@

manual.html: $(srcdir)/manual.sgml $(HTML_STYLESHEET)
	jade -d $(HTML_STYLESHEET) -t sgml $(srcdir)/manual.sgml

manual.php3: $(srcdir)/manual.sgml $(PHPWEB_STYLESHEET)
	jade -d $(PHPWEB_STYLESHEET) -t sgml $(srcdir)/manual.sgml

manual.txt: bigmanual.html
	lynx -nolist -dump file:`pwd`/bigmanual.html > manual.txt

manual.prc: manual.txt makedoc
	./makedoc -b manual.txt manual.prc 'PHP3 Manual'

manual.zip: $(srcdir)/manual.html
	-rm -f $@ && (cd $(srcdir); zip -q $@ [a-z]*.html)

manual.tar.gz: $(srcdir)/manual.html
	-rm -f $@ && (cd $(srcdir); tar -cf - [a-z]*.html | gzip > manual.tar.gz)

howto.html: $(srcdir)/howto.sgml $(HOWTO_STYLESHEET) global.ent
	jade -d $(HOWTO_STYLESHEET) -t sgml $(srcdir)/howto.sgml

tex latex: $(srcdir)/manual.tex

# File endings we are going to define general rules for:
.SUFFIXES: .html .sgml .tex .dvi .ps .rtf

# General rules:
.sgml.tex:
	jade -d $(PRINT_STYLESHEET) -t tex $<

.sgml.rtf:
	jade -d $(PRINT_STYLESHEET) -t rtf $<

.tex.dvi:
	jadetex $<

.dvi.ps:
	dvips -o $@ $<

test: manual.sgml
	nsgmls -s $<

clean:
	( \
	cd $(srcdir); \
	rm -f manual.txt [a-z]*.html manual.rtf manual.info \
	rm -f manual.zip manual.tar.gz sync-no commit-no .manual.sgml \
	rm -f manual.txt manual.prc makedoc \
	rm -f *.aux *.tex *.log *.dvi *.toc *.ps \
	rm -f status.txt missing.txt \
	rm -f *.php3 $(GENREF) \
	)
