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