#
#  GNUmakefile
#
#  Copyright (C) 1996 Free Software Foundation, Inc.
#
#  Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
#  Date: December 1996
#
#  This file is part of the GNUstep Database Library.
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Library General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
#
#  This library 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
#  Library General Public License for more details.
#
#  You should have received a copy of the GNU Library General Public
#  License along with this library; see the file COPYING.LIB.
#  If not, write to the Free Software Foundation,
#  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

srcdir=.
include $(srcdir)/../Version

ORIG_FILES = \
version.tmpl.texi \
announce.tmpl.texi \
install.tmpl.texi \
news.tmpl.texi \
readme.tmpl.texi \
status.tmpl.texi \
todo.tmpl.texi \
faq.tmpl.texi

TEXI_FILES = \
version.texi \
announce.texi \
install.texi \
news.texi \
readme.texi \
status.texi \
todo.texi \
faq.texi

TEXT_FILES = \
TODO INSTALL NEWS README ANNOUNCE FAQ STATUS

DVI_FILES = 
PS_FILES = 
HTML_FILES = 
INFO_FILES = 

INFO_FLAGS = -I $(srcdir) -D NO-TEXI2HTML --no-header
HTML_FLAGS = -split_chapter -expandinfo -I $(srcdir)
TEXT_FLAGS = -I $(srcdir) -D NO-TEXI2HTML -D TEXT-ONLY --no-header --no-split

all: text

info: $(INFO_FILES)
dvi: $(DVI_FILES)
html: $(HTML_FILES)
text: $(TEXT_FILES)
ps: $(PS_FILES)

version.tmpl.texi: $(srcdir)/../Version
	rm -f version.tmpl.texi
	echo '@set GDL-VERSION' $(GDL_VERSION) \
		> version.tmpl.texi
	echo '@set GDL-GCC-VERSION $(GDL_GCC_VERSION)' \
		>> version.tmpl.texi
	echo '@set GDL-GNUSTEP-BASE $(GDL_GNUSTEP_BASE)' \
		>> version.tmpl.texi
	echo '@set GDL-LIBFOUNDATION $(GDL_LIBFOUNDATION)' \
		>> version.tmpl.texi
	echo '@set GDL-FOUNDATION-EXT $(GDL_FOUNDATION_EXT)' \
		>> version.tmpl.texi
	if [ $(GDL_FTP_MACHINE) ]; then \
		echo '@set GDL-FTP-MACHINE $(GDL_FTP_MACHINE)' \
		>> version.tmpl.texi; fi
	if [ $(GDL_FTP_DIRECTORY) ]; then \
		echo '@set GDL-FTP-DIRECTORY $(GDL_FTP_DIRECTORY)' \
		>> version.tmpl.texi; fi
	if [ $(GDL_SNAP_FTP_MACHINE) ]; then \
		echo '@set GDL-SNAP-FTP-MACHINE $(GDL_SNAP_FTP_MACHINE)' \
		>> version.tmpl.texi; fi
	if [ $(GDL_SNAP_FTP_DIRECTORY) ]; then \
		echo '@set GDL-SNAP-FTP-DIRECTORY $(GDL_SNAP_FTP_DIRECTORY)' \
		>> version.tmpl.texi; fi

# Rules for producing the text files
README: version.tmpl.texi readme.tmpl.texi
	rm -f $(TEXI_FILES)
	for i in $(ORIG_FILES); do \
	   sed -e 's,@email{\([^}]*\)},<\1>,g' \
		$(srcdir)/$$i \
		| sed -e 's,@url{\([^}]*\)},@samp{\1},g' \
		| sed -e 's,@keyword{\([^}]*\)},@strong{\1},g' \
		> `basename $$i .tmpl.texi`.texi ; \
	done
	$(MAKEINFO) $(TEXT_FLAGS) -o README $(srcdir)/readme.texi

