#*=====================================================================*/
#*    serrano/prgm/project/bigloo/manuals/Makefile                     */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Mon Jun 15 07:21:19 1998                          */
#*    Last change :  Mon Jan 18 12:02:42 1999 (serrano)                */
#*    -------------------------------------------------------------    */
#*    The Makefile to build the Bigloo documentation                   */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    Compiler and flags ...                                           */
#*---------------------------------------------------------------------*/
DVIPS		= dvips
TEXI2INFO	= makeinfo
TEXI2DVI	= texi2dvi
TEXI2HTML	= texi2html -menu -monolithic -number
BACKUPDIR	= $$HOUSE/backup
BACKUPNAME	= manuals
BMASK		= 0777
BIGLOO		= bigloo
INFOOPTION	= 

#*---------------------------------------------------------------------*/
#*    Sources ...                                                      */
#*---------------------------------------------------------------------*/
MASTER		= bigloo.texi
SOURCES		= modules.texi body.texi rgc.texi lalr.texi match.texi \
                  error.texi assert.texi struct.texi process.texi      \
                  eval.texi macro.texi typing.texi foreign.texi        \
                  library.texi object.texi dsssl.texi dsssl.texi       \
                  compiler.texi option.texi extension.texi socket.texi \
                  bee.texi oldtexinfo.texi

BDB_MASTER	= bdb.texi
BDB_SOURCES	=

MAN		= bigloo.man afile.man bdepend.man bmake.man bpp.man   \
                  bprof.man btags.man

POPULATION	= Makefile                     \
                  $(MASTER) $(SOURCES)         \
                  $(BDB_MASTER) $(BDB_SOURCES) \
                  $(MAN)

#*---------------------------------------------------------------------*/
#*    Everything ...                                                   */
#*---------------------------------------------------------------------*/
all: dvi ps html

dvi: bigloo.dvi bdb.dvi
bigloo.dvi: $(MASTER) $(SOURCES)
	$(TEXI2DVI) $(MASTER)
bdb.dvi: $(BDB_MASTER) $(BDB_SOURCES)
	$(TEXI2DVI) $(BDB_MASTER)

ps: bigloo.ps bdb.ps
bigloo.ps: bigloo.dvi
	$(DVIPS) -o bigloo.ps bigloo.dvi
bdb.ps: bdb.dvi
	$(DVIPS) -o bdb.ps bdb.dvi

info: bigloo.info bdb.info
bigloo.info: $(MASTER) $(SOURCES)
	$(TEXI2INFO) $(INFOOPTION) $(MASTER)
bdb.info: $(BDB_MASTER) $(BDB_SOURCES)
	$(TEXI2INFO) $(INFOOPTION) $(BDB_MASTER)

html: bigloo.html bdb.html
bigloo.html: $(MASTER) $(SOURCES)
	$(TEXI2HTML) $(MASTER)
bdb.html: $(BDB_MASTER) $(BDB_SOURCES)
	$(TEXI2HTML) $(BDB_MASTER)

#*---------------------------------------------------------------------*/
#*    touchall                                                         */
#*---------------------------------------------------------------------*/
touchall:
	touch $(SOURCES)

#*---------------------------------------------------------------------*/
#*    Cleaning ...                                                     */
#*---------------------------------------------------------------------*/
clean:
	-rm -f *.cp *.cps *.fn *.fns *.ky *.op *.pg *.tp *.vr *.toc *.log *.aux
	find . \( -name '*[~%]'                   \
                     -o -name '.??*[~%]'          \
                     -o -name '#*#'               \
                     -o -name '?*#'               \
                     -o -name \*core \)           \
                     -type f -exec rm {} \;   

fast-clean: clean

DClean: clean
	-rm -f bigloo.dvi
	-rm -f bigloo.ps
	-rm -f bigloo.info*
	-rm -f bigloo.html
	-rm -f bigloo_toc.html
	-rm -f bigloo_foot.html
	-rm -f bdb.dvi
	-rm -f bdb.ps
	-rm -f bdb.info*
	-rm -f bdb.html
	-rm -f bdb_toc.html
	-rm -f bdb_foot.html

