xref: /freebsd/contrib/sqlite3/Makefile.msc (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
1#### DO NOT EDIT ####
2# This makefile is automatically generated from the Makefile.msc at
3# the root of the canonical SQLite source tree (not the
4# amalgamation tarball) using the tool/mkmsvcmin.tcl
5# script.
6#
7
8#
9# nmake Makefile for SQLite
10#
11###############################################################################
12############################## START OF OPTIONS ###############################
13###############################################################################
14
15# The toplevel directory of the source tree.  This is the directory
16# that contains this "Makefile.msc".
17#
18TOP = .
19
20
21# Set this non-0 to enable full warnings (-W4, etc) when compiling.
22#
23!IFNDEF USE_FULLWARN
24USE_FULLWARN = 1
25!ENDIF
26
27# Set this non-0 to enable treating warnings as errors (-WX, etc) when
28# compiling.
29#
30!IFNDEF USE_FATAL_WARN
31USE_FATAL_WARN = 0
32!ENDIF
33
34# Set this non-0 to enable full runtime error checks (-RTC1, etc).  This
35# has no effect if (any) optimizations are enabled.
36#
37!IFNDEF USE_RUNTIME_CHECKS
38USE_RUNTIME_CHECKS = 0
39!ENDIF
40
41# Set this non-0 to create a SQLite amalgamation file that excludes the
42# various built-in extensions.
43#
44!IFNDEF MINIMAL_AMALGAMATION
45MINIMAL_AMALGAMATION = 0
46!ENDIF
47
48# Set this non-0 to use "stdcall" calling convention for the core library
49# and shell executable.
50#
51!IFNDEF USE_STDCALL
52USE_STDCALL = 0
53!ENDIF
54
55# Set this non-0 to have the shell executable link against the core dynamic
56# link library.
57#
58!IFNDEF DYNAMIC_SHELL
59DYNAMIC_SHELL = 0
60!ENDIF
61
62# Set this non-0 to enable extra code that attempts to detect misuse of the
63# SQLite API.
64#
65!IFNDEF API_ARMOR
66API_ARMOR = 0
67!ENDIF
68
69# If necessary, create a list of harmless compiler warnings to disable when
70# compiling the various tools.  For the SQLite source code itself, warnings,
71# if any, will be disabled from within it.
72#
73!IFNDEF NO_WARN
74!IF $(USE_FULLWARN)!=0
75NO_WARN = -wd4054 -wd4055 -wd4100 -wd4127 -wd4130 -wd4152 -wd4189 -wd4206
76NO_WARN = $(NO_WARN) -wd4210 -wd4232 -wd4244 -wd4305 -wd4306 -wd4702 -wd4706
77!ENDIF
78!ENDIF
79
80# Set this non-0 to use the library paths and other options necessary for
81# Windows Phone 8.1.
82#
83!IFNDEF USE_WP81_OPTS
84USE_WP81_OPTS = 0
85!ENDIF
86
87# Set this non-0 to split the SQLite amalgamation file into chunks to
88# be used for debugging with Visual Studio.
89#
90!IFNDEF SPLIT_AMALGAMATION
91SPLIT_AMALGAMATION = 0
92!ENDIF
93
94
95# Set this non-0 to dynamically link to the MSVC runtime library.
96#
97!IFNDEF USE_CRT_DLL
98USE_CRT_DLL = 0
99!ENDIF
100
101# Set this non-0 to link to the RPCRT4 library.
102#
103!IFNDEF USE_RPCRT4_LIB
104USE_RPCRT4_LIB = 0
105!ENDIF
106
107# Set this non-0 to generate assembly code listings for the source code
108# files.
109#
110!IFNDEF USE_LISTINGS
111USE_LISTINGS = 0
112!ENDIF
113
114# Set this non-0 to attempt setting the native compiler automatically
115# for cross-compiling the command line tools needed during the compilation
116# process.
117#
118!IFNDEF XCOMPILE
119XCOMPILE = 0
120!ENDIF
121
122# Set this non-0 to use the native libraries paths for cross-compiling
123# the command line tools needed during the compilation process.
124#
125!IFNDEF USE_NATIVE_LIBPATHS
126USE_NATIVE_LIBPATHS = 0
127!ENDIF
128
129# Set this 0 to skip the compiling and embedding of version resources.
130#
131!IFNDEF USE_RC
132USE_RC = 1
133!ENDIF
134
135# Set this non-0 to compile binaries suitable for the WinRT environment.
136# This setting does not apply to any binaries that require Tcl to operate
137# properly (i.e. the text fixture, etc).
138#
139!IFNDEF FOR_WINRT
140FOR_WINRT = 0
141!ENDIF
142
143# Set this non-0 to compile binaries suitable for the UWP environment.
144# This setting does not apply to any binaries that require Tcl to operate
145# properly (i.e. the text fixture, etc).
146#
147!IFNDEF FOR_UWP
148FOR_UWP = 0
149!ENDIF
150
151# Set this non-0 to compile binaries suitable for the Windows 10 platform.
152#
153!IFNDEF FOR_WIN10
154FOR_WIN10 = 0
155!ENDIF
156
157
158# Set this to non-0 to create and use PDBs.
159#
160!IFNDEF SYMBOLS
161SYMBOLS = 1
162!ENDIF
163
164# Set this to non-0 to use the SQLite debugging heap subsystem.
165#
166!IFNDEF MEMDEBUG
167MEMDEBUG = 0
168!ENDIF
169
170# Set this to non-0 to use the Win32 native heap subsystem.
171#
172!IFNDEF WIN32HEAP
173WIN32HEAP = 0
174!ENDIF
175
176# Set this to non-0 to enable OSTRACE() macros, which can be useful when
177# debugging.
178#
179!IFNDEF OSTRACE
180OSTRACE = 0
181!ENDIF
182
183# Set this to one of the following values to enable various debugging
184# features.  Each level includes the debugging options from the previous
185# levels.  Currently, the recognized values for DEBUG are:
186#
187# 0 == NDEBUG: Disables assert() and other runtime diagnostics.
188# 1 == SQLITE_ENABLE_API_ARMOR: extra attempts to detect misuse of the API.
189# 2 == Disables NDEBUG and all optimizations and then enables PDBs.
190# 3 == SQLITE_DEBUG: Enables various diagnostics messages and code.
191# 4 == SQLITE_WIN32_MALLOC_VALIDATE: Validate the Win32 native heap per call.
192# 5 == SQLITE_DEBUG_OS_TRACE: Enables output from the OSTRACE() macros.
193# 6 == SQLITE_ENABLE_IOTRACE: Enables output from the IOTRACE() macros.
194#
195!IFNDEF DEBUG
196DEBUG = 0
197!ENDIF
198
199
200# Enable use of available compiler optimizations?  Normally, this should be
201# non-zero.  Setting this to zero, thus disabling all compiler optimizations,
202# can be useful for testing.
203#
204!IFNDEF OPTIMIZATIONS
205OPTIMIZATIONS = 2
206!ENDIF
207
208# Set this to non-0 to enable support for the session extension.
209#
210!IFNDEF SESSION
211SESSION = 0
212!ENDIF
213
214# Set this to non-0 to enable support for the rbu extension.
215#
216!IFNDEF RBU
217RBU = 0
218!ENDIF
219
220# Set the source code file to be used by executables and libraries when
221# they need the amalgamation.
222#
223!IFNDEF SQLITE3C
224!IF $(SPLIT_AMALGAMATION)!=0
225SQLITE3C = sqlite3-all.c
226!ELSE
227SQLITE3C = sqlite3.c
228!ENDIF
229!ENDIF
230
231# Set the include code file to be used by executables and libraries when
232# they need SQLite.
233#
234!IFNDEF SQLITE3H
235SQLITE3H = sqlite3.h
236!ENDIF
237
238# This is the name to use for the SQLite dynamic link library (DLL).
239#
240!IFNDEF SQLITE3DLL
241!IF $(FOR_WIN10)!=0
242SQLITE3DLL = winsqlite3.dll
243!ELSE
244SQLITE3DLL = sqlite3.dll
245!ENDIF
246!ENDIF
247
248# This is the name to use for the SQLite import library (LIB).
249#
250!IFNDEF SQLITE3LIB
251!IF $(FOR_WIN10)!=0
252SQLITE3LIB = winsqlite3.lib
253!ELSE
254SQLITE3LIB = sqlite3.lib
255!ENDIF
256!ENDIF
257
258# This is the name to use for the SQLite shell executable (EXE).
259#
260!IFNDEF SQLITE3EXE
261!IF $(FOR_WIN10)!=0
262SQLITE3EXE = winsqlite3shell.exe
263!ELSE
264SQLITE3EXE = sqlite3.exe
265!ENDIF
266!ENDIF
267
268# This is the argument used to set the program database (PDB) file for the
269# SQLite shell executable (EXE).
270#
271!IFNDEF SQLITE3EXEPDB
272!IF $(FOR_WIN10)!=0
273SQLITE3EXEPDB =
274!ELSE
275SQLITE3EXEPDB = /pdb:sqlite3sh.pdb
276!ENDIF
277!ENDIF
278
279
280# These are the "standard" SQLite compilation options used when compiling for
281# the Windows platform.
282#
283!IFNDEF OPT_FEATURE_FLAGS
284!IF $(MINIMAL_AMALGAMATION)==0
285OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1
286OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1
287OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_GEOPOLY=1
288OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_STMTVTAB=1
289OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBPAGE_VTAB=1
290OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBSTAT_VTAB=1
291OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_BYTECODE_VTAB=1
292!ENDIF
293OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
294!ENDIF
295
296# Should the session extension be enabled?  If so, add compilation options
297# to enable it.
298#
299!IF $(SESSION)!=0
300OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1
301OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1
302!ENDIF
303
304# Always enable math functions on Windows
305OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_MATH_FUNCTIONS
306
307# Should the rbu extension be enabled?  If so, add compilation options
308# to enable it.
309#
310!IF $(RBU)!=0
311OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RBU=1
312!ENDIF
313
314# These are the "extended" SQLite compilation options used when compiling for
315# the Windows 10 platform.
316#
317!IFNDEF EXT_FEATURE_FLAGS
318!IF $(FOR_WIN10)!=0
319EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS4=1
320EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_SYSTEM_MALLOC=1
321EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_OMIT_LOCALTIME=1
322!ELSE
323EXT_FEATURE_FLAGS =
324!ENDIF
325!ENDIF
326
327###############################################################################
328############################### END OF OPTIONS ################################
329###############################################################################
330
331# When compiling for the Windows 10 platform, the PLATFORM macro must be set
332# to an appropriate value (e.g. x86, x64, arm, arm64, etc).
333#
334!IF $(FOR_WIN10)!=0
335!IFNDEF PLATFORM
336!ERROR Using the FOR_WIN10 option requires a value for PLATFORM.
337!ENDIF
338!ENDIF
339
340# This assumes that MSVC is always installed in 32-bit Program Files directory
341# and sets the variable for use in locating other 32-bit installs accordingly.
342#
343PROGRAMFILES_X86 = $(VCINSTALLDIR)\..\..
344PROGRAMFILES_X86 = $(PROGRAMFILES_X86:\\=\)
345
346# Check for the predefined command macro CC.  This should point to the compiler
347# binary for the target platform.  If it is not defined, simply define it to
348# the legacy default value 'cl.exe'.
349#
350!IFNDEF CC
351CC = cl.exe
352!ENDIF
353
354# Check for the predefined command macro CSC.  This should point to a working
355# C Sharp compiler binary.  If it is not defined, simply define it to the
356# legacy default value 'csc.exe'.
357#
358!IFNDEF CSC
359CSC = csc.exe
360!ENDIF
361
362# Check for the command macro LD.  This should point to the linker binary for
363# the target platform.  If it is not defined, simply define it to the legacy
364# default value 'link.exe'.
365#
366!IFNDEF LD
367LD = link.exe
368!ENDIF
369
370# Check for the predefined command macro RC.  This should point to the resource
371# compiler binary for the target platform.  If it is not defined, simply define
372# it to the legacy default value 'rc.exe'.
373#
374!IFNDEF RC
375RC = rc.exe
376!ENDIF
377
378# Check for the MSVC runtime library path macro.  Otherwise, this value will
379# default to the 'lib' directory underneath the MSVC installation directory.
380#
381!IFNDEF CRTLIBPATH
382CRTLIBPATH = $(VCINSTALLDIR)\lib
383!ENDIF
384
385CRTLIBPATH = $(CRTLIBPATH:\\=\)
386
387# Check for the command macro NCC.  This should point to the compiler binary
388# for the platform the compilation process is taking place on.  If it is not
389# defined, simply define it to have the same value as the CC macro.  When
390# cross-compiling, it is suggested that this macro be modified via the command
391# line (since nmake itself does not provide a built-in method to guess it).
392# For example, to use the x86 compiler when cross-compiling for x64, a command
393# line similar to the following could be used (all on one line):
394#
395#     nmake /f Makefile.msc sqlite3.dll
396#           XCOMPILE=1 USE_NATIVE_LIBPATHS=1
397#
398# Alternatively, the full path and file name to the compiler binary for the
399# platform the compilation process is taking place may be specified (all on
400# one line):
401#
402#     nmake /f Makefile.msc sqlite3.dll
403#           "NCC=""%VCINSTALLDIR%\bin\cl.exe"""
404#           USE_NATIVE_LIBPATHS=1
405#
406!IFDEF NCC
407NCC = $(NCC:\\=\)
408!ELSEIF $(XCOMPILE)!=0
409NCC = "$(VCINSTALLDIR)\bin\$(CC)"
410NCC = $(NCC:\\=\)
411!ELSE
412NCC = $(CC)
413!ENDIF
414
415# Check for the MSVC native runtime library path macro.  Otherwise,
416# this value will default to the 'lib' directory underneath the MSVC
417# installation directory.
418#
419!IFNDEF NCRTLIBPATH
420NCRTLIBPATH = $(VCINSTALLDIR)\lib
421!ENDIF
422
423NCRTLIBPATH = $(NCRTLIBPATH:\\=\)
424
425# Check for the Platform SDK library path macro.  Otherwise, this
426# value will default to the 'lib' directory underneath the Windows
427# SDK installation directory (the environment variable used appears
428# to be available when using Visual C++ 2008 or later via the
429# command line).
430#
431!IFNDEF NSDKLIBPATH
432NSDKLIBPATH = $(WINDOWSSDKDIR)\lib
433!ENDIF
434
435NSDKLIBPATH = $(NSDKLIBPATH:\\=\)
436
437# Check for the UCRT library path macro.  Otherwise, this value will
438# default to the version-specific, platform-specific 'lib' directory
439# underneath the Windows SDK installation directory.
440#
441!IFNDEF UCRTLIBPATH
442UCRTLIBPATH = $(WINDOWSSDKDIR)\lib\$(WINDOWSSDKLIBVERSION)\ucrt\$(PLATFORM)
443!ENDIF
444
445UCRTLIBPATH = $(UCRTLIBPATH:\\=\)
446
447# C compiler and options for use in building executables that
448# will run on the platform that is doing the build.
449#
450!IF $(USE_FULLWARN)!=0
451BCC = $(NCC) -nologo -W4 -Fd$*.pdb $(CCOPTS) $(BCCOPTS)
452!ELSE
453BCC = $(NCC) -nologo -W3 -Fd$*.pdb $(CCOPTS) $(BCCOPTS)
454!ENDIF
455
456# Check if assembly code listings should be generated for the source
457# code files to be compiled.
458#
459!IF $(USE_LISTINGS)!=0
460BCC = $(BCC) -FAcs
461!ENDIF
462
463# Check if the native library paths should be used when compiling
464# the command line tools used during the compilation process.  If
465# so, set the necessary macro now.
466#
467!IF $(USE_NATIVE_LIBPATHS)!=0
468NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)"
469
470!IFDEF NUCRTLIBPATH
471NUCRTLIBPATH = $(NUCRTLIBPATH:\\=\)
472NLTLIBPATHS = $(NLTLIBPATHS) "/LIBPATH:$(NUCRTLIBPATH)"
473!ENDIF
474!ENDIF
475
476# C compiler and options for use in building executables that
477# will run on the target platform.  (BCC and TCC are usually the
478# same unless your are cross-compiling.)
479#
480!IF $(USE_FULLWARN)!=0
481TCC = $(CC) -nologo -W4 -DINCLUDE_MSVC_H=1 $(CCOPTS) $(TCCOPTS)
482!ELSE
483TCC = $(CC) -nologo -W3 $(CCOPTS) $(TCCOPTS)
484!ENDIF
485
486# Check if warnings should be treated as errors when compiling.
487#
488!IF $(USE_FATAL_WARN)!=0
489TCC = $(TCC) -WX
490!ENDIF
491
492TCC = $(TCC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -fp:precise
493RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) $(RCOPTS) $(RCCOPTS)
494
495# Check if we want to use the "stdcall" calling convention when compiling.
496# This is not supported by the compilers for non-x86 platforms.  It should
497# also be noted here that building any target with these "stdcall" options
498# will most likely fail if the Tcl library is also required.  This is due
499# to how the Tcl library functions are declared and exported (i.e. without
500# an explicit calling convention, which results in "cdecl").
501#
502!IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
503!IF "$(PLATFORM)"=="x86"
504CORE_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
505SHELL_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
506!ELSE
507!IFNDEF PLATFORM
508CORE_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
509SHELL_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
510!ELSE
511CORE_CCONV_OPTS =
512SHELL_CCONV_OPTS =
513!ENDIF
514!ENDIF
515!ELSE
516CORE_CCONV_OPTS =
517SHELL_CCONV_OPTS =
518!ENDIF
519
520# These are additional compiler options used for the core library.
521#
522!IFNDEF CORE_COMPILE_OPTS
523!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
524CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS) -DSQLITE_API=__declspec(dllexport)
525!ELSE
526CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS)
527!ENDIF
528!ENDIF
529
530# These are the additional targets that the core library should depend on
531# when linking.
532#
533!IFNDEF CORE_LINK_DEP
534!IF $(DYNAMIC_SHELL)!=0
535CORE_LINK_DEP =
536!ELSEIF $(FOR_WIN10)==0 || "$(PLATFORM)"=="x86"
537CORE_LINK_DEP = sqlite3.def
538!ELSE
539CORE_LINK_DEP =
540!ENDIF
541!ENDIF
542
543# These are additional linker options used for the core library.
544#
545!IFNDEF CORE_LINK_OPTS
546!IF $(DYNAMIC_SHELL)!=0
547CORE_LINK_OPTS =
548!ELSEIF $(FOR_WIN10)==0 || "$(PLATFORM)"=="x86"
549CORE_LINK_OPTS = /DEF:sqlite3.def
550!ELSE
551CORE_LINK_OPTS =
552!ENDIF
553!ENDIF
554
555# These are additional compiler options used for the shell executable.
556#
557!IFNDEF SHELL_COMPILE_OPTS
558!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
559SHELL_COMPILE_OPTS = $(SHELL_CCONV_OPTS) -DSQLITE_API=__declspec(dllimport)
560!ELSE
561SHELL_COMPILE_OPTS = $(SHELL_CCONV_OPTS)
562!ENDIF
563!ENDIF
564
565# This is the source code that the shell executable should be compiled
566# with.
567#
568!IFNDEF SHELL_CORE_SRC
569!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
570SHELL_CORE_SRC =
571!ELSE
572SHELL_CORE_SRC = $(SQLITE3C)
573!ENDIF
574!ENDIF
575
576# This is the core library that the shell executable should depend on.
577#
578!IFNDEF SHELL_CORE_DEP
579!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
580SHELL_CORE_DEP = $(SQLITE3DLL)
581!ELSE
582SHELL_CORE_DEP =
583!ENDIF
584!ENDIF
585
586
587# This is the core library that the shell executable should link with.
588#
589!IFNDEF SHELL_CORE_LIB
590!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
591SHELL_CORE_LIB = $(SQLITE3LIB)
592!ELSE
593SHELL_CORE_LIB =
594!ENDIF
595!ENDIF
596
597# These are additional linker options used for the shell executable.
598#
599!IFNDEF SHELL_LINK_OPTS
600SHELL_LINK_OPTS = $(SHELL_CORE_LIB)
601!ENDIF
602
603# Check if assembly code listings should be generated for the source
604# code files to be compiled.
605#
606!IF $(USE_LISTINGS)!=0
607TCC = $(TCC) -FAcs
608!ENDIF
609
610# When compiling the library for use in the WinRT environment,
611# the following compile-time options must be used as well to
612# disable use of Win32 APIs that are not available and to enable
613# use of Win32 APIs that are specific to Windows 8 and/or WinRT.
614#
615!IF $(FOR_WINRT)!=0
616TCC = $(TCC) -DSQLITE_OS_WINRT=1
617RCC = $(RCC) -DSQLITE_OS_WINRT=1
618TCC = $(TCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
619RCC = $(RCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
620!ENDIF
621
622# C compiler options for the Windows 10 platform (needs MSVC 2015).
623#
624!IF $(FOR_WIN10)!=0
625TCC = $(TCC) /d2guard4 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
626BCC = $(BCC) /d2guard4 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
627!ENDIF
628
629# Also, we need to dynamically link to the correct MSVC runtime
630# when compiling for WinRT (e.g. debug or release) OR if the
631# USE_CRT_DLL option is set to force dynamically linking to the
632# MSVC runtime library.
633#
634!IF $(FOR_WINRT)!=0 || $(USE_CRT_DLL)!=0
635!IF $(DEBUG)>1
636TCC = $(TCC) -MDd
637BCC = $(BCC) -MDd
638!ELSE
639TCC = $(TCC) -MD
640BCC = $(BCC) -MD
641!ENDIF
642!ELSE
643!IF $(DEBUG)>1
644TCC = $(TCC) -MTd
645BCC = $(BCC) -MTd
646!ELSE
647TCC = $(TCC) -MT
648BCC = $(BCC) -MT
649!ENDIF
650!ENDIF
651
652
653# Define -DNDEBUG to compile without debugging (i.e., for production usage)
654# Omitting the define will cause extra debugging code to be inserted and
655# includes extra comments when "EXPLAIN stmt" is used.
656#
657!IF $(DEBUG)==0
658TCC = $(TCC) -DNDEBUG
659BCC = $(BCC) -DNDEBUG
660RCC = $(RCC) -DNDEBUG
661!ENDIF
662
663!IF $(DEBUG)>0 || $(API_ARMOR)!=0 || $(FOR_WIN10)!=0
664TCC = $(TCC) -DSQLITE_ENABLE_API_ARMOR=1
665RCC = $(RCC) -DSQLITE_ENABLE_API_ARMOR=1
666!ENDIF
667
668!IF $(DEBUG)>2
669TCC = $(TCC) -DSQLITE_DEBUG=1
670RCC = $(RCC) -DSQLITE_DEBUG=1
671!IF $(DYNAMIC_SHELL)==0
672TCC = $(TCC) -DSQLITE_ENABLE_WHERETRACE -DSQLITE_ENABLE_SELECTTRACE
673RCC = $(RCC) -DSQLITE_ENABLE_WHERETRACE -DSQLITE_ENABLE_SELECTTRACE
674!ENDIF
675!ENDIF
676
677!IF $(DEBUG)>4 || $(OSTRACE)!=0
678TCC = $(TCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1
679RCC = $(RCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1
680!ENDIF
681
682!IF $(DEBUG)>5
683TCC = $(TCC) -DSQLITE_ENABLE_IOTRACE=1
684RCC = $(RCC) -DSQLITE_ENABLE_IOTRACE=1
685!ENDIF
686
687# Prevent warnings about "insecure" MSVC runtime library functions
688# being used.
689#
690TCC = $(TCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
691BCC = $(BCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
692RCC = $(RCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
693
694# Prevent warnings about "deprecated" POSIX functions being used.
695#
696TCC = $(TCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
697BCC = $(BCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
698RCC = $(RCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
699
700# Use the SQLite debugging heap subsystem?
701#
702!IF $(MEMDEBUG)!=0
703TCC = $(TCC) -DSQLITE_MEMDEBUG=1
704RCC = $(RCC) -DSQLITE_MEMDEBUG=1
705
706# Use native Win32 heap subsystem instead of malloc/free?
707#
708!ELSEIF $(WIN32HEAP)!=0
709TCC = $(TCC) -DSQLITE_WIN32_MALLOC=1
710RCC = $(RCC) -DSQLITE_WIN32_MALLOC=1
711
712# Validate the heap on every call into the native Win32 heap subsystem?
713#
714!IF $(DEBUG)>3
715TCC = $(TCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1
716RCC = $(RCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1
717!ENDIF
718!ENDIF
719
720
721# Compiler options needed for programs that use the readline() library.
722#
723!IFNDEF READLINE_FLAGS
724READLINE_FLAGS = -DHAVE_READLINE=0
725!ENDIF
726
727# The library that programs using readline() must link against.
728#
729!IFNDEF LIBREADLINE
730LIBREADLINE =
731!ENDIF
732
733# Should the database engine be compiled threadsafe
734#
735TCC = $(TCC) -DSQLITE_THREADSAFE=1
736RCC = $(RCC) -DSQLITE_THREADSAFE=1
737
738# Do threads override each others locks by default (1), or do we test (-1)
739#
740TCC = $(TCC) -DSQLITE_THREAD_OVERRIDE_LOCK=-1
741RCC = $(RCC) -DSQLITE_THREAD_OVERRIDE_LOCK=-1
742
743# Any target libraries which libsqlite must be linked against
744#
745!IFNDEF TLIBS
746TLIBS =
747!ENDIF
748
749# Flags controlling use of the in memory btree implementation
750#
751# SQLITE_TEMP_STORE is 0 to force temporary tables to be in a file, 1 to
752# default to file, 2 to default to memory, and 3 to force temporary
753# tables to always be in memory.
754#
755TCC = $(TCC) -DSQLITE_TEMP_STORE=1
756RCC = $(RCC) -DSQLITE_TEMP_STORE=1
757
758# Enable/disable loadable extensions, and other optional features
759# based on configuration. (-DSQLITE_OMIT*, -DSQLITE_ENABLE*).
760# The same set of OMIT and ENABLE flags should be passed to the
761# LEMON parser generator and the mkkeywordhash tool as well.
762
763# These are the required SQLite compilation options used when compiling for
764# the Windows platform.
765#
766REQ_FEATURE_FLAGS = $(REQ_FEATURE_FLAGS) -DSQLITE_MAX_TRIGGER_DEPTH=100
767
768# If we are linking to the RPCRT4 library, enable features that need it.
769#
770!IF $(USE_RPCRT4_LIB)!=0
771REQ_FEATURE_FLAGS = $(REQ_FEATURE_FLAGS) -DSQLITE_WIN32_USE_UUID=1
772!ENDIF
773
774# Add the required and optional SQLite compilation options into the command
775# lines used to invoke the MSVC code and resource compilers.
776#
777TCC = $(TCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS)
778RCC = $(RCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS)
779
780# Add in any optional parameters specified on the commane line, e.g.
781# nmake /f Makefile.msc all "OPTS=-DSQLITE_ENABLE_FOO=1 -DSQLITE_OMIT_FOO=1"
782#
783TCC = $(TCC) $(OPTS)
784RCC = $(RCC) $(OPTS)
785
786# If compiling for debugging, add some defines.
787#
788!IF $(DEBUG)>1
789TCC = $(TCC) -D_DEBUG
790BCC = $(BCC) -D_DEBUG
791RCC = $(RCC) -D_DEBUG
792!ENDIF
793
794# If optimizations are enabled or disabled (either implicitly or
795# explicitly), add the necessary flags.
796#
797!IF $(DEBUG)>1 || $(OPTIMIZATIONS)==0
798TCC = $(TCC) -Od
799BCC = $(BCC) -Od
800!IF $(USE_RUNTIME_CHECKS)!=0
801TCC = $(TCC) -RTC1
802BCC = $(BCC) -RTC1
803!ENDIF
804!ELSEIF $(OPTIMIZATIONS)>=3
805TCC = $(TCC) -Ox
806BCC = $(BCC) -Ox
807!ELSEIF $(OPTIMIZATIONS)==2
808TCC = $(TCC) -O2
809BCC = $(BCC) -O2
810!ELSEIF $(OPTIMIZATIONS)==1
811TCC = $(TCC) -O1
812BCC = $(BCC) -O1
813!ENDIF
814
815# If symbols are enabled (or compiling for debugging), enable PDBs.
816#
817!IF $(DEBUG)>1 || $(SYMBOLS)!=0
818TCC = $(TCC) -Zi
819BCC = $(BCC) -Zi
820!ENDIF
821
822
823# Command line prefixes for compiling code, compiling resources,
824# linking, etc.
825#
826LTCOMPILE = $(TCC) -Fo$@ -Fd$*.pdb
827LTRCOMPILE = $(RCC) -r
828LTLIB = lib.exe
829LTLINK = $(TCC) -Fe$@
830
831# If requested, link to the RPCRT4 library.
832#
833!IF $(USE_RPCRT4_LIB)!=0
834LTLIBS = $(LTLIBS) rpcrt4.lib
835!ENDIF
836
837# If a platform was set, force the linker to target that.
838# Note that the vcvars*.bat family of batch files typically
839# set this for you.  Otherwise, the linker will attempt
840# to deduce the binary type based on the object files.
841!IFDEF PLATFORM
842LTLINKOPTS = /NOLOGO /MACHINE:$(PLATFORM)
843LTLIBOPTS = /NOLOGO /MACHINE:$(PLATFORM)
844!ELSEIF "$(VISUALSTUDIOVERSION)"=="12.0" || \
845        "$(VISUALSTUDIOVERSION)"=="14.0" || \
846        "$(VISUALSTUDIOVERSION)"=="15.0"
847LTLINKOPTS = /NOLOGO /MACHINE:x86
848LTLIBOPTS = /NOLOGO /MACHINE:x86
849!ELSE
850LTLINKOPTS = /NOLOGO
851LTLIBOPTS = /NOLOGO
852!ENDIF
853
854# When compiling for use in the WinRT environment, the following
855# linker option must be used to mark the executable as runnable
856# only in the context of an application container.
857#
858!IF $(FOR_WINRT)!=0
859LTLINKOPTS = $(LTLINKOPTS) /APPCONTAINER
860!IF "$(VISUALSTUDIOVERSION)"=="12.0" || "$(VISUALSTUDIOVERSION)"=="14.0"
861!IFNDEF STORELIBPATH
862!IF "$(PLATFORM)"=="x86"
863STORELIBPATH = $(CRTLIBPATH)\store
864!ELSEIF "$(PLATFORM)"=="x64"
865STORELIBPATH = $(CRTLIBPATH)\store\amd64
866!ELSEIF "$(PLATFORM)"=="ARM"
867STORELIBPATH = $(CRTLIBPATH)\store\arm
868!ELSE
869STORELIBPATH = $(CRTLIBPATH)\store
870!ENDIF
871!ENDIF
872STORELIBPATH = $(STORELIBPATH:\\=\)
873LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(STORELIBPATH)"
874!ENDIF
875!ENDIF
876
877# When compiling for Windows Phone 8.1, an extra library path is
878# required.
879#
880!IF $(USE_WP81_OPTS)!=0
881!IFNDEF WP81LIBPATH
882!IF "$(PLATFORM)"=="x86"
883WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\x86
884!ELSEIF "$(PLATFORM)"=="ARM"
885WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\ARM
886!ELSE
887WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\x86
888!ENDIF
889!ENDIF
890!ENDIF
891
892# When compiling for Windows Phone 8.1, some extra linker options
893# are also required.
894#
895!IF $(USE_WP81_OPTS)!=0
896!IFDEF WP81LIBPATH
897LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(WP81LIBPATH)"
898!ENDIF
899LTLINKOPTS = $(LTLINKOPTS) /DYNAMICBASE
900LTLINKOPTS = $(LTLINKOPTS) WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib
901LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:ole32.lib
902!ENDIF
903
904# When compiling for UWP or the Windows 10 platform, some extra linker
905# options are also required.
906#
907!IF $(FOR_UWP)!=0 || $(FOR_WIN10)!=0
908LTLINKOPTS = $(LTLINKOPTS) /DYNAMICBASE /NODEFAULTLIB:kernel32.lib
909LTLINKOPTS = $(LTLINKOPTS) mincore.lib
910!IFDEF PSDKLIBPATH
911LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(PSDKLIBPATH)"
912!ENDIF
913!ENDIF
914
915!IF $(FOR_WIN10)!=0
916LTLINKOPTS = $(LTLINKOPTS) /guard:cf "/LIBPATH:$(UCRTLIBPATH)"
917!IF $(DEBUG)>1
918LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:libucrtd.lib /DEFAULTLIB:ucrtd.lib
919!ELSE
920LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib
921!ENDIF
922!ENDIF
923
924# If either debugging or symbols are enabled, enable PDBs.
925#
926!IF $(DEBUG)>1 || $(SYMBOLS)!=0
927LDFLAGS = /DEBUG $(LDOPTS)
928!ELSE
929LDFLAGS = $(LDOPTS)
930!ENDIF
931
932
933# You should not have to change anything below this line
934###############################################################################
935
936
937# Object files for the amalgamation.
938#
939LIBOBJS1 = sqlite3.lo
940
941# Determine the real value of LIBOBJ based on the 'configure' script
942#
943LIBOBJ = $(LIBOBJS1)
944
945# Determine if embedded resource compilation and usage are enabled.
946#
947!IF $(USE_RC)!=0
948LIBRESOBJS = sqlite3res.lo
949!ELSE
950LIBRESOBJS =
951!ENDIF
952
953
954# Additional compiler options for the shell.  These are only effective
955# when the shell is not being dynamically linked.
956#
957!IF $(DYNAMIC_SHELL)==0 && $(FOR_WIN10)==0
958SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_DQS=0
959SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_FTS4=1
960SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_EXPLAIN_COMMENTS=1
961SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_OFFSET_SQL_FUNC=1
962!ENDIF
963
964
965# This is the default Makefile target.  The objects listed here
966# are what get build when you type just "make" with no arguments.
967#
968core:	dll shell
969
970# Targets that require the Tcl library.
971#
972tcl:	$(ALL_TCL_TARGETS)
973
974# This Makefile target builds all of the standard binaries.
975#
976all:	core tcl
977
978# Dynamic link library section.
979#
980dll:	$(SQLITE3DLL)
981
982# Shell executable.
983#
984shell:	$(SQLITE3EXE)
985
986
987$(SQLITE3DLL):	$(LIBOBJ) $(LIBRESOBJS) $(CORE_LINK_DEP)
988	$(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL $(CORE_LINK_OPTS) /OUT:$@ $(LIBOBJ) $(LIBRESOBJS) $(LTLIBS) $(TLIBS)
989
990Replace.exe:
991	$(CSC) /target:exe $(TOP)\Replace.cs
992
993sqlite3.def:	Replace.exe $(LIBOBJ)
994	echo EXPORTS > sqlite3.def
995	dumpbin /all $(LIBOBJ) \
996		| .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset|changegroup|rebaser|rbu)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \
997		| sort >> sqlite3.def
998
999$(SQLITE3EXE):	shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLITE3H)
1000	$(LTLINK) $(SHELL_COMPILE_OPTS) $(READLINE_FLAGS) shell.c $(SHELL_CORE_SRC) \
1001		/link $(SQLITE3EXEPDB) $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS)
1002
1003
1004# Rule to build the amalgamation
1005#
1006sqlite3.lo:	$(SQLITE3C)
1007	$(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(SQLITE3C)
1008
1009
1010# Rule to build the Win32 resources object file.
1011#
1012!IF $(USE_RC)!=0
1013_HASHCHAR=^#
1014!IF ![echo !IFNDEF VERSION > rcver.vc] && \
1015    ![for /F "delims=" %V in ('type "$(SQLITE3H)" ^| "%SystemRoot%\System32\find.exe" "$(_HASHCHAR)define SQLITE_VERSION "') do (echo VERSION = ^^%V >> rcver.vc)] && \
1016    ![echo !ENDIF >> rcver.vc]
1017!INCLUDE rcver.vc
1018!ENDIF
1019
1020RESOURCE_VERSION = $(VERSION:^#=)
1021RESOURCE_VERSION = $(RESOURCE_VERSION:define=)
1022RESOURCE_VERSION = $(RESOURCE_VERSION:SQLITE_VERSION=)
1023RESOURCE_VERSION = $(RESOURCE_VERSION:"=)
1024RESOURCE_VERSION = $(RESOURCE_VERSION:.=,)
1025
1026$(LIBRESOBJS):	$(TOP)\sqlite3.rc rcver.vc $(SQLITE3H)
1027	echo #ifndef SQLITE_RESOURCE_VERSION > sqlite3rc.h
1028	echo #define SQLITE_RESOURCE_VERSION $(RESOURCE_VERSION) >> sqlite3rc.h
1029	echo #endif >> sqlite3rc.h
1030	$(LTRCOMPILE) -fo $(LIBRESOBJS) -DRC_VERONLY $(TOP)\sqlite3.rc
1031!ENDIF
1032
1033
1034clean:
1035	del /Q *.exp *.lo *.ilk *.lib *.obj *.ncb *.pdb *.sdf *.suo 2>NUL
1036	del /Q *.bsc *.def *.cod *.da *.bb *.bbg *.vc gmon.out 2>NUL
1037	del /Q $(SQLITE3EXE) $(SQLITE3DLL) Replace.exe 2>NUL
1038