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