# Makefile for ChessPrn program
# Copyright (C) 1993  Ed Maillet
# ChessPrn based on Notation by Henry Thomas


FILES      = notation.c drivers.c lexer.c lexer.l movegen.c movedo.c
HEADERS    = notation.h drivers.h lexer.h \
		movegen.h movedo.h \
		config.h chesstyp.h chesssym.def

LIBDIR = .
LIBTEX = .
BINDIR = .

#LIBDIR     = $(HOME)/lib
#LIBTEX    = $(HOME)/lib/tex
#BINDIR    = $(HOME)/bin/$(HOSTTYPE)

#For UNIX et al
OBJEXT = o
OUTNAME = -o chessprn

#For Turbo C/C++ 3.0
#OBJEXT = obj
#OUTNAME = -echessprn


OBJECTS    = notation.$(OBJEXT) drivers.$(OBJEXT) \
	     lexer.$(OBJEXT) movegen.$(OBJEXT) movedo.$(OBJEXT)

OTHERFILES = Makefile notation.hlp \
	keywords.ntn algebric.ntn shortalg.ntn boudy.ntn\
	notation.doc \
	README TODO COPYING CHANGES \
	header.ps footer.ps \
	wheader.ps wfooter.ps \
	convsymb.txt convsymb.tex \
	symboles.txt symboles.tex chesssym.tex symb.tex \
	notation.tex chessprn.cfg

SYMBKIT    = ChessSymb
SYMBFILES  = symboles.tex symb.tex chesssym.tex

############################################################
# you might want to define the lib path :
#       do not forget the trailing /
# ( the library is the place where the HELPFILE, Heading, fonts etc are)
# also you can have default language for input/ouput
# define IN_LANG and OUT_LANG
# value can be:
#       FRENCH, ENGLISH, GERMAN, ITALIAN, SPANISH, DUTCH
# ANSI C/ TURBO C (MSDOS)
# to compile with TURBO C or ANSI C, define TURBOC

#For UNIX et al
CFLAGS     = -O2 \
       -DLIB_DIR=\"$(LIBDIR)/\" \
       -DIN_LANG=ENGLISH \
       -DOUT_LANG=ENGLISH

# For Turbo C/C++ 3.0
#CFLAGS     =

LDFLAGS    =

LEX= flex

COPY = cp
#COPY = copy

DEL = rm -f
#DEL = del

CC= gcc -ansi -pedantic
#CC = tcc +chessprn.cfg

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

# KEEP_STATE is used only by SUN OS -- comment it out otherwise
#.KEEP_STATE:

## BASIC DEPENDANCES FOR BUILDING NOTATION

all: chessprn notation.doc symboles.txt

# lexer.c can be generated by (f)lex fom lexer.l
# If you don't have (f)lex, lexer.c is provided in the distribution
# so remove the next two lines
lexer.c: lexer.l chesstyp.h
	$(LEX) -t lexer.l > lexer.c

chessprn: $(OBJECTS)
	$(CC) $(CFLAGS) $(OUTNAME) $(OBJECTS)

## ALL FILES

files: notation.hlp chesssym.def
	make chessprn
	make symboles.txt symb.tex

## INSTALLATION

install:
	make files
	$(COPY) notation $(BINDIR)
	$(COPY) chesssymb.tex $(LIBTEX)
	$(COPY) notation.tex $(LIBTEX)
	$(COPY) notation.hlp $(LIBDIR)
	$(COPY) notation.doc $(LIBDIR)
	$(COPY) header.ps $(LIBDIR)
	$(COPY) footer.ps $(LIBDIR)
	$(COPY) symboles.txt $(LIBDIR)
	$(COPY) symboles.tex $(LIBDIR)
	$(COPY) wheader.ps $(LIBDIR)
	$(COPY) wfooter.ps $(LIBDIR)

## REMOVE BINARIES AND .o
#I wouldn't do this unless you have (f)lex
clean:
	$(DEL) chessprn $(OBJECTS) lexer.c


## DEPENDANCES FOR TEXT FILES/ USED FOR LIBRARY
## THESE FILES ARE NOT NECESSARY TO EXECUTE ChessPrn

# symboles.txt and symb.txt are generated by /lib/cpp from UNIX
# Turbo C and MSC should provide a similar utility
# sed is a stream-line UNIX editor. Some implementations
# exists for PC
# Anyway these files are included in the distribution
# so remove these lines if you have any problem
symboles.txt:  chesssym.def convsymb.txt
	/lib/cpp -P convsymb.txt| sed -e "s/\\\\//" |\
	sed -e 's/\"//g' | cat -s > symboles.txt

symb.tex:  chesssym.def convsymb.tex
	/lib/cpp -P convsymb.tex | sed -e 's/\\\\/\\/g' |\
	sed -e 's/\"//g' | cat -s > symb.tex

symboles.dvi: symboles.tex symb.tex
	latex symboles.tex

symboles: $(SYMBFILES)
	shar -o$(SYMBKIT).shar $(SYMBFILES)
	compress -f $(SYMBKIT).shar

## AND NOW THE REAL DEPENDANCES, needed to build ChessPrn

# DO NOT DELETE THIS LINE -- make depend depends on it.

notation.$(OBJEXT): config.h chesstyp.h notation.h chesssym.def movedo.h \
		    movegen.h drivers.h lexer.h

drivers.$(OBJEXT): config.h chesstyp.h notation.h chesssym.def movegen.h \
		   drivers.h
lexer.$(OBJEXT): chesstyp.h notation.h chesssym.def

movegen.$(OBJEXT): config.h chesstyp.h notation.h chesssym.def lexer.h \
		   movedo.h movegen.h

movedo.$(OBJEXT): config.h chesstyp.h notation.h chesssym.def movedo.h
