xref: /freebsd/contrib/sqlite3/Makefile.msc (revision e17f5b1d)
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_JSON1=1
289OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_STMTVTAB=1
290OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBPAGE_VTAB=1
291OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBSTAT_VTAB=1
292OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_BYTECODE_VTAB=1
293OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DESERIALIZE=1
294!ENDIF
295OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
296!ENDIF
297
298# Should the session extension be enabled?  If so, add compilation options
299# to enable it.
300#
301!IF $(SESSION)!=0
302OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1
303OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1
304!ENDIF
305
306# Should the rbu extension be enabled?  If so, add compilation options
307# to enable it.
308#
309!IF $(RBU)!=0
310OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RBU=1
311!ENDIF
312
313# These are the "extended" SQLite compilation options used when compiling for
314# the Windows 10 platform.
315#
316!IFNDEF EXT_FEATURE_FLAGS
317!IF $(FOR_WIN10)!=0
318EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS4=1
319EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_SYSTEM_MALLOC=1
320EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_OMIT_LOCALTIME=1
321!ELSE
322EXT_FEATURE_FLAGS =
323!ENDIF
324!ENDIF
325
326###############################################################################
327############################### END OF OPTIONS ################################
328###############################################################################
329
330# When compiling for the Windows 10 platform, the PLATFORM macro must be set
331# to an appropriate value (e.g. x86, x64, arm, arm64, etc).
332#
333!IF $(FOR_WIN10)!=0
334!IFNDEF PLATFORM
335!ERROR Using the FOR_WIN10 option requires a value for PLATFORM.
336!ENDIF
337!ENDIF
338
339# This assumes that MSVC is always installed in 32-bit Program Files directory
340# and sets the variable for use in locating other 32-bit installs accordingly.
341#
342PROGRAMFILES_X86 = $(VCINSTALLDIR)\..\..
343PROGRAMFILES_X86 = $(PROGRAMFILES_X86:\\=\)
344
345# Check for the predefined command macro CC.  This should point to the compiler
346# binary for the target platform.  If it is not defined, simply define it to
347# the legacy default value 'cl.exe'.
348#
349!IFNDEF CC
350CC = cl.exe
351!ENDIF
352
353# Check for the predefined command macro CSC.  This should point to a working
354# C Sharp compiler binary.  If it is not defined, simply define it to the
355# legacy default value 'csc.exe'.
356#
357!IFNDEF CSC
358CSC = csc.exe
359!ENDIF
360
361# Check for the command macro LD.  This should point to the linker binary for
362# the target platform.  If it is not defined, simply define it to the legacy
363# default value 'link.exe'.
364#
365!IFNDEF LD
366LD = link.exe
367!ENDIF
368
369# Check for the predefined command macro RC.  This should point to the resource
370# compiler binary for the target platform.  If it is not defined, simply define
371# it to the legacy default value 'rc.exe'.
372#
373!IFNDEF RC
374RC = rc.exe
375!ENDIF
376
377# Check for the MSVC runtime library path macro.  Otherwise, this value will
378# default to the 'lib' directory underneath the MSVC installation directory.
379#
380!IFNDEF CRTLIBPATH
381CRTLIBPATH = $(VCINSTALLDIR)\lib
382!ENDIF
383
384CRTLIBPATH = $(CRTLIBPATH:\\=\)
385
386# Check for the command macro NCC.  This should point to the compiler binary
387# for the platform the compilation process is taking place on.  If it is not
388# defined, simply define it to have the same value as the CC macro.  When
389# cross-compiling, it is suggested that this macro be modified via the command
390# line (since nmake itself does not provide a built-in method to guess it).
391# For example, to use the x86 compiler when cross-compiling for x64, a command
392# line similar to the following could be used (all on one line):
393#
394#     nmake /f Makefile.msc sqlite3.dll
395#           XCOMPILE=1 USE_NATIVE_LIBPATHS=1
396#
397# Alternatively, the full path and file name to the compiler binary for the
398# platform the compilation process is taking place may be specified (all on
399# one line):
400#
401#     nmake /f Makefile.msc sqlite3.dll
402#           "NCC=""%VCINSTALLDIR%\bin\cl.exe"""
403#           USE_NATIVE_LIBPATHS=1
404#
405!IFDEF NCC
406NCC = $(NCC:\\=\)
407!ELSEIF $(XCOMPILE)!=0
408NCC = "$(VCINSTALLDIR)\bin\$(CC)"
409NCC = $(NCC:\\=\)
410!ELSE
411NCC = $(CC)
412!ENDIF
413
414# Check for the MSVC native runtime library path macro.  Otherwise,
415# this value will default to the 'lib' directory underneath the MSVC
416# installation directory.
417#
418!IFNDEF NCRTLIBPATH
419NCRTLIBPATH = $(VCINSTALLDIR)\lib
420!ENDIF
421
422NCRTLIBPATH = $(NCRTLIBPATH:\\=\)
423
424# Check for the Platform SDK library path macro.  Otherwise, this
425# value will default to the 'lib' directory underneath the Windows
426# SDK installation directory (the environment variable used appears
427# to be available when using Visual C++ 2008 or later via the
428# command line).
429#
430!IFNDEF NSDKLIBPATH
431NSDKLIBPATH = $(WINDOWSSDKDIR)\lib
432!ENDIF
433
434NSDKLIBPATH = $(NSDKLIBPATH:\\=\)
435
436# Check for the UCRT library path macro.  Otherwise, this value will
437# default to the version-specific, platform-specific 'lib' directory
438# underneath the Windows SDK installation directory.
439#
440!IFNDEF UCRTLIBPATH
441UCRTLIBPATH = $(WINDOWSSDKDIR)\lib\$(WINDOWSSDKLIBVERSION)\ucrt\$(PLATFORM)
442!ENDIF
443
444UCRTLIBPATH = $(UCRTLIBPATH:\\=\)
445
446# C compiler and options for use in building executables that
447# will run on the platform that is doing the build.
448#
449!IF $(USE_FULLWARN)!=0
450BCC = $(NCC) -nologo -W4 -Fd$*.pdb $(CCOPTS) $(BCCOPTS)
451!ELSE
452BCC = $(NCC) -nologo -W3 -Fd$*.pdb $(CCOPTS) $(BCCOPTS)
453!ENDIF
454
455# Check if assembly code listings should be generated for the source
456# code files to be compiled.
457#
458!IF $(USE_LISTINGS)!=0
459BCC = $(BCC) -FAcs
460!ENDIF
461
462# Check if the native library paths should be used when compiling
463# the command line tools used during the compilation process.  If
464# so, set the necessary macro now.
465#
466!IF $(USE_NATIVE_LIBPATHS)!=0
467NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)"
468
469!IFDEF NUCRTLIBPATH
470NUCRTLIBPATH = $(NUCRTLIBPATH:\\=\)
471NLTLIBPATHS = $(NLTLIBPATHS) "/LIBPATH:$(NUCRTLIBPATH)"
472!ENDIF
473!ENDIF
474
475# C compiler and options for use in building executables that
476# will run on the target platform.  (BCC and TCC are usually the
477# same unless your are cross-compiling.)
478#
479!IF $(USE_FULLWARN)!=0
480TCC = $(CC) -nologo -W4 -DINCLUDE_MSVC_H=1 $(CCOPTS) $(TCCOPTS)
481!ELSE
482TCC = $(CC) -nologo -W3 $(CCOPTS) $(TCCOPTS)
483!ENDIF
484
485# Check if warnings should be treated as errors when compiling.
486#
487!IF $(USE_FATAL_WARN)!=0
488TCC = $(TCC) -WX
489!ENDIF
490
491TCC = $(TCC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -fp:precise
492RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) $(RCOPTS) $(RCCOPTS)
493
494# Check if we want to use the "stdcall" calling convention when compiling.
495# This is not supported by the compilers for non-x86 platforms.  It should
496# also be noted here that building any target with these "stdcall" options
497# will most likely fail if the Tcl library is also required.  This is due
498# to how the Tcl library functions are declared and exported (i.e. without
499# an explicit calling convention, which results in "cdecl").
500#
501!IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
502!IF "$(PLATFORM)"=="x86"
503CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
504SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
505!ELSE
506!IFNDEF PLATFORM
507CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
508SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
509!ELSE
510CORE_CCONV_OPTS =
511SHELL_CCONV_OPTS =
512!ENDIF
513!ENDIF
514!ELSE
515CORE_CCONV_OPTS =
516SHELL_CCONV_OPTS =
517!ENDIF
518
519# These are additional compiler options used for the core library.
520#
521!IFNDEF CORE_COMPILE_OPTS
522!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
523CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS) -DSQLITE_API=__declspec(dllexport)
524!ELSE
525CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS)
526!ENDIF
527!ENDIF
528
529# These are the additional targets that the core library should depend on
530# when linking.
531#
532!IFNDEF CORE_LINK_DEP
533!IF $(DYNAMIC_SHELL)!=0
534CORE_LINK_DEP =
535!ELSEIF $(FOR_WIN10)==0 || "$(PLATFORM)"=="x86"
536CORE_LINK_DEP = sqlite3.def
537!ELSE
538CORE_LINK_DEP =
539!ENDIF
540!ENDIF
541
542# These are additional linker options used for the core library.
543#
544!IFNDEF CORE_LINK_OPTS
545!IF $(DYNAMIC_SHELL)!=0
546CORE_LINK_OPTS =
547!ELSEIF $(FOR_WIN10)==0 || "$(PLATFORM)"=="x86"
548CORE_LINK_OPTS = /DEF:sqlite3.def
549!ELSE
550CORE_LINK_OPTS =
551!ENDIF
552!ENDIF
553
554# These are additional compiler options used for the shell executable.
555#
556!IFNDEF SHELL_COMPILE_OPTS
557!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
558SHELL_COMPILE_OPTS = $(SHELL_CCONV_OPTS) -DSQLITE_API=__declspec(dllimport)
559!ELSE
560SHELL_COMPILE_OPTS = $(SHELL_CCONV_OPTS)
561!ENDIF
562!ENDIF
563
564# This is the source code that the shell executable should be compiled
565# with.
566#
567!IFNDEF SHELL_CORE_SRC
568!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
569SHELL_CORE_SRC =
570!ELSE
571SHELL_CORE_SRC = $(SQLITE3C)
572!ENDIF
573!ENDIF
574
575# This is the core library that the shell executable should depend on.
576#
577!IFNDEF SHELL_CORE_DEP
578!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
579SHELL_CORE_DEP = $(SQLITE3DLL)
580!ELSE
581SHELL_CORE_DEP =
582!ENDIF
583!ENDIF
584
585
586# This is the core library that the shell executable should link with.
587#
588!IFNDEF SHELL_CORE_LIB
589!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
590SHELL_CORE_LIB = $(SQLITE3LIB)
591!ELSE
592SHELL_CORE_LIB =
593!ENDIF
594!ENDIF
595
596# These are additional linker options used for the shell executable.
597#
598!IFNDEF SHELL_LINK_OPTS
599SHELL_LINK_OPTS = $(SHELL_CORE_LIB)
600!ENDIF
601
602# Check if assembly code listings should be generated for the source
603# code files to be compiled.
604#
605!IF $(USE_LISTINGS)!=0
606TCC = $(TCC) -FAcs
607!ENDIF
608
609# When compiling the library for use in the WinRT environment,
610# the following compile-time options must be used as well to
611# disable use of Win32 APIs that are not available and to enable
612# use of Win32 APIs that are specific to Windows 8 and/or WinRT.
613#
614!IF $(FOR_WINRT)!=0
615TCC = $(TCC) -DSQLITE_OS_WINRT=1
616RCC = $(RCC) -DSQLITE_OS_WINRT=1
617TCC = $(TCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
618RCC = $(RCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
619!ENDIF
620
621# C compiler options for the Windows 10 platform (needs MSVC 2015).
622#
623!IF $(FOR_WIN10)!=0
624TCC = $(TCC) /d2guard4 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
625BCC = $(BCC) /d2guard4 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
626!ENDIF
627
628# Also, we need to dynamically link to the correct MSVC runtime
629# when compiling for WinRT (e.g. debug or release) OR if the
630# USE_CRT_DLL option is set to force dynamically linking to the
631# MSVC runtime library.
632#
633!IF $(FOR_WINRT)!=0 || $(USE_CRT_DLL)!=0
634!IF $(DEBUG)>1
635TCC = $(TCC) -MDd
636BCC = $(BCC) -MDd
637!ELSE
638TCC = $(TCC) -MD
639BCC = $(BCC) -MD
640!ENDIF
641!ELSE
642!IF $(DEBUG)>1
643TCC = $(TCC) -MTd
644BCC = $(BCC) -MTd
645!ELSE
646TCC = $(TCC) -MT
647BCC = $(BCC) -MT
648!ENDIF
649!ENDIF
650
651
652# Define -DNDEBUG to compile without debugging (i.e., for production usage)
653# Omitting the define will cause extra debugging code to be inserted and
654# includes extra comments when "EXPLAIN stmt" is used.
655#
656!IF $(DEBUG)==0
657TCC = $(TCC) -DNDEBUG
658BCC = $(BCC) -DNDEBUG
659RCC = $(RCC) -DNDEBUG
660!ENDIF
661
662!IF $(DEBUG)>0 || $(API_ARMOR)!=0 || $(FOR_WIN10)!=0
663TCC = $(TCC) -DSQLITE_ENABLE_API_ARMOR=1
664RCC = $(RCC) -DSQLITE_ENABLE_API_ARMOR=1
665!ENDIF
666
667!IF $(DEBUG)>2
668TCC = $(TCC) -DSQLITE_DEBUG=1
669RCC = $(RCC) -DSQLITE_DEBUG=1
670!IF $(DYNAMIC_SHELL)==0
671TCC = $(TCC) -DSQLITE_ENABLE_WHERETRACE -DSQLITE_ENABLE_SELECTTRACE
672RCC = $(RCC) -DSQLITE_ENABLE_WHERETRACE -DSQLITE_ENABLE_SELECTTRACE
673!ENDIF
674!ENDIF
675
676!IF $(DEBUG)>4 || $(OSTRACE)!=0
677TCC = $(TCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1
678RCC = $(RCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1
679!ENDIF
680
681!IF $(DEBUG)>5
682TCC = $(TCC) -DSQLITE_ENABLE_IOTRACE=1
683RCC = $(RCC) -DSQLITE_ENABLE_IOTRACE=1
684!ENDIF
685
686# Prevent warnings about "insecure" MSVC runtime library functions
687# being used.
688#
689TCC = $(TCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
690BCC = $(BCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
691RCC = $(RCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
692
693# Prevent warnings about "deprecated" POSIX functions being used.
694#
695TCC = $(TCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
696BCC = $(BCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
697RCC = $(RCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
698
699# Use the SQLite debugging heap subsystem?
700#
701!IF $(MEMDEBUG)!=0
702TCC = $(TCC) -DSQLITE_MEMDEBUG=1
703RCC = $(RCC) -DSQLITE_MEMDEBUG=1
704
705# Use native Win32 heap subsystem instead of malloc/free?
706#
707!ELSEIF $(WIN32HEAP)!=0
708TCC = $(TCC) -DSQLITE_WIN32_MALLOC=1
709RCC = $(RCC) -DSQLITE_WIN32_MALLOC=1
710
711# Validate the heap on every call into the native Win32 heap subsystem?
712#
713!IF $(DEBUG)>3
714TCC = $(TCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1
715RCC = $(RCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1
716!ENDIF
717!ENDIF
718
719
720# Compiler options needed for programs that use the readline() library.
721#
722!IFNDEF READLINE_FLAGS
723READLINE_FLAGS = -DHAVE_READLINE=0
724!ENDIF
725
726# The library that programs using readline() must link against.
727#
728!IFNDEF LIBREADLINE
729LIBREADLINE =
730!ENDIF
731
732# Should the database engine be compiled threadsafe
733#
734TCC = $(TCC) -DSQLITE_THREADSAFE=1
735RCC = $(RCC) -DSQLITE_THREADSAFE=1
736
737# Do threads override each others locks by default (1), or do we test (-1)
738#
739TCC = $(TCC) -DSQLITE_THREAD_OVERRIDE_LOCK=-1
740RCC = $(RCC) -DSQLITE_THREAD_OVERRIDE_LOCK=-1
741
742# Any target libraries which libsqlite must be linked against
743#
744!IFNDEF TLIBS
745TLIBS =
746!ENDIF
747
748# Flags controlling use of the in memory btree implementation
749#
750# SQLITE_TEMP_STORE is 0 to force temporary tables to be in a file, 1 to
751# default to file, 2 to default to memory, and 3 to force temporary
752# tables to always be in memory.
753#
754TCC = $(TCC) -DSQLITE_TEMP_STORE=1
755RCC = $(RCC) -DSQLITE_TEMP_STORE=1
756
757# Enable/disable loadable extensions, and other optional features
758# based on configuration. (-DSQLITE_OMIT*, -DSQLITE_ENABLE*).
759# The same set of OMIT and ENABLE flags should be passed to the
760# LEMON parser generator and the mkkeywordhash tool as well.
761
762# These are the required SQLite compilation options used when compiling for
763# the Windows platform.
764#
765REQ_FEATURE_FLAGS = $(REQ_FEATURE_FLAGS) -DSQLITE_MAX_TRIGGER_DEPTH=100
766
767# If we are linking to the RPCRT4 library, enable features that need it.
768#
769!IF $(USE_RPCRT4_LIB)!=0
770REQ_FEATURE_FLAGS = $(REQ_FEATURE_FLAGS) -DSQLITE_WIN32_USE_UUID=1
771!ENDIF
772
773# Add the required and optional SQLite compilation options into the command
774# lines used to invoke the MSVC code and resource compilers.
775#
776TCC = $(TCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS)
777RCC = $(RCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS)
778
779# Add in any optional parameters specified on the commane line, e.g.
780# nmake /f Makefile.msc all "OPTS=-DSQLITE_ENABLE_FOO=1 -DSQLITE_OMIT_FOO=1"
781#
782TCC = $(TCC) $(OPTS)
783RCC = $(RCC) $(OPTS)
784
785# If compiling for debugging, add some defines.
786#
787!IF $(DEBUG)>1
788TCC = $(TCC) -D_DEBUG
789BCC = $(BCC) -D_DEBUG
790RCC = $(RCC) -D_DEBUG
791!ENDIF
792
793# If optimizations are enabled or disabled (either implicitly or
794# explicitly), add the necessary flags.
795#
796!IF $(DEBUG)>1 || $(OPTIMIZATIONS)==0
797TCC = $(TCC) -Od
798BCC = $(BCC) -Od
799!IF $(USE_RUNTIME_CHECKS)!=0
800TCC = $(TCC) -RTC1
801BCC = $(BCC) -RTC1
802!ENDIF
803!ELSEIF $(OPTIMIZATIONS)>=3
804TCC = $(TCC) -Ox
805BCC = $(BCC) -Ox
806!ELSEIF $(OPTIMIZATIONS)==2
807TCC = $(TCC) -O2
808BCC = $(BCC) -O2
809!ELSEIF $(OPTIMIZATIONS)==1
810TCC = $(TCC) -O1
811BCC = $(BCC) -O1
812!ENDIF
813
814# If symbols are enabled (or compiling for debugging), enable PDBs.
815#
816!IF $(DEBUG)>1 || $(SYMBOLS)!=0
817TCC = $(TCC) -Zi
818BCC = $(BCC) -Zi
819!ENDIF
820
821
822# Command line prefixes for compiling code, compiling resources,
823# linking, etc.
824#
825LTCOMPILE = $(TCC) -Fo$@ -Fd$*.pdb
826LTRCOMPILE = $(RCC) -r
827LTLIB = lib.exe
828LTLINK = $(TCC) -Fe$@
829
830# If requested, link to the RPCRT4 library.
831#
832!IF $(USE_RPCRT4_LIB)!=0
833LTLIBS = $(LTLIBS) rpcrt4.lib
834!ENDIF
835
836# If a platform was set, force the linker to target that.
837# Note that the vcvars*.bat family of batch files typically
838# set this for you.  Otherwise, the linker will attempt
839# to deduce the binary type based on the object files.
840!IFDEF PLATFORM
841LTLINKOPTS = /NOLOGO /MACHINE:$(PLATFORM)
842LTLIBOPTS = /NOLOGO /MACHINE:$(PLATFORM)
843!ELSEIF "$(VISUALSTUDIOVERSION)"=="12.0" || \
844        "$(VISUALSTUDIOVERSION)"=="14.0" || \
845        "$(VISUALSTUDIOVERSION)"=="15.0"
846LTLINKOPTS = /NOLOGO /MACHINE:x86
847LTLIBOPTS = /NOLOGO /MACHINE:x86
848!ELSE
849LTLINKOPTS = /NOLOGO
850LTLIBOPTS = /NOLOGO
851!ENDIF
852
853# When compiling for use in the WinRT environment, the following
854# linker option must be used to mark the executable as runnable
855# only in the context of an application container.
856#
857!IF $(FOR_WINRT)!=0
858LTLINKOPTS = $(LTLINKOPTS) /APPCONTAINER
859!IF "$(VISUALSTUDIOVERSION)"=="12.0" || "$(VISUALSTUDIOVERSION)"=="14.0"
860!IFNDEF STORELIBPATH
861!IF "$(PLATFORM)"=="x86"
862STORELIBPATH = $(CRTLIBPATH)\store
863!ELSEIF "$(PLATFORM)"=="x64"
864STORELIBPATH = $(CRTLIBPATH)\store\amd64
865!ELSEIF "$(PLATFORM)"=="ARM"
866STORELIBPATH = $(CRTLIBPATH)\store\arm
867!ELSE
868STORELIBPATH = $(CRTLIBPATH)\store
869!ENDIF
870!ENDIF
871STORELIBPATH = $(STORELIBPATH:\\=\)
872LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(STORELIBPATH)"
873!ENDIF
874!ENDIF
875
876# When compiling for Windows Phone 8.1, an extra library path is
877# required.
878#
879!IF $(USE_WP81_OPTS)!=0
880!IFNDEF WP81LIBPATH
881!IF "$(PLATFORM)"=="x86"
882WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\x86
883!ELSEIF "$(PLATFORM)"=="ARM"
884WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\ARM
885!ELSE
886WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\x86
887!ENDIF
888!ENDIF
889!ENDIF
890
891# When compiling for Windows Phone 8.1, some extra linker options
892# are also required.
893#
894!IF $(USE_WP81_OPTS)!=0
895!IFDEF WP81LIBPATH
896LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(WP81LIBPATH)"
897!ENDIF
898LTLINKOPTS = $(LTLINKOPTS) /DYNAMICBASE
899LTLINKOPTS = $(LTLINKOPTS) WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib
900LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:ole32.lib
901!ENDIF
902
903# When compiling for UWP or the Windows 10 platform, some extra linker
904# options are also required.
905#
906!IF $(FOR_UWP)!=0 || $(FOR_WIN10)!=0
907LTLINKOPTS = $(LTLINKOPTS) /DYNAMICBASE /NODEFAULTLIB:kernel32.lib
908LTLINKOPTS = $(LTLINKOPTS) mincore.lib
909!IFDEF PSDKLIBPATH
910LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(PSDKLIBPATH)"
911!ENDIF
912!ENDIF
913
914!IF $(FOR_WIN10)!=0
915LTLINKOPTS = $(LTLINKOPTS) /guard:cf "/LIBPATH:$(UCRTLIBPATH)"
916!IF $(DEBUG)>1
917LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:libucrtd.lib /DEFAULTLIB:ucrtd.lib
918!ELSE
919LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib
920!ENDIF
921!ENDIF
922
923# If either debugging or symbols are enabled, enable PDBs.
924#
925!IF $(DEBUG)>1 || $(SYMBOLS)!=0
926LDFLAGS = /DEBUG $(LDOPTS)
927!ELSE
928LDFLAGS = $(LDOPTS)
929!ENDIF
930
931
932# You should not have to change anything below this line
933###############################################################################
934
935
936# Object files for the amalgamation.
937#
938LIBOBJS1 = sqlite3.lo
939
940# Determine the real value of LIBOBJ based on the 'configure' script
941#
942LIBOBJ = $(LIBOBJS1)
943
944# Determine if embedded resource compilation and usage are enabled.
945#
946!IF $(USE_RC)!=0
947LIBRESOBJS = sqlite3res.lo
948!ELSE
949LIBRESOBJS =
950!ENDIF
951
952
953# Additional compiler options for the shell.  These are only effective
954# when the shell is not being dynamically linked.
955#
956!IF $(DYNAMIC_SHELL)==0 && $(FOR_WIN10)==0
957SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_FTS4=1
958SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_EXPLAIN_COMMENTS=1
959SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_OFFSET_SQL_FUNC=1
960SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_DESERIALIZE=1
961!ENDIF
962
963
964# This is the default Makefile target.  The objects listed here
965# are what get build when you type just "make" with no arguments.
966#
967core:	dll shell
968
969# Targets that require the Tcl library.
970#
971tcl:	$(ALL_TCL_TARGETS)
972
973# This Makefile target builds all of the standard binaries.
974#
975all:	core tcl
976
977# Dynamic link library section.
978#
979dll:	$(SQLITE3DLL)
980
981# Shell executable.
982#
983shell:	$(SQLITE3EXE)
984
985
986$(SQLITE3DLL):	$(LIBOBJ) $(LIBRESOBJS) $(CORE_LINK_DEP)
987	$(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL $(CORE_LINK_OPTS) /OUT:$@ $(LIBOBJ) $(LIBRESOBJS) $(LTLIBS) $(TLIBS)
988
989Replace.exe:
990	$(CSC) /target:exe $(TOP)\Replace.cs
991
992sqlite3.def:	Replace.exe $(LIBOBJ)
993	echo EXPORTS > sqlite3.def
994	dumpbin /all $(LIBOBJ) \
995		| .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset|changegroup|rebaser|rbu)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \
996		| sort >> sqlite3.def
997
998$(SQLITE3EXE):	shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLITE3H)
999	$(LTLINK) $(SHELL_COMPILE_OPTS) $(READLINE_FLAGS) shell.c $(SHELL_CORE_SRC) \
1000		/link $(SQLITE3EXEPDB) $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS)
1001
1002
1003# Rule to build the amalgamation
1004#
1005sqlite3.lo:	$(SQLITE3C)
1006	$(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(SQLITE3C)
1007
1008
1009# Rule to build the Win32 resources object file.
1010#
1011!IF $(USE_RC)!=0
1012_HASHCHAR=^#
1013!IF ![echo !IFNDEF VERSION > rcver.vc] && \
1014    ![for /F "delims=" %V in ('type "$(SQLITE3H)" ^| "%SystemRoot%\System32\find.exe" "$(_HASHCHAR)define SQLITE_VERSION "') do (echo VERSION = ^^%V >> rcver.vc)] && \
1015    ![echo !ENDIF >> rcver.vc]
1016!INCLUDE rcver.vc
1017!ENDIF
1018
1019RESOURCE_VERSION = $(VERSION:^#=)
1020RESOURCE_VERSION = $(RESOURCE_VERSION:define=)
1021RESOURCE_VERSION = $(RESOURCE_VERSION:SQLITE_VERSION=)
1022RESOURCE_VERSION = $(RESOURCE_VERSION:"=)
1023RESOURCE_VERSION = $(RESOURCE_VERSION:.=,)
1024
1025$(LIBRESOBJS):	$(TOP)\sqlite3.rc rcver.vc $(SQLITE3H)
1026	echo #ifndef SQLITE_RESOURCE_VERSION > sqlite3rc.h
1027	echo #define SQLITE_RESOURCE_VERSION $(RESOURCE_VERSION) >> sqlite3rc.h
1028	echo #endif >> sqlite3rc.h
1029	$(LTRCOMPILE) -fo $(LIBRESOBJS) -DRC_VERONLY $(TOP)\sqlite3.rc
1030!ENDIF
1031
1032
1033clean:
1034	del /Q *.exp *.lo *.ilk *.lib *.obj *.ncb *.pdb *.sdf *.suo 2>NUL
1035	del /Q *.bsc *.def *.cod *.da *.bb *.bbg *.vc gmon.out 2>NUL
1036	del /Q $(SQLITE3EXE) $(SQLITE3DLL) Replace.exe 2>NUL
1037