#
# Run ./configure to generate a Makefile from Makefile.in
# See INSTALL for more information
#

PRODUCT = @PRODUCT@
VERSION = @VERSION@
PATCHLEVEL = @PATCHLEVEL@

SHELL = /bin/sh
srcdir = @srcdir@
VPATH = @srcdir@

CC = @CC@
CFLAGS = @CFLAGS@
ALL_CFLAGS = -I$(srcdir) @X_CFLAGS@ @CONF_CFLAGS@ $(CFLAGS)
DEFINES = @DEFS@ -DATTENTION 
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
LDFLAGS = @LDFLAGS@
ALL_LDFLAGS = @CONF_LDFLAGS@ $(LDFLAGS)
LEX = @LEX@
LEXFLAGS = 
LIBS = @X_LIBS@ -lXaw @PRE_XMULIB@ -lXmu @POST_XMULIB@ -lXt -lXext \
	@X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@ @LIBS@ -lm
NROFF = @NROFF@
NROFFFLAGS = @NROFFFLAGS@

prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = $(exec_prefix)/bin
mandir = $(prefix)/man/man6
manext = .6

DISTSOURCE = COPYING COPYRIGHT ChangeLog ChangeLog.2 FAQ INSTALL Makefile.in \
	READ_ME ToDo backend.c backend.h bitmaps bitmaps.h bitmaps.xchess \
	childio.c childio.h cmail.in cmail.man comment.in common.h \
	config.guess config.sub configure configure.in frontend.h \
	ics-addresses ics-info install-sh kk13.pgn moves.c \
	moves.h parser.h parser.l xboard.c xboard.h xboard.man

ZIPPYSOURCE = zippy.README zippy.c zippy.h

DISTDIR = @PRODUCT@-@VERSION@.pl@PATCHLEVEL@

### Targets required by GNU standards #######################################

all: xboard xboard.doc cmail.doc

install:
	$(INSTALL_PROGRAM) -s xboard $(bindir)/xboard
	$(INSTALL_PROGRAM) cmail $(bindir)/cmail
	$(INSTALL_DATA) xboard.man $(mandir)/xboard$(manext)
	$(INSTALL_DATA) cmail.man $(mandir)/cmail$(manext)

uninstall:
	rm -f $(bindir)/xboard $(bindir)/cmail 
	rm -f $(mandir)/xboard$(manext) $(mandir)/cmail$(manext)

clean:
	rm -f xboard *.o *.doc lex.yy.c

distclean: clean tidy
	rm -f config.cache config.log config.status Makefile

mostlyclean: clean

realclean: distclean
	rm -f parser.c

TAGS:
	etags *.c *.h

info:
	@echo Sorry, xboard is documented by a man page, not a texinfo file.

dvi:
	@echo Sorry, xboard is documented by a man page, not a texinfo file.

dist:
	mkdir $(DISTDIR)
	test `rlog -L -R RCS/*,v | tee .locked | wc -l` = 0 || \
		( echo 'ERROR - the following are locked: ' 2>&1 ;\
		  cat .locked 2>&1 ;\
		  false )
	rlog -h RCS/*,v > RCS/$(DISTDIR).rcs
	cp -r $(DISTSOURCE) $(DISTDIR)/
	cp parser.c $(DISTDIR)/
	if echo $(DISTDIR) | grep -i zippy ; then \
	    cp -r $(ZIPPYSOURCE) $(DISTDIR)/ ; \
	fi
	if echo $(DISTDIR) | grep -i beta ; then \
	    cp -r READ_ME_FIRST $(DISTDIR)/ ; \
	fi
	tar cvf - $(DISTDIR) | gzip > $(DISTDIR).tar.gz
	uuencode $(DISTDIR).tar.gz $(DISTDIR).tar.gz > $(DISTDIR).tar.gz.uu

check: all

### End targets required by GNU standards ###################################

Makefile: Makefile.in config.status
	./config.status
     
config.status: configure
	./config.status --recheck

.SUFFIXES:
.SUFFIXES: .c .o .man .doc

.c.o:
	$(CC) $(DEFINES) $(ALL_CFLAGS) -c $<

.man.doc:
	$(NROFF) $(NROFFFLAGS) $< > $*.doc

xboard: parser.o xboard.o backend.o moves.o childio.o @ZIPPY_O@
	$(CC) -o xboard $(ALL_LDFLAGS) \
		parser.o xboard.o backend.o moves.o childio.o @ZIPPY_O@ \
		$(LIBS)

parser.c: parser.l
	$(LEX) $(LEXFLAGS) $(srcdir)/parser.l
	mv lex.yy.c parser.c

parser.o: parser.c common.h backend.h parser.h moves.h
xboard.o: common.h frontend.h backend.h xboard.h childio.h bitmaps.h
backend.o: common.h frontend.h backend.h parser.h moves.h
moves.o: common.h backend.h moves.h parser.h
childio.o: common.h childio.h frontend.h
zippy.o: common.h zippy.h frontend.h

tidy:
	rm -f ,* .,* .emacs_[0-9]* core a.out *~ *.BAK *.CKP .nfs*
