/*   CrossFire, A Multiplayer game for X-windows
 *
 *   $Id: Imakefile,v 1.8 1993/04/25 16:09:04 frankj Exp $
 *
 *   Copyright (C) 1992 Frank Tore Johansen
 *
 *   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., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *   The author can be reached via e-mail to frankj@ifi.uio.no.
 */

#include "../config/crossfire.tmpl"

all::

spoiler.dvi:
	$(RM) spliz arc
	$(RM) monput.tex spells.tex stats.tex weap.tex shield.tex helmet.tex mag.tex arm.tex 
	$(C_BINDIR)/crossfire -m2 | tr A-Z a-z | sort | uniq | gawk -F'|' -f monster-extract | sed -e s/:,/:/g >monput.tex
	tr -d \" < ../include/spellist.h | $(AWK) -f spells-extract > spliz
	sort < spliz | gawk -F'&' -f sorter -v lengde=`wc -l < spliz | tr -d ' '` | sort | cut -d'&' -f 2- > spells.tex
	tr -d '{}/*' < ../include/living.h | awk -F',' -f ../doc/stats-extract > stats.tex
	gawk -f weapons < $(C_LIBDIR)/archetypes > arc
	egrep -e "^15" arc | cut -d'&' -f 3,5,6 | sort | gawk -F'&' -f sorter -v lengde=`egrep -e "^15" arc | wc -l | tr -d ' ' ` | sort | cut -d'&' -f 2- > weap.tex
	egrep -e "^33" arc | gawk -F'&' -f shield-extract | sort -t'&' -n +3 -4 > shield.tex
	egrep -e "^16" arc | gawk -F'&' -f arm-extract | sort -t'&' -n +3 -4 > arm.tex
	egrep -e "^34" arc | gawk -F'&' -f helm-extract | sort -t'&' -n +2 -3 | sed -e s/_/' '/g > helmet.tex
	gawk -F'&' -f mag-extract arc | sort +0.9 -0.10 > mag.tex
	latex spoiler.tex
	$(RM) spoiler.log spoiler.aux
	$(RM) monput.tex stats.tex spells.tex weap.tex shield.tex helmet.tex mag.tex arm.tex 
	$(RM) spliz
spoiler.ps: spoiler.dvi
	dvips -o spoiler.ps spoiler.dvi

crosslib.doc: force_depend
	(cd ../common; make doc)

force_depend:

install::

/* InstallManPage(crossfire) */

/* InstallManPage(xledit) */

depend::

clean::
	$(RM) monput.tex spells.tex stats.tex weap.tex shield.tex helmet.tex mag.tex arm.tex 
	$(RM) spliz arc
	$(RM) spoiler.dvi spoiler.log spoiler.aux

FILES = spoiler.ps crossfire.doc crosslib.doc crossfire.man \
	xbmtobdf.man xledit.man monster-extract spells-extract \
	stats-extract arm-extract helm-extract mag-extract \
	shield-extract spoiler.tex sorter PlayerStats \
	RunTimeCommands SurvivalGuide

InsertArchieve(Imakefile $(FILES),doc)

# Depends:
spoiler.dvi: spells-extract monster-extract stats-extract arm-extract helm-extract mag-extract shield-extract spoiler.tex
spoiler.dvi: $(C_LIBDIR)/treasures $(C_LIBDIR)/archetypes

