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