Merge branch 'maint'
[gnushogi.git] / gnushogi / Makefile.in
index b07df75..176454c 100644 (file)
@@ -1,16 +1,19 @@
 #
 # Makefile for GNU Shogi
 #
-# Copyright (c) 2012 Free Software Foundation
+# Copyright (c) 1993, 1994 Matthias Mutz
+# Copyright (c) 1998, 1999 Michael Vanier and the Free Software Foundation
+# Copyright (c) 2008, 2013, 2014 Yann Dirson and the Free Software Foundation
 #
 # GNU Shogi is based on GNU Chess
+# Copyright (c) 1992 Free Software Foundation
 #
 # This file is part of GNU Shogi.
 #
 # GNU Shogi 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 3 of the License, or (at your option)
-# any later ../version.
+# the Free Software Foundation; either version 3 of the License, or (at your option)
+# any later version.
 #
 # GNU Shogi is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 #
 # gnushogi   is GNU shogi, for raw text, curses, or x output.
+# gnuminishogi is GNU minishogi, for raw text, curses, or x output.
 # pat2inc    converts pattern textfile to "pattern.inc" include file.
 # sizetest   shows the memory usage of the main data structures.
 #
 
 SHELL           = /bin/sh
-VERS            = 1.3
 INSTALL         = @INSTALL@
 INSTALL_DATA    = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -38,6 +41,8 @@ SRCDIR                = @srcdir@
 
 VPATH=$(SRCDIR)
 
+PROGNAME=@PROGNAME@
+
 # Installation directory.
 prefix  =   @prefix@
 
@@ -46,7 +51,7 @@ BINDIR  =   $(prefix)/bin
 
 # Where the language description, the book, and the 
 # persistent hashtable live.
-LIBDIR  =   $(prefix)/lib/gnushogi
+LIBDIR  =   $(prefix)/lib/$(PROGNAME)
 
 # Where the man page goes.
 MANDIR  = $(prefix)/man/man6
@@ -58,7 +63,7 @@ INFODIR = $(prefix)/info
 LIBS    = -lm
 
 # Display routines.
-LCURSES =   -lcurses -ltermcap
+LCURSES = @LIBCURSES@
 
 
 #
@@ -68,34 +73,28 @@ LCURSES =   -lcurses -ltermcap
 CC          = @CC@
 CWARNINGS   = @WARNINGS@
 CEXTRAFLAGS = @CEXTRAFLAGS@
-CFLAGS      = @CFLAGS@ $(CEXTRAFLAGS) $(CWARNINGS) -I$(ROOT) -I@top_builddir@
-
+CFLAGS      = @CFLAGS@ $(HASH) $(CEXTRAFLAGS) $(CWARNINGS) -I. -I@top_builddir@ -I$(ROOT)
+LDFLAGS     = @LDFLAGS@
 
 # The hashfile is a record of positions seen. It is used by
 # GNU Shogi to avoid making the same mistakes, a form of learning.
 
-HASH       = -DHASHFILE=\"$(LIBDIR)/gnushogi.hsh\"
+HASH       = -DHASHFILE=\"$(LIBDIR)/$(PROGNAME).hsh\"
 
 
 # The "book" is a record of the first few moves, for playing good
 # moves easily and quickly, saving time, and irritating the human
 # opponent.
 
-TEXTBOOK   = -DBOOK=\"$(LIBDIR)/gnushogi.tbk\"
-BINBOOK    = -DBINBOOK=\"$(LIBDIR)/gnushogi.bbk\"
-
-
-# The language file describes capabilities of the program.  It may
-# be useful for customizing gnushogi for non-English-speaking players.
-
-LANGF      = -DLANGFILE=\"../misc/gnushogi.lng\"
+TEXTBOOK   = -DBOOK=\"$(LIBDIR)/$(PROGNAME).tbk\"
+BINBOOK    = -DBINBOOK=\"$(LIBDIR)/$(PROGNAME).bbk\"
 
 
 # The pattern file contains various opening patterns. The program tries to
 # obtain such a pattern in the opening stage. Sequences of opening
 # patterns may be described in order to support the correct order of moves.
 
-PATTERN    = -DPATTERNFILE=\"../misc/gnushogi.pat\"
+PATTERNFILE=$(ROOT)/misc/$(PROGNAME).pat
 
 
 all:
@@ -107,23 +106,25 @@ all:
 #
 
 COMMONFILES = \
+                globals.o      \
+                init-common.o    \
+                pattern-common.o
+
+NOTCOMMONFILES = \
                 attacks.o      \
                 book.o         \
                 commondsp.o    \
