Stop hardcoding filenames inside pat2inc, use commandline parameters.
[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
98
99 all:
100         @echo No target specified.
101
102
103 #
104 # Source files.
105 #
106
107 COMMONFILES = \
108                 globals.o      \
109                 init-common.o    \
110                 pattern-common.o
111
112 NOTCOMMONFILES = \
113                 attacks.o      \
114                 book.o         \
115                 commondsp.o    \
116                 @CURSESDSP@    \
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 $(PROGNAME):
137         $(CC) $(CFLAGS) -o $(PROGNAME) $(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 genmove.o: genmove.c
167         $(CC) $(CFLAGS) -c $<
168
169 globals.o: globals.c
170         $(CC) $(CFLAGS) -c $<
171
172 eval.o: eval.c
173         $(CC) $(CFLAGS) -c $<
174
175 init.o: init.c
176         $(CC)  $(CFLAGS) -c $<
177
178 init-common.o: init-common.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) -c $<
189
190 pattern.o: pattern.c
191         $(CC)  $(CFLAGS) -c $<
192
193 pattern-common.o: pattern-common.c
194         $(CC)  $(CFLAGS) -c $<
195
196 rawdsp.o: rawdsp.c
197         $(CC) $(CFLAGS) -c $<
198
199 search.o: search.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) -c $<
213
214 sizetest.o: sizetest.c
215         $(CC) $(CFLAGS) -c $<
216
217 pattern.inc: $(PATTERNFILE) pat2inc
218         ./pat2inc $< $@
219
220 #
221 # Other targets.
222 #
223
224 $(PROGNAME).bbk:
225         @if [ -f ./$(PROGNAME).bbk ]; then rm ./$(PROGNAME).bbk; fi
226         echo quit > test
227         cat $(ROOT)/misc/$(PROGNAME).tbk > _tmp_t
228         cat test | ./$(PROGNAME) -R -b _tmp_t -B ./$(PROGNAME).bbk -S 8000 -P 40 3 0
229         rm test _tmp_t
230         @echo
231
232
233 #
234 # Installation.
235 #
236
237 install: $(PROGNAME)
238         strip $(PROGNAME)
239         $(INSTALL_PROGRAM) -d $(BINDIR)
240         $(INSTALL_PROGRAM) -d $(LIBDIR)
241         $(INSTALL_PROGRAM) -d $(MANDIR)
242         $(INSTALL_PROGRAM) -d $(INFODIR)
243         $(INSTALL_PROGRAM) $(PROGNAME) $(BINDIR)
244         $(INSTALL_DATA)    $(ROOT)/doc/gnushogi.6     $(MANDIR)
245         $(INSTALL_DATA)    $(ROOT)/doc/gnushogi.info* $(INFODIR)
246         $(INSTALL_DATA)    $(PROGNAME).bbk $(LIBDIR)/$(PROGNAME).bbk
247
248
249 #
250 # Cleanup.
251 #
252
253 CLEANFILES = *.o gnushogi gnuminishogi sizetest pat2inc CLp* *.bbk
254
255 clean: 
256         @for file in $(CLEANFILES); do \
257         if [ -f $$file ]; then rm $$file; fi; \
258         done
259
260
261 #
262 # Dependencies.
263 #
264
265 $(PROGNAME):   $(GNUSHOGI_FILES)
266 pat2inc:       $(PAT2INCFILES)
267 sizetest:      sizetest.o 
268 attacks.o:     attacks.c gnushogi.h
269 book.o:        book.c gnushogi.h
270 commondsp.o:   commondsp.c gnushogi.h
271 cursesdsp.o:   cursesdsp.c gnushogi.h
272 genmove.o:     genmove.c gnushogi.h
273 globals.o:     globals.c gnushogi.h
274 eval.o:        eval.c eval.h gnushogi.h $(SRCDIR)/pattern.h
275 init.o:        init.c gnushogi.h $(SRCDIR)/pattern.h
276 init-common.o: init-common.c gnushogi.h
277 main.o:        main.c gnushogi.h
278 makepattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h
279 pattern.o:     pattern.c gnushogi.h $(SRCDIR)/pattern.h pattern.inc
280 rawdsp.o:      rawdsp.c gnushogi.h
281 search.o:      search.c gnushogi.h
282 tcontrl.o:     tcontrl.c gnushogi.h
283 util.o:        util.c gnushogi.h
284 pat2inc.o:     pat2inc.c $(SRCDIR)/pattern.h $(SRCDIR)/gnushogi.h
285 sizetest.o:    sizetest.c $(SRCDIR)/gnushogi.h $(SRCDIR)/eval.h
286 $(PROGNAME).bbk:  $(PROGNAME)
287