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