ANNOUNCE: version.tmpl.texi announce.tmpl.texi news.tmpl.texi
	rm -f $(TEXI_FILES)
	for i in $(ORIG_FILES); do \
	   sed -e 's,@email{\([^}]*\)},<\1>,g' \
		$(srcdir)/$$i \
		| sed -e 's,@url{\([^}]*\)},@samp{\1},g' \
		| sed -e 's,@keyword{\([^}]*\)},@strong{\1},g' \
		> `basename $$i .tmpl.texi`.texi ; \
	done
	$(MAKEINFO) $(TEXT_FLAGS) -o ANNOUNCE $(srcdir)/announce.texi

INSTALL: version.tmpl.texi install.tmpl.texi
	rm -f $(TEXI_FILES)
	for i in $(ORIG_FILES); do \
	   sed -e 's,@email{\([^}]*\)},<\1>,g' \
		$(srcdir)/$$i \
		| sed -e 's,@url{\([^}]*\)},@samp{\1},g' \
		| sed -e 's,@keyword{\([^}]*\)},@strong{\1},g' \
		> `basename $$i .tmpl.texi`.texi ; \
	done
	$(MAKEINFO) $(TEXT_FLAGS) -o INSTALL $(srcdir)/install.texi

NEWS: version.tmpl.texi news.tmpl.texi
	rm -f $(TEXI_FILES)
	for i in $(ORIG_FILES); do \
	   sed -e 's,@email{\([^}]*\)},<\1>,g' \
		$(srcdir)/$$i \
		| sed -e 's,@url{\([^}]*\)},@samp{\1},g' \
		| sed -e 's,@keyword{\([^}]*\)},@strong{\1},g' \
		> `basename $$i .tmpl.texi`.texi ; \
	done
	$(MAKEINFO) $(TEXT_FLAGS) -o NEWS $(srcdir)/news.texi

FAQ: version.tmpl.texi faq.tmpl.texi
	rm -f $(TEXI_FILES)
	for i in $(ORIG_FILES); do \
	   sed -e 's,@email{\([^}]*\)},<\1>,g' \
		$(srcdir)/$$i \
		| sed -e 's,@url{\([^}]*\)},@samp{\1},g' \
		| sed -e 's,@keyword{\([^}]*\)},@strong{\1},g' \
		> `basename $$i .tmpl.texi`.texi ; \
	done
	$(MAKEINFO) $(TEXT_FLAGS) -o FAQ $(srcdir)/faq.texi

STATUS: version.tmpl.texi status.tmpl.texi
	rm -f $(TEXI_FILES)
	for i in $(ORIG_FILES); do \
	   sed -e 's,@email{\([^}]*\)},<\1>,g' \
		$(srcdir)/$$i \
		| sed -e 's,@url{\([^}]*\)},@samp{\1},g' \
		| sed -e 's,@keyword{\([^}]*\)},@strong{\1},g' \
		> `basename $$i .tmpl.texi`.texi ; \
	done
	$(MAKEINFO) $(TEXT_FLAGS) -o STATUS $(srcdir)/status.texi

TODO: version.tmpl.texi todo.tmpl.texi
	rm -f $(TEXI_FILES)
	for i in $(ORIG_FILES); do \
	   sed -e 's,@email{\([^}]*\)},<\1>,g' \
		$(srcdir)/$$i \
		| sed -e 's,@url{\([^}]*\)},@samp{\1},g' \
		| sed -e 's,@keyword{\([^}]*\)},@strong{\1},g' \
		> `basename $$i .tmpl.texi`.texi ; \
	done
	$(MAKEINFO) $(TEXT_FLAGS) -o TODO $(srcdir)/todo.texi

install:
uninstall:

update-top: ANNOUNCE FAQ INSTALL NEWS README TODO STATUS
	cp ANNOUNCE ..
	cp FAQ ..
	cp INSTALL ..
	cp NEWS ..
	cp README ..
	cp TODO ..
	cp STATUS ..

mostlyclean:
	rm -f *~
	rm -f *.aux *.cp *.cps *.fn *.fns *.pr *.cl *.cls
	rm -f *.ky *.log *.pg *.toc *.tp *.tps *.vr *.vrs
	rm -f $(TEXI_FILES)

clean: mostlyclean
	rm -f version.tmpl.texi
	rm -f $(TEXT_FILES)
	rm -f *.html
	rm -f *.info
	rm -f *.dvi
	rm -f *.ps

distclean: clean
