d8749dc7b2b45059b5496521734a1b9b4f664815
[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 # gnuminishogi is GNU minishogi, for raw text, curses, or x output.
30 # pat2inc    converts pattern textfile to "pattern.inc" include file.
31 # sizetest   shows the memory usage of the main data structures.
32 #
33
34 SHELL           = /bin/sh
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 PROGNAME=@PROGNAME@
44
45 # Installation directory.
46 prefix  =   @prefix@
47
48 # Where the binaries live.
49 BINDIR  =   $(prefix)/bin
50
51 # Where the language description, the book, and the 
52 # persistent hashtable live.
53 LIBDIR  =   $(prefix)/lib/$(PROGNAME)
54
55 # Where the man page goes.
56 MANDIR  = $(prefix)/man/man6
57
58 # Where the info file goes.
59 INFODIR = $(prefix)/info
60
61 # For _pow external 
62 LIBS    = -lm
63
64 # Display routines.
65 LCURSES = @LIBCURSES@
66
67
68 #
69 # C compiler and compiler options.
70 #
71
72 CC          = @CC@
73 CWARNINGS   = @WARNINGS@
74 CEXTRAFLAGS = @CEXTRAFLAGS@
75 CFLAGS      = @CFLAGS@ $(HASH) $(CEXTRAFLAGS) $(CWARNINGS) -I. -I@top_builddir@ -I$(ROOT)
76 LDFLAGS     = @LDFLAGS@
77
78 # The hashfile is a record of positions seen. It is used by
79 # GNU Shogi to avoid making the same mistakes, a form of learning.
80
81 HASH       = -DHASHFILE=\"$(LIBDIR)/$(PROGNAME).hsh\"
82
83
84 # The "book" is a record of the first few moves, for playing good
85 # moves easily and quickly, saving time, and irritating the human
86 # opponent.
87
88 TEXTBOOK   = -DBOOK=\"$(LIBDIR)/$(PROGNAME).tbk\"
89 BINBOOK    = -DBINBOOK=\"$(LIBDIR)/$(PROGNAME).bbk\"
90
91
92 # The pattern file contains various opening patterns. The program tries to
93 # obtain such a pattern in the opening stage. Sequences of opening
94 # patterns may be described in order to support the correct order of moves.
95
96 PATTERNFILE=$(ROOT)/misc/$(PROGNAME).pat
97 PATTERN    = -DPATTERNFILE=\"$(PATTERNFILE)\"
98
99
100 all:
101         @echo No target specified.
102
103
104 #
105 # Source files.
106 #
107
108 COMMONFILES = \
109                 globals.o      \
110                 init-common.o    \
111                 pattern-common.o
112
113 NOTCOMMONFILES = \
114                 attacks.o      \
115                 book.o         \
116                 commondsp.o    \
117                 @CURSESDSP@    \
118                 dspwrappers.o  \
119                 eval.o         \
120                 genmove.o      \
121                 init.o         \
122                 pattern.o      \
123                 rawdsp.o       \
124                 search.o       \
125                 tcontrl.o      \
126                 util.o
127
128 GNUSHOGI_FILES  = $(COMMONFILES) $(NOTCOMMONFILES) main.o
129
130
131 PAT2INCFILES    = $(COMMONFILES) makepattern.o pat2inc.o
132
133
134 #
135 # Primary targets.
136 #
137
138 $(PROGNAME):
139         $(CC) $(CFLAGS) -o $(PROGNAME) $(GNUSHOGI_FILES) $(LDFLAGS) $(LCURSES) $(LIBS)
140
141 pat2inc:
142         $(CC) $(CFLAGS) -o pat2inc $(PAT2INCFILES) $(LDFLAGS) $(LCURSES) $(LIBS)
143
144 sizetest:
145         $(CC) $(CFLAGS) -o sizetest sizetest.o $(LDFLAGS) $(LIBS)
146
147 profile:
148         $(MAKE) -f Makefile.profile gnushogi
149
150 #
151 # Object files.
152 #
153
154 # Common files.
155
156 attacks.o: attacks.c
157         $(CC) $(CFLAGS) -c $<
158
159 book.o: book.c
160         $(CC) $(CFLAGS) $(TEXTBOOK) $(BINBOOK) -c $<
161
162 commondsp.o: commondsp.c
163         $(CC) $(CFLAGS) -c $<
164
165 cursesdsp.o: cursesdsp.c
166         $(CC) $(CFLAGS) -c $<
167
168 dspwrappers.o: dspwrappers.c
169         $(CC) $(CFLAGS) -c $<
170
171 genmove.o: genmove.c
172         $(CC) $(CFLAGS) -c $<
173
174 globals.o: globals.c
175         $(CC) $(CFLAGS) -c $<
176
177 eval.o: eval.c
178         $(CC) $(CFLAGS) -c $<
179
180 init.o: init.c
181         $(CC)  $(CFLAGS) -c $<
182
183 init-common.o: init-common.c
184         $(CC)  $(CFLAGS) $(LANGF) -c $<
185
186 main.o: main.c
187         $(CC) $(CFLAGS) $(BINBOOK) -c $<
188
189 # To create "pattern.inc" with "pat2inc", the external
190 # pattern textfile must be used.
191
192 makepattern.o: makepattern.c
193         $(CC) $(CFLAGS) $(PATTERN) -c $<
194
195 pattern.o: pattern.c
196         $(CC)  $(CFLAGS) -c $<
197
198 pattern-common.o: pattern-common.c
199         $(CC)  $(CFLAGS) -c $<
200
201 rawdsp.o: rawdsp.c
202         $(CC) $(CFLAGS) -c $<
203
204 search.o: search.c
205         $(CC) $(CFLAGS) -c $<
206
207 tcontrl.o: tcontrl.c
208         $(CC) $(CFLAGS) -c $<
209
210 util.o: util.c
211         $(CC) $(CFLAGS) -c $<
212
213
214 # Files specific to particular targets.
215
216 pat2inc.o: pat2inc.c
217         $(CC) $(CFLAGS) -c $<
218
219 sizetest.o: sizetest.c
220         $(CC) $(CFLAGS) -c $<
221
222 pattern.inc: $(PATTERNFILE) pat2inc
223         ./pat2inc
224
225 #
226 # Other targets.
227 #
228
229 $(PROGNAME).bbk:
230         @if [ -f ./$(PROGNAME).bbk ]; then rm ./$(PROGNAME).bbk; fi
231         echo quit > test
232         cat $(ROOT)/misc/$(PROGNAME).tbk > _tmp_t
233         cat test | ./$(PROGNAME) -R -b _tmp_t -B ./$(PROGNAME).bbk -S 8000 -P 40 3 0
234         rm test _tmp_t
235         @echo
236
237
238 #
239 # Installation.
240 #
241
242 install: $(PROGNAME)
243         strip $(PROGNAME)
244         $(INSTALL_PROGRAM) -d $(BINDIR)
245         $(INSTALL_PROGRAM) -d $(LIBDIR)
246         $(INSTALL_PROGRAM) -d $(MANDIR)
247         $(INSTALL_PROGRAM) -d $(INFODIR)
248         $(INSTALL_PROGRAM) $(PROGNAME) $(BINDIR)
249         $(INSTALL_DATA)    $(ROOT)/doc/gnushogi.6     $(MANDIR)
250         $(INSTALL_DATA)    $(ROOT)/doc/gnushogi.info* $(INFODIR)
251         $(INSTALL_DATA)    $(PROGNAME).bbk $(LIBDIR)/$(PROGNAME).bbk
252
253
254 #
255 # Cleanup.
256 #
257
258 CLEANFILES = *.o gnushogi gnuminishogi sizetest pat2inc CLp* *.bbk
259
260 clean: 
261         @for file in $(CLEANFILES); do \
262         if [ -f $$file ]; then rm $$file; fi; \
263         done
264
265
266 #
267 # Dependencies.
268 #
269
270 $(PROGNAME):   $(GNUSHOGI_FILES)
271 pat2inc:       $(PAT2INCFILES)
272 sizetest:      sizetest.o 
273 attacks.o:     attacks.c gnushogi.h
274 book.o:        book.c gnushogi.h
275 commondsp.o:   commondsp.c gnushogi.h
276 cursesdsp.o:   cursesdsp.c gnushogi.h
277 dspwrappers.o: dspwrappers.c gnushogi.h
278 genmove.o:     genmove.c gnushogi.h
279 globals.o:     globals.c gnushogi.h
280 eval.o:        eval.c eval.h gnushogi.h $(SRCDIR)/pattern.h
281 init.o:        init.c gnushogi.h $(SRCDIR)/pattern.h
282 main.o:        main.c gnushogi.h
283 makepattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h
284 pattern.o:     pattern.c gnushogi.h $(SRCDIR)/pattern.h pattern.inc
285 rawdsp.o:      rawdsp.c gnushogi.h
286 search.o:      search.c gnushogi.h
287 tcontrl.o:     tcontrl.c gnushogi.h
288 util.o:        util.c gnushogi.h
289 pat2inc.o:     pat2inc.c $(SRCDIR)/pattern.h $(SRCDIR)/gnushogi.h
290 sizetest.o:    sizetest.c $(SRCDIR)/gnushogi.h $(SRCDIR)/eval.h
291 $(PROGNAME).bbk:  $(PROGNAME)
292