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
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".
21 # Set this non-0 to enable full warnings (-W4, etc) when compiling.
27 # Set this non-0 to enable treating warnings as errors (-WX, etc) when
30 !IFNDEF USE_FATAL_WARN
34 # Set this non-0 to enable full runtime error checks (-RTC1, etc). This
35 # has no effect if (any) optimizations are enabled.
37 !IFNDEF USE_RUNTIME_CHECKS
38 USE_RUNTIME_CHECKS = 0
41 # Set this non-0 to create a SQLite amalgamation file that excludes the
42 # various built-in extensions.
44 !IFNDEF MINIMAL_AMALGAMATION
45 MINIMAL_AMALGAMATION = 0
48 # Set this non-0 to use "stdcall" calling convention for the core library
49 # and shell executable.
55 # Set this non-0 to use structured exception handling (SEH) for WAL mode
56 # in the core library.
62 # Set this non-0 to have the shell executable link against the core dynamic
69 # Set this non-0 to enable extra code that attempts to detect misuse of the
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.
81 !IF $(USE_FULLWARN)!=0
82 NO_WARN = -wd4054 -wd4055 -wd4100 -wd4127 -wd4130 -wd4152 -wd4189 -wd4206
83 NO_WARN = $(NO_WARN) -wd4210 -wd4232 -wd4244 -wd4305 -wd4306 -wd4702 -wd4706
87 # Set this non-0 to use the library paths and other options necessary for
94 # Set this non-0 to split the SQLite amalgamation file into chunks to
95 # be used for debugging with Visual Studio.
97 !IFNDEF SPLIT_AMALGAMATION
98 SPLIT_AMALGAMATION = 0
102 # Set this non-0 to dynamically link to the MSVC runtime library.
108 # Set this non-0 to link to the RPCRT4 library.
110 !IFNDEF USE_RPCRT4_LIB
114 # Set this non-0 to generate assembly code listings for the source code
121 # Set this non-0 to attempt setting the native compiler automatically
122 # for cross-compiling the command line tools needed during the compilation
129 # Set this non-0 to use the native libraries paths for cross-compiling
130 # the command line tools needed during the compilation process.
132 !IFNDEF USE_NATIVE_LIBPATHS
133 USE_NATIVE_LIBPATHS = 0
136 # Set this 0 to skip the compiling and embedding of version resources.
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).
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).
158 # Set this non-0 to compile binaries suitable for the Windows 10 platform.
165 # Set this to non-0 to create and use PDBs.
171 # Set this to non-0 to use the SQLite debugging heap subsystem.
177 # Set this to non-0 to use the Win32 native heap subsystem.
183 # Set this to non-0 to enable OSTRACE() macros, which can be useful when
190 # enable address sanitizer using ASAN=1 on the command-line.
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:
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.
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.
217 !IFNDEF OPTIMIZATIONS
221 # Set this to non-0 to enable support for the session extension.
227 # Set this to non-0 to enable support for the rbu extension.
233 # Set the source code file to be used by executables and libraries when
234 # they need the amalgamation.
237 !IF $(SPLIT_AMALGAMATION)!=0
238 SQLITE3C = sqlite3-all.c
244 # Set the include code file to be used by executables and libraries when
251 # This is the name to use for the SQLite dynamic link library (DLL).
255 SQLITE3DLL = winsqlite3.dll
257 SQLITE3DLL = sqlite3.dll
261 # This is the name to use for the SQLite import library (LIB).
265 SQLITE3LIB = winsqlite3.lib
267 SQLITE3LIB = sqlite3.lib
271 # This is the name to use for the SQLite shell executable (EXE).
275 SQLITE3EXE = winsqlite3shell.exe
277 SQLITE3EXE = sqlite3.exe
281 # This is the argument used to set the program database (PDB) file for the
282 # SQLite shell executable (EXE).
284 !IFNDEF SQLITE3EXEPDB
288 SQLITE3EXEPDB = /pdb:sqlite3sh.pdb
293 # These are the "standard" SQLite compilation options used when compiling for
294 # the Windows platform.
296 !IFNDEF OPT_FEATURE_FLAGS
297 !IF $(MINIMAL_AMALGAMATION)==0
298 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1
299 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1
300 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_GEOPOLY=1
301 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_STMTVTAB=1
302 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBPAGE_VTAB=1
303 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBSTAT_VTAB=1
304 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_BYTECODE_VTAB=1
306 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
309 # Should the session extension be enabled? If so, add compilation options
313 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1
314 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1
317 # Always enable math functions on Windows
318 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_MATH_FUNCTIONS
320 # Should the rbu extension be enabled? If so, add compilation options
324 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RBU=1
327 # Should structured exception handling (SEH) be enabled for WAL mode in
331 OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_USE_SEH=1
334 # These are the "extended" SQLite compilation options used when compiling for
335 # the Windows 10 platform.
337 !IFNDEF EXT_FEATURE_FLAGS
339 EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS4=1
340 EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_SYSTEM_MALLOC=1
341 EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_OMIT_LOCALTIME=1
347 ###############################################################################
348 ############################### END OF OPTIONS ################################
349 ###############################################################################
351 # When compiling for the Windows 10 platform, the PLATFORM macro must be set
352 # to an appropriate value (e.g. x86, x64, arm, arm64, etc).
356 !ERROR Using the FOR_WIN10 option requires a value for PLATFORM.
360 # This assumes that MSVC is always installed in 32-bit Program Files directory
361 # and sets the variable for use in locating other 32-bit installs accordingly.
363 PROGRAMFILES_X86 = $(VCINSTALLDIR)\..\..
364 PROGRAMFILES_X86 = $(PROGRAMFILES_X86:\\=\)
366 # Check for the predefined command macro CC. This should point to the compiler
367 # binary for the target platform. If it is not defined, simply define it to
368 # the legacy default value 'cl.exe'.
374 # Check for the predefined command macro CSC. This should point to a working
375 # C Sharp compiler binary. If it is not defined, simply define it to the
376 # legacy default value 'csc.exe'.
382 # Check for the command macro LD. This should point to the linker binary for
383 # the target platform. If it is not defined, simply define it to the legacy
384 # default value 'link.exe'.
390 # Check for the predefined command macro RC. This should point to the resource
391 # compiler binary for the target platform. If it is not defined, simply define
392 # it to the legacy default value 'rc.exe'.
398 # Check for the MSVC runtime library path macro. Otherwise, this value will
399 # default to the 'lib' directory underneath the MSVC installation directory.
402 CRTLIBPATH = $(VCINSTALLDIR)\lib
405 CRTLIBPATH = $(CRTLIBPATH:\\=\)
407 # Check for the command macro NCC. This should point to the compiler binary
408 # for the platform the compilation process is taking place on. If it is not
409 # defined, simply define it to have the same value as the CC macro. When
410 # cross-compiling, it is suggested that this macro be modified via the command
411 # line (since nmake itself does not provide a built-in method to guess it).
412 # For example, to use the x86 compiler when cross-compiling for x64, a command
413 # line similar to the following could be used (all on one line):
415 # nmake /f Makefile.msc sqlite3.dll
416 # XCOMPILE=1 USE_NATIVE_LIBPATHS=1
418 # Alternatively, the full path and file name to the compiler binary for the
419 # platform the compilation process is taking place may be specified (all on
422 # nmake /f Makefile.msc sqlite3.dll
423 # "NCC=""%VCINSTALLDIR%\bin\cl.exe"""
424 # USE_NATIVE_LIBPATHS=1
428 !ELSEIF $(XCOMPILE)!=0
429 NCC = "$(VCINSTALLDIR)\bin\$(CC)"
435 # Check for the MSVC native runtime library path macro. Otherwise,
436 # this value will default to the 'lib' directory underneath the MSVC
437 # installation directory.
440 NCRTLIBPATH = $(VCINSTALLDIR)\lib
443 NCRTLIBPATH = $(NCRTLIBPATH:\\=\)
445 # Check for the Platform SDK library path macro. Otherwise, this
446 # value will default to the 'lib' directory underneath the Windows
447 # SDK installation directory (the environment variable used appears
448 # to be available when using Visual C++ 2008 or later via the
452 NSDKLIBPATH = $(WINDOWSSDKDIR)\lib
455 NSDKLIBPATH = $(NSDKLIBPATH:\\=\)
457 # Check for the UCRT library path macro. Otherwise, this value will
458 # default to the version-specific, platform-specific 'lib' directory
459 # underneath the Windows SDK installation directory.
462 UCRTLIBPATH = $(WINDOWSSDKDIR)\lib\$(WINDOWSSDKLIBVERSION)\ucrt\$(PLATFORM)
465 UCRTLIBPATH = $(UCRTLIBPATH:\\=\)
467 # C compiler and options for use in building executables that
468 # will run on the platform that is doing the build.
470 !IF $(USE_FULLWARN)!=0
471 BCC = $(NCC) -nologo -W4 -Fd$*.pdb $(CCOPTS) $(BCCOPTS)
473 BCC = $(NCC) -nologo -W3 -Fd$*.pdb $(CCOPTS) $(BCCOPTS)
476 # Check if assembly code listings should be generated for the source
477 # code files to be compiled.
479 !IF $(USE_LISTINGS)!=0
483 # Check if the native library paths should be used when compiling
484 # the command line tools used during the compilation process. If
485 # so, set the necessary macro now.
487 !IF $(USE_NATIVE_LIBPATHS)!=0
488 NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)"
491 NUCRTLIBPATH = $(NUCRTLIBPATH:\\=\)
492 NLTLIBPATHS = $(NLTLIBPATHS) "/LIBPATH:$(NUCRTLIBPATH)"
496 # C compiler and options for use in building executables that
497 # will run on the target platform. (BCC and TCC are usually the
498 # same unless your are cross-compiling.)
500 !IF $(USE_FULLWARN)!=0
501 TCC = $(CC) -nologo -W4 -DINCLUDE_MSVC_H=1 $(CCOPTS) $(TCCOPTS)
503 TCC = $(CC) -nologo -W3 $(CCOPTS) $(TCCOPTS)
506 # Check if warnings should be treated as errors when compiling.
508 !IF $(USE_FATAL_WARN)!=0
512 TCC = $(TCC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -fp:precise
513 RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) $(RCOPTS) $(RCCOPTS)
515 # Check if we want to use the "stdcall" calling convention when compiling.
516 # This is not supported by the compilers for non-x86 platforms. It should
517 # also be noted here that building any target with these "stdcall" options
518 # will most likely fail if the Tcl library is also required. This is due
519 # to how the Tcl library functions are declared and exported (i.e. without
520 # an explicit calling convention, which results in "cdecl").
522 !IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
523 !IF "$(PLATFORM)"=="x86"
524 CORE_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
525 SHELL_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
528 CORE_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
529 SHELL_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
540 # These are additional compiler options used for the core library.
542 !IFNDEF CORE_COMPILE_OPTS
543 !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
544 CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS) -DSQLITE_API=__declspec(dllexport)
546 CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS)
550 # These are the additional targets that the core library should depend on
553 !IFNDEF CORE_LINK_DEP
554 !IF $(DYNAMIC_SHELL)!=0
556 !ELSEIF $(FOR_WIN10)==0 || "$(PLATFORM)"=="x86"
557 CORE_LINK_DEP = sqlite3.def
563 # These are additional linker options used for the core library.
565 !IFNDEF CORE_LINK_OPTS
566 !IF $(DYNAMIC_SHELL)!=0
568 !ELSEIF $(FOR_WIN10)==0 || "$(PLATFORM)"=="x86"
569 CORE_LINK_OPTS = /DEF:sqlite3.def
575 # These are additional compiler options used for the shell executable.
577 !IFNDEF SHELL_COMPILE_OPTS
578 !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
579 SHELL_COMPILE_OPTS = $(SHELL_CCONV_OPTS) -DSQLITE_API=__declspec(dllimport)
581 SHELL_COMPILE_OPTS = $(SHELL_CCONV_OPTS)
585 # This is the source code that the shell executable should be compiled
588 !IFNDEF SHELL_CORE_SRC
589 !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
592 SHELL_CORE_SRC = $(SQLITE3C)
596 # This is the core library that the shell executable should depend on.
598 !IFNDEF SHELL_CORE_DEP
599 !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
600 SHELL_CORE_DEP = $(SQLITE3DLL)
607 # This is the core library that the shell executable should link with.
609 !IFNDEF SHELL_CORE_LIB
610 !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
611 SHELL_CORE_LIB = $(SQLITE3LIB)
617 # These are additional linker options used for the shell executable.
619 !IFNDEF SHELL_LINK_OPTS
620 SHELL_LINK_OPTS = $(SHELL_CORE_LIB)
623 # Check if assembly code listings should be generated for the source
624 # code files to be compiled.
626 !IF $(USE_LISTINGS)!=0
630 # When compiling the library for use in the WinRT environment,
631 # the following compile-time options must be used as well to
632 # disable use of Win32 APIs that are not available and to enable
633 # use of Win32 APIs that are specific to Windows 8 and/or WinRT.
636 TCC = $(TCC) -DSQLITE_OS_WINRT=1
637 RCC = $(RCC) -DSQLITE_OS_WINRT=1
638 TCC = $(TCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
639 RCC = $(RCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
642 # C compiler options for the Windows 10 platform (needs MSVC 2015).
645 TCC = $(TCC) /d2guard4 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
646 BCC = $(BCC) /d2guard4 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
649 # Also, we need to dynamically link to the correct MSVC runtime
650 # when compiling for WinRT (e.g. debug or release) OR if the
651 # USE_CRT_DLL option is set to force dynamically linking to the
652 # MSVC runtime library.
654 !IF $(FOR_WINRT)!=0 || $(USE_CRT_DLL)!=0
673 # Define -DNDEBUG to compile without debugging (i.e., for production usage)
674 # Omitting the define will cause extra debugging code to be inserted and
675 # includes extra comments when "EXPLAIN stmt" is used.
678 TCC = $(TCC) -DNDEBUG
679 BCC = $(BCC) -DNDEBUG
680 RCC = $(RCC) -DNDEBUG
683 !IF $(DEBUG)>0 || $(API_ARMOR)!=0 || $(FOR_WIN10)!=0
684 TCC = $(TCC) -DSQLITE_ENABLE_API_ARMOR=1
685 RCC = $(RCC) -DSQLITE_ENABLE_API_ARMOR=1
689 TCC = $(TCC) -DSQLITE_DEBUG=1
690 RCC = $(RCC) -DSQLITE_DEBUG=1
691 !IF $(DYNAMIC_SHELL)==0
692 TCC = $(TCC) -DSQLITE_ENABLE_WHERETRACE -DSQLITE_ENABLE_SELECTTRACE
693 RCC = $(RCC) -DSQLITE_ENABLE_WHERETRACE -DSQLITE_ENABLE_SELECTTRACE
697 !IF $(DEBUG)>4 || $(OSTRACE)!=0
698 TCC = $(TCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1
699 RCC = $(RCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1
703 TCC = $(TCC) -DSQLITE_ENABLE_IOTRACE=1
704 RCC = $(RCC) -DSQLITE_ENABLE_IOTRACE=1
707 # Prevent warnings about "insecure" MSVC runtime library functions
710 TCC = $(TCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
711 BCC = $(BCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
712 RCC = $(RCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
714 # Prevent warnings about "deprecated" POSIX functions being used.
716 TCC = $(TCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
717 BCC = $(BCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
718 RCC = $(RCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
720 # Use the SQLite debugging heap subsystem?
723 TCC = $(TCC) -DSQLITE_MEMDEBUG=1
724 RCC = $(RCC) -DSQLITE_MEMDEBUG=1
726 # Use native Win32 heap subsystem instead of malloc/free?
728 !ELSEIF $(WIN32HEAP)!=0
729 TCC = $(TCC) -DSQLITE_WIN32_MALLOC=1
730 RCC = $(RCC) -DSQLITE_WIN32_MALLOC=1
732 # Validate the heap on every call into the native Win32 heap subsystem?
735 TCC = $(TCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1
736 RCC = $(RCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1
741 # Address sanitizer if ASAN=1
744 TCC = $(TCC) /fsanitize=address
748 # Compiler options needed for programs that use the readline() library.
750 !IFNDEF READLINE_FLAGS
751 READLINE_FLAGS = -DHAVE_READLINE=0
754 # The library that programs using readline() must link against.
760 # Should the database engine be compiled threadsafe
762 TCC = $(TCC) -DSQLITE_THREADSAFE=1
763 RCC = $(RCC) -DSQLITE_THREADSAFE=1
765 # Do threads override each others locks by default (1), or do we test (-1)
767 TCC = $(TCC) -DSQLITE_THREAD_OVERRIDE_LOCK=-1
768 RCC = $(RCC) -DSQLITE_THREAD_OVERRIDE_LOCK=-1
770 # Any target libraries which libsqlite must be linked against
776 # Flags controlling use of the in memory btree implementation
778 # SQLITE_TEMP_STORE is 0 to force temporary tables to be in a file, 1 to
779 # default to file, 2 to default to memory, and 3 to force temporary
780 # tables to always be in memory.
782 TCC = $(TCC) -DSQLITE_TEMP_STORE=1
783 RCC = $(RCC) -DSQLITE_TEMP_STORE=1
785 # Enable/disable loadable extensions, and other optional features
786 # based on configuration. (-DSQLITE_OMIT*, -DSQLITE_ENABLE*).
787 # The same set of OMIT and ENABLE flags should be passed to the
788 # LEMON parser generator and the mkkeywordhash tool as well.
790 # These are the required SQLite compilation options used when compiling for
791 # the Windows platform.
793 REQ_FEATURE_FLAGS = $(REQ_FEATURE_FLAGS) -DSQLITE_MAX_TRIGGER_DEPTH=100
795 # If we are linking to the RPCRT4 library, enable features that need it.
797 !IF $(USE_RPCRT4_LIB)!=0
798 REQ_FEATURE_FLAGS = $(REQ_FEATURE_FLAGS) -DSQLITE_WIN32_USE_UUID=1
801 # Add the required and optional SQLite compilation options into the command
802 # lines used to invoke the MSVC code and resource compilers.
804 TCC = $(TCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS)
805 RCC = $(RCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS)
807 # Add in any optional parameters specified on the commane line, e.g.
808 # nmake /f Makefile.msc all "OPTS=-DSQLITE_ENABLE_FOO=1 -DSQLITE_OMIT_FOO=1"
813 # If compiling for debugging, add some defines.
816 TCC = $(TCC) -D_DEBUG
817 BCC = $(BCC) -D_DEBUG
818 RCC = $(RCC) -D_DEBUG
821 # If optimizations are enabled or disabled (either implicitly or
822 # explicitly), add the necessary flags.
824 !IF $(DEBUG)>1 || $(OPTIMIZATIONS)==0
827 !IF $(USE_RUNTIME_CHECKS)!=0
831 !ELSEIF $(OPTIMIZATIONS)>=3
834 !ELSEIF $(OPTIMIZATIONS)==2
837 !ELSEIF $(OPTIMIZATIONS)==1
842 # If symbols are enabled (or compiling for debugging), enable PDBs.
844 !IF $(DEBUG)>1 || $(SYMBOLS)!=0
850 # Command line prefixes for compiling code, compiling resources,
853 LTCOMPILE = $(TCC) -Fo$@ -Fd$*.pdb
854 LTRCOMPILE = $(RCC) -r
856 LTLINK = $(TCC) -Fe$@
858 # If requested, link to the RPCRT4 library.
860 !IF $(USE_RPCRT4_LIB)!=0
861 LTLIBS = $(LTLIBS) rpcrt4.lib
864 # If a platform was set, force the linker to target that.
865 # Note that the vcvars*.bat family of batch files typically
866 # set this for you. Otherwise, the linker will attempt
867 # to deduce the binary type based on the object files.
869 LTLINKOPTS = /NOLOGO /MACHINE:$(PLATFORM)
870 LTLIBOPTS = /NOLOGO /MACHINE:$(PLATFORM)
871 !ELSEIF "$(VISUALSTUDIOVERSION)"=="12.0" || \
872 "$(VISUALSTUDIOVERSION)"=="14.0" || \
873 "$(VISUALSTUDIOVERSION)"=="15.0"
874 LTLINKOPTS = /NOLOGO /MACHINE:x86
875 LTLIBOPTS = /NOLOGO /MACHINE:x86
881 # When compiling for use in the WinRT environment, the following
882 # linker option must be used to mark the executable as runnable
883 # only in the context of an application container.
886 LTLINKOPTS = $(LTLINKOPTS) /APPCONTAINER
887 !IF "$(VISUALSTUDIOVERSION)"=="12.0" || "$(VISUALSTUDIOVERSION)"=="14.0"
889 !IF "$(PLATFORM)"=="x86"
890 STORELIBPATH = $(CRTLIBPATH)\store
891 !ELSEIF "$(PLATFORM)"=="x64"
892 STORELIBPATH = $(CRTLIBPATH)\store\amd64
893 !ELSEIF "$(PLATFORM)"=="ARM"
894 STORELIBPATH = $(CRTLIBPATH)\store\arm
896 STORELIBPATH = $(CRTLIBPATH)\store
899 STORELIBPATH = $(STORELIBPATH:\\=\)
900 LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(STORELIBPATH)"
904 # When compiling for Windows Phone 8.1, an extra library path is
907 !IF $(USE_WP81_OPTS)!=0
909 !IF "$(PLATFORM)"=="x86"
910 WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\x86
911 !ELSEIF "$(PLATFORM)"=="ARM"
912 WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\ARM
914 WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\x86
919 # When compiling for Windows Phone 8.1, some extra linker options
922 !IF $(USE_WP81_OPTS)!=0
924 LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(WP81LIBPATH)"
926 LTLINKOPTS = $(LTLINKOPTS) /DYNAMICBASE
927 LTLINKOPTS = $(LTLINKOPTS) WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib
928 LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:ole32.lib
931 # When compiling for UWP or the Windows 10 platform, some extra linker
932 # options are also required.
934 !IF $(FOR_UWP)!=0 || $(FOR_WIN10)!=0
935 LTLINKOPTS = $(LTLINKOPTS) /DYNAMICBASE /NODEFAULTLIB:kernel32.lib
936 LTLINKOPTS = $(LTLINKOPTS) mincore.lib
938 LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(PSDKLIBPATH)"
943 LTLINKOPTS = $(LTLINKOPTS) /guard:cf "/LIBPATH:$(UCRTLIBPATH)"
945 LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:libucrtd.lib /DEFAULTLIB:ucrtd.lib
947 LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib
951 # If either debugging or symbols are enabled, enable PDBs.
953 !IF $(DEBUG)>1 || $(SYMBOLS)!=0
954 LDFLAGS = /DEBUG $(LDOPTS)
960 # You should not have to change anything below this line
961 ###############################################################################
964 # Object files for the amalgamation.
966 LIBOBJS1 = sqlite3.lo
968 # Determine the real value of LIBOBJ based on the 'configure' script
972 # Determine if embedded resource compilation and usage are enabled.
975 LIBRESOBJS = sqlite3res.lo
981 # Additional compiler options for the shell. These are only effective
982 # when the shell is not being dynamically linked.
984 !IF $(DYNAMIC_SHELL)==0 && $(FOR_WIN10)==0
985 SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_DQS=0
986 SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_FTS4=1
987 SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_EXPLAIN_COMMENTS=1
988 SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_OFFSET_SQL_FUNC=1
992 # This is the default Makefile target. The objects listed here
993 # are what get build when you type just "make" with no arguments.
997 # Targets that require the Tcl library.
999 tcl: $(ALL_TCL_TARGETS)
1001 # This Makefile target builds all of the standard binaries.
1005 # Dynamic link library section.
1011 shell: $(SQLITE3EXE)
1014 $(SQLITE3DLL): $(LIBOBJ) $(LIBRESOBJS) $(CORE_LINK_DEP)
1015 $(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL $(CORE_LINK_OPTS) /OUT:$@ $(LIBOBJ) $(LIBRESOBJS) $(LTLIBS) $(TLIBS)
1018 $(CSC) /target:exe $(TOP)\Replace.cs
1020 sqlite3.def: Replace.exe $(LIBOBJ)
1021 echo EXPORTS > sqlite3.def
1022 dumpbin /all $(LIBOBJ) \
1023 | .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset|changegroup|rebaser|rbu)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \
1024 | sort >> sqlite3.def
1026 $(SQLITE3EXE): shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLITE3H)
1027 $(LTLINK) $(SHELL_COMPILE_OPTS) $(READLINE_FLAGS) shell.c $(SHELL_CORE_SRC) \
1028 /link $(SQLITE3EXEPDB) $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS)
1031 # Rule to build the amalgamation
1033 sqlite3.lo: $(SQLITE3C)
1034 $(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(SQLITE3C)
1037 # Rule to build the Win32 resources object file.
1041 !IF ![echo !IFNDEF VERSION > rcver.vc] && \
1042 ![for /F "delims=" %V in ('type "$(SQLITE3H)" ^| "%SystemRoot%\System32\find.exe" "$(_HASHCHAR)define SQLITE_VERSION "') do (echo VERSION = ^^%V >> rcver.vc)] && \
1043 ![echo !ENDIF >> rcver.vc]
1047 RESOURCE_VERSION = $(VERSION:^#=)
1048 RESOURCE_VERSION = $(RESOURCE_VERSION:define=)
1049 RESOURCE_VERSION = $(RESOURCE_VERSION:SQLITE_VERSION=)
1050 RESOURCE_VERSION = $(RESOURCE_VERSION:"=)
1051 RESOURCE_VERSION = $(RESOURCE_VERSION:.=,)
1053 $(LIBRESOBJS): $(TOP)\sqlite3.rc rcver.vc $(SQLITE3H)
1054 echo #ifndef SQLITE_RESOURCE_VERSION > sqlite3rc.h
1055 echo #define SQLITE_RESOURCE_VERSION $(RESOURCE_VERSION) >> sqlite3rc.h
1056 echo #endif >> sqlite3rc.h
1057 $(LTRCOMPILE) -fo $(LIBRESOBJS) -DRC_VERONLY $(TOP)\sqlite3.rc
1062 del /Q *.exp *.lo *.ilk *.lib *.obj *.ncb *.pdb *.sdf *.suo 2>NUL
1063 del /Q *.bsc *.def *.cod *.da *.bb *.bbg *.vc gmon.out 2>NUL
1064 del /Q $(SQLITE3EXE) $(SQLITE3DLL) Replace.exe 2>NUL