-                cursesdsp.o    \
-                dspwrappers.o  \
+                @CURSESDSP@    \
                 eval.o         \
                 genmove.o      \
-                globals.o      \
                 init.o         \
                 pattern.o      \
                 rawdsp.o       \
                 search.o       \
-                sysdeps.o      \
                 tcontrl.o      \
                 util.o
 
-GNUSHOGI_FILES  = $(COMMONFILES) main.o      
+GNUSHOGI_FILES  = $(COMMONFILES) $(NOTCOMMONFILES) main.o
 
 
 PAT2INCFILES    = $(COMMONFILES) makepattern.o pat2inc.o
@@ -133,14 +134,14 @@ PAT2INCFILES    = $(COMMONFILES) makepattern.o pat2inc.o
 # Primary targets.
 #
 
-gnushogi:
-       $(CC) $(CFLAGS) -o gnushogi $(GNUSHOGI_FILES) $(LCURSES) $(LIBS)
+$(PROGNAME):
+       $(CC) $(CFLAGS) -o $(PROGNAME) $(GNUSHOGI_FILES) $(LDFLAGS) $(LCURSES) $(LIBS)
 
 pat2inc:
-       $(CC) $(CFLAGS) -o pat2inc $(PAT2INCFILES) $(LCURSES) $(LIBS)
+       $(CC) $(CFLAGS) -o pat2inc $(PAT2INCFILES) $(LDFLAGS) $(LCURSES) $(LIBS)
 
 sizetest:
-       $(CC) $(CFLAGS) -o sizetest sizetest.o $(LIBS)
+       $(CC) $(CFLAGS) -o sizetest sizetest.o $(LDFLAGS) $(LIBS)
 
 profile:
        $(MAKE) -f Makefile.profile gnushogi
@@ -163,9 +164,6 @@ commondsp.o: commondsp.c
 cursesdsp.o: cursesdsp.c
        $(CC) $(CFLAGS) -c $<
 
-dspwrappers.o: dspwrappers.c
-       $(CC) $(CFLAGS) -c $<
-
 genmove.o: genmove.c
        $(CC) $(CFLAGS) -c $<
 
@@ -176,6 +174,9 @@ eval.o: eval.c
        $(CC) $(CFLAGS) -c $<
 
 init.o: init.c
+       $(CC)  $(CFLAGS) -c $<
+
+init-common.o: init-common.c
        $(CC)  $(CFLAGS) $(LANGF) -c $<
 
 main.o: main.c
@@ -185,20 +186,20 @@ main.o: main.c
 # pattern textfile must be used.
 
 makepattern.o: makepattern.c
-       $(CC) $(CFLAGS) $(PATTERN) -c $<
+       $(CC) $(CFLAGS) -c $<
 
 pattern.o: pattern.c
        $(CC)  $(CFLAGS) -c $<
 
+pattern-common.o: pattern-common.c
+       $(CC)  $(CFLAGS) -c $<
+
 rawdsp.o: rawdsp.c
        $(CC) $(CFLAGS) -c $<
 
 search.o: search.c
        $(CC) $(CFLAGS) -c $<
 
-sysdeps.o: sysdeps.c
-       $(CC) $(CFLAGS) -c $<
-
 tcontrl.o: tcontrl.c
        $(CC) $(CFLAGS) -c $<
 
@@ -209,21 +210,23 @@ util.o: util.c
 # Files specific to particular targets.
 
 pat2inc.o: pat2inc.c
-       $(CC) $(CFLAGS) $(LANGF) $(BINBOOK) $(PATTERN) -c $<
+       $(CC) $(CFLAGS) -c $<
 
 sizetest.o: sizetest.c
        $(CC) $(CFLAGS) -c $<
 
+pattern.inc: $(PATTERNFILE) pat2inc
+       ./pat2inc $< $@
 
 #
 # Other targets.
 #
 
-gnushogi.bbk: 
-       @if [ -f ./gnushogi.bbk ]; then rm ./gnushogi.bbk; fi
+$(PROGNAME).bbk:
+       @if [ -f ./$(PROGNAME).bbk ]; then rm ./$(PROGNAME).bbk; fi
        echo quit > test
-       cat $(ROOT)/misc/gnushogi.tbk > _tmp_t
-       cat test | ./gnushogi -R -b _tmp_t -B ./gnushogi.bbk -S 8000 -P 40 3 0
+       cat $(ROOT)/misc/$(PROGNAME).tbk > _tmp_t
+       cat test | ./$(PROGNAME) -R -b _tmp_t -B ./$(PROGNAME).bbk -S 8000 -P 40 3 0
        rm test _tmp_t
        @echo
 