Clean: DClean
	-rm -f option.texi

cleanall: Clean

#*---------------------------------------------------------------------*/
#*    backup                                                           */
#*---------------------------------------------------------------------*/
backup:
	@ echo "Backuping $(BACKUPNAME) in $(BACKUPDIR)"
	@ (\rm -f $(BACKUPDIR)/$(BACKUPNAME).tar.gz;                   \
	   cleanup;                                                    \
           tar cf $(BACKUPDIR)/$(BACKUPNAME).tar $(POPULATION);        \
           gzip $(BACKUPDIR)/$(BACKUPNAME).tar)
	@ echo "done..."
	@ echo "-------------------------------"

#*---------------------------------------------------------------------*/
#*    restore ...                                                      */
#*---------------------------------------------------------------------*/
restore:
	@ echo "Restoring $(BACKUPNAME) from $(BACKUPDIR)"
	@ (gzip -d --to-stdout $(BACKUPDIR)/$(BACKUPNAME).tar.gz | tar xfp -)
	@ echo "done..."
	@ echo "-------------------------------"

#*---------------------------------------------------------------------*/
#*    pop                                                              */
#*---------------------------------------------------------------------*/
pop: 
	@ echo $(POPULATION:%=$(BACKUPNAME)/%)

#*---------------------------------------------------------------------*/
#*    .tar.gz.uu                                                       */
#*---------------------------------------------------------------------*/
$(DOCUMENTNAME).tar.gz.uu: $(DOCUMENTNAME).tar.gz
	@ echo "uuencoding..."
	@ uuencode (DOCUMENTNAME).tar.gz (DOCUMENTNAME).tar.gz > (DOCUMENTNAME).tar.gz.uu
	@ echo "done."

#*---------------------------------------------------------------------*/
#*    distrib                                                          */
#*---------------------------------------------------------------------*/
distrib: 
	@ if [ `pwd` = $$HOME/prgm/project/bigloo/doc ]; then        \
             echo "*** ERROR:Illegal dir to make a distrib `pwd`";   \
             exit 1;                                                 \
          fi
	@ $(MAKE) Clean option.texi

#*---------------------------------------------------------------------*/
#*    Dmakefile                                                        */
#*    -------------------------------------------------------------    */
#*    This entry build the Dmakefile file that is used to boot         */
#*    Cigloo on a new host.                                            */
#*    -------------------------------------------------------------    */
#*    This entry can be used only on a platform that has bootstrapped  */
#*    Bigloo. That is, this makefile cannot be generated on a          */
#*    platform that wants to install Bigloo.                           */
#*---------------------------------------------------------------------*/
Dmakefile: Makefile
	@- rm -f $@
	@ echo "# !!! This is a generated file, don't edit !!!" > $@
	@ echo "" >> $@
	@ echo "	@ $(MAKE) -f Makefile info ps" >> $@
	@ echo "	@ mv $(MAN) bigloo.1" >> $@
	@ echo "" >> $@
	@ echo "clean:" >> $@
	@ echo '	@- rm -f bigloo.ps' >> $@
	@ echo '	@- rm -f bigloo.info*' >> $@

#*---------------------------------------------------------------------*/
#*    option.texi                                                      */
#*---------------------------------------------------------------------*/
option.texi:
	@ echo "@c -- The Bigloo's command line -------------------------------------- @c" > $*.texi
	@ echo "@subsection The Bigloo's command line" >> $*.texi
	@ echo "@cindex compiler options" >> $*.texi
	@ echo "" >> $*.texi
	@ echo "If no input file is specified, Bigloo enters its interpreter." >> $*.texi
	@ echo "Here is the exhaustive list of Bigloo options and configuration variables:" >> $*.texi
	@ echo "" >> $*.texi
	@ echo "@smalllisp" >> $*.texi
	@ $(BIGLOO) -help-manual | tail +9 >> $*.texi
	@ echo "@end smalllisp" >> $*.texi
	@ echo "" >> $*.texi



