@@ -13,6 +13,13 @@ TOP = .
1313USE_AMALGAMATION = 1
1414!ENDIF
1515
16+ # Set this non-0 to split the SQLite amalgamation file into chunks to
17+ # be used for debugging with Visual Studio.
18+ #
19+ !IFNDEF SPLIT_AMALGAMATION
20+ SPLIT_AMALGAMATION = 0
21+ !ENDIF
22+
1623# Set this non-0 to use the International Components for Unicode (ICU).
1724#
1825!IFNDEF USE_ICU
@@ -25,6 +32,13 @@ USE_ICU = 0
2532USE_CRT_DLL = 0
2633!ENDIF
2734
35+ # Set this non-0 to generate assembly code listings for the source code
36+ # files.
37+ #
38+ !IFNDEF USE_LISTINGS
39+ USE_LISTINGS = 0
40+ !ENDIF
41+
2842# Set this non-0 to attempt setting the native compiler automatically
2943# for cross-compiling the command line tools needed during the compilation
3044# process.
@@ -94,6 +108,14 @@ WIN32HEAP = 0
94108DEBUG = 0
95109!ENDIF
96110
111+ # Enable use of available compiler optimizations? Normally, this should be
112+ # non-zero. Setting this to zero, thus disabling all compiler optimizations,
113+ # can be useful for testing.
114+ #
115+ !IFNDEF OPTIMIZATIONS
116+ OPTIMIZATIONS = 2
117+ !ENDIF
118+
97119# Check for the predefined command macro CC. This should point to the compiler
98120# binary for the target platform. If it is not defined, simply define it to
99121# the legacy default value 'cl.exe'.
@@ -140,7 +162,7 @@ RC = rc.exe
140162!IFDEF NCC
141163NCC = $(NCC:\\=\)
142164!ELSEIF $(XCOMPILE)!=0
143- NCC = "$(VCINSTALLDIR)\bin\cl.exe "
165+ NCC = "$(VCINSTALLDIR)\bin\$(CC) "
144166NCC = $(NCC:\\=\)
145167!ELSE
146168NCC = $(CC)
@@ -173,6 +195,13 @@ NSDKLIBPATH = $(NSDKLIBPATH:\\=\)
173195#
174196BCC = $(NCC) -W3
175197
198+ # Check if assembly code listings should be generated for the source
199+ # code files to be compiled.
200+ #
201+ !IF $(USE_LISTINGS)!=0
202+ BCC = $(BCC) -FAcs
203+ !ENDIF
204+
176205# Check if the native library paths should be used when compiling
177206# the command line tools used during the compilation process. If
178207# so, set the necessary macro now.
@@ -185,9 +214,16 @@ NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)"
185214# will run on the target platform. (BCC and TCC are usually the
186215# same unless your are cross-compiling.)
187216#
188- TCC = $(CC) -W3 -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src -fp:precise
217+ TCC = $(CC) -W3 -DSQLITE_OS_WIN=1 -I. -I $(TOP) -I$(TOP)\src -fp:precise
189218RCC = $(RC) -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src
190219
220+ # Check if assembly code listings should be generated for the source
221+ # code files to be compiled.
222+ #
223+ !IF $(USE_LISTINGS)!=0
224+ TCC = $(TCC) -FAcs
225+ !ENDIF
226+
191227# When compiling the library for use in the WinRT environment,
192228# the following compile-time options must be used as well to
193229# disable use of Win32 APIs that are not available and to enable
@@ -234,6 +270,17 @@ TCC = $(TCC) -I$(TOP)\ext\rtree
234270RCC = $(RCC) -I$(TOP)\ext\rtree
235271!ENDIF
236272
273+ # The mksqlite3c.tcl script accepts some options on the command
274+ # line. When compiling with debugging enabled, some of these
275+ # options are necessary in order to allow debugging symbols to
276+ # work correctly with Visual Studio when using the amalgamation.
277+ #
278+ !IF $(DEBUG)>0
279+ MKSQLITE3C_ARGS = --linemacros
280+ !ELSE
281+ MKSQLITE3C_ARGS =
282+ !ENDIF
283+
237284# Define -DNDEBUG to compile without debugging (i.e., for production usage)
238285# Omitting the define will cause extra debugging code to be inserted and
239286# includes extra comments when "EXPLAIN stmt" is used.
@@ -343,11 +390,15 @@ TCLSH_CMD = tclsh85
343390
344391# Compiler options needed for programs that use the readline() library.
345392#
393+ !IFNDEF READLINE_FLAGS
346394READLINE_FLAGS = -DHAVE_READLINE=0
395+ !ENDIF
347396
348397# The library that programs using readline() must link against.
349398#
399+ !IFNDEF LIBREADLINE
350400LIBREADLINE =
401+ !ENDIF
351402
352403# Should the database engine be compiled threadsafe
353404#
@@ -397,17 +448,30 @@ RCC = $(RCC) $(OPT_FEATURE_FLAGS)
397448TCC = $(TCC) $(OPTS)
398449RCC = $(RCC) $(OPTS)
399450
400- # If symbols are enabled, enable PDBs.
401- # If debugging is enabled, disable all optimizations and enable PDBs.
451+ # If compiling for debugging, add some defines.
402452!IF $(DEBUG)>0
403- TCC = $(TCC) -Od - D_DEBUG
404- BCC = $(BCC) -Od - D_DEBUG
453+ TCC = $(TCC) -D_DEBUG
454+ BCC = $(BCC) -D_DEBUG
405455RCC = $(RCC) -D_DEBUG
406- !ELSE
456+ !ENDIF
457+
458+ # If optimizations are enabled or disabled (either implicitly or
459+ # explicitly), add the necessary flags.
460+ !IF $(DEBUG)>0 || $(OPTIMIZATIONS)==0
461+ TCC = $(TCC) -Od
462+ BCC = $(BCC) -Od
463+ !ELSEIF $(OPTIMIZATIONS)>=3
464+ TCC = $(TCC) -Ox
465+ BCC = $(BCC) -Ox
466+ !ELSEIF $(OPTIMIZATIONS)==2
407467TCC = $(TCC) -O2
408468BCC = $(BCC) -O2
469+ !ELSEIF $(OPTIMIZATIONS)==1
470+ TCC = $(TCC) -O1
471+ BCC = $(BCC) -O1
409472!ENDIF
410473
474+ # If symbols are enabled (or compiling for debugging), enable PDBs.
411475!IF $(DEBUG)>0 || $(SYMBOLS)!=0
412476TCC = $(TCC) -Zi
413477BCC = $(BCC) -Zi
@@ -445,6 +509,17 @@ LTLIBOPTS = /MACHINE:$(PLATFORM)
445509#
446510!IF $(FOR_WINRT)!=0
447511LTLINKOPTS = $(LTLINKOPTS) /APPCONTAINER
512+ !IF "$(VISUALSTUDIOVERSION)"=="12.0"
513+ !IF "$(PLATFORM)"=="x86"
514+ LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(VCINSTALLDIR)\lib\store"
515+ !ELSEIF "$(PLATFORM)"=="x64"
516+ LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(VCINSTALLDIR)\lib\store\amd64"
517+ !ELSEIF "$(PLATFORM)"=="ARM"
518+ LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(VCINSTALLDIR)\lib\store\arm"
519+ !ELSE
520+ LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(VCINSTALLDIR)\lib\store"
521+ !ENDIF
522+ !ENDIF
448523!ENDIF
449524
450525# If either debugging or symbols are enabled, enable PDBs.
@@ -465,7 +540,9 @@ LTLIBS = $(LTLIBS) $(LIBICU)
465540!ENDIF
466541
467542# nawk compatible awk.
543+ !IFNDEF NAWK
468544NAWK = gawk.exe
545+ !ENDIF
469546
470547# You should not have to change anything below this line
471548###############################################################################
@@ -602,7 +679,8 @@ SRC = \
602679 $(TOP)\src\wal.c \
603680 $(TOP)\src\wal.h \
604681 $(TOP)\src\walker.c \
605- $(TOP)\src\where.c
682+ $(TOP)\src\where.c \
683+ $(TOP)\src\whereInt.h
606684
607685# Source code for extensions
608686#
@@ -716,6 +794,7 @@ TESTEXT = \
716794 $(TOP)\ext\misc\percentile.c \
717795 $(TOP)\ext\misc\regexp.c \
718796 $(TOP)\ext\misc\spellfix.c \
797+ $(TOP)\ext\misc\totype.c \
719798 $(TOP)\ext\misc\wholenumber.c
720799
721800
@@ -787,7 +866,8 @@ HDR = \
787866 $(TOP)\src\sqliteInt.h \
788867 $(TOP)\src\sqliteLimit.h \
789868 $(TOP)\src\vdbe.h \
790- $(TOP)\src\vdbeInt.h
869+ $(TOP)\src\vdbeInt.h \
870+ $(TOP)\src\whereInt.h
791871
792872# Header files used by extensions
793873#
@@ -842,22 +922,31 @@ mptester.exe: $(TOP)\mptest\mptest.c libsqlite3.lib $(LIBRESOBJS) sqlite3.h
842922 -mkdir tsrc
843923 for %i in ($(SRC)) do copy /Y %i tsrc
844924 del /Q tsrc\sqlite.h.in tsrc\parse.y
845- $(TCLSH_CMD) $(TOP)\tool\vdbe-compress.tcl < tsrc\vdbe.c > vdbe.new
925+ $(TCLSH_CMD) $(TOP)\tool\vdbe-compress.tcl $(OPTS) < tsrc\vdbe.c > vdbe.new
846926 move vdbe.new tsrc\vdbe.c
847927 echo > .target_source
848928
849929sqlite3.c: .target_source $(TOP)\tool\mksqlite3c.tcl
850- $(TCLSH_CMD) $(TOP)\tool\mksqlite3c.tcl
930+ $(TCLSH_CMD) $(TOP)\tool\mksqlite3c.tcl $(MKSQLITE3C_ARGS)
851931 copy tsrc\shell.c .
852932 copy tsrc\sqlite3ext.h .
853933
854934sqlite3-all.c: sqlite3.c $(TOP)\tool\split-sqlite3c.tcl
855935 $(TCLSH_CMD) $(TOP)\tool\split-sqlite3c.tcl
856936
937+ # Set the source code file to be used by executables and libraries when
938+ # they need the amalgamation.
939+ #
940+ !IF $(SPLIT_AMALGAMATION)!=0
941+ SQLITE3C = sqlite3-all.c
942+ !ELSE
943+ SQLITE3C = sqlite3.c
944+ !ENDIF
945+
857946# Rule to build the amalgamation
858947#
859- sqlite3.lo: sqlite3.c
860- $(LTCOMPILE) -c sqlite3.c
948+ sqlite3.lo: $(SQLITE3C)
949+ $(LTCOMPILE) -c $(SQLITE3C)
861950
862951# Rules to build the LEMON compiler generator
863952#
@@ -1130,7 +1219,7 @@ parse.c: $(TOP)\src\parse.y lemon.exe $(TOP)\addopcodes.awk
11301219 $(NAWK) -f $(TOP)\addopcodes.awk parse.h.temp > parse.h
11311220
11321221sqlite3.h: $(TOP)\src\sqlite.h.in $(TOP)\manifest.uuid $(TOP)\VERSION
1133- $(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP) > sqlite3.h
1222+ $(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP:\=/ ) > sqlite3.h
11341223
11351224mkkeywordhash.exe: $(TOP)\tool\mkkeywordhash.c
11361225 $(BCC) -Fe$@ $(OPT_FEATURE_FLAGS) $(OPTS) $(TOP)\tool\mkkeywordhash.c /link $(NLTLIBPATHS)
@@ -1217,7 +1306,7 @@ TESTFIXTURE_FLAGS = -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1
12171306TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" -DSQLITE_CORE
12181307
12191308TESTFIXTURE_SRC0 = $(TESTEXT) $(TESTSRC2) libsqlite3.lib
1220- TESTFIXTURE_SRC1 = $(TESTEXT) sqlite3.c
1309+ TESTFIXTURE_SRC1 = $(TESTEXT) $(SQLITE3C)
12211310!IF $(USE_AMALGAMATION)==0
12221311TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC0)
12231312!ELSE
@@ -1230,6 +1319,9 @@ testfixture.exe: $(TESTFIXTURE_SRC) $(LIBRESOBJS) $(HDR)
12301319 $(TESTFIXTURE_SRC) \
12311320 /link $(LTLINKOPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LTLIBS) $(TLIBS)
12321321
1322+ extensiontest: testfixture.exe testloadext.dll
1323+ .\testfixture.exe $(TOP)\test\loadext.test
1324+
12331325fulltest: testfixture.exe sqlite3.exe
12341326 .\testfixture.exe $(TOP)\test\all.test
12351327
@@ -1245,8 +1337,8 @@ queryplantest: testfixture.exe sqlite3.exe
12451337test: testfixture.exe sqlite3.exe
12461338 .\testfixture.exe $(TOP)\test\veryquick.test
12471339
1248- sqlite3_analyzer.c: sqlite3.c $(TOP)\src\test_stat.c $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl
1249- copy sqlite3.c + $(TOP)\src\test_stat.c + $(TOP)\src\tclsqlite.c $@
1340+ sqlite3_analyzer.c: $(SQLITE3C) $(TOP)\src\test_stat.c $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl
1341+ copy $(SQLITE3C) + $(TOP)\src\test_stat.c + $(TOP)\src\tclsqlite.c $@
12501342 echo static const char *tclsh_main_loop(void){ >> $@
12511343 echo static const char *zMainloop = >> $@
12521344 $(NAWK) -f $(TOP)\tool\tostr.awk $(TOP)\tool\spaceanal.tcl >> $@
@@ -1256,12 +1348,31 @@ sqlite3_analyzer.exe: sqlite3_analyzer.c $(LIBRESOBJS)
12561348 $(LTLINK) -DBUILD_sqlite -DTCLSH=2 -I$(TCLINCDIR) sqlite3_analyzer.c \
12571349 /link $(LTLINKOPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LTLIBS) $(TLIBS)
12581350
1351+ testloadext.lo: $(TOP)\src\test_loadext.c
1352+ $(LTCOMPILE) -c $(TOP)\src\test_loadext.c
1353+
1354+ testloadext.dll: testloadext.lo
1355+ $(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL /OUT:$@ testloadext.lo
1356+
1357+ showdb.exe: $(TOP)\tool\showdb.c $(SQLITE3C)
1358+ $(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
1359+ $(TOP)\tool\showdb.c $(SQLITE3C)
1360+
1361+ wordcount.exe: $(TOP)\test\wordcount.c $(SQLITE3C)
1362+ $(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
1363+ $(TOP)\test\wordcount.c $(SQLITE3C)
1364+
1365+ speedtest1.exe: $(TOP)\test\speedtest1.c $(SQLITE3C)
1366+ $(LTLINK) -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
1367+ $(TOP)\test\speedtest1.c $(SQLITE3C)
1368+
12591369clean:
12601370 del /Q *.lo *.ilk *.lib *.obj *.pdb sqlite3.exe libsqlite3.lib
1261- del /Q *.da *.bb *.bbg gmon.out
1371+ del /Q *.cod *. da *.bb *.bbg gmon.out
12621372 del /Q sqlite3.h opcodes.c opcodes.h
12631373 del /Q lemon.exe lempar.c parse.*
12641374 del /Q mkkeywordhash.exe keywordhash.h
1375+ del /Q notasharedlib.*
12651376 -rmdir /Q/S .deps
12661377 -rmdir /Q/S .libs
12671378 -rmdir /Q/S quota2a
@@ -1270,9 +1381,10 @@ clean:
12701381 -rmdir /Q/S tsrc
12711382 del /Q .target_source
12721383 del /Q tclsqlite3.exe tclsqlite3.exp
1384+ del /Q testloadext.dll testloadext.exp
12731385 del /Q testfixture.exe testfixture.exp test.db
12741386 del /Q sqlite3.dll sqlite3.lib sqlite3.exp sqlite3.def
1275- del /Q sqlite3.c
1387+ del /Q sqlite3.c sqlite3-*.c
12761388 del /Q sqlite3rc.h
12771389 del /Q shell.c sqlite3ext.h
12781390 del /Q sqlite3_analyzer.exe sqlite3_analyzer.exp sqlite3_analyzer.c
0 commit comments