forked from brianb/FreeTDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNmakefile
executable file
·388 lines (333 loc) · 12.1 KB
/
Nmakefile
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# $Id: Nmakefile,v 1.14 2011/07/07 07:24:22 freddy77 Exp $
# Build FreeTDS and assorted utilities for Win32/Win64 without an IDE.
# Makefiles, unlike Visual Studio project files, are stable over time.
# Contributed to the public domain by James K. Lowden, February 2009
# Define in the environment or on the command line:
# 1. CONFIGURATION = debug/release
# 2. PLATFORM = win32/x64
# These will determine what is built and where outputs are placed.
#
# Example invocations:
# nmake.exe -f Nmakefile -nologo PLATFORM=win32 CONFIGURATION=debug
# nmake.exe -f Nmakefile -nologo build-win32d
#
!IFNDEF PLATFORM
PLATFORM = Win32
!ENDIF
!IFNDEF CONFIGURATION
CONFIGURATION = Debug
!ENDIF
MKDIR = MD
MV = move /Y
DBLIB_DIR = src\dblib
REPLACEMENTS_DIR = src\replacements
TDS_DIR = src\tds
APPS_DIR = src\apps
DBLIB_OUT = $(DBLIB_DIR)\$(PLATFORM)\$(CONFIGURATION)
REPLACEMENTS_OUT = $(REPLACEMENTS_DIR)\$(PLATFORM)\$(CONFIGURATION)
TDS_OUT = $(TDS_DIR)\$(PLATFORM)\$(CONFIGURATION)
APPS_OUT = $(APPS_DIR)\$(PLATFORM)\$(CONFIGURATION)
DBLIB_SRC = $(DBLIB_DIR)\bcp.c \
$(DBLIB_DIR)\dblib.c \
$(DBLIB_DIR)\dbopen.c \
$(DBLIB_DIR)\dbutil.c \
$(DBLIB_DIR)\rpc.c \
$(DBLIB_DIR)\xact.c
DBLIB_OBJ = $(DBLIB_OUT)\bcp.obj \
$(DBLIB_OUT)\dblib.obj \
$(DBLIB_OUT)\dbopen.obj \
$(DBLIB_OUT)\dbutil.obj \
$(DBLIB_OUT)\rpc.obj \
$(DBLIB_OUT)\xact.obj
REPLACEMENTS_SRC = $(REPLACEMENTS_DIR)\asprintf.c \
$(REPLACEMENTS_DIR)\basename.c \
$(REPLACEMENTS_DIR)\fakepoll.c \
$(REPLACEMENTS_DIR)\gettimeofday.c \
$(REPLACEMENTS_DIR)\getopt.c \
$(REPLACEMENTS_DIR)\iconv.c \
$(REPLACEMENTS_DIR)\readpassphrase.c \
$(REPLACEMENTS_DIR)\strlcat.c \
$(REPLACEMENTS_DIR)\strlcpy.c \
$(REPLACEMENTS_DIR)\strtok_r.c \
$(REPLACEMENTS_DIR)\vasprintf.c
REPLACEMENTS_OBJ = $(REPLACEMENTS_OUT)\asprintf.obj \
$(REPLACEMENTS_OUT)\basename.obj \
$(REPLACEMENTS_OUT)\fakepoll.obj \
$(REPLACEMENTS_OUT)\gettimeofday.obj \
$(REPLACEMENTS_OUT)\getopt.obj \
$(REPLACEMENTS_OUT)\iconv.obj \
$(REPLACEMENTS_OUT)\readpassphrase.obj \
$(REPLACEMENTS_OUT)\strlcat.obj \
$(REPLACEMENTS_OUT)\strlcpy.obj \
$(REPLACEMENTS_OUT)\strtok_r.obj \
$(REPLACEMENTS_OUT)\vasprintf.obj
TDS_SRC = $(TDS_DIR)\bulk.c \
$(TDS_DIR)\challenge.c \
$(TDS_DIR)\config.c \
$(TDS_DIR)\convert.c \
$(TDS_DIR)\data.c \
$(TDS_DIR)\des.c \
$(TDS_DIR)\getmac.c \
$(TDS_DIR)\gssapi.c \
$(TDS_DIR)\hmac_md5.c \
$(TDS_DIR)\iconv.c \
$(TDS_DIR)\locale.c \
$(TDS_DIR)\log.c \
$(TDS_DIR)\login.c \
$(TDS_DIR)\md4.c \
$(TDS_DIR)\md5.c \
$(TDS_DIR)\mem.c \
$(TDS_DIR)\net.c \
$(TDS_DIR)\numeric.c \
$(TDS_DIR)\query.c \
$(TDS_DIR)\read.c \
$(TDS_DIR)\sspi.c \
$(TDS_DIR)\tds_checks.c \
$(TDS_DIR)\tdsstring.c \
$(TDS_DIR)\threadsafe.c \
$(TDS_DIR)\token.c \
$(TDS_DIR)\util.c \
$(TDS_DIR)\vstrbuild.c \
$(TDS_DIR)\win_mutex.c \
$(TDS_DIR)\write.c
TDS_OBJ = $(TDS_OUT)\bulk.obj \
$(TDS_OUT)\challenge.obj \
$(TDS_OUT)\config.obj \
$(TDS_OUT)\convert.obj \
$(TDS_OUT)\data.obj \
$(TDS_OUT)\des.obj \
$(TDS_OUT)\getmac.obj \
$(TDS_OUT)\gssapi.obj \
$(TDS_OUT)\hmac_md5.obj \
$(TDS_OUT)\iconv.obj \
$(TDS_OUT)\locale.obj \
$(TDS_OUT)\log.obj \
$(TDS_OUT)\login.obj \
$(TDS_OUT)\md4.obj \
$(TDS_OUT)\md5.obj \
$(TDS_OUT)\mem.obj \
$(TDS_OUT)\net.obj \
$(TDS_OUT)\numeric.obj \
$(TDS_OUT)\query.obj \
$(TDS_OUT)\read.obj \
$(TDS_OUT)\sspi.obj \
$(TDS_OUT)\tds_checks.obj \
$(TDS_OUT)\tdsstring.obj \
$(TDS_OUT)\threadsafe.obj \
$(TDS_OUT)\token.obj \
$(TDS_OUT)\util.obj \
$(TDS_OUT)\vstrbuild.obj \
$(TDS_OUT)\win_mutex.obj \
$(TDS_OUT)\write.obj
# not yet: $(APPS_DIR)\bsqlodbc.c
APPS_SRC = $(APPS_DIR)\bsqldb.c \
$(APPS_DIR)\datacopy.c \
$(APPS_DIR)\defncopy.c \
$(APPS_DIR)\freebcp.c \
$(APPS_DIR)\tsql.c
APPS_OBJ = $(APPS_OUT)\bsqldb.obj \
$(APPS_OUT)\datacopy.obj \
$(APPS_OUT)\defncopy.obj \
$(APPS_OUT)\freebcp.obj \
$(APPS_OUT)\tsql.obj
APPS_EXE = $(APPS_OUT)\bsqldb.exe \
$(APPS_OUT)\datacopy.exe \
$(APPS_OUT)\defncopy.exe \
$(APPS_OUT)\freebcp.exe \
$(APPS_OUT)\tsql.exe
db-lib: $(DBLIB_OUT)\db-lib.lib
apps: $(DBLIB_OUT)\db-lib.lib $(APPS_EXE)
tsql: $(APPS_OUT)\tsql.exe
bsqldb: $(APPS_OUT)\bsqldb.exe
help:
@echo targets: db-lib, apps, tsql, bsqldb
##(APPS_OUT)\bsqldb.exe: $(APPS_DIR)\bsqldb.exe $(DBLIB_OUT)\db-lib.lib
# Don't know how to create this dependency without explicitly defining every output.
#
# Sadly the environment settings for building for different architectures
# is undocumented. Microsoft's directions are to run the requisite
# batch file without explaining what it does. While it's possible to
# read the file -- and it's not complicated -- it's impossible to
# know the purpose of setting PATH/INCLUDE/LIB just so. Worse, the
# settings are per-machine, and if the file is lost, the only way to
# recreate it is to reinstall the compiler.
#
# The "solution" is to follow their advice. Run vcvarsall.bat with the
# appropriate argument to set up the environment, and go from there.
#
# As of this writing, the variables are:
# x86 Native: Vcvarsall "x86"
# x64 Native: Vcvarsall "amd64"
# x64 Cross: Vcvarsall "x86_amd64"
#
# Check that cl.exe is in the PATH. Cf. "help FOR" to see how this works.
# See above comments regarding environment setup.
#
COMPILER = cl.exe
!IF 0 != [for /f %I in ("$(COMPILER)") DO @dir /b "%~dp$$PATH:I\$(COMPILER)" > NUL:]
!MESSAGE cl.exe not in PATH
!ERROR Perhaps run vcvarsall.bat to set up the command-line development environment?
!ENDIF
all: build-win32d build-win32r build-win64d build-win64r
build-win32d:
$(MAKE) -fNmakefile -nologo apps PLATFORM=win32 CONFIGURATION=debug
build-win32r:
$(MAKE) -fNmakefile -nologo apps PLATFORM=win32 CONFIGURATION=release
build-win64d:
$(MAKE) -fNmakefile -nologo apps PLATFORM=win64 CONFIGURATION=debug
build-win64r:
$(MAKE) -fNmakefile -nologo apps PLATFORM=win64 CONFIGURATION=release
clean:
@if "" equ "$(PLATFORM)" PLATFORM not defined, see comments in Nmakefile >&2 && exit 1
@if "" equ "$(CONFIGURATION)" CONFIGURATION not defined, see comments in Nmakefile >&2 && exit 1
if exist $(DBLIB_OUT) del /q $(DBLIB_OUT)\*.obj $(DBLIB_OUT)\*.lib
if exist $(REPLACEMENTS_OUT) del /q $(REPLACEMENTS_OUT)\*.obj $(REPLACEMENTS_OUT)\*.lib
if exist $(TDS_OUT) del /q $(TDS_OUT)\*.obj $(TDS_OUT)\*.lib
if exist $(APPS_OUT) del /q $(APPS_OUT)\*.obj $(APPS_OUT)\*.exe
clean-app:
@if "" equ "$(PLATFORM)" PLATFORM not defined, see comments in Nmakefile >&2 && exit 1
@if "" equ "$(CONFIGURATION)" CONFIGURATION not defined, see comments in Nmakefile >&2 && exit 1
if exist $(APPS_OUT) del /q $(APPS_OUT)\*.obj $(APPS_OUT)\*.exe
# Create output directories
$(DBLIB_OUT) $(REPLACEMENTS_OUT) $(TDS_OUT) $(APPS_OUT):
@echo creating output directory for configuration: "$(PLATFORM)|$(CONFIGURATION)"
@if "" equ "$(PLATFORM)" PLATFORM not defined, see comments in Nmakefile >&2 && exit 1
@if "" equ "$(CONFIGURATION)" CONFIGURATION not defined, see comments in Nmakefile >&2 && exit 1
$(MKDIR) $@
#
# Some header files are generated with Perl for consistency.
# The Perl scripts are maintained in CVS, and someone developing
# with CVS needs Perl to build FreeTDS.
#
# To avoid any dependency on Perl for everyone else, the
# distribution tarball contains the pre-generated files.
#
# The preprocessing test below checks for the existence of a CVS
# directory, which wouldn't be present in a freshly unpacked tarball.
# If it finds one, it enables the code to generate the header files.
#
!IF 0 == [dir /b /ad CVS 2>NUL:]
#
# Generate distributed header files
#
include\tdsver.h:
perl -e"@a=localtime; printf qq(#undef TDS_VERSION_NO\n#define TDS_VERSION_NO \"freetds v0.83.dev.%d%02d%02d\"\n), 1900+$$a[5], 1+$$a[-1], $$a[3]" \
move /Y [email protected] $@
src\tds\tds_types.h:
perl src\tds\types.pl misc\types.txt > [email protected]
move /Y [email protected] $@
src\tds\tds_willconvert.h: src\tds\tds_willconvert.pl
perl src\tds\tds_willconvert.pl > [email protected]
$(MV) [email protected] $@
src\tds\encodings.h: src\tds\encodings.pl src\tds\alternative_character_sets.h
perl src\tds\encodings.pl src\tds > [email protected] 2> NUL:
$(MV) [email protected] $@
src\tds\num_limits.h: src\tds\num_limits.pl
perl src\tds\num_limits.pl > [email protected]
$(MV) [email protected] $@
!ENDIF
GENERATED_FILES = include\tdsver.h src\tds\tds_types.h \
src\tds\tds_willconvert.h src\tds\encodings.h src\tds\num_limits.h
$(DBLIB_OUT)\db-lib.lib: $(GENERATED_FILES) $(DBLIB_OUT) $(DBLIB_OBJ) $(REPLACEMENTS_OUT)\replacements.lib $(TDS_OUT)\tds.lib
@echo building $@ >&2
lib -nologo -out:"$@" $(DBLIB_OBJ) \
$(REPLACEMENTS_OUT)\replacements.lib \
$(TDS_OUT)\tds.lib
$(REPLACEMENTS_OUT)\replacements.lib: $(REPLACEMENTS_OUT) $(REPLACEMENTS_OBJ)
lib -nologo -out:"$@" $(REPLACEMENTS_OBJ)
$(TDS_OUT)\tds.lib: $(TDS_OUT) $(TDS_OBJ)
lib -nologo -out:"$@" $(TDS_OBJ)
#
# set compiler flags
#
INC = -I "include" -I "win32" -I "include\x64"
FLG = -nologo -W3 -Wp64 -EHsc -TC -Gm -errorReport:prompt
DEF = -D "_MBCS" -D "_LIB" -D "WIN32" \
-D MSDBLIB \
-D "_CRT_SECURE_NO_WARNINGS" -D _CRT_NONSTDC_NO_DEPRECATE
DBG = -MTd -Od -D "_DEBUG" -ZI -RTC1
REL = -MT -O2 -D "_NDEBUG" -Zi
MSLIBS = Ws2_32.lib shell32.lib
CC = cl $(CFLAGS) $(FLG) $(DEF) $(INC)
CC32 = $(CC)
CC64 = $(CC)
## Rules ##
#
# dblib
#
#c.{$(DBLIB_DIR)\win32\debug}.obj::
{$(DBLIB_DIR)}.c{$(DBLIB_DIR)\win32\debug}.obj::
$(CC32) -c $(DBG) -Fo"$(DBLIB_OUT)\\" \
-Fd"$(DBLIB_OUT)\vc80.pdb" \
$<
{$(DBLIB_DIR)\}.c{$(DBLIB_DIR)\win32\release}.obj::
$(CC32) -c $(REL) -Fo"$(DBLIB_OUT)\\" \
-Fd"$(DBLIB_OUT)\vc80.pdb" \
$<
{$(DBLIB_DIR)}.c{$(DBLIB_DIR)\x64\debug}.obj::
$(CC64) -c $(DBG) -Fo"$(DBLIB_OUT)\\" \
-Fd"$(DBLIB_OUT)\vc80.pdb" \
$<
{$(DBLIB_DIR)}.c{$(DBLIB_DIR)\x64\release}.obj::
$(CC64) -c $(REL) -Fo"$(DBLIB_OUT)\\" \
-Fd"$(DBLIB_OUT)\vc80.pdb" \
$<
#
# replacements
#
{$(REPLACEMENTS_DIR)}.c{$(REPLACEMENTS_DIR)\win32\debug}.obj::
$(CC32) -c $(DBG) -Fo"$(REPLACEMENTS_OUT)\\" \
-Fd"$(REPLACEMENTS_OUT)\vc80.pdb" \
$<
{$(REPLACEMENTS_DIR)}.c{$(REPLACEMENTS_DIR)\win32\release}.obj::
$(CC32) -c $(REL) -Fo"$(REPLACEMENTS_OUT)\\" \
-Fd"$(REPLACEMENTS_OUT)\vc80.pdb" \
$<
{$(REPLACEMENTS_DIR)}.c{$(REPLACEMENTS_DIR)\x64\debug}.obj::
$(CC64) -c $(DBG) -Fo"$(REPLACEMENTS_OUT)\\" \
-Fd"$(REPLACEMENTS_OUT)\vc80.pdb" \
$<
{$(REPLACEMENTS_DIR)}.c{$(REPLACEMENTS_DIR)\x64\release}.obj::
$(CC64) -c $(REL) -Fo"$(REPLACEMENTS_OUT)\\" \
-Fd"$(REPLACEMENTS_OUT)\vc80.pdb" \
$<
#
# tds
#
{$(TDS_DIR)}.c{$(TDS_DIR)\win32\debug}.obj::
$(CC32) -c $(DBG) -Fo"$(TDS_OUT)\\" \
-Fd"$(TDS_OUT)\vc80.pdb" \
$<
{$(TDS_DIR)}.c{$(TDS_DIR)\win32\release}.obj::
$(CC32) -c $(REL) -Fo"$(TDS_OUT)\\" \
-Fd"$(TDS_OUT)\vc80.pdb" \
$<
{$(TDS_DIR)}.c{$(TDS_DIR)\x64\debug}.obj::
$(CC64) -c $(DBG) -Fo"$(TDS_OUT)\\" \
-Fd"$(TDS_OUT)\vc80.pdb" \
$<
{$(TDS_DIR)}.c{$(TDS_DIR)\x64\release}.obj::
$(CC64) -c $(REL) -Fo"$(TDS_OUT)\\" \
-Fd"$(TDS_OUT)\vc80.pdb" \
$<
#
# Utilities
#
$(APPS_EXE): $(DBLIB_OUT)\db-lib.lib
{$(APPS_DIR)}.c{$(APPS_DIR)\win32\debug}.exe:
@if not exist $(APPS_OUT) $(MKDIR) $(APPS_OUT)
$(CC32) $(DBG) -Fd"$(APPS_OUT)\vc80.pdb" -Fe$@ \
$< -link -LIBPATH:$(DBLIB_OUT) db-lib.lib $(MSLIBS)
{$(APPS_DIR)\}.c{$(APPS_DIR)\win32\release}.exe:
@if not exist $(APPS_OUT) $(MKDIR) $(APPS_OUT)
$(CC32) $(REL) -Fe$@ -Fd"$(APPS_OUT)\vc80.pdb" \
$< -link -LIBPATH:$(DBLIB_OUT) db-lib.lib $(MSLIBS)
{$(APPS_DIR)}.c{$(APPS_DIR)\x64\debug}.exe:
@if not exist $(APPS_OUT) $(MKDIR) $(APPS_OUT)
$(CC64) $(DBG) -Fe$@ -Fd"$(APPS_OUT)\vc80.pdb" \
$< -link -LIBPATH:$(DBLIB_OUT) db-lib.lib $(MSLIBS)
{$(APPS_DIR)}.c{$(APPS_DIR)\x64\release}.exe:
@if not exist $(APPS_OUT) $(MKDIR) $(APPS_OUT)
$(CC64) $(REL) -Fe$@ -Fd"$(APPS_OUT)\vc80.pdb" \
$< -link -LIBPATH:$(DBLIB_OUT) db-lib.lib $(MSLIBS)