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