#
# Makefile for XShogi, part of GNU shogi.
#
# Copyright (c) 1993 Matthias Mutz
# Copyright (c) 1998, 1999 Michael C. Vanier and the Free Software Foundation
#
# XShogi 1.1 is based on XBoard 2.0
# Copyright (c) 1992 Free Software Foundation
#
# This file is part of XShogi.
#
# XShogi 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 1, or (at your option)
# any later version.
#
# XShogi 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 XShogi; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#

#
# xshogi is the X Windows-based user interface for GNU Shogi.
#

SHELL           = /bin/sh
VERS            = 1.3
INSTALL         = @INSTALL@
INSTALL_DATA    = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
ROOT            = ..


#
# Installation directories.
#

prefix  = @prefix@
BINDIR  = $(prefix)/bin
MANDIR  = $(prefix)/man/man6


#
# Parser generator.
#

LEX    =   @LEX@
YACC   =   @YACC@


#
# C compiler and compiler options.
#

CC          = @CC@
XINCLUDES   = @X_CFLAGS@
CWARNINGS   = @WARNINGS@
CEXTRAFLAGS = @CEXTRAFLAGS@
CFLAGS      = @CFLAGS@ $(XINCLUDES) -I..
LIBS        =
XLIBS       = @X_LIBS@ -lXaw -lXmu -lXt -lXext -lX11
LDFLAGS     = $(XLIBS) $(LIBS)


OPT                   = @OPT@
FIRST_SHOGI_PROGRAM   = -DFIRST_SHOGI_PROGRAM=\"@FIRST_SHOGI_PROGRAM@\"
SECOND_SHOGI_PROGRAM  = -DSECOND_SHOGI_PROGRAM=\"@SECOND_SHOGI_PROGRAM@\"
FIRST_HOST            = -DFIRST_HOST=\"@FIRST_HOST@\"
SECOND_HOST           = -DSECOND_HOST=\"@SECOND_HOST@\"


#
# Targets.
#

all: xshogi

xshogi: 
	$(CC) -o xshogi xshogi.o parser.o $(CFLAGS) $(LDFLAGS) 

xshogi.o: 
	$(CC) -c xshogi.c $(CWARNINGS) $(CFLAGS) \
        $(OPT) $(FIRST_SHOGI_PROGRAM) $(SECOND_SHOGI_PROGRAM) \
        $(FIRST_HOST) $(SECOND_HOST) 


#
# Regenerate the parser.  NOTE: scanner.c is never compiled; it
# is #included into parser.y.
#

parser.o: 
	$(CC) -c parser.c $(CFLAGS)

parser.c: 
	$(YACC) parser.y
	mv y.tab.c parser.c

scanner.c: scanner.l
	$(LEX) scanner.l
	mv lex.yy.c scanner.c


#
# Sources.
#

SOURCES = xshogi.c 


#
# Installation.
#

install: xshogi
	strip xshogi
	$(INSTALL_PROGRAM) -d $(BINDIR)
	$(INSTALL_PROGRAM) -d $(MANDIR)
	$(INSTALL_PROGRAM) xshogi $(BINDIR)
	$(INSTALL_DATA)    $(ROOT)/doc/xshogi.6 $(MANDIR)


#
# Cleanup.
#

CLEANFILES = xshogi *.o parser.c y.tab.c scanner.c lex.yy.c

clean:
	for file in $(CLEANFILES); do \
    if [ -f $$file ]; then rm $$file; fi; \
	done


#
# Dependencies.
#

xshogi:     xshogi.o parser.o
xshogi.o:   xshogi.c sysdeps.h xshogi.h bitmaps.h ../version.h ../config.h
parser.o:   parser.c xshogi.h
parser.c:   parser.y scanner.c
scanner.c:  scanner.l

