Generate patterns.inc at build time.
[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@ -I.
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 PATTERNFILE=$(ROOT)/misc/gnushogi.pat
95 PATTERN    = -DPATTERNFILE=\"$(PATTERNFILE)\"
96
97
98 all:
99         @echo No target specified.
100
101
102 #
103 # Source files.
104 #
105
106 COMMONFILES = \
107                 globals.o      \
108                 init-common.o    \
109                 pattern-common.o
110
111 NOTCOMMONFILES = \
112                 attacks.o      \
113                 book.o         \
114                 commondsp.o    \
115                 @CURSESDSP@    \
116                 dspwrappers.o  \
117                 eval.o         \
118                 genmove.o      \
119                 init.o         \
120                 pattern.o      \
121                 rawdsp.o       \
122                 search.o       \
123                 tcontrl.o      \
124                 util.o
125
126 GNUSHOGI_FILES  = $(COMMONFILES) $(NOTCOMMONFILES) main.o
127
128
129 PAT2INCFILES    = $(COMMONFILES) makepattern.o pat2inc.o
130
131
132 #
133 # Primary targets.
134 #
135
136 gnushogi:
137         $(CC) $(CFLAGS) -o gnushogi $(GNUSHOGI_FILES) $(LDFLAGS) $(LCURSES) $(LIBS)
138
139 pat2inc:
140         $(CC) $(CFLAGS) -o pat2inc $(PAT2INCFILES) $(LDFLAGS) $(LCURSES) $(LIBS)
141
142 sizetest:
143         $(CC) $(CFLAGS) -o sizetest sizetest.o $(LDFLAGS) $(LIBS)
144
145 profile:
146         $(MAKE) -f Makefile.profile gnushogi
147
148 #
149 # Object files.
150 #
151
152 # Common files.
153
154 attacks.o: attacks.c
155         $(CC) $(CFLAGS) -c $<
156
157 book.o: book.c
158         $(CC) $(CFLAGS) $(TEXTBOOK) $(BINBOOK) -c $<
159
160 commondsp.o: commondsp.c
161         $(CC) $(CFLAGS) -c $<
162
163 cursesdsp.o: cursesdsp.c
164         $(CC) $(CFLAGS) -c $<
165
166 dspwrappers.o: dspwrappers.c
167         $(CC) $(CFLAGS) -c $<
168
169 genmove.o: genmove.c
170         $(CC) $(CFLAGS) -c $<
171
172 globals.o: globals.c
173         $(CC) $(CFLAGS) -c $<
174
175 eval.o: eval.c
176         $(CC) $(CFLAGS) -c $<
177
178 init.o: init.c
179         $(CC)  $(CFLAGS) -c $<
180
181 init-common.o: init-common.c
182         $(CC)  $(CFLAGS) $(LANGF) -c $<
183
184 main.o: main.c
185         $(CC) $(CFLAGS) $(BINBOOK) -c $<
186
187 # To create "pattern.inc" with "pat2inc", the external
188 # pattern textfile must be used.
189
190 makepattern.o: makepattern.c
191         $(CC) $(CFLAGS) $(PATTERN) -c $<
192
193 pattern.o: pattern.c
194         $(CC)  $(CFLAGS) -c $<
195
196 pattern-common.o: pattern-common.c
197         $(CC)  $(CFLAGS) -c $<
198
199 rawdsp.o: rawdsp.c
200         $(CC) $(CFLAGS) -c $<
201
202 search.o: search.c
203         $(CC) $(CFLAGS) -c $<
204
205 tcontrl.o: tcontrl.c
206         $(CC) $(CFLAGS) -c $<
207
208 util.o: util.c
209         $(CC) $(CFLAGS) -c $<
210
211
212 # Files specific to particular targets.
213
214 pat2inc.o: pat2inc.c
215         $(CC) $(CFLAGS) $(BINBOOK) $(PATTERN) -c $<
216
217 sizetest.o: sizetest.c
218         $(CC) $(CFLAGS) -c $<
219
220 pattern.inc: $(PATTERNFILE) pat2inc
221         ./pat2inc
222
223 #
224 # Other targets.
225 #
226
227 gnushogi.bbk: 
228         @if [ -f ./gnushogi.bbk ]; then rm ./gnushogi.bbk; fi
229         echo quit > test
230         cat $(ROOT)/misc/gnushogi.tbk > _tmp_t
231         cat test | ./gnushogi -R -b _tmp_t -B ./gnushogi.bbk -S 8000 -P 40 3 0
232         rm test _tmp_t
233         @echo
234
235
236 #
237 # Installation.
238 #
239
240 install: gnushogi
241         strip gnushogi
242         $(INSTALL_PROGRAM) -d $(BINDIR)
243         $(INSTALL_PROGRAM) -d $(LIBDIR)
244         $(INSTALL_PROGRAM) -d $(MANDIR)
245         $(INSTALL_PROGRAM) -d $(INFODIR)
246         $(INSTALL_PROGRAM) gnushogi $(BINDIR)
247         $(INSTALL_DATA)    $(ROOT)/doc/gnushogi.6     $(MANDIR)
248         $(INSTALL_DATA)    $(ROOT)/doc/gnushogi.info* $(INFODIR)
249         $(INSTALL_DATA)    gnushogi.bbk $(LIBDIR)/gnushogi.bbk
250
251
252 #
253 # Cleanup.
254 #
255
256 CLEANFILES = *.o gnushogi sizetest pat2inc CLp* *.bbk
257
258 clean: 
259         @for file in $(CLEANFILES); do \
260         if [ -f $$file ]; then rm $$file; fi; \
261         done
262
263
264 #
265 # Dependencies.
266 #
267
268 gnushogi:   $(GNUSHOGI_FILES)
269 pat2inc:       $(PAT2INCFILES)
270 sizetest:      sizetest.o 
271 attacks.o:     attacks.c gnushogi.h
272 book.o:        book.c gnushogi.h
273 commondsp.o:   commondsp.c gnushogi.h
274 cursesdsp.o:   cursesdsp.c gnushogi.h
275 dspwrappers.o: dspwrappers.c gnushogi.h
276 genmove.o:     genmove.c gnushogi.h
277 globals.o:     globals.c gnushogi.h
278 eval.o:        eval.c eval.h gnushogi.h $(SRCDIR)/pattern.h
279 init.o:        init.c gnushogi.h $(SRCDIR)/pattern.h
280 main.o:        main.c gnushogi.h
281 makepattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h
282 pattern.o:     pattern.c gnushogi.h $(SRCDIR)/pattern.h pattern.inc
283 rawdsp.o:      rawdsp.c gnushogi.h
284 search.o:      search.c gnushogi.h
285 tcontrl.o:     tcontrl.c gnushogi.h
286 util.o:        util.c gnushogi.h
287 pat2inc.o:     pat2inc.c $(SRCDIR)/pattern.h $(SRCDIR)/gnushogi.h
288 sizetest.o:    sizetest.c $(SRCDIR)/gnushogi.h $(SRCDIR)/eval.h
289 gnushogi.bbk:  gnushogi
290