#
#  Makefile for ChkTeX project, creates the stuff.
#  Copyright (C) 1996 Jens T. Berger Thielemann
#
#  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.
#
#  Contact the author at:
#		Jens Berger
#		Spektrumvn. 4
#		N-0666 Oslo
#		Norway
#		E-mail: <jensthi@ifi.uio.no>
#
# @configure_input@
#


#
# If your compiler barfs on the flags below, use this define instead
#
# compileflags=
#

#####################################################################

compileflags= -ansi -W -Wall

prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
datadir=@datadir@
INSTALL=@INSTALL@

USRDEFS=-DDATADIR=\"$(datadir)\"

OBJS= ChkTeX.o FindErrs.o getopt.o getopt1.o OpSys.o Resource.o Utility.o

REXXFILES= ChkTeX.ced ChkTeX.ged ChkTeX.rexx

INSTALLFILES= configure configure.in install-sh \
Makefile.in config.h.in configure.in chktexrc

WEBFILES= chkweb.in deweb.in

DOCFILES= ChkTeX.tex ChkTeX.dvi ChkTeX.ps \
ChkTeX.readme ChkTeX.readme.info COPYING COPYING.info \
WB2Argv.readme

SOURCEFILES= ChkTeX.c FindErrs.c OpSys.c Resource.c Utility.c \
WB2Argv.c getopt.c getopt1.c ChkTeX.h WB2Argv.h getopt.h 

AMIGAFILES= config.h.AMIGA ChkTeX.install ChkTeX.install.info \
SMakefile SCOPTIONS ChkTeX

MSDOSFILES=ChkTeX.dsk ChkTeX.exe ChkTeX.prj config.msd

TESTFILES= Test.tex input.tex

DISTFILES= $(REXXFILES) $(INSTALLFILES) $(DOCFILES) $(SOURCEFILES) \
$(AMIGAFILES) $(MSDOSFILES) $(TESTFILES) $(WEBFILES) 


.c.o:
	@CC@ @CFLAGS@ @CPPFLAGS@ @DEFS@ $(USRDEFS) $(compileflags) -c $<

###################### MAIN DEPENDENCIES ################################

all: chktex ChkTeX.ps 

chktex: $(OBJS)
	touch chktex
	rm -r chktex
	@CC@ @LIBS@ @LDFLAGS@ $(compileflags) -o chktex $(OBJS)

install: chktex ChkTeX.ps ChkTeX.dvi
	@INSTALL@ chkweb deweb $(bindir)
	@INSTALL_PROGRAM@ chktex $(bindir)
	@INSTALL_DATA@ chktexrc $(datadir)/chktexrc

clean:
	rm -r *.o *.dvi *.ps *.aux *.log *.tar.gz *.lha *.cache *.status \
chktex deweb chkweb config.h

dist: $(DISTFILES)
	touch chktex chktex.lha chktex.tar.gz
	rm -r chktex chktex.lha chktex.tar.gz
	mkdir chktex
	cp $(DISTFILES) ChkTeX chktex
	mkdir chktex/exec
	cp exec/* chktex/exec/
	lha a chktex.lha chktex
	tar cf chktex.tar chktex
	gzip chktex.tar
	rm -r chktex

###################### INDIVIDUAL DEPENDENCIES ##########################

configure: configure.in
	autoconf

ChkTeX.dvi: ChkTeX.tex
	@LATEX@ ChkTeX.tex

ChkTeX.ps: ChkTeX.dvi
	@DVIPS@ -o ChkTeX.ps ChkTeX.dvi


ChkTeX: ChkTeX.c
	@echo

ChkTeX.o: ChkTeX.c ChkTeX.h exec/types.h getopt.h Makefile

FindErrs.o: FindErrs.c ChkTeX.h exec/types.h getopt.h Makefile

getopt.o: getopt.c  getopt.h Makefile

getopt1.o: getopt1.c  getopt.h Makefile

OpSys.o: OpSys.c ChkTeX.h exec/types.h getopt.h Makefile

Resource.o: Resource.c ChkTeX.h exec/types.h getopt.h Makefile

Utility.o: Utility.c ChkTeX.h exec/types.h getopt.h Makefile

check:
	chktex -h
	chktex Test.tex
	chktex -v2 -t -o tmptmptmp <Test.tex
	chktex -v2 -t -o tmptmptmp Test.tex
	chktex Test.tex -v
	chktex Test.tex -v0
	chktex Test.tex -v1
	chktex Test.tex -v2
	chktex Test.tex -v3
	chktex Test.tex -v4
	chktex -t -v0s::: Test.tex -x
	chktex -p FOO Test.tex
	chktex -t Test.tex
	chktex -o tmptmptmp -o tmptmptmptmp Test.tex
	chktex -l t:faultrc test.tex
	chktex -e30w22n1 Test.tex
	chktex -w33e-n1 Test.tex
	chktex -i
	chktex -v2 -t -o tmptmptmp <Test.tex
	chktex -I Test.tex
	chktex -rd2 Test.tex
	chktex -gd2 Test.tex
	chktex -f "*N\
Between: %b*N\
Column: %c*N\
Lenght: %d*N\
File: %f*N\
%iInverse%I*N\
Kind: %k*N\
Line: %l*N\
Msg: %m*N\
Num: %n*N\
Und: %u*N\
Pre:  %r*N\
Str:  %s*N\
Post: %t*N\
*N\
%k in %f line %l: %m*N\
%r%i%s%I%t*N\
%u*N\
*N" Test.tex
	chktex -o tmptmptmp -r -d2 Test.tex
	chktex -qv0 Test.tex
	chktex -w30 Test.tex
	chktex -g --localrc=.testrc -d2 Test.tex
	cover
