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