f48a1b00fb2f70a6912c17f02483d215be5bb154
[gnushogi.git] / gnushogi / Makefile.in
1 #
2 # Makefile for GNU Shogi
3 #
4 # Copyright (c) 1993, 1994 Matthias Mutz
5 # Copyright (c) 1998, 1999 Michael Vanier and the Free Software Foundation
6 #
7 # GNU Shogi is based on GNU Chess
8 # Copyright (c) 1992 Free Software Foundation
9 #
10 # This file is part of GNU Shogi.
11 #
12 # GNU Shogi is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 3 of the License, or (at your option)
15 # any later version.
16 #
17 # GNU Shogi is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with GNU Shogi; see the file COPYING.
24 # If not, see <http://www.gnu.org/licenses/>.
25 #
26
27 #
28 # gnushogi   is GNU shogi, for raw text, curses, or x output.
29 # pat2inc    converts pattern textfile to "pattern.inc" include file.
30 # sizetest   shows the memory usage of the main data structures.
31 #
32
33 SHELL           = /bin/sh
34 VERS            = 1.3
35 INSTALL         = @INSTALL@
36 INSTALL_DATA    = @INSTALL_DATA@
37 INSTALL_PROGRAM = @INSTALL_PROGRAM@
38 ROOT            = @top_srcdir@
39 SRCDIR          = @srcdir@
40
41 VPATH=$(SRCDIR)
42
43 # Installation directory.
44 prefix  =   @prefix@
45
46 # Where the binaries live.
47 BINDIR  =   $(prefix)/bin
48
49 # Where the language description, the book, and the 
50 # persistent hashtable live.
51 LIBDIR  =   $(prefix)/lib/gnushogi
52
53 # Where the man page goes.
54 MANDIR  = $(prefix)/man/man6
55
56 # Where the info file goes.
57 INFODIR = $(prefix)/info
58
59 # For _pow external 
60 LIBS    = -lm
61
62 # Display routines.
63 LCURSES = @LIBCURSES@
64
65
66 #
67 # C compiler and compiler options.
68 #
69
70 CC          = @CC@
71 CWARNINGS   = @WARNINGS@
72 CEXTRAFLAGS = @CEXTRAFLAGS@
73 CFLAGS      = @CFLAGS@ $(CEXTRAFLAGS) $(CWARNINGS) -I$(ROOT) -I@top_builddir@
74 LDFLAGS     = @LDFLAGS@
75
76 # The hashfile is a record of positions seen. It is used by
77 # GNU Shogi to avoid making the same mistakes, a form of learning.
78
79 HASH       = -DHASHFILE=\"$(LIBDIR)/gnushogi.hsh\"
80
81
82 # The "book" is a record of the first few moves, for playing good
83 # moves easily and quickly, saving time, and irritating the human
84 # opponent.
85
86 TEXTBOOK   = -DBOOK=\"$(LIBDIR)/gnushogi.tbk\"
87 BINBOOK    = -DBINBOOK=\"$(LIBDIR)/gnushogi.bbk\"
88
89
90 # The pattern file contains various opening patterns. The program tries to
91 # obtain such a pattern in the opening stage. Sequences of opening
92 # patterns may be described in order to support the correct order of moves.
93
94 PATTERN    = -DPATTERNFILE=\"../misc/gnushogi.pat\"
95
96
97 all:
98         @echo No target specified.
99
100
101 #
102 # Source files.
103 #
104
105 COMMONFILES = \
106                 attacks.o      \
107                 book.o         \
108                 commondsp.o    \
109                 @CURSESDSP@    \
110                 dspwrappers.o  \
111                 eval.o         \
112                 genmove.o      \
113                 globals.o      \
114                 init.o         \
115                 pattern.o      \
116                 rawdsp.o       \
117                 search.o       \
118                 tcontrl.o      \
119                 util.o
120
121 GNUSHOGI_FILES  = $(COMMONFILES) main.o      
122
123
124 PAT2INCFILES    = $(COMMONFILES) makepattern.o pat2inc.o
125
126
127 #
128 # Primary targets.
129 #
130
131 gnushogi:
132         $(CC) $(CFLAGS) -o gnushogi $(GNUSHOGI_FILES) $(LDFLAGS) $(LCURSES) $(LIBS)
133
134 pat2inc:
135         $(CC) $(CFLAGS) -o pat2inc $(PAT2INCFILES) $(LDFLAGS) $(LCURSES) $(LIBS)
136
137 sizetest:
138         $(CC) $(CFLAGS) -o sizetest sizetest.o $(LDFLAGS) $(LIBS)
139
140 profile:
141         $(MAKE) -f Makefile.profile gnushogi
142
143 #
144 # Object files.
145 #
146
147 # Common files.
148
149 attacks.o: attacks.c
150         $(CC) $(CFLAGS) -c $<
151
152 book.o: book.c
153         $(CC) $(CFLAGS) $(TEXTBOOK) $(BINBOOK) -c $<
154
155 commondsp.o: commondsp.c
156         $(CC) $(CFLAGS) -c $<
157
158 cursesdsp.o: cursesdsp.c
159         $(CC) $(CFLAGS) -c $<
160
161 dspwrappers.o: dspwrappers.c
162         $(CC) $(CFLAGS) -c $<
163
164 genmove.o: genmove.c
165         $(CC) $(CFLAGS) -c $<
166
167 globals.o: globals.c
168         $(CC) $(CFLAGS) -c $<
169
170 eval.o: eval.c
171         $(CC) $(CFLAGS) -c $<
172
173 init.o: init.c
174         $(CC)  $(CFLAGS) -c $<
175
176 main.o: main.c
177         $(CC) $(CFLAGS) $(BINBOOK) -c $<
178
179 # To create "pattern.inc" with "pat2inc", the external
180 # pattern textfile must be used.
181
182 makepattern.o: makepattern.c
183         $(CC) $(CFLAGS) $(PATTERN) -c $<
184
185 pattern.o: pattern.c
186         $(CC)  $(CFLAGS) -c $<
187
188 rawdsp.o: rawdsp.c
189         $(CC) $(CFLAGS) -c $<
190
191 search.o: search.c
192         $(CC) $(CFLAGS) -c $<
193
194 tcontrl.o: tcontrl.c
195         $(CC) $(CFLAGS) -c $<
196
197 util.o: util.c
198         $(CC) $(CFLAGS) -c $<
199
200
201 # Files specific to particular targets.
202
203 pat2inc.o: pat2inc.c
204         $(CC) $(CFLAGS) $(BINBOOK) $(PATTERN) -c $<
205
206 sizetest.o: sizetest.c
207         $(CC) $(CFLAGS) -c $<
208
209
210 #
211 # Other targets.
212 #
213
214 gnushogi.bbk: 
215         @if [ -f ./gnushogi.bbk ]; then rm ./gnushogi.bbk; fi
216         echo quit > test
217         cat $(ROOT)/misc/gnushogi.tbk > _tmp_t
218         cat test | ./gnushogi -R -b _tmp_t -B ./gnushogi.bbk -S 8000 -P 40 3 0
219         rm test _tmp_t
220         @echo
221
222
223 #
224 # Installation.
225 #
226
227 install: gnushogi
228         strip gnushogi
229         $(INSTALL_PROGRAM) -d $(BINDIR)
230         $(INSTALL_PROGRAM) -d $(LIBDIR)
231         $(INSTALL_PROGRAM) -d $(MANDIR)
232         $(INSTALL_PROGRAM) -d $(INFODIR)
233         $(INSTALL_PROGRAM) gnushogi $(BINDIR)
234         $(INSTALL_DATA)    $(ROOT)/doc/gnushogi.6     $(MANDIR)
235         $(INSTALL_DATA)    $(ROOT)/doc/gnushogi.info* $(INFODIR)
236         $(INSTALL_DATA)    gnushogi.bbk $(LIBDIR)/gnushogi.bbk
237
238
239 #
240 # Cleanup.
241 #
242
243 CLEANFILES = *.o gnushogi sizetest pat2inc CLp* *.bbk
244
245 clean: 
246         @for file in $(CLEANFILES); do \
247         if [ -f $$file ]; then rm $$file; fi; \
248         done
249
250
251 #
252 # Dependencies.
253 #
254
255 gnushogi:   $(GNUSHOGI_FILES)
256 pat2inc:       $(PAT2INCFILES)
257 sizetest:      sizetest.o 
258 attacks.o:     attacks.c gnushogi.h
259 book.o:        book.c gnushogi.h
260 commondsp.o:   commondsp.c gnushogi.h
261 cursesdsp.o:   cursesdsp.c gnushogi.h
262 dspwrappers.o: dspwrappers.c gnushogi.h
263 genmove.o:     genmove.c gnushogi.h
264 globals.o:     globals.c gnushogi.h
265 eval.o:        eval.c eval.h gnushogi.h $(SRCDIR)/pattern.h
266 init.o:        init.c gnushogi.h $(SRCDIR)/pattern.h
267 main.o:        main.c gnushogi.h
268 makepattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h
269 pattern.o:     pattern.c gnushogi.h $(SRCDIR)/pattern.h $(SRCDIR)/pattern.inc
270 rawdsp.o:      rawdsp.c gnushogi.h
271 search.o:      search.c gnushogi.h
272 tcontrl.o:     tcontrl.c gnushogi.h
273 util.o:        util.c gnushogi.h
274 pat2inc.o:     pat2inc.c $(SRCDIR)/pattern.h $(SRCDIR)/gnushogi.h
275 sizetest.o:    sizetest.c $(SRCDIR)/gnushogi.h $(SRCDIR)/eval.h
276 gnushogi.bbk:  gnushogi
277