-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMakefile.vc
370 lines (325 loc) · 10.4 KB
/
Makefile.vc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
#------------------------------------------------------------------------------
# Scid (Shane's Chess Information Database)
# Copyright (C) 2000-2002, Shane Hudson ([email protected])
#
# Microsoft Visual C++ makefile for use with nmake.exe v1.62+ (VC++ 5.0+)
# VC++ 6 and 7
#------------------------------------------------------------------------------
#
# Usage:
#
# 1) Targets are:
# release -- Builds scid.exe (default).
# all -- Builds everything.
# clean -- removes the contents of $(TMP_DIR).
# hose -- removes the contents of $(TMP_DIR) and $(OUT_DIR).
# rebuild -- first cleans then builds release.
#
#
# 2) Macros usable on the commandline:
# LANG=<language>
# -- This allows you to build the GUI with only english
# and one other language
# <language>
# portbr -- Brazilian Portuguese
# czech -- Czech
# deutsch -- German
# english -- English only
# spanish -- Spanish
# francais -- French
# hungary -- Hungarian
# italian -- Italian
# nederlan -- Dutch
# norsk -- Norwegian
# polish -- Polish
# russian -- Russian
# serbian -- Serbian
# swedish -- Swedish
#
# DEBUG=1
# -- Builds debug versions of scid.exe.
#
# GLOBAL_OPT=1
# -- Enables 'Whole Program Optimization' (VC 7.0+)
#
# TMP_DIR=<path>
# OUT_DIR=<path>
# -- Allows the intermediate and output directories to be
# changed.
# $(OUT_DIR) is assumed to be .\(Release|Debug) based
# on if debug is requested or not.
# $(TMP_DIR) will be $(OUT_DIR)\Temp by default.
#
# TCL_DIR=<path>
# -- Allows the Tcl directory location to be changed. If
# this is not set, the makefile will attempt to locate
# Tcl in its default install directory.
# "C:\Program Files\Tcl"
#
# 3) Examples:
#
# Basic syntax of calling nmake looks like this:
# nmake -f makefile.vc [target|macrodef [target|macrodef] [...]]
#
# Release
# c:\scid_src>nmake -f makefile.vc release
#
# Release with English and French only
# c:\scid_src>nmake -f makefile.vc release LANG=francais
#
# Release with Tcl in a non-default directory
# c:\scid_src>nmake -f makefile.vc release TCL_DIR="C:\Temp\Tcl"
#
# Everything with Tcl and Tk in a non-default directory
# c:\scid_src>nmake -f makefile.vc all TCL_DIR="E:\Tcl" TK_DIR="E:\Tcl"
#------------------------------------------------------------------------------
!message ===============================================================================
#--------------------------------------------------------------------
# Environment Setup
#--------------------------------------------------------------------
## Set compiler and linker
#
CC = @cl
LD = @link
RC = @rc
## Set Output and Intermediate directory
#
!if "$(OUT_DIR)" == ""
!if "$(DEBUG)" == "1"
OUT_DIR = .\Debug
!else
OUT_DIR = .\Release
!endif
!endif
!message *** Output directory = '$(OUT_DIR)'
!ifndef TMP_DIR
TMP_DIR = $(OUT_DIR)\Temp
!endif
!message *** Intermediate directory = '$(TMP_DIR)'
## TCL_VERSION: Tcl/Tk version
# This should be "85" for Tcl/Tk 8.5, etc.
#
TCL_VERSION = 86
## SCID_INCLUDES: included files from Tcl/Tk
# This will try to find your Tcl/Tk installation.
#
!ifndef TCL_DIR
!if exist("C:\Tcl\include\tcl.h")
TCL_DIR = C:\Tcl
!else
MSG=^
*** Don't know where Tcl is. Set the TCL_DIR macro.
!error $(MSG)
!endif
!else
!if exist("$(TCL_DIR)\include\tcl.h")
!elseif exist("$(TCL_DIR)\generic\tcl.h")
MSG =^
*** Tcl source found. The TCL_DIR macro must point to the installed version.
!error $(MSG)
!else
MSG =^
*** Don't know where Tcl is. The TCL_DIR macro doesn't appear correct.
!error $(MSG)
!endif
!endif
TCL_INCLUDES = -I"$(TCL_DIR)\include"
!message *** Tcl directory = '$(TCL_DIR)'
SCID_INCLUDES = $(TCL_INCLUDES)
!if exist("$(TCL_DIR)\lib\tcl$(TCL_VERSION)t.lib")
TCL_LIB = "$(TCL_DIR)\lib\tcl$(TCL_VERSION)t.lib"
!elseif exist("$(TCL_DIR)\lib\tcl$(TCL_VERSION).lib")
TCL_LIB = "$(TCL_DIR)\lib\tcl$(TCL_VERSION).lib"
!else
MSG =^
*** The file tcl$(TCL_VERSION).lib appears to be missing or the wrong version.
!error $(MSG)
!endif
## SCID_EXECS: all the executable programs compiled from C++ files.
# Note: only "scid.exe" is compiled by default.
#
SCID_EXECS = \
scid.exe \
## SCID_OBJS: not all the .obj files that make up Scid, just the standard
# files that most of the Scid programs use.
#
SCID_OBJS = \
$(TMP_DIR)\codec_scid4.obj \
$(TMP_DIR)\game.obj \
$(TMP_DIR)\matsig.obj \
$(TMP_DIR)\misc.obj \
$(TMP_DIR)\position.obj \
$(TMP_DIR)\stored.obj \
$(TMP_DIR)\textbuf.obj \
$(TMP_DIR)\scid.res \
$(TMP_DIR)\sortcache.obj \
$(TMP_DIR)\scidbase.obj \
$(TMP_DIR)\spellchk.obj \
$(TMP_DIR)\filter.obj \
$(TMP_DIR)\searchindex.obj \
$(TMP_DIR)\sc_base.obj \
$(TMP_DIR)\sc_filter.obj \
$(TMP_DIR)\sc_info.obj \
$(TMP_DIR)\dbasepool.obj \
$(TMP_DIR)\polyglot\attack.obj $(TMP_DIR)\polyglot\board.obj $(TMP_DIR)\polyglot\book.obj \
$(TMP_DIR)\polyglot\colour.obj $(TMP_DIR)\polyglot\fen.obj $(TMP_DIR)\polyglot\hash.obj \
$(TMP_DIR)\polyglot\list.obj $(TMP_DIR)\polyglot\main.obj $(TMP_DIR)\polyglot\move.obj \
$(TMP_DIR)\polyglot\move_do.obj $(TMP_DIR)\polyglot\move_gen.obj $(TMP_DIR)\polyglot\move_legal.obj $(TMP_DIR)\polyglot\option.obj \
$(TMP_DIR)\polyglot\piece.obj $(TMP_DIR)\polyglot\random.obj \
$(TMP_DIR)\polyglot\san.obj $(TMP_DIR)\polyglot\square.obj $(TMP_DIR)\polyglot\util.obj
## SCID_XOBJS: all the extra .obj files that make up Scid.
#
SCID_XOBJS = \
$(SCID_OBJS) \
$(TMP_DIR)\crosstab.obj \
$(TMP_DIR)\engine.obj \
$(TMP_DIR)\optable.obj \
$(TMP_DIR)\pbook.obj
#--------------------------------------------------------------------
# Compile flags
#--------------------------------------------------------------------
## OPTIMIZE: Optimization
# -O2 :Maximize Speed
# -Op :Improve Float Consistency
# -GL :Whole Program Optimization
# -QI0f :Enable Pentium 0x0f Fix
#
!if "$(DEBUG)" == "1"
OPTIMIZE = -ZI -Fd$(TMP_DIR)\ -Od
!message *** Build 'Debug' Version = yes
!else
OPTIMIZE = -O2 /EHsc
!message *** Build 'Release' Version = yes
!if "$(GLOBAL_OPT)" == "1"
OPTIMIZE = $(OPTIMIZE) -GL
!message *** Whole Program Optimization = yes
!endif
!endif
## WARNINGS: I always compile with all warnings on (-Wall)
# Note: (-W2) is the default for MS compiler.
#
!if "$(DEBUG)" == "1"
WARNINGS = -W3
!else
WARNINGS = -W2
!endif
## PROFILE: Set profile for compiling
# -DNDEBUG :Turn off debug code
# -DWIN32 :Target Windows 32bit
# -DWIN32_LEAN_AND_MEAN :Speeds building times by excluding some less
# common APIs
#
!if "$(DEBUG)" == "1"
PROFILE = -D_DEBUG -DDEBUG
!else
PROFILE = -DNDEBUG
!endif
PROFILE = $(PROFILE) -DWIN32 -DWIN32_LEAN_AND_MEAN
## CFLAGS: C++ compiler flags
# -c :Compile Without linking
#
CFLAGS = $(PROFILE) $(OPTIMIZE) $(WARNINGS) \
$(SCID_INCLUDES) -c -nologo -std:c++20
!message *** CFLAGS: $(CFLAGS)
#--------------------------------------------------------------------
# Link flags
#--------------------------------------------------------------------
## LDFLAGS: C++ linker flags
# -LTCG :Link-time Code Generation
#
!if "$(DEBUG)" == "1"
LDFLAGS = -debug:full
!else
LDFLAGS = -opt:icf,3
!if "$(GLOBAL_OPT)" == "1"
LDFLAGS = $(LDFLAGS) -ltcg:status
!endif
!endif
LDFLAGS = $(LDFLAGS) -nologo
!message *** LDFLAGS: $(LDFLAGS)
!message ===============================================================================
!message
#--------------------------------------------------------------------
# Project specific targets
#--------------------------------------------------------------------
release: setup scid.exe
all: setup $(SCID_EXECS)
setup:
@if not exist $(OUT_DIR)\nul \
@echo *** Creating directory '$(OUT_DIR)'...
@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
@if not exist $(TMP_DIR)\nul \
@echo *** Creating directory '$(TMP_DIR)'...
@if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
@if not exist $(TMP_DIR)\polyglot\nul \
@echo *** Creating directory '$(TMP_DIR)\polyglot'...
@if not exist $(TMP_DIR)\polyglot\nul mkdir $(TMP_DIR)\polyglot
@if not exist $(OUT_DIR)\books\nul \
@echo *** Creating directory '$(OUT_DIR)\books'...
@if not exist $(OUT_DIR)\books\nul mkdir $(OUT_DIR)\books
scid.exe: $(TMP_DIR)\scid.obj $(SCID_XOBJS)
@echo *** scid.exe
$(LD) $(LDFLAGS) $(TMP_DIR)\scid.obj $(SCID_XOBJS) $(TCL_LIB) \
/out:$(OUT_DIR)\scid.exe \
/subsystem:windows /entry:mainCRTStartup
#--------------------------------------------------------------------
# Special case object file targets
#--------------------------------------------------------------------
$(TMP_DIR)\scid.obj: src\tkscid.cpp
$(CC) $(CFLAGS) /Fo$@ $?
#--------------------------------------------------------------------
# Implicit rules
#--------------------------------------------------------------------
{src}.cpp{$(TMP_DIR)}.obj:
$(CC) $(CFLAGS) -Fo$(TMP_DIR)\ $<
{src\egtb}.cpp{$(TMP_DIR)}.obj:
$(CC) $(CFLAGS) -Fo$(TMP_DIR)\ $<
{src\egtb}.c{$(TMP_DIR)}.obj:
$(CC) $(CFLAGS) -Fo$(TMP_DIR)\ $<
{src\polyglot}.cpp{$(TMP_DIR)\polyglot}.obj:
$(CC) $(CFLAGS) -Fo$(TMP_DIR)\polyglot\ $<
{resources\win}.rc{$(TMP_DIR)}.res:
$(RC) -r -Fo$(TMP_DIR)\$(@B).res $<
#--------------------------------------------------------------------
# Clean up
#--------------------------------------------------------------------
!if "$(OS)" == "Windows_NT"
RMDIR = rmdir /S /Q
!else
RMDIR = deltree /Y
!endif
## clean:
# This will remove .obj files.
#
clean:
@echo Cleaning...
@echo.
@if exist $(TMP_DIR)\nul @echo *** Removing directory '$(TMP_DIR)'...
@if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
@echo.
@echo Finished
@echo ===============================================================================
## hose:
# This will remove .exe and .obj files.
#
hose:
@echo Hosing...
@echo.
@if exist $(OUT_DIR)\nul @echo *** Removing directory '$(OUT_DIR)'...
@if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
@echo.
@echo Finished
@echo ===============================================================================
## rebuild:
# This will clean and then rebuild .obj and .exe files.
#
rebuild:
@echo Cleaning...
@echo.
@$(MAKE) -fmakefile.vc -$(MAKEFLAGS) clean -nologo > nul
@echo Building...
@echo.
@$(MAKE) -fmakefile.vc -$(MAKEFLAGS) -nologo
@echo.
@echo Finished
@echo ===============================================================================