@@ -232,23 +235,23 @@ gnushogi.bbk:
 # Installation.
 #
 
-install: gnushogi
-       strip gnushogi
+install: $(PROGNAME)
+       strip $(PROGNAME)
        $(INSTALL_PROGRAM) -d $(BINDIR)
        $(INSTALL_PROGRAM) -d $(LIBDIR)
        $(INSTALL_PROGRAM) -d $(MANDIR)
        $(INSTALL_PROGRAM) -d $(INFODIR)
-       $(INSTALL_PROGRAM) gnushogi $(BINDIR)
+       $(INSTALL_PROGRAM) $(PROGNAME) $(BINDIR)
        $(INSTALL_DATA)    $(ROOT)/doc/gnushogi.6     $(MANDIR)
        $(INSTALL_DATA)    $(ROOT)/doc/gnushogi.info* $(INFODIR)
-       $(INSTALL_DATA)    gnushogi.bbk $(LIBDIR)/gnushogi.bbk
+       $(INSTALL_DATA)    $(PROGNAME).bbk $(LIBDIR)/$(PROGNAME).bbk
 
 
 #
 # Cleanup.
 #
 
-CLEANFILES = *.o gnushogi sizetest pat2inc CLp* *.bbk
+CLEANFILES = *.o gnushogi gnuminishogi sizetest pat2inc CLp* *.bbk
 
 clean: 
        @for file in $(CLEANFILES); do \
@@ -260,27 +263,26 @@ clean:
 # Dependencies.
 #
 
-gnushogi:   $(GNUSHOGI_FILES)
+$(PROGNAME):   $(GNUSHOGI_FILES)
 pat2inc:       $(PAT2INCFILES)
 sizetest:      sizetest.o 
-attacks.o:     attacks.c gnushogi.h $(ROOT)/version.h
-book.o:        book.c gnushogi.h $(ROOT)/version.h
-commondsp.o:   commondsp.c gnushogi.h $(ROOT)/version.h
-cursesdsp.o:   cursesdsp.c gnushogi.h $(ROOT)/version.h
-dspwrappers.o: dspwrappers.c gnushogi.h $(ROOT)/version.h
-genmove.o:     genmove.c gnushogi.h $(ROOT)/version.h
-globals.o:     globals.c gnushogi.h $(ROOT)/version.h
-eval.o:        eval.c eval.h gnushogi.h $(ROOT)/version.h $(SRCDIR)/pattern.h
-init.o:        init.c gnushogi.h $(ROOT)/version.h $(SRCDIR)/pattern.h
-main.o:        main.c gnushogi.h $(ROOT)/version.h
+attacks.o:     attacks.c gnushogi.h
+book.o:        book.c gnushogi.h
+commondsp.o:   commondsp.c gnushogi.h
+cursesdsp.o:   cursesdsp.c gnushogi.h
+genmove.o:     genmove.c gnushogi.h
+globals.o:     globals.c gnushogi.h
+eval.o:        eval.c eval.h gnushogi.h $(SRCDIR)/pattern.h
+init.o:        init.c gnushogi.h $(SRCDIR)/pattern.h
+init-common.o: init-common.c gnushogi.h
+main.o:        main.c gnushogi.h
 makepattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h
-pattern.o:     pattern.c gnushogi.h $(SRCDIR)/pattern.h $(SRCDIR)/pattern.inc
-rawdsp.o:      rawdsp.c gnushogi.h $(ROOT)/version.h
-search.o:      search.c gnushogi.h $(ROOT)/version.h
-sysdeps.o:     sysdeps.c gnushogi.h $(ROOT)/version.h
-tcontrl.o:     tcontrl.c gnushogi.h $(ROOT)/version.h
-util.o:        util.c gnushogi.h $(ROOT)/version.h
+pattern.o:     pattern.c gnushogi.h $(SRCDIR)/pattern.h pattern.inc
+rawdsp.o:      rawdsp.c gnushogi.h
+search.o:      search.c gnushogi.h
+tcontrl.o:     tcontrl.c gnushogi.h
+util.o:        util.c gnushogi.h
 pat2inc.o:     pat2inc.c $(SRCDIR)/pattern.h $(SRCDIR)/gnushogi.h
 sizetest.o:    sizetest.c $(SRCDIR)/gnushogi.h $(SRCDIR)/eval.h
-gnushogi.bbk:  gnushogi
+$(PROGNAME).bbk:  $(PROGNAME)