1#!/usr/make
2#
3# Makefile for SQLITE
4#
5# This makefile is suppose to be configured automatically using the
6# autoconf.  But if that does not work for you, you can configure
7# the makefile manually.  Just set the parameters below to values that
8# work well for your system.
9#
10# If the configure script does not work out-of-the-box, you might
11# be able to get it to work by giving it some hints.  See the comment
12# at the beginning of configure.in for additional information.
13#
14
15# The toplevel directory of the source tree.  This is the directory
16# that contains this "Makefile.in" and the "configure.in" script.
17#
18TOP = @abs_srcdir@
19
20
21# C Compiler and options for use in building executables that
22# will run on the platform that is doing the build.
23#
24BCC = @BUILD_CC@ @BUILD_CFLAGS@
25
26# TCC is the C Compile and options for use in building executables that
27# will run on the target platform.  (BCC and TCC are usually the
28# same unless your are cross-compiling.)  Separate CC and CFLAGS macros
29# are provide so that these aspects of the build process can be changed
30# on the "make" command-line.  Ex:  "make CC=clang CFLAGS=-fsanitize=undefined"
31#
32CC = @CC@
33CFLAGS = @CPPFLAGS@ @CFLAGS@
34TCC = ${CC} ${CFLAGS} -I. -I${TOP}/src -I${TOP}/ext/rtree -I${TOP}/ext/icu
35TCC += -I${TOP}/ext/fts3 -I${TOP}/ext/async -I${TOP}/ext/session
36
37# Define this for the autoconf-based build, so that the code knows it can
38# include the generated config.h
39#
40TCC += -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite
41
42# Define -DNDEBUG to compile without debugging (i.e., for production usage)
43# Omitting the define will cause extra debugging code to be inserted and
44# includes extra comments when "EXPLAIN stmt" is used.
45#
46TCC += @TARGET_DEBUG@
47
48# Compiler options needed for programs that use the TCL library.
49#
50TCC += @TCL_INCLUDE_SPEC@
51
52# The library that programs using TCL must link against.
53#
54LIBTCL = @TCL_LIB_SPEC@
55
56# Compiler options needed for programs that use the readline() library.
57#
58READLINE_FLAGS = -DHAVE_READLINE=@TARGET_HAVE_READLINE@ @TARGET_READLINE_INC@
59READLINE_FLAGS += -DHAVE_EDITLINE=@TARGET_HAVE_EDITLINE@
60
61# The library that programs using readline() must link against.
62#
63LIBREADLINE = @TARGET_READLINE_LIBS@
64
65# Should the database engine be compiled threadsafe
66#
67TCC += -DSQLITE_THREADSAFE=@SQLITE_THREADSAFE@
68
69# Any target libraries which libsqlite must be linked against
70#
71TLIBS = @LIBS@ $(LIBS)
72
73# Flags controlling use of the in memory btree implementation
74#
75# SQLITE_TEMP_STORE is 0 to force temporary tables to be in a file, 1 to
76# default to file, 2 to default to memory, and 3 to force temporary
77# tables to always be in memory.
78#
79TEMP_STORE = -DSQLITE_TEMP_STORE=@TEMP_STORE@
80
81# Enable/disable loadable extensions, and other optional features
82# based on configuration. (-DSQLITE_OMIT*, -DSQLITE_ENABLE*).
83# The same set of OMIT and ENABLE flags should be passed to the
84# LEMON parser generator and the mkkeywordhash tool as well.
85OPT_FEATURE_FLAGS = @OPT_FEATURE_FLAGS@
86
87TCC += $(OPT_FEATURE_FLAGS)
88
89# Add in any optional parameters specified on the make commane line
90# ie.  make "OPTS=-DSQLITE_ENABLE_FOO=1 -DSQLITE_OMIT_FOO=1".
91TCC += $(OPTS)
92
93# Version numbers and release number for the SQLite being compiled.
94#
95VERSION = @VERSION@
96VERSION_NUMBER = @VERSION_NUMBER@
97RELEASE = @RELEASE@
98
99# Filename extensions
100#
101BEXE = @BUILD_EXEEXT@
102TEXE = @TARGET_EXEEXT@
103
104# The following variable is "1" if the configure script was able to locate
105# the tclConfig.sh file.  It is an empty string otherwise.  When this
106# variable is "1", the TCL extension library (libtclsqlite3.so) is built
107# and installed.
108#
109HAVE_TCL = @HAVE_TCL@
110
111# This is the command to use for tclsh - normally just "tclsh", but we may
112# know the specific version we want to use
113#
114TCLSH_CMD = @TCLSH_CMD@
115
116# Where do we want to install the tcl plugin
117#
118TCLLIBDIR = @TCLLIBDIR@
119
120# The suffix used on shared libraries.  Ex:  ".dll", ".so", ".dylib"
121#
122SHLIB_SUFFIX = @TCL_SHLIB_SUFFIX@
123
124# If gcov support was enabled by the configure script, add the appropriate
125# flags here.  It's not always as easy as just having the user add the right
126# CFLAGS / LDFLAGS, because libtool wants to use CFLAGS when linking, which
127# causes build errors with -fprofile-arcs -ftest-coverage with some GCCs.
128# Supposedly GCC does the right thing if you use --coverage, but in
129# practice it still fails.  See:
130#
131# http://www.mail-archive.com/debian-gcc@lists.debian.org/msg26197.html
132#
133# for more info.
134#
135GCOV_CFLAGS1 = -DSQLITE_COVERAGE_TEST=1 -fprofile-arcs -ftest-coverage
136GCOV_LDFLAGS1 = -lgcov
137USE_GCOV = @USE_GCOV@
138LTCOMPILE_EXTRAS += $(GCOV_CFLAGS$(USE_GCOV))
139LTLINK_EXTRAS += $(GCOV_LDFLAGS$(USE_GCOV))
140
141# BEGIN CRYPTO
142CRYPTOLIBOBJ = \
143  crypto.lo \
144  crypto_impl.lo \
145  crypto_openssl.lo \
146  crypto_libtomcrypt.lo \
147  crypto_cc.lo
148
149CRYPTOSRC = \
150  $(TOP)/src/crypto.h \
151  $(TOP)/src/sqlcipher.h \
152  $(TOP)/src/crypto.c \
153  $(TOP)/src/crypto_impl.c \
154	$(TOP)/src/crypto_libtomcrypt.c \
155	$(TOP)/src/crypto_openssl.c \
156	$(TOP)/src/crypto_cc.c
157
158# END CRYPTO
159
160# The directory into which to store package information for
161
162# Some standard variables and programs
163#
164prefix = @prefix@
165exec_prefix = @exec_prefix@
166libdir = @libdir@
167pkgconfigdir = $(prefix)/libdata/pkgconfig
168bindir = @bindir@
169includedir = @includedir@/sqlcipher
170INSTALL = @INSTALL@
171LIBTOOL = ./libtool
172ALLOWRELEASE = @ALLOWRELEASE@
173
174# libtool compile/link/install
175LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(TCC) $(LTCOMPILE_EXTRAS)
176LTLINK = $(LIBTOOL) --mode=link $(TCC) $(LTCOMPILE_EXTRAS) @LDFLAGS@ $(LTLINK_EXTRAS)
177LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
178
179# You should not have to change anything below this line
180###############################################################################
181
182USE_AMALGAMATION = @USE_AMALGAMATION@
183
184# Object files for the SQLite library (non-amalgamation).
185#
186LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \
187         backup.lo bitvec.lo btmutex.lo btree.lo build.lo \
188         callback.lo complete.lo ctime.lo date.lo dbstat.lo delete.lo \
189         expr.lo fault.lo fkey.lo \
190         fts3.lo fts3_aux.lo fts3_expr.lo fts3_hash.lo fts3_icu.lo \
191         fts3_porter.lo fts3_snippet.lo fts3_tokenizer.lo fts3_tokenizer1.lo \
192         fts3_tokenize_vtab.lo \
193         fts3_unicode.lo fts3_unicode2.lo fts3_write.lo \
194	 fts5.lo \
195         func.lo global.lo hash.lo \
196         icu.lo insert.lo json1.lo legacy.lo loadext.lo \
197         main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \
198         memjournal.lo \
199         mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
200         notify.lo opcodes.lo os.lo os_unix.lo os_win.lo \
201         pager.lo parse.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \
202         random.lo resolve.lo rowset.lo rtree.lo \
203         sqlite3session.lo select.lo sqlite3rbu.lo status.lo stmt.lo \
204         table.lo threads.lo tokenize.lo treeview.lo trigger.lo \
205         update.lo util.lo vacuum.lo \
206         vdbe.lo vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbesort.lo \
207         vdbetrace.lo wal.lo walker.lo where.lo wherecode.lo whereexpr.lo \
208         utf.lo vtab.lo $(CRYPTOLIBOBJ)
209
210# Object files for the amalgamation.
211#
212LIBOBJS1 = sqlite3.lo
213
214# Determine the real value of LIBOBJ based on the 'configure' script
215#
216LIBOBJ = $(LIBOBJS$(USE_AMALGAMATION))
217
218
219# All of the source code files.
220#
221SRC = \
222  $(CRYPTOSRC) \
223  $(TOP)/src/alter.c \
224  $(TOP)/src/analyze.c \
225  $(TOP)/src/attach.c \
226  $(TOP)/src/auth.c \
227  $(TOP)/src/backup.c \
228  $(TOP)/src/bitvec.c \
229  $(TOP)/src/btmutex.c \
230  $(TOP)/src/btree.c \
231  $(TOP)/src/btree.h \
232  $(TOP)/src/btreeInt.h \
233  $(TOP)/src/build.c \
234  $(TOP)/src/callback.c \
235  $(TOP)/src/complete.c \
236  $(TOP)/src/ctime.c \
237  $(TOP)/src/date.c \
238  $(TOP)/src/dbstat.c \
239  $(TOP)/src/delete.c \
240  $(TOP)/src/expr.c \
241  $(TOP)/src/fault.c \
242  $(TOP)/src/fkey.c \
243  $(TOP)/src/func.c \
244  $(TOP)/src/global.c \
245  $(TOP)/src/hash.c \
246  $(TOP)/src/hash.h \
247  $(TOP)/src/hwtime.h \
248  $(TOP)/src/insert.c \
249  $(TOP)/src/legacy.c \
250  $(TOP)/src/loadext.c \
251  $(TOP)/src/main.c \
252  $(TOP)/src/malloc.c \
253  $(TOP)/src/mem0.c \
254  $(TOP)/src/mem1.c \
255  $(TOP)/src/mem2.c \
256  $(TOP)/src/mem3.c \
257  $(TOP)/src/mem5.c \
258  $(TOP)/src/memjournal.c \
259  $(TOP)/src/msvc.h \
260  $(TOP)/src/mutex.c \
261  $(TOP)/src/mutex.h \
262  $(TOP)/src/mutex_noop.c \
263  $(TOP)/src/mutex_unix.c \
264  $(TOP)/src/mutex_w32.c \
265  $(TOP)/src/notify.c \
266  $(TOP)/src/os.c \
267  $(TOP)/src/os.h \
268  $(TOP)/src/os_common.h \
269  $(TOP)/src/os_setup.h \
270  $(TOP)/src/os_unix.c \
271  $(TOP)/src/os_win.c \
272  $(TOP)/src/os_win.h \
273  $(TOP)/src/pager.c \
274  $(TOP)/src/pager.h \
275  $(TOP)/src/parse.y \
276  $(TOP)/src/pcache.c \
277  $(TOP)/src/pcache.h \
278  $(TOP)/src/pcache1.c \
279  $(TOP)/src/pragma.c \
280  $(TOP)/src/pragma.h \
281  $(TOP)/src/prepare.c \
282  $(TOP)/src/printf.c \
283  $(TOP)/src/random.c \
284  $(TOP)/src/resolve.c \
285  $(TOP)/src/rowset.c \
286  $(TOP)/src/select.c \
287  $(TOP)/src/status.c \
288  $(TOP)/src/shell.c \
289  $(TOP)/src/sqlite.h.in \
290  $(TOP)/src/sqlite3ext.h \
291  $(TOP)/src/sqliteInt.h \
292  $(TOP)/src/sqliteLimit.h \
293  $(TOP)/src/table.c \
294  $(TOP)/src/tclsqlite.c \
295  $(TOP)/src/threads.c \
296  $(TOP)/src/tokenize.c \
297  $(TOP)/src/treeview.c \
298  $(TOP)/src/trigger.c \
299  $(TOP)/src/utf.c \
300  $(TOP)/src/update.c \
301  $(TOP)/src/util.c \
302  $(TOP)/src/vacuum.c \
303  $(TOP)/src/vdbe.c \
304  $(TOP)/src/vdbe.h \
305  $(TOP)/src/vdbeapi.c \
306  $(TOP)/src/vdbeaux.c \
307  $(TOP)/src/vdbeblob.c \
308  $(TOP)/src/vdbemem.c \
309  $(TOP)/src/vdbesort.c \
310  $(TOP)/src/vdbetrace.c \
311  $(TOP)/src/vdbeInt.h \
312  $(TOP)/src/vtab.c \
313  $(TOP)/src/vxworks.h \
314  $(TOP)/src/wal.c \
315  $(TOP)/src/wal.h \
316  $(TOP)/src/walker.c \
317  $(TOP)/src/where.c \
318  $(TOP)/src/wherecode.c \
319  $(TOP)/src/whereexpr.c \
320  $(TOP)/src/whereInt.h
321
322# Source code for extensions
323#
324SRC += \
325  $(TOP)/ext/fts1/fts1.c \
326  $(TOP)/ext/fts1/fts1.h \
327  $(TOP)/ext/fts1/fts1_hash.c \
328  $(TOP)/ext/fts1/fts1_hash.h \
329  $(TOP)/ext/fts1/fts1_porter.c \
330  $(TOP)/ext/fts1/fts1_tokenizer.h \
331  $(TOP)/ext/fts1/fts1_tokenizer1.c
332SRC += \
333  $(TOP)/ext/fts2/fts2.c \
334  $(TOP)/ext/fts2/fts2.h \
335  $(TOP)/ext/fts2/fts2_hash.c \
336  $(TOP)/ext/fts2/fts2_hash.h \
337  $(TOP)/ext/fts2/fts2_icu.c \
338  $(TOP)/ext/fts2/fts2_porter.c \
339  $(TOP)/ext/fts2/fts2_tokenizer.h \
340  $(TOP)/ext/fts2/fts2_tokenizer.c \
341  $(TOP)/ext/fts2/fts2_tokenizer1.c
342SRC += \
343  $(TOP)/ext/fts3/fts3.c \
344  $(TOP)/ext/fts3/fts3.h \
345  $(TOP)/ext/fts3/fts3Int.h \
346  $(TOP)/ext/fts3/fts3_aux.c \
347  $(TOP)/ext/fts3/fts3_expr.c \
348  $(TOP)/ext/fts3/fts3_hash.c \
349  $(TOP)/ext/fts3/fts3_hash.h \
350  $(TOP)/ext/fts3/fts3_icu.c \
351  $(TOP)/ext/fts3/fts3_porter.c \
352  $(TOP)/ext/fts3/fts3_snippet.c \
353  $(TOP)/ext/fts3/fts3_tokenizer.h \
354  $(TOP)/ext/fts3/fts3_tokenizer.c \
355  $(TOP)/ext/fts3/fts3_tokenizer1.c \
356  $(TOP)/ext/fts3/fts3_tokenize_vtab.c \
357  $(TOP)/ext/fts3/fts3_unicode.c \
358  $(TOP)/ext/fts3/fts3_unicode2.c \
359  $(TOP)/ext/fts3/fts3_write.c
360SRC += \
361  $(TOP)/ext/icu/sqliteicu.h \
362  $(TOP)/ext/icu/icu.c
363SRC += \
364  $(TOP)/ext/rtree/rtree.h \
365  $(TOP)/ext/rtree/rtree.c
366SRC += \
367  $(TOP)/ext/session/sqlite3session.c \
368  $(TOP)/ext/session/sqlite3session.h
369SRC += \
370  $(TOP)/ext/rbu/sqlite3rbu.h \
371  $(TOP)/ext/rbu/sqlite3rbu.c
372SRC += \
373  $(TOP)/ext/misc/json1.c \
374  $(TOP)/ext/misc/stmt.c
375
376# Generated source code files
377#
378SRC += \
379  keywordhash.h \
380  opcodes.c \
381  opcodes.h \
382  parse.c \
383  parse.h \
384  config.h \
385  sqlite3.h
386
387# Source code to the test files.
388#
389TESTSRC = \
390  $(TOP)/src/test1.c \
391  $(TOP)/src/test2.c \
392  $(TOP)/src/test3.c \
393  $(TOP)/src/test4.c \
394  $(TOP)/src/test5.c \
395  $(TOP)/src/test6.c \
396  $(TOP)/src/test7.c \
397  $(TOP)/src/test8.c \
398  $(TOP)/src/test9.c \
399  $(TOP)/src/test_autoext.c \
400  $(TOP)/src/test_async.c \
401  $(TOP)/src/test_backup.c \
402  $(TOP)/src/test_bestindex.c \
403  $(TOP)/src/test_blob.c \
404  $(TOP)/src/test_btree.c \
405  $(TOP)/src/test_config.c \
406  $(TOP)/src/test_delete.c \
407  $(TOP)/src/test_demovfs.c \
408  $(TOP)/src/test_devsym.c \
409  $(TOP)/src/test_fs.c \
410  $(TOP)/src/test_func.c \
411  $(TOP)/src/test_hexio.c \
412  $(TOP)/src/test_init.c \
413  $(TOP)/src/test_intarray.c \
414  $(TOP)/src/test_journal.c \
415  $(TOP)/src/test_malloc.c \
416  $(TOP)/src/test_multiplex.c \
417  $(TOP)/src/test_mutex.c \
418  $(TOP)/src/test_onefile.c \
419  $(TOP)/src/test_osinst.c \
420  $(TOP)/src/test_pcache.c \
421  $(TOP)/src/test_quota.c \
422  $(TOP)/src/test_rtree.c \
423  $(TOP)/src/test_schema.c \
424  $(TOP)/src/test_server.c \
425  $(TOP)/src/test_superlock.c \
426  $(TOP)/src/test_syscall.c \
427  $(TOP)/src/test_tclvar.c \
428  $(TOP)/src/test_thread.c \
429  $(TOP)/src/test_vfs.c \
430  $(TOP)/src/test_windirent.c \
431  $(TOP)/src/test_wsd.c       \
432  $(TOP)/ext/fts3/fts3_term.c \
433  $(TOP)/ext/fts3/fts3_test.c  \
434  $(TOP)/ext/session/test_session.c \
435  $(TOP)/ext/rbu/test_rbu.c
436
437# Statically linked extensions
438#
439TESTSRC += \
440  $(TOP)/ext/misc/amatch.c \
441  $(TOP)/ext/misc/carray.c \
442  $(TOP)/ext/misc/closure.c \
443  $(TOP)/ext/misc/csv.c \
444  $(TOP)/ext/misc/eval.c \
445  $(TOP)/ext/misc/fileio.c \
446  $(TOP)/ext/misc/fuzzer.c \
447  $(TOP)/ext/fts5/fts5_tcl.c \
448  $(TOP)/ext/fts5/fts5_test_mi.c \
449  $(TOP)/ext/fts5/fts5_test_tok.c \
450  $(TOP)/ext/misc/ieee754.c \
451  $(TOP)/ext/misc/nextchar.c \
452  $(TOP)/ext/misc/percentile.c \
453  $(TOP)/ext/misc/regexp.c \
454  $(TOP)/ext/misc/remember.c \
455  $(TOP)/ext/misc/series.c \
456  $(TOP)/ext/misc/spellfix.c \
457  $(TOP)/ext/misc/totype.c \
458  $(TOP)/ext/misc/unionvtab.c \
459  $(TOP)/ext/misc/wholenumber.c
460
461# Source code to the library files needed by the test fixture
462#
463TESTSRC2 = \
464  $(TOP)/src/attach.c \
465  $(TOP)/src/backup.c \
466  $(TOP)/src/bitvec.c \
467  $(TOP)/src/btree.c \
468  $(TOP)/src/build.c \
469  $(TOP)/src/ctime.c \
470  $(TOP)/src/date.c \
471  $(TOP)/src/dbstat.c \
472  $(TOP)/src/expr.c \
473  $(TOP)/src/func.c \
474  $(TOP)/src/insert.c \
475  $(TOP)/src/wal.c \
476  $(TOP)/src/main.c \
477  $(TOP)/src/mem5.c \
478  $(TOP)/src/os.c \
479  $(TOP)/src/os_unix.c \
480  $(TOP)/src/os_win.c \
481  $(TOP)/src/pager.c \
482  $(TOP)/src/pragma.c \
483  $(TOP)/src/prepare.c \
484  $(TOP)/src/printf.c \
485  $(TOP)/src/random.c \
486  $(TOP)/src/pcache.c \
487  $(TOP)/src/pcache1.c \
488  $(TOP)/src/select.c \
489  $(TOP)/src/tokenize.c \
490  $(TOP)/src/utf.c \
491  $(TOP)/src/util.c \
492  $(TOP)/src/vdbeapi.c \
493  $(TOP)/src/vdbeaux.c \
494  $(TOP)/src/vdbe.c \
495  $(TOP)/src/vdbemem.c \
496  $(TOP)/src/vdbetrace.c \
497  $(TOP)/src/where.c \
498  $(TOP)/src/wherecode.c \
499  $(TOP)/src/whereexpr.c \
500  parse.c \
501  $(TOP)/ext/fts3/fts3.c \
502  $(TOP)/ext/fts3/fts3_aux.c \
503  $(TOP)/ext/fts3/fts3_expr.c \
504  $(TOP)/ext/fts3/fts3_term.c \
505  $(TOP)/ext/fts3/fts3_tokenizer.c \
506  $(TOP)/ext/fts3/fts3_write.c \
507  $(TOP)/ext/async/sqlite3async.c \
508  $(TOP)/ext/session/sqlite3session.c \
509  $(TOP)/ext/misc/stmt.c
510
511# Header files used by all library source files.
512#
513HDR = \
514   $(TOP)/src/btree.h \
515   $(TOP)/src/btreeInt.h \
516   $(TOP)/src/hash.h \
517   $(TOP)/src/hwtime.h \
518   keywordhash.h \
519   $(TOP)/src/msvc.h \
520   $(TOP)/src/mutex.h \
521   opcodes.h \
522   $(TOP)/src/os.h \
523   $(TOP)/src/os_common.h \
524   $(TOP)/src/os_setup.h \
525   $(TOP)/src/os_win.h \
526   $(TOP)/src/pager.h \
527   $(TOP)/src/pcache.h \
528   parse.h  \
529   $(TOP)/src/pragma.h \
530   sqlite3.h  \
531   $(TOP)/src/sqlite3ext.h \
532   $(TOP)/src/sqliteInt.h  \
533   $(TOP)/src/sqliteLimit.h \
534   $(TOP)/src/vdbe.h \
535   $(TOP)/src/vdbeInt.h \
536   $(TOP)/src/vxworks.h \
537   $(TOP)/src/whereInt.h \
538   config.h
539
540# Header files used by extensions
541#
542EXTHDR += \
543  $(TOP)/ext/fts1/fts1.h \
544  $(TOP)/ext/fts1/fts1_hash.h \
545  $(TOP)/ext/fts1/fts1_tokenizer.h
546EXTHDR += \
547  $(TOP)/ext/fts2/fts2.h \
548  $(TOP)/ext/fts2/fts2_hash.h \
549  $(TOP)/ext/fts2/fts2_tokenizer.h
550EXTHDR += \
551  $(TOP)/ext/fts3/fts3.h \
552  $(TOP)/ext/fts3/fts3Int.h \
553  $(TOP)/ext/fts3/fts3_hash.h \
554  $(TOP)/ext/fts3/fts3_tokenizer.h
555EXTHDR += \
556  $(TOP)/ext/rtree/rtree.h
557EXTHDR += \
558  $(TOP)/ext/icu/sqliteicu.h
559EXTHDR += \
560  $(TOP)/ext/rtree/sqlite3rtree.h
561
562# executables needed for testing
563#
564TESTPROGS = \
565  testfixture$(TEXE) \
566  sqlite3$(TEXE) \
567  sqlite3_analyzer$(TEXE) \
568  sqldiff$(TEXE) \
569  dbhash$(TEXE)
570
571# Databases containing fuzzer test cases
572#
573FUZZDATA = \
574  $(TOP)/test/fuzzdata1.db \
575  $(TOP)/test/fuzzdata2.db \
576  $(TOP)/test/fuzzdata3.db \
577  $(TOP)/test/fuzzdata4.db \
578  $(TOP)/test/fuzzdata5.db
579
580# Standard options to testfixture
581#
582TESTOPTS = --verbose=file --output=test-out.txt
583
584# Extra compiler options for various shell tools
585#
586SHELL_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4
587# SHELL_OPT += -DSQLITE_ENABLE_FTS5
588SHELL_OPT += -DSQLITE_ENABLE_EXPLAIN_COMMENTS
589SHELL_OPT += -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
590SHELL_OPT += -DSQLITE_ENABLE_STMTVTAB
591FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1
592FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ
593FUZZCHECK_OPT += -DSQLITE_MAX_MEMORY=50000000
594FUZZCHECK_SRC = $(TOP)/test/fuzzcheck.c $(TOP)/test/ossfuzz.c
595DBFUZZ_OPT =
596
597# This is the default Makefile target.  The objects listed here
598# are what get build when you type just "make" with no arguments.
599#
600all:	sqlite3.h libsqlcipher.la sqlcipher$(TEXE) $(HAVE_TCL:1=libtclsqlite3.la)
601
602Makefile: $(TOP)/Makefile.in
603	./config.status
604
605sqlcipher.pc: $(TOP)/sqlcipher.pc.in
606	./config.status
607
608libsqlcipher.la:	$(LIBOBJ)
609	$(LTLINK) -no-undefined -o $@ $(LIBOBJ) $(TLIBS) \
610		${ALLOWRELEASE} -rpath "$(libdir)" -version-info "8:6:8"
611
612libtclsqlite3.la:	tclsqlite.lo libsqlcipher.la
613	$(LTLINK) -no-undefined -o $@ tclsqlite.lo \
614		libsqlcipher.la @TCL_STUB_LIB_SPEC@ $(TLIBS) \
615		-rpath "$(TCLLIBDIR)" \
616		-version-info "8:6:8" \
617		-avoid-version
618
619sqlcipher$(TEXE):	$(TOP)/src/shell.c libsqlcipher.la sqlite3.h
620	$(LTLINK) $(READLINE_FLAGS) $(SHELL_OPT) \
621		-o $@ $(TOP)/src/shell.c libsqlcipher.la \
622		$(LIBREADLINE) $(TLIBS) -rpath "$(libdir)"
623
624sqldiff$(TEXE):	$(TOP)/tool/sqldiff.c sqlite3.lo sqlite3.h
625	$(LTLINK) -o $@ $(TOP)/tool/sqldiff.c sqlite3.lo $(TLIBS)
626
627dbhash$(TEXE):	$(TOP)/tool/dbhash.c sqlite3.lo sqlite3.h
628	$(LTLINK) -o $@ $(TOP)/tool/dbhash.c sqlite3.lo $(TLIBS)
629
630scrub$(TEXE):	$(TOP)/ext/misc/scrub.c sqlite3.lo
631	$(LTLINK) -o $@ -I. -DSCRUB_STANDALONE \
632		$(TOP)/ext/misc/scrub.c sqlite3.lo $(TLIBS)
633
634srcck1$(BEXE):	$(TOP)/tool/srcck1.c
635	$(BCC) -o srcck1$(BEXE) $(TOP)/tool/srcck1.c
636
637sourcetest:	srcck1$(BEXE) sqlite3.c
638	./srcck1 sqlite3.c
639
640fuzzershell$(TEXE):	$(TOP)/tool/fuzzershell.c sqlite3.c sqlite3.h
641	$(LTLINK) -o $@ $(FUZZERSHELL_OPT) \
642	  $(TOP)/tool/fuzzershell.c sqlite3.c $(TLIBS)
643
644fuzzcheck$(TEXE):	$(FUZZCHECK_SRC) sqlite3.c sqlite3.h
645	$(LTLINK) -o $@ $(FUZZCHECK_OPT) $(FUZZCHECK_SRC) sqlite3.c $(TLIBS)
646
647ossshell$(TEXE):	$(TOP)/test/ossfuzz.c $(TOP)/test/ossshell.c sqlite3.c sqlite3.h
648	$(LTLINK) -o $@ $(FUZZCHECK_OPT) $(TOP)/test/ossshell.c \
649             $(TOP)/test/ossfuzz.c sqlite3.c $(TLIBS)
650
651dbfuzz$(TEXE):	$(TOP)/test/dbfuzz.c sqlite3.c sqlite3.h
652	$(LTLINK) -o $@ $(DBFUZZ_OPT) $(TOP)/test/dbfuzz.c sqlite3.c $(TLIBS)
653
654mptester$(TEXE):	sqlite3.lo $(TOP)/mptest/mptest.c
655	$(LTLINK) -o $@ -I. $(TOP)/mptest/mptest.c sqlite3.lo \
656		$(TLIBS) -rpath "$(libdir)"
657
658MPTEST1=./mptester$(TEXE) mptest.db $(TOP)/mptest/crash01.test --repeat 20
659MPTEST2=./mptester$(TEXE) mptest.db $(TOP)/mptest/multiwrite01.test --repeat 20
660mptest:	mptester$(TEXE)
661	rm -f mptest.db
662	$(MPTEST1) --journalmode DELETE
663	$(MPTEST2) --journalmode WAL
664	$(MPTEST1) --journalmode WAL
665	$(MPTEST2) --journalmode PERSIST
666	$(MPTEST1) --journalmode PERSIST
667	$(MPTEST2) --journalmode TRUNCATE
668	$(MPTEST1) --journalmode TRUNCATE
669	$(MPTEST2) --journalmode DELETE
670
671
672# This target creates a directory named "tsrc" and fills it with
673# copies of all of the C source code and header files needed to
674# build on the target system.  Some of the C source code and header
675# files are automatically generated.  This target takes care of
676# all that automatic generation.
677#
678.target_source:	$(SRC) $(TOP)/tool/vdbe-compress.tcl fts5.c
679	rm -rf tsrc
680	mkdir tsrc
681	cp -f $(SRC) tsrc
682	rm tsrc/sqlite.h.in tsrc/parse.y
683	$(TCLSH_CMD) $(TOP)/tool/vdbe-compress.tcl $(OPTS) <tsrc/vdbe.c >vdbe.new
684	mv vdbe.new tsrc/vdbe.c
685	cp fts5.c fts5.h tsrc
686	touch .target_source
687
688sqlite3.c:	.target_source $(TOP)/tool/mksqlite3c.tcl
689	$(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl
690	cp tsrc/shell.c tsrc/sqlite3ext.h .
691	cp $(TOP)/ext/session/sqlite3session.h .
692
693sqlite3ext.h:	.target_source
694	cp tsrc/sqlite3ext.h .
695
696tclsqlite3.c:	sqlite3.c
697	echo '#ifndef USE_SYSTEM_SQLITE' >tclsqlite3.c
698	cat sqlite3.c >>tclsqlite3.c
699	echo '#endif /* USE_SYSTEM_SQLITE */' >>tclsqlite3.c
700	cat $(TOP)/src/tclsqlite.c >>tclsqlite3.c
701
702sqlite3-all.c:	sqlite3.c $(TOP)/tool/split-sqlite3c.tcl
703	$(TCLSH_CMD) $(TOP)/tool/split-sqlite3c.tcl
704
705# Rule to build the amalgamation
706#
707sqlite3.lo:	sqlite3.c
708	$(LTCOMPILE) $(TEMP_STORE) -c sqlite3.c
709
710# Rules to build the LEMON compiler generator
711#
712lemon$(BEXE):	$(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
713	$(BCC) -o $@ $(TOP)/tool/lemon.c
714	cp $(TOP)/tool/lempar.c .
715
716# Rules to build individual *.o files from generated *.c files. This
717# applies to:
718#
719#     parse.o
720#     opcodes.o
721#
722parse.lo:	parse.c $(HDR)
723	$(LTCOMPILE) $(TEMP_STORE) -c parse.c
724
725opcodes.lo:	opcodes.c
726	$(LTCOMPILE) $(TEMP_STORE) -c opcodes.c
727
728# BEGIN CRYPTO
729crypto.lo:	$(TOP)/src/crypto.c $(HDR)
730	$(LTCOMPILE) -c $(TOP)/src/crypto.c
731crypto_impl.lo:	$(TOP)/src/crypto_impl.c $(HDR)
732	$(LTCOMPILE) -c $(TOP)/src/crypto_impl.c
733crypto_openssl.lo:	$(TOP)/src/crypto_openssl.c $(HDR)
734	$(LTCOMPILE) -c $(TOP)/src/crypto_openssl.c
735crypto_libtomcrypt.lo:	$(TOP)/src/crypto_libtomcrypt.c $(HDR)
736	$(LTCOMPILE) -c $(TOP)/src/crypto_libtomcrypt.c
737crypto_cc.lo:	$(TOP)/src/crypto_cc.c $(HDR)
738	$(LTCOMPILE) -c $(TOP)/src/crypto_cc.c
739# END CRYPTO
740
741# Rules to build individual *.o files from files in the src directory.
742#
743alter.lo:	$(TOP)/src/alter.c $(HDR)
744	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/alter.c
745
746analyze.lo:	$(TOP)/src/analyze.c $(HDR)
747	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/analyze.c
748
749attach.lo:	$(TOP)/src/attach.c $(HDR)
750	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/attach.c
751
752auth.lo:	$(TOP)/src/auth.c $(HDR)
753	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/auth.c
754
755backup.lo:	$(TOP)/src/backup.c $(HDR)
756	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/backup.c
757
758bitvec.lo:	$(TOP)/src/bitvec.c $(HDR)
759	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/bitvec.c
760
761btmutex.lo:	$(TOP)/src/btmutex.c $(HDR)
762	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/btmutex.c
763
764btree.lo:	$(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
765	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/btree.c
766
767build.lo:	$(TOP)/src/build.c $(HDR)
768	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/build.c
769
770callback.lo:	$(TOP)/src/callback.c $(HDR)
771	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/callback.c
772
773complete.lo:	$(TOP)/src/complete.c $(HDR)
774	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/complete.c
775
776ctime.lo:	$(TOP)/src/ctime.c $(HDR)
777	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/ctime.c
778
779date.lo:	$(TOP)/src/date.c $(HDR)
780	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/date.c
781
782dbstat.lo:	$(TOP)/src/dbstat.c $(HDR)
783	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/dbstat.c
784
785delete.lo:	$(TOP)/src/delete.c $(HDR)
786	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/delete.c
787
788expr.lo:	$(TOP)/src/expr.c $(HDR)
789	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/expr.c
790
791fault.lo:	$(TOP)/src/fault.c $(HDR)
792	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/fault.c
793
794fkey.lo:	$(TOP)/src/fkey.c $(HDR)
795	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/fkey.c
796
797func.lo:	$(TOP)/src/func.c $(HDR)
798	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/func.c
799
800global.lo:	$(TOP)/src/global.c $(HDR)
801	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/global.c
802
803hash.lo:	$(TOP)/src/hash.c $(HDR)
804	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/hash.c
805
806insert.lo:	$(TOP)/src/insert.c $(HDR)
807	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/insert.c
808
809legacy.lo:	$(TOP)/src/legacy.c $(HDR)
810	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/legacy.c
811
812loadext.lo:	$(TOP)/src/loadext.c $(HDR)
813	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/loadext.c
814
815main.lo:	$(TOP)/src/main.c $(HDR)
816	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/main.c
817
818malloc.lo:	$(TOP)/src/malloc.c $(HDR)
819	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/malloc.c
820
821mem0.lo:	$(TOP)/src/mem0.c $(HDR)
822	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/mem0.c
823
824mem1.lo:	$(TOP)/src/mem1.c $(HDR)
825	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/mem1.c
826
827mem2.lo:	$(TOP)/src/mem2.c $(HDR)
828	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/mem2.c
829
830mem3.lo:	$(TOP)/src/mem3.c $(HDR)
831	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/mem3.c
832
833mem5.lo:	$(TOP)/src/mem5.c $(HDR)
834	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/mem5.c
835
836memjournal.lo:	$(TOP)/src/memjournal.c $(HDR)
837	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/memjournal.c
838
839mutex.lo:	$(TOP)/src/mutex.c $(HDR)
840	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/mutex.c
841
842mutex_noop.lo:	$(TOP)/src/mutex_noop.c $(HDR)
843	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/mutex_noop.c
844
845mutex_unix.lo:	$(TOP)/src/mutex_unix.c $(HDR)
846	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/mutex_unix.c
847
848mutex_w32.lo:	$(TOP)/src/mutex_w32.c $(HDR)
849	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/mutex_w32.c
850
851notify.lo:	$(TOP)/src/notify.c $(HDR)
852	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/notify.c
853
854pager.lo:	$(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
855	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/pager.c
856
857pcache.lo:	$(TOP)/src/pcache.c $(HDR) $(TOP)/src/pcache.h
858	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/pcache.c
859
860pcache1.lo:	$(TOP)/src/pcache1.c $(HDR) $(TOP)/src/pcache.h
861	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/pcache1.c
862
863os.lo:	$(TOP)/src/os.c $(HDR)
864	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/os.c
865
866os_unix.lo:	$(TOP)/src/os_unix.c $(HDR)
867	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/os_unix.c
868
869os_win.lo:	$(TOP)/src/os_win.c $(HDR)
870	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/os_win.c
871
872pragma.lo:	$(TOP)/src/pragma.c $(HDR)
873	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/pragma.c
874
875prepare.lo:	$(TOP)/src/prepare.c $(HDR)
876	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/prepare.c
877
878printf.lo:	$(TOP)/src/printf.c $(HDR)
879	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/printf.c
880
881random.lo:	$(TOP)/src/random.c $(HDR)
882	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/random.c
883
884resolve.lo:	$(TOP)/src/resolve.c $(HDR)
885	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/resolve.c
886
887rowset.lo:	$(TOP)/src/rowset.c $(HDR)
888	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/rowset.c
889
890select.lo:	$(TOP)/src/select.c $(HDR)
891	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/select.c
892
893status.lo:	$(TOP)/src/status.c $(HDR)
894	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/status.c
895
896table.lo:	$(TOP)/src/table.c $(HDR)
897	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/table.c
898
899threads.lo:	$(TOP)/src/threads.c $(HDR)
900	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/threads.c
901
902tokenize.lo:	$(TOP)/src/tokenize.c keywordhash.h $(HDR)
903	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/tokenize.c
904
905treeview.lo:	$(TOP)/src/treeview.c $(HDR)
906	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/treeview.c
907
908trigger.lo:	$(TOP)/src/trigger.c $(HDR)
909	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/trigger.c
910
911update.lo:	$(TOP)/src/update.c $(HDR)
912	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/update.c
913
914utf.lo:	$(TOP)/src/utf.c $(HDR)
915	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/utf.c
916
917util.lo:	$(TOP)/src/util.c $(HDR)
918	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/util.c
919
920vacuum.lo:	$(TOP)/src/vacuum.c $(HDR)
921	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/vacuum.c
922
923vdbe.lo:	$(TOP)/src/vdbe.c $(HDR)
924	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/vdbe.c
925
926vdbeapi.lo:	$(TOP)/src/vdbeapi.c $(HDR)
927	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/vdbeapi.c
928
929vdbeaux.lo:	$(TOP)/src/vdbeaux.c $(HDR)
930	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/vdbeaux.c
931
932vdbeblob.lo:	$(TOP)/src/vdbeblob.c $(HDR)
933	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/vdbeblob.c
934
935vdbemem.lo:	$(TOP)/src/vdbemem.c $(HDR)
936	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/vdbemem.c
937
938vdbesort.lo:	$(TOP)/src/vdbesort.c $(HDR)
939	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/vdbesort.c
940
941vdbetrace.lo:	$(TOP)/src/vdbetrace.c $(HDR)
942	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/vdbetrace.c
943
944vtab.lo:	$(TOP)/src/vtab.c $(HDR)
945	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/vtab.c
946
947wal.lo:	$(TOP)/src/wal.c $(HDR)
948	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/wal.c
949
950walker.lo:	$(TOP)/src/walker.c $(HDR)
951	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/walker.c
952
953where.lo:	$(TOP)/src/where.c $(HDR)
954	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/where.c
955
956wherecode.lo:	$(TOP)/src/wherecode.c $(HDR)
957	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/wherecode.c
958
959whereexpr.lo:	$(TOP)/src/whereexpr.c $(HDR)
960	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/whereexpr.c
961
962tclsqlite.lo:	$(TOP)/src/tclsqlite.c $(HDR)
963	$(LTCOMPILE) -DUSE_TCL_STUBS=1 -c $(TOP)/src/tclsqlite.c
964
965tclsqlite-shell.lo:	$(TOP)/src/tclsqlite.c $(HDR)
966	$(LTCOMPILE) -DTCLSH=1 -o $@ -c $(TOP)/src/tclsqlite.c
967
968tclsqlite-stubs.lo:	$(TOP)/src/tclsqlite.c $(HDR)
969	$(LTCOMPILE) -DUSE_TCL_STUBS=1 -o $@ -c $(TOP)/src/tclsqlite.c
970
971tclsqlcipher$(TEXE):	tclsqlite-shell.lo libsqlcipher.la
972	$(LTLINK) -o $@ tclsqlite-shell.lo \
973		 libsqlcipher.la $(LIBTCL)
974
975# Rules to build opcodes.c and opcodes.h
976#
977opcodes.c:	opcodes.h $(TOP)/tool/mkopcodec.tcl
978	$(TCLSH_CMD) $(TOP)/tool/mkopcodec.tcl opcodes.h >opcodes.c
979
980opcodes.h:	parse.h $(TOP)/src/vdbe.c $(TOP)/tool/mkopcodeh.tcl
981	cat parse.h $(TOP)/src/vdbe.c | $(TCLSH_CMD) $(TOP)/tool/mkopcodeh.tcl >opcodes.h
982
983# Rules to build parse.c and parse.h - the outputs of lemon.
984#
985parse.h:	parse.c
986
987parse.c:	$(TOP)/src/parse.y lemon$(BEXE) $(TOP)/tool/addopcodes.tcl
988	cp $(TOP)/src/parse.y .
989	rm -f parse.h
990	./lemon$(BEXE) $(OPT_FEATURE_FLAGS) $(OPTS) parse.y
991	mv parse.h parse.h.temp
992	$(TCLSH_CMD) $(TOP)/tool/addopcodes.tcl parse.h.temp >parse.h
993
994sqlite3.h:	$(TOP)/src/sqlite.h.in $(TOP)/manifest.uuid $(TOP)/VERSION
995	$(TCLSH_CMD) $(TOP)/tool/mksqlite3h.tcl $(TOP) >sqlite3.h
996
997keywordhash.h:	$(TOP)/tool/mkkeywordhash.c
998	$(BCC) -o mkkeywordhash$(BEXE) $(OPT_FEATURE_FLAGS) $(OPTS) $(TOP)/tool/mkkeywordhash.c
999	./mkkeywordhash$(BEXE) >keywordhash.h
1000
1001
1002
1003# Rules to build the extension objects.
1004#
1005icu.lo:	$(TOP)/ext/icu/icu.c $(HDR) $(EXTHDR)
1006	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/icu/icu.c
1007
1008fts2.lo:	$(TOP)/ext/fts2/fts2.c $(HDR) $(EXTHDR)
1009	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts2/fts2.c
1010
1011fts2_hash.lo:	$(TOP)/ext/fts2/fts2_hash.c $(HDR) $(EXTHDR)
1012	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts2/fts2_hash.c
1013
1014fts2_icu.lo:	$(TOP)/ext/fts2/fts2_icu.c $(HDR) $(EXTHDR)
1015	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts2/fts2_icu.c
1016
1017fts2_porter.lo:	$(TOP)/ext/fts2/fts2_porter.c $(HDR) $(EXTHDR)
1018	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts2/fts2_porter.c
1019
1020fts2_tokenizer.lo:	$(TOP)/ext/fts2/fts2_tokenizer.c $(HDR) $(EXTHDR)
1021	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts2/fts2_tokenizer.c
1022
1023fts2_tokenizer1.lo:	$(TOP)/ext/fts2/fts2_tokenizer1.c $(HDR) $(EXTHDR)
1024	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts2/fts2_tokenizer1.c
1025
1026fts3.lo:	$(TOP)/ext/fts3/fts3.c $(HDR) $(EXTHDR)
1027	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3.c
1028
1029fts3_aux.lo:	$(TOP)/ext/fts3/fts3_aux.c $(HDR) $(EXTHDR)
1030	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_aux.c
1031
1032fts3_expr.lo:	$(TOP)/ext/fts3/fts3_expr.c $(HDR) $(EXTHDR)
1033	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_expr.c
1034
1035fts3_hash.lo:	$(TOP)/ext/fts3/fts3_hash.c $(HDR) $(EXTHDR)
1036	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_hash.c
1037
1038fts3_icu.lo:	$(TOP)/ext/fts3/fts3_icu.c $(HDR) $(EXTHDR)
1039	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_icu.c
1040
1041fts3_porter.lo:	$(TOP)/ext/fts3/fts3_porter.c $(HDR) $(EXTHDR)
1042	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_porter.c
1043
1044fts3_snippet.lo:	$(TOP)/ext/fts3/fts3_snippet.c $(HDR) $(EXTHDR)
1045	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_snippet.c
1046
1047fts3_tokenizer.lo:	$(TOP)/ext/fts3/fts3_tokenizer.c $(HDR) $(EXTHDR)
1048	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_tokenizer.c
1049
1050fts3_tokenizer1.lo:	$(TOP)/ext/fts3/fts3_tokenizer1.c $(HDR) $(EXTHDR)
1051	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_tokenizer1.c
1052
1053fts3_tokenize_vtab.lo:	$(TOP)/ext/fts3/fts3_tokenize_vtab.c $(HDR) $(EXTHDR)
1054	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_tokenize_vtab.c
1055
1056fts3_unicode.lo:	$(TOP)/ext/fts3/fts3_unicode.c $(HDR) $(EXTHDR)
1057	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_unicode.c
1058
1059fts3_unicode2.lo:	$(TOP)/ext/fts3/fts3_unicode2.c $(HDR) $(EXTHDR)
1060	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_unicode2.c
1061
1062fts3_write.lo:	$(TOP)/ext/fts3/fts3_write.c $(HDR) $(EXTHDR)
1063	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_write.c
1064
1065rtree.lo:	$(TOP)/ext/rtree/rtree.c $(HDR) $(EXTHDR)
1066	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/rtree/rtree.c
1067
1068sqlite3session.lo:	$(TOP)/ext/session/sqlite3session.c $(HDR) $(EXTHDR)
1069	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/session/sqlite3session.c
1070
1071json1.lo:	$(TOP)/ext/misc/json1.c
1072	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/misc/json1.c
1073
1074stmt.lo:	$(TOP)/ext/misc/stmt.c
1075	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/misc/stmt.c
1076
1077# FTS5 things
1078#
1079FTS5_SRC = \
1080   $(TOP)/ext/fts5/fts5.h \
1081   $(TOP)/ext/fts5/fts5Int.h \
1082   $(TOP)/ext/fts5/fts5_aux.c \
1083   $(TOP)/ext/fts5/fts5_buffer.c \
1084   $(TOP)/ext/fts5/fts5_main.c \
1085   $(TOP)/ext/fts5/fts5_config.c \
1086   $(TOP)/ext/fts5/fts5_expr.c \
1087   $(TOP)/ext/fts5/fts5_hash.c \
1088   $(TOP)/ext/fts5/fts5_index.c \
1089   fts5parse.c fts5parse.h \
1090   $(TOP)/ext/fts5/fts5_storage.c \
1091   $(TOP)/ext/fts5/fts5_tokenize.c \
1092   $(TOP)/ext/fts5/fts5_unicode2.c \
1093   $(TOP)/ext/fts5/fts5_varint.c \
1094   $(TOP)/ext/fts5/fts5_vocab.c  \
1095
1096fts5parse.c:	$(TOP)/ext/fts5/fts5parse.y lemon
1097	cp $(TOP)/ext/fts5/fts5parse.y .
1098	rm -f fts5parse.h
1099	./lemon$(BEXE) $(OPTS) fts5parse.y
1100
1101fts5parse.h: fts5parse.c
1102
1103fts5.c: $(FTS5_SRC)
1104	$(TCLSH_CMD) $(TOP)/ext/fts5/tool/mkfts5c.tcl
1105	cp $(TOP)/ext/fts5/fts5.h .
1106
1107fts5.lo:	fts5.c $(HDR) $(EXTHDR)
1108	$(LTCOMPILE) -DSQLITE_CORE -c fts5.c
1109
1110sqlite3rbu.lo:	$(TOP)/ext/rbu/sqlite3rbu.c $(HDR) $(EXTHDR)
1111	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/rbu/sqlite3rbu.c
1112
1113
1114# Rules to build the 'testfixture' application.
1115#
1116# If using the amalgamation, use sqlite3.c directly to build the test
1117# fixture.  Otherwise link against libsqlcipher.la.  (This distinction is
1118# necessary because the test fixture requires non-API symbols which are
1119# hidden when the library is built via the amalgamation).
1120#
1121TESTFIXTURE_FLAGS  = -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1
1122TESTFIXTURE_FLAGS += -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" -DSQLITE_CORE
1123TESTFIXTURE_FLAGS += -DBUILD_sqlite
1124TESTFIXTURE_FLAGS += -DSQLITE_SERIES_CONSTRAINT_VERIFY=1
1125TESTFIXTURE_FLAGS += -DSQLITE_DEFAULT_PAGE_SIZE=1024
1126TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_STMTVTAB
1127
1128TESTFIXTURE_SRC0 = $(TESTSRC2) libsqlcipher.la
1129TESTFIXTURE_SRC1 = sqlite3.c
1130TESTFIXTURE_SRC = $(TESTSRC) $(TOP)/src/tclsqlite.c
1131TESTFIXTURE_SRC += $(TESTFIXTURE_SRC$(USE_AMALGAMATION))
1132
1133testfixture$(TEXE):	$(TESTFIXTURE_SRC)
1134	$(LTLINK) -DSQLITE_NO_SYNC=1 $(TEMP_STORE) $(TESTFIXTURE_FLAGS) \
1135		-o $@ $(TESTFIXTURE_SRC) $(LIBTCL) $(TLIBS)
1136
1137# A very detailed test running most or all test cases
1138fulltest:	$(TESTPROGS) fuzztest
1139	./testfixture$(TEXE) $(TOP)/test/all.test $(TESTOPTS)
1140
1141# Really really long testing
1142soaktest:	$(TESTPROGS)
1143	./testfixture$(TEXE) $(TOP)/test/all.test -soak=1 $(TESTOPTS)
1144
1145# Do extra testing but not everything.
1146fulltestonly:	$(TESTPROGS) fuzztest
1147	./testfixture$(TEXE) $(TOP)/test/full.test
1148
1149# Fuzz testing
1150fuzztest:	fuzzcheck$(TEXE) $(FUZZDATA)
1151	./fuzzcheck$(TEXE) $(FUZZDATA)
1152
1153fastfuzztest:	fuzzcheck$(TEXE) $(FUZZDATA)
1154	./fuzzcheck$(TEXE) --limit-mem 100M $(FUZZDATA)
1155
1156valgrindfuzz:	fuzzcheck$(TEXT) $(FUZZDATA)
1157	valgrind ./fuzzcheck$(TEXE) --cell-size-check --limit-mem 10M --timeout 600 $(FUZZDATA)
1158
1159# The veryquick.test TCL tests.
1160#
1161tcltest:	./testfixture$(TEXE)
1162	./testfixture$(TEXE) $(TOP)/test/veryquick.test $(TESTOPTS)
1163
1164# Minimal testing that runs in less than 3 minutes
1165#
1166quicktest:	./testfixture$(TEXE)
1167	./testfixture$(TEXE) $(TOP)/test/extraquick.test $(TESTOPTS)
1168
1169# This is the common case.  Run many tests that do not take too long,
1170# including fuzzcheck, sqlite3_analyzer, and sqldiff tests.
1171#
1172test:	fastfuzztest sourcetest $(TESTPROGS) tcltest
1173
1174# Run a test using valgrind.  This can take a really long time
1175# because valgrind is so much slower than a native machine.
1176#
1177valgrindtest:	$(TESTPROGS) valgrindfuzz
1178	OMIT_MISUSE=1 valgrind -v ./testfixture$(TEXE) $(TOP)/test/permutations.test valgrind $(TESTOPTS)
1179
1180# A very fast test that checks basic sanity.  The name comes from
1181# the 60s-era electronics testing:  "Turn it on and see if smoke
1182# comes out."
1183#
1184smoketest:	$(TESTPROGS) fuzzcheck$(TEXE)
1185	./testfixture$(TEXE) $(TOP)/test/main.test $(TESTOPTS)
1186
1187sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl
1188	echo "#define TCLSH 2" > $@
1189	echo "#define SQLITE_ENABLE_DBSTAT_VTAB 1" >> $@
1190	cat sqlite3.c $(TOP)/src/tclsqlite.c >> $@
1191	echo "static const char *tclsh_main_loop(void){" >> $@
1192	echo "static const char *zMainloop = " >> $@
1193	$(TCLSH_CMD) $(TOP)/tool/tostr.tcl $(TOP)/tool/spaceanal.tcl >> $@
1194	echo "; return zMainloop; }" >> $@
1195
1196sqlite3_analyzer$(TEXE): sqlite3_analyzer.c
1197	$(LTLINK) sqlite3_analyzer.c -o $@ $(LIBTCL) $(TLIBS)
1198
1199dbdump$(TEXE): $(TOP)/ext/misc/dbdump.c sqlite3.lo
1200	$(LTLINK) -DDBDUMP_STANDALONE -o $@ \
1201           $(TOP)/ext/misc/dbdump.c sqlite3.lo $(TLIBS)
1202
1203showdb$(TEXE):	$(TOP)/tool/showdb.c sqlite3.lo
1204	$(LTLINK) -o $@ $(TOP)/tool/showdb.c sqlite3.lo $(TLIBS)
1205
1206showstat4$(TEXE):	$(TOP)/tool/showstat4.c sqlite3.lo
1207	$(LTLINK) -o $@ $(TOP)/tool/showstat4.c sqlite3.lo $(TLIBS)
1208
1209showjournal$(TEXE):	$(TOP)/tool/showjournal.c sqlite3.lo
1210	$(LTLINK) -o $@ $(TOP)/tool/showjournal.c sqlite3.lo $(TLIBS)
1211
1212showwal$(TEXE):	$(TOP)/tool/showwal.c sqlite3.lo
1213	$(LTLINK) -o $@ $(TOP)/tool/showwal.c sqlite3.lo $(TLIBS)
1214
1215changeset$(TEXE):	$(TOP)/ext/session/changeset.c sqlite3.lo
1216	$(LTLINK) -o $@ $(TOP)/ext/session/changeset.c sqlite3.lo $(TLIBS)
1217
1218rollback-test$(TEXE):	$(TOP)/tool/rollback-test.c sqlite3.lo
1219	$(LTLINK) -o $@ $(TOP)/tool/rollback-test.c sqlite3.lo $(TLIBS)
1220
1221LogEst$(TEXE):	$(TOP)/tool/logest.c sqlite3.h
1222	$(LTLINK) -I. -o $@ $(TOP)/tool/logest.c
1223
1224wordcount$(TEXE):	$(TOP)/test/wordcount.c sqlite3.lo
1225	$(LTLINK) -o $@ $(TOP)/test/wordcount.c sqlite3.lo $(TLIBS)
1226
1227speedtest1$(TEXE):	$(TOP)/test/speedtest1.c sqlite3.c
1228	$(LTLINK) $(ST_OPT) -o $@ $(TOP)/test/speedtest1.c sqlite3.c $(TLIBS)
1229
1230KV_OPT += -DSQLITE_DIRECT_OVERFLOW_READ
1231
1232kvtest$(TEXE):	$(TOP)/test/kvtest.c sqlite3.c
1233	$(LTLINK) $(KV_OPT) -o $@ $(TOP)/test/kvtest.c sqlite3.c $(TLIBS)
1234
1235rbu$(EXE): $(TOP)/ext/rbu/rbu.c $(TOP)/ext/rbu/sqlite3rbu.c sqlite3.lo
1236	$(LTLINK) -I. -o $@ $(TOP)/ext/rbu/rbu.c sqlite3.lo $(TLIBS)
1237
1238loadfts$(EXE): $(TOP)/tool/loadfts.c libsqlite3.la
1239	$(LTLINK) $(TOP)/tool/loadfts.c libsqlite3.la -o $@ $(TLIBS)
1240
1241# This target will fail if the SQLite amalgamation contains any exported
1242# symbols that do not begin with "sqlite3_". It is run as part of the
1243# releasetest.tcl script.
1244#
1245VALIDIDS=' sqlite3(changeset|changegroup|session)?_'
1246checksymbols: sqlite3.lo
1247	nm -g --defined-only sqlite3.lo | egrep -v $(VALIDIDS); test $$? -ne 0
1248	echo '0 errors out of 1 tests'
1249
1250# Build the amalgamation-autoconf package.  The amalamgation-tarball target builds
1251# a tarball named for the version number.  Ex:  sqlite-autoconf-3110000.tar.gz.
1252# The snapshot-tarball target builds a tarball named by the SHA1 hash
1253#
1254amalgamation-tarball: sqlite3.c
1255	TOP=$(TOP) sh $(TOP)/tool/mkautoconfamal.sh --normal
1256
1257snapshot-tarball: sqlite3.c
1258	TOP=$(TOP) sh $(TOP)/tool/mkautoconfamal.sh --snapshot
1259
1260# The next two rules are used to support the "threadtest" target. Building
1261# threadtest runs a few thread-safety tests that are implemented in C. This
1262# target is invoked by the releasetest.tcl script.
1263#
1264THREADTEST3_SRC = $(TOP)/test/threadtest3.c    \
1265                  $(TOP)/test/tt3_checkpoint.c \
1266                  $(TOP)/test/tt3_index.c      \
1267                  $(TOP)/test/tt3_vacuum.c      \
1268                  $(TOP)/test/tt3_stress.c      \
1269                  $(TOP)/test/tt3_lookaside1.c
1270
1271threadtest3$(TEXE): sqlite3.lo $(THREADTEST3_SRC)
1272	$(LTLINK) $(TOP)/test/threadtest3.c $(TOP)/src/test_multiplex.c sqlite3.lo -o $@ $(TLIBS)
1273
1274threadtest: threadtest3$(TEXE)
1275	./threadtest3$(TEXE)
1276
1277releasetest:
1278	$(TCLSH_CMD) $(TOP)/test/releasetest.tcl
1279
1280# Standard install and cleanup targets
1281#
1282lib_install:	libsqlcipher.la
1283	$(INSTALL) -d $(DESTDIR)$(libdir)
1284	$(LTINSTALL) libsqlcipher.la $(DESTDIR)$(libdir)
1285
1286install:	sqlcipher$(TEXE) lib_install sqlite3.h sqlcipher.pc ${HAVE_TCL:1=tcl_install}
1287	$(INSTALL) -d $(DESTDIR)$(bindir)
1288	$(LTINSTALL) sqlcipher$(TEXE) $(DESTDIR)$(bindir)
1289	$(INSTALL) -d $(DESTDIR)$(includedir)
1290	$(INSTALL) -m 0644 sqlite3.h $(DESTDIR)$(includedir)
1291	$(INSTALL) -m 0644 $(TOP)/src/sqlite3ext.h $(DESTDIR)$(includedir)
1292	$(INSTALL) -d $(DESTDIR)$(pkgconfigdir)
1293	$(INSTALL) -m 0644 sqlcipher.pc $(DESTDIR)$(pkgconfigdir)
1294
1295pkgIndex.tcl:
1296	echo 'package ifneeded sqlite3 $(RELEASE) [list load $(TCLLIBDIR)/libtclsqlite3$(SHLIB_SUFFIX) sqlite3]' > $@
1297tcl_install:	lib_install libtclsqlite3.la pkgIndex.tcl
1298	$(INSTALL) -d $(DESTDIR)$(TCLLIBDIR)
1299	$(LTINSTALL) libtclsqlite3.la $(DESTDIR)$(TCLLIBDIR)
1300	rm -f $(DESTDIR)$(TCLLIBDIR)/libtclsqlite3.la $(DESTDIR)$(TCLLIBDIR)/libtclsqlite3.a
1301	$(INSTALL) -m 0644 pkgIndex.tcl $(DESTDIR)$(TCLLIBDIR)
1302
1303clean:
1304	rm -f *.lo *.la *.o sqlcipher$(TEXE) libsqlcipher.la
1305	rm -f sqlite3.h opcodes.*
1306	rm -rf .libs .deps
1307	rm -f lemon$(BEXE) lempar.c parse.* sqlite*.tar.gz
1308	rm -f mkkeywordhash$(BEXE) keywordhash.h
1309	rm -f *.da *.bb *.bbg gmon.out
1310	rm -rf tsrc .target_source
1311	rm -f tclsqlcipher$(TEXE)
1312	rm -f testfixture$(TEXE) test.db
1313	rm -f LogEst$(TEXE) fts3view$(TEXE) rollback-test$(TEXE) showdb$(TEXE)
1314	rm -f showjournal$(TEXE) showstat4$(TEXE) showwal$(TEXE) speedtest1$(TEXE)
1315	rm -f wordcount$(TEXE) changeset$(TEXE)
1316	rm -f sqlite3.dll sqlite3.lib sqlite3.exp sqlite3.def
1317	rm -f sqlite3.c
1318	rm -f sqlite3rc.h
1319	rm -f shell.c sqlite3ext.h
1320	rm -f sqlite3_analyzer$(TEXE) sqlite3_analyzer.c
1321	rm -f sqlite-*-output.vsix
1322	rm -f mptester mptester.exe
1323	rm -f rbu rbu.exe
1324	rm -f srcck1 srcck1.exe
1325	rm -f fuzzershell fuzzershell.exe
1326	rm -f fuzzcheck fuzzcheck.exe
1327	rm -f sqldiff sqldiff.exe
1328	rm -f dbhash dbhash.exe
1329	rm -f fts5.* fts5parse.*
1330
1331distclean:	clean
1332	rm -f config.h config.log config.status libtool Makefile sqlcipher.pc
1333
1334#
1335# Windows section
1336#
1337dll: sqlite3.dll
1338
1339REAL_LIBOBJ = $(LIBOBJ:%.lo=.libs/%.o)
1340
1341$(REAL_LIBOBJ): $(LIBOBJ)
1342
1343sqlite3.def: $(REAL_LIBOBJ)
1344	echo 'EXPORTS' >sqlite3.def
1345	nm $(REAL_LIBOBJ) | grep ' T ' | grep ' _sqlite3_' \
1346		| sed 's/^.* _//' >>sqlite3.def
1347
1348sqlite3.dll: $(REAL_LIBOBJ) sqlite3.def
1349	$(TCC) -shared -o $@ sqlite3.def \
1350		-Wl,"--strip-all" $(REAL_LIBOBJ)
1351