SQLite

Changes On Branch configure-dll-support
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch configure-dll-support Excluding Merge-Ins

This is equivalent to a diff from ebf41fc90a to d84f591b96

2025-02-25
16:17
Diverse configure tweaks to better support package maintainers on the unix-on-windows environments like msys2, cygwin, and mingw, based largely on feedback in forum posts e6cf2bbb70da2922 and 828fdfe9041fd725. (check-in: 144aacfdf7 user: stephan tags: branch-3.49)
15:54
Diverse configure tweaks to better support package maintainers on the unix-on-windows environments like msys2, cygwin, and mingw, based largely on feedback in forum posts e6cf2bbb70da2922 and 828fdfe9041fd725. (check-in: 85b56fb0cc user: stephan tags: trunk)
2025-02-24
20:53
Slightly simplify auto.def and autoconf/auto.def. (Closed-Leaf check-in: d84f591b96 user: stephan tags: configure-dll-support)
18:45
autoconf/auto.def: remove a define which made superfluous by [b8bf966628c0]. Add a check/status message for whether to statically link the library into the CLI shell. (check-in: df95e908ca user: stephan tags: configure-dll-support)
2025-02-21
20:35
The number of declared columns in an index is limited to SQLITE_LIMIT_COLUMN. But the actual number of columns in the implementation might need to be twice as much to account for the primary key at the end. Ensure that the code is able to deal with this. This is a correction to check-in [d7729dbbf231d57c]. (check-in: 5822feec43 user: drh tags: trunk)
20:28
Extend --out-implib to optionally specify the import lib's name. Add as-yet-unused internals for specifying the DLL's base name (which differs across the Windows-side Unix-esque environments). (check-in: 12a55d343f user: stephan tags: configure-dll-support)
20:22
Makefile-internal var renaming in prep for pending portability-related changes in the handling of DLLs. No functional/build interface changes. (check-in: ebf41fc90a user: stephan tags: trunk)
17:03
Detect when a UNIQUE or PRIMARY KEY on a WITHOUT ROWID table would need to use more than SQLITE_LIMIT_COLUMN columns and raise an error. Also include some unrelated compiler warning fixes. (check-in: d7729dbbf2 user: drh tags: trunk)

Changes to Makefile.in.
75
76
77
78
79
80
81
82

83
84
85
86
87
88
89
75
76
77
78
79
80
81

82
83
84
85
86
87
88
89







-
+







includedir  = @includedir@
exec_prefix = @exec_prefix@
bindir      = @bindir@
libdir      = @libdir@

INSTALL = @BIN_INSTALL@
AR = @AR@
AR.flags = cr # TODO? Add a configure test to determine this?
AR.flags = cr
CC = @CC@
B.cc = @CC_FOR_BUILD@ @BUILD_CFLAGS@
T.cc = $(CC)
#
# $(CFLAGS) is problematic because it is frequently overridden when
# invoking make, which loses things like -fPIC. So... we avoid using
# it directly and instead add a level of indirection.  We combine
122
123
124
125
126
127
128




129
130


131

132
133
134
135
136
137
138
122
123
124
125
126
127
128
129
130
131
132


133
134
135
136
137
138
139
140
141
142
143







+
+
+
+
-
-
+
+

+







CFLAGS.icu = @CFLAGS_ICU@
LDFLAGS.libsqlite3.soname = @LDFLAGS_LIBSQLITE3_SONAME@
# soname: see https://sqlite.org/src/forumpost/5a3b44f510df8ded
LDFLAGS.libsqlite3.os-specific = @LDFLAGS_MAC_CVERSION@ @LDFLAGS_OUT_IMPLIB@
# os-specific: see
# - https://sqlite.org/forum/forumpost/9dfd5b8fd525a5d7
# - https://sqlite.org/forum/forumpost/0c7fc097b2
libsqlite3.DLL.basename = @SQLITE_DLL_BASENAME@
# DLL.basename: see https://sqlite.org/forum/forumpost/828fdfe904
libsqlite3.out.implib = @SQLITE_OUT_IMPLIB@
# libsqlite3.out.implib => the output filename part of LDFLAGS_OUT_IMPLIB.
ENABLE_SHARED = @ENABLE_SHARED@
ENABLE_STATIC = @ENABLE_STATIC@
ENABLE_LIB_SHARED = @ENABLE_LIB_SHARED@
ENABLE_LIB_STATIC = @ENABLE_LIB_STATIC@
HAVE_WASI_SDK = @HAVE_WASI_SDK@
libsqlite3.DLL.install-rules = @SQLITE_DLL_INSTALL_RULES@

T.cc.sqlite = $(T.cc) @TARGET_DEBUG@

#
# Define -D_HAVE_SQLITE_CONFIG_H so that the code knows it
# can include the generated sqlite_cfg.h.
#
Changes to auto.def.
1
2
3
4
5
6
7
8
9
10
11





12
13
14
15
16
17

18
19
20
21
22
23
24
25
26
27
28
29











30
31
32
33



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

51
52

53
54
55


56
57
58


59
60

61
62
63
64
65

66
67
68
69
70
71
72

73

1
2
3
4
5
6





7
8
9
10
11
12
13
14
15
16

17












18
19
20
21
22
23
24
25
26
27
28




29
30
31















32

33
34

35
36


37
38
39


40
41
42

43
44




45







46

47






-
-
-
-
-
+
+
+
+
+





-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

-
+

-
+

-
-
+
+

-
-
+
+

-
+

-
-
-
-
+
-
-
-
-
-
-
-
+
-
+
#!/do/not/tclsh
# ^^^ help out editors which guess this file's content type.
#
# This is the main autosetup-compatible configure script for the
# SQLite project.
#
# This script should be kept compatible with JimTCL, a copy of which
# is included in this source tree as ./autosetup/jimsh0.c. The number
# of incompatibilities between canonical TCL and JimTCL is very low
# and alternative formulations of incompatible constructs have, so
# far, been easy to find.
# This script and all of its dependencies must be kept compatible with
# JimTCL, a copy of which is included in this source tree as
# ./autosetup/jimsh0.c. The number of incompatibilities between
# canonical TCL and JimTCL is very low and alternative formulations of
# incompatible constructs have, so far, been easy to find.
#
# JimTCL: https://jim.tcl.tk
#

use sqlite-config
sqlite-config-bootstrap canonical
sqlite-configure canonical {
sqlite-setup-default-cflags
proj-if-opt-truthy dev {
  # --enable-dev needs to come early so that the downstream tests
  # which check for the following flags use their updated state.
  proj-opt-set all 1
  proj-opt-set debug 1
  proj-opt-set amalgamation 0
  define CFLAGS [get-env CFLAGS {-O0 -g}]
  # -------------^^^^^^^ intentionally using [get-env] instead of
  # [proj-get-env] here because [sqlite-setup-default-cflags] uses
  # [proj-get-env] and we want this to supercede that.
}
  proj-if-opt-truthy dev {
    # --enable-dev needs to come early so that the downstream tests
    # which check for the following flags use their updated state.
    proj-opt-set all 1
    proj-opt-set debug 1
    proj-opt-set amalgamation 0
    define CFLAGS [get-env CFLAGS {-O0 -g}]
    # -------------^^^^^^^ intentionally using [get-env] instead of
    # [proj-get-env] here because [sqlite-setup-default-cflags] uses
    # [proj-get-env] and we want this to supercede that.
  }

sqlite-check-common-bins ;# must come before [sqlite-handle-wasi-sdk]
sqlite-handle-wasi-sdk   ;# must run relatively early, as it changes the environment
sqlite-check-common-system-deps
  sqlite-check-common-bins ;# must come before [sqlite-handle-wasi-sdk]
  sqlite-handle-wasi-sdk   ;# must run relatively early, as it changes the environment
  sqlite-check-common-system-deps

#
# Enable large file support (if special flags are necessary)
#
define HAVE_LFS 0
if {[opt-bool largefile]} {
  cc-check-lfs
}

proj-define-for-opt shared ENABLE_SHARED "Build shared library?"

if {![proj-define-for-opt static ENABLE_STATIC \
        "Build static library?"]} {
  proj-warn "Static lib build may be implicitly re-activated by other components, e.g. some test apps."
}

proj-define-for-opt amalgamation USE_AMALGAMATION "Use amalgamation for builds?"
  proj-define-for-opt amalgamation USE_AMALGAMATION "Use amalgamation for builds?"

proj-define-for-opt gcov USE_GCOV "Use gcov?"
  proj-define-for-opt gcov USE_GCOV "Use gcov?"

proj-define-for-opt test-status TSTRNNR_OPTS \
  "test-runner flags:" {--status} {}
  proj-define-for-opt test-status TSTRNNR_OPTS \
    "test-runner flags:" {--status} {}

proj-define-for-opt linemacros AMALGAMATION_LINE_MACROS \
  "Use #line macros in the amalgamation:"
  proj-define-for-opt linemacros AMALGAMATION_LINE_MACROS \
    "Use #line macros in the amalgamation:"

define LINK_TOOLS_DYNAMICALLY [proj-opt-was-provided dynlink-tools]
  define LINK_TOOLS_DYNAMICALLY [proj-opt-was-provided dynlink-tools]

proj-check-rpath
sqlite-handle-soname
sqlite-handle-debug
sqlite-handle-tcl
  sqlite-handle-tcl
sqlite-handle-threadsafe
sqlite-handle-tempstore
sqlite-handle-line-editing
sqlite-handle-load-extension
sqlite-handle-math
sqlite-handle-icu
sqlite-handle-emsdk
  sqlite-handle-emsdk
sqlite-config-finalize
}
Changes to autoconf/Makefile.in.
139
140
141
142
143
144
145


146


147
148
149
150
151
152
153
154
155
156
157
158
159
160
161




162

163
164
165


166
167

168
169
170
171

172
173
174
175


176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
















195
196
197


















198
199
200



201
202
203
204
205
206
207
139
140
141
142
143
144
145
146
147

148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168

169



170
171
172

173




174




175
176



















177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192

193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212



213
214
215
216
217
218
219
220
221
222







+
+
-
+
+















+
+
+
+
-
+
-
-
-
+
+

-
+
-
-
-
-
+
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-


+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+







  $(LDFLAGS.rt) $(LDFLAGS.configure)
CFLAGS.libsqlite3 = -I. $(CFLAGS.core) $(CFLAGS.icu) $(OPT_FEATURE_FLAGS)

sqlite3.o: $(TOP)/sqlite3.h $(TOP)/sqlite3.c
	$(CC) -c $(TOP)/sqlite3.c -o $@ $(CFLAGS) $(CFLAGS.libsqlite3)

libsqlite3.LIB = libsqlite3$(T.lib)
libsqlite3.DLL.basename = @SQLITE_DLL_BASENAME@
libsqlite3.out.implib = @SQLITE_OUT_IMPLIB@
libsqlite3.DLL = libsqlite3$(T.dll)
libsqlite3.DLL = $(libsqlite3.DLL.basename)$(T.dll)
libsqlite3.DLL.install-rules = @SQLITE_DLL_INSTALL_RULES@

$(libsqlite3.DLL): sqlite3.o
	$(CC) -o $@  sqlite3.o $(LDFLAGS.shlib) \
		$(LDFLAGS) $(LDFLAGS.libsqlite3) \
		$(LDFLAGS.libsqlite3.os-specific) $(LDFLAGS.libsqlite3.soname)
$(libsqlite3.DLL)-1: $(libsqlite3.DLL)
$(libsqlite3.DLL)-0:
all: $(libsqlite3.DLL)-$(ENABLE_LIB_SHARED)

$(libsqlite3.LIB): sqlite3.o
	$(AR) $(AR.flags) $@ sqlite3.o
$(libsqlite3.LIB)-1: $(libsqlite3.LIB)
$(libsqlite3.LIB)-0:
all: $(libsqlite3.LIB)-$(ENABLE_LIB_STATIC)

#
# Maintenance reminder: the install-dll-... rules must be kept in sync
# with the main copies rom /main.mk.
#
install-so-1: $(install-dir.lib) $(libsqlite3.DLL)
install-dll-out-implib: $(install-dir.lib) $(libsqlite3.DLL)
	$(INSTALL) $(libsqlite3.DLL) "$(install-dir.lib)"
	@if [ -f $(libsqlite3.DLL).a ]; then \
		$(INSTALL) $(libsqlite3.DLL).a "$(install-dir.lib)"; \
	if [ x != "x$(libsqlite3.out.implib)" ] && [ -f "$(libsqlite3.out.implib)" ]; then \
		$(INSTALL) $(libsqlite3.out.implib) "$(install-dir.lib)"; \
	fi
	@echo "Setting up $(libsqlite3.DLL) version symlinks..."; \

	if [ x.dll = x$(T.dll) ]; then \
		echo "No library symlinks needed on this platform"; \
	elif [ x.dylib = x$(T.dll) ]; then \
		cd "$(install-dir.lib)" || exit $$?; \
install-dll-unix-generic: install-dll-out-implib
		rm -f libsqlite3.0$(T.dll) libsqlite3.$(PACKAGE_VERSION)$(T.dll) || exit $$?; \
		dllname=libsqlite3.$(PACKAGE_VERSION)$(T.dll); \
		mv $(libsqlite3.DLL) $$dllname || exit $$?; \
		ln -s $$dllname $(libsqlite3.DLL) || exit $$?; \
	$(INSTALL) $(libsqlite3.DLL) "$(install-dir.lib)"
	@echo "Setting up $(libsqlite3.DLL) version symlinks..."; \
		ln -s $$dllname libsqlite3.0$(T.dll) || exit $$?; \
		ls -la $$dllname $(libsqlite3.DLL) libsqlite3.0$(T.dll); \
	else \
		cd "$(install-dir.lib)" || exit $$?; \
		rm -f $(libsqlite3.DLL).0 $(libsqlite3.DLL).$(PACKAGE_VERSION) || exit $$?; \
		mv $(libsqlite3.DLL) $(libsqlite3.DLL).$(PACKAGE_VERSION) || exit $$?; \
		ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL) || exit $$?; \
		ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL).0 || exit $$?; \
		ls -la $(libsqlite3.DLL) $(libsqlite3.DLL).[a03]*; \
		if [ -e $(libsqlite3.DLL).0.8.6 ]; then \
			echo "ACHTUNG: legacy libtool-compatible install found. Re-linking it..."; \
			rm -f libsqlite3.la $(libsqlite3.DLL).0.8.6 || exit $$?; \
			ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL).0.8.6 || exit $$?; \
			ls -la $(libsqlite3.DLL).0.8.6; \
		elif [ x1 = "x$(INSTALL_SO_086_LINK)" ]; then \
			echo "ACHTUNG: installing legacy libtool-style links because INSTALL_SO_086_LINK=1"; \
			rm -f libsqlite3.la $(libsqlite3.DLL).0.8.6 || exit $$?; \
			ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL).0.8.6 || exit $$?; \
			ls -la $(libsqlite3.DLL).0.8.6; \
	cd "$(install-dir.lib)" || exit $$?; \
	rm -f $(libsqlite3.DLL).0 $(libsqlite3.DLL).$(PACKAGE_VERSION) || exit $$?; \
	mv $(libsqlite3.DLL) $(libsqlite3.DLL).$(PACKAGE_VERSION) || exit $$?; \
	ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL) || exit $$?; \
	ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL).0 || exit $$?; \
	ls -la $(libsqlite3.DLL) $(libsqlite3.DLL).[a03]*; \
	if [ -e $(libsqlite3.DLL).0.8.6 ]; then \
		echo "ACHTUNG: legacy libtool-compatible install found. Re-linking it..."; \
		rm -f libsqlite3.la $(libsqlite3.DLL).0.8.6 || exit $$?; \
		ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL).0.8.6 || exit $$?; \
		ls -la $(libsqlite3.DLL).0.8.6; \
	elif [ x1 = "x$(INSTALL_SO_086_LINK)" ]; then \
		echo "ACHTUNG: installing legacy libtool-style links because INSTALL_SO_086_LINK=1"; \
		rm -f libsqlite3.la $(libsqlite3.DLL).0.8.6 || exit $$?; \
		ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL).0.8.6 || exit $$?; \
		ls -la $(libsqlite3.DLL).0.8.6; \
		fi; \
	fi

install-dll-msys: install-dll-out-implib $(install-dir.bin)
	$(INSTALL) $(libsqlite3.DLL) "$(install-dir.bin)"
# ----------------------------------------------^^^ yes, bin
install-dll-mingw:  install-dll-msys
install-dll-cygwin: install-dll-msys

install-dll-darwin: $(install-dir.lib) $(libsqlite3.DLL)
	$(INSTALL) $(libsqlite3.DLL) "$(install-dir.lib)"
	@echo "Setting up $(libsqlite3.DLL) version symlinks..."; \
	cd "$(install-dir.lib)" || exit $$?; \
	rm -f libsqlite3.0$(T.dll) libsqlite3.$(PACKAGE_VERSION)$(T.dll) || exit $$?; \
	dllname=libsqlite3.$(PACKAGE_VERSION)$(T.dll); \
	mv $(libsqlite3.DLL) $$dllname || exit $$?; \
	ln -s $$dllname $(libsqlite3.DLL) || exit $$?; \
	ln -s $$dllname libsqlite3.0$(T.dll) || exit $$?; \
	ls -la $$dllname $(libsqlite3.DLL) libsqlite3.0$(T.dll)

install-dll-1: install-dll-$(libsqlite3.DLL.install-rules)
install-so-0 install-so-:
install-so: install-so-$(ENABLE_LIB_SHARED)
install: install-so
install-dll-0 install-dll-:
install-dll: install-dll-$(ENABLE_LIB_SHARED)
install: install-dll

install-lib-1: $(install-dir.lib) $(libsqlite3.LIB)
	$(INSTALL.noexec) $(libsqlite3.LIB) "$(install-dir.lib)"
install-lib-0 install-lib-:
install-lib: install-lib-$(ENABLE_LIB_STATIC)
install: install-lib

237
238
239
240
241
242
243
244

245
246
247
248
249
250
251
252
253
254
255
256
257
258

259
260
261
262
263
264
265
266







-
+








install-man1: $(TOP)/sqlite3.1 $(install-dir.man1)
	$(INSTALL.noexec) $(TOP)/sqlite3.1 "$(install-dir.man1)"
install: install-man1

clean:
	rm -f *.o sqlite3$(T.exe)
	rm -f $(libsqlite3.LIB) $(libsqlite3.DLL) $(libsqlite3.DLL).a
	rm -f $(libsqlite3.LIB) $(libsqlite3.DLL) libsqlite3$(T.dll).a

distclean: clean
	rm -f jimsh0$(T.exe) config.* sqlite3.pc sqlite_cfg.h Makefile

DIST_FILES := \
  README.txt VERSION \
  auto.def autosetup configure tea \
Changes to autoconf/auto.def.
1
2
3
4
5
6
7
8
9
10
11
12
13



14
15
16
17
18
19
20
21
22
23
24

25
26
27
28
29
1
2
3
4
5




6



7
8
9











10










-
-
-
-

-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
#!/do/not/tclsh
# ^^^ help out editors which guess this file's content type.
#
# This is the main autosetup-compatible configure script for the
# "autoconf" bundle of the SQLite project.
#
# This script must be kept compatible with JimTCL, a copy of which is
# included in this source tree as ./autosetup/jimsh0.c.
#
use sqlite-config
sqlite-config-bootstrap autoconf
sqlite-check-common-bins
sqlite-check-common-system-deps
sqlite-configure autoconf {
  sqlite-check-common-bins
  sqlite-check-common-system-deps
proj-check-rpath
sqlite-handle-soname
sqlite-setup-default-cflags
sqlite-handle-debug
sqlite-handle-threadsafe
sqlite-handle-tempstore
sqlite-handle-line-editing
sqlite-handle-load-extension
sqlite-handle-math
sqlite-handle-icu

}
define ENABLE_STATIC_SHELL [opt-bool static-shell]
define ENABLE_LIB_SHARED [opt-bool shared]
define ENABLE_LIB_STATIC [opt-bool static]

sqlite-config-finalize
Changes to autosetup/jimsh0.c.
1248
1249
1250
1251
1252
1253
1254








1255
1256
1257
1258
1259
1260
1261
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269







+
+
+
+
+
+
+
+








    #ifndef O_TEXT
        #define O_TEXT 0
    #endif

#endif

# ifndef MAXPATHLEN
# ifdef PATH_MAX
# define MAXPATHLEN PATH_MAX
# else
# define MAXPATHLEN JIM_PATH_LEN
# endif
# endif


int Jim_FileStoreStatData(Jim_Interp *interp, Jim_Obj *varName, const jim_stat_t *sb);

#endif
int Jim_bootstrapInit(Jim_Interp *interp)
{
	if (Jim_PackageProvide(interp, "bootstrap", "1.0", JIM_ERRMSG))
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2092
2093
2094
2095
2096
2097
2098




2099
2100
2101
2102
2103
2104
2105







-
-
-
-







#endif
#if defined(HAVE_SYS_UN_H) && defined(PF_UNIX)
#define UNIX_SOCKETS 1
#else
#define UNIX_SOCKETS 0
#endif

#ifndef MAXPATHLEN
#define MAXPATHLEN JIM_PATH_LEN
#endif




static int JimReadableTimeout(int fd, long ms)
{
#ifdef HAVE_SELECT
    int retval;
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4173
4174
4175
4176
4177
4178
4179








4180
4181
4182
4183
4184
4185
4186







-
-
-
-
-
-
-
-







#define F_OK 0
#define W_OK 2
#define R_OK 4
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif

# ifndef MAXPATHLEN
# ifdef PATH_MAX
# define MAXPATHLEN PATH_MAX
# else
# define MAXPATHLEN JIM_PATH_LEN
# endif
# endif

#if defined(__MINGW32__) || defined(__MSYS__) || defined(_MSC_VER)
#define ISWINDOWS 1

#undef HAVE_SYMLINK
#else
#define ISWINDOWS 0
#endif
Changes to autosetup/proj.tcl.
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390









391
392
393
394
395
396
397
375
376
377
378
379
380
381

382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405







-








+
+
+
+
+
+
+
+
+







# @proj-opt-set flag ?val?
#
# Force-set autosetup option $flag to $val. The value can be fetched
# later with [opt-val], [opt-bool], and friends.
#
# Returns $val.
proc proj-opt-set {flag {val 1}} {
  global autosetup
  if {$flag ni $::autosetup(options)} {
    # We have to add this to autosetup(options) or else future calls
    # to [opt-bool $flag] will fail validation of $flag.
    lappend ::autosetup(options) $flag
  }
  dict set ::autosetup(optset) $flag $val
  return $val
}

########################################################################
# @proj-opt-exists flag
#
# Returns 1 if the given flag has been defined as a legal configure
# option, else returns 0.
proc proj-opt-exists {flag} {
  expr {$flag in $::autosetup(options)};
}

########################################################################
# @proj-val-truthy val
#
# Returns 1 if $val appears to be a truthy value, else returns
# 0. Truthy values are any of {1 on true yes enabled}
proc proj-val-truthy {val} {
928
929
930
931
932
933
934





























935
936
937
938
939
940
941
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  if {$hadValue && 0 == $rc} {
    # Fail if it was explicitly requested but not found
    proj-fatal "Cannot find the Emscripten SDK"
  }
  define HAVE_EMSDK $rc
  return $rc
}

########################################################################
# @proj-cc-check-Wl-flag ?flag ?args??
#
# Checks whether the given linker flag (and optional arguments) can be
# passed from the compiler to the linker using one of these formats:
#
# - -Wl,flag[,arg1[,...argN]]
# - -Wl,flag -Wl,arg1 ...-Wl,argN
#
# If so, that flag string is returned, else an empty string is
# returned.
proc proj-cc-check-Wl-flag {args} {
  cc-with {-link 1} {
    # Try -Wl,flag,...args
    set fli "-Wl"
    foreach f $args { append fli ",$f" }
    if {[cc-check-flags $fli]} {
      return $fli
    }
    # Try -Wl,flag -Wl,arg1 ...-Wl,argN
    set fli ""
    foreach f $args { append fli "-Wl,$f " }
    if {[cc-check-flags $fli]} {
      return [string trim $fli]
    }
    return ""
  }
}

########################################################################
# @proj-check-rpath
#
# Tries various approaches to handling the -rpath link-time
# flag. Defines LDFLAGS_RPATH to that/those flag(s) or an empty
# string. Returns 1 if it finds an option, else 0.
954
955
956
957
958
959
960
961
962
963
964
965
966
967




968

969
970
971
972
973
974
975
991
992
993
994
995
996
997






998
999
1000
1001
1002

1003
1004
1005
1006
1007
1008
1009
1010







-
-
-
-
-
-

+
+
+
+
-
+







  # If we _don't_ use cc-with {} here (to avoid updating the global
  # CFLAGS or LIBS or whatever it is that cc-check-flags updates) then
  # downstream tests may fail because the resulting rpath gets
  # implicitly injected into them.
  cc-with {-link 1} {
    if {[cc-check-flags "-rpath $lp"]} {
      define LDFLAGS_RPATH "-rpath $lp"
    } elseif {[cc-check-flags "-Wl,-rpath,$lp"]} {
      define LDFLAGS_RPATH "-Wl,-rpath,$lp"
    } elseif {[cc-check-flags "-Wl,-rpath -Wl,$lp"]} {
      define LDFLAGS_RPATH "-Wl,-rpath -Wl,$lp"
    } elseif {[cc-check-flags -Wl,-R$lp]} {
      define LDFLAGS_RPATH "-Wl,-R$lp"
    } else {
      set wl [proj-cc-check-Wl-flag -rpath $lp]
      if {"" eq $wl} {
        set wl [proj-cc-check-Wl-flag -R$lp]
      }
      define LDFLAGS_RPATH ""
      define LDFLAGS_RPATH $wl
    }
  }
  expr {"" ne [get-define LDFLAGS_RPATH]}
}

########################################################################
# @proj-check-soname ?libname?
1154
1155
1156
1157
1158
1159
1160
1161

1162
1163
1164
1165
1166
1167
1168
1169

1170
1171
1172
1173
1174
1175
1176
1189
1190
1191
1192
1193
1194
1195

1196
1197
1198
1199
1200
1201
1202
1203

1204
1205
1206
1207
1208
1209
1210
1211







-
+







-
+







    }
  }
}

########################################################################
# Arguable/debatable...
#
# When _not_ cross-compiling and CC_FOR_BUILD is _not_ explcitely
# When _not_ cross-compiling and CC_FOR_BUILD is _not_ explicitly
# specified, force CC_FOR_BUILD to be the same as CC, so that:
#
# ./configure CC=clang
#
# will use CC_FOR_BUILD=clang, instead of cc, for building in-tree
# tools. This is based off of an email discussion and is thought to
# be likely to cause less confusion than seeing 'cc' invocations
# will when the user passes CC=clang.
# when when the user passes CC=clang.
#
# Sidebar: if we do this before the cc package is installed, it gets
# reverted by that package. Ergo, the cc package init will tell the
# user "Build C compiler...cc" shortly before we tell them otherwise.
proc proj-redefine-cc-for-build {} {
  if {![proj-is-cross-compiling]
      && [get-define CC] ne [get-define CC_FOR_BUILD]
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218





1219
1220
1221
1222
1223
1224
1225
1242
1243
1244
1245
1246
1247
1248





1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260







-
-
-
-
-
+
+
+
+
+







# Consider:
#
# $ ./configure --prefix=/foo
# $ make install prefix=/blah
#
# In that make invocation, $(libdir) would, at make-time, normally be
# hard-coded to /foo/lib, rather than /blah/lib. That happens because
# the autosetup exports conventional $prefix-based values for the
# numerous autoconfig-compatible XYZdir vars at configure-time.  What
# we would normally want, however, is that --libdir derives from the
# make-time $(prefix).  The distinction between configure-time and
# make-time is the significant factor there.
# autosetup exports conventional $prefix-based values for the numerous
# autoconfig-compatible XYZdir vars at configure-time.  What we would
# normally want, however, is that --libdir derives from the make-time
# $(prefix).  The distinction between configure-time and make-time is
# the significant factor there.
#
# This function attempts to reconcile those vars in such a way that
# they will derive, at make-time, from $(prefix) in a conventional
# manner unless they are explicitly overridden at configure-time, in
# which case those overrides takes precedence.
#
# Each --XYZdir flag which is explicitly passed to configure is
Changes to autosetup/sqlite-config.tcl.
8
9
10
11
12
13
14
15
















16
17
18
19
20
21
22
8
9
10
11
12
13
14

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37







-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







              may not contain space characters"
}
if {[string first " " $autosetup(builddir)] != -1} {
  user-error "The pathname of the build directory\
              may not contain space characters"
}

use cc cc-db cc-shared cc-lib pkg-config proj
use proj
########################################################################
# Set up PACKAGE_NAME and related defines and emit some useful
# bootstrapping info to the user.
proc sqlite-setup-package-info {} {
  set srcdir $::autosetup(srcdir)
  set PACKAGE_VERSION [proj-file-content -trim $srcdir/VERSION]
  define PACKAGE_NAME "sqlite"
  define PACKAGE_URL {https://sqlite.org}
  define PACKAGE_VERSION $PACKAGE_VERSION
  define PACKAGE_STRING "[get-define PACKAGE_NAME] $PACKAGE_VERSION"
  define PACKAGE_BUGREPORT [get-define PACKAGE_URL]/forum
  msg-result "Configuring SQLite version $PACKAGE_VERSION"
  msg-result "Source dir = $srcdir"
  msg-result "Build dir  = $::autosetup(builddir)"
}

#
# Object for communicating config-time state across various
# auto.def-related pieces.
#
array set sqliteConfig [proj-strip-hash-comments {
  #
45
46
47
48
49
50
51
52
53
54
55









56

57
58
59
60
61
62
63
60
61
62
63
64
65
66




67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84







-
-
-
-
+
+
+
+
+
+
+
+
+

+







# [proj-is-cross-compiling].
#
set sqliteConfig(is-cross-compiling) [proj-is-cross-compiling]

########################################################################
# Processes all configure --flags for this build $buildMode must be
# either "canonical" or "autoconf", and others may be added in the
# future.
proc sqlite-config-bootstrap {buildMode} {
  if {$buildMode ni {canonical autoconf}} {
    user-error "Invalid build mode: $buildMode. Expecting one of: canonical, autoconf"
# future. After bootstrapping, $configScript is eval'd in the caller's
# scope, then post-configuration finalization is run. $configScript is
# intended to hold configure code which is specific to the given
# $buildMode, with the caveat that _some_ build-specific code is
# encapsulated in the configuration finalization step.
proc sqlite-configure {buildMode configScript} {
  set allBuildModes {canonical autoconf}
  if {$buildMode ni $allBuildModes} {
    user-error "Invalid build mode: $buildMode. Expecting one of: $allBuildModes"
  }
  set ::sqliteConfig(build-mode) $buildMode
  ########################################################################
  # A gentle introduction to flags handling in autosetup
  #
  # Reference: https://msteveb.github.io/autosetup/developer/
  #
  # All configure flags must be described in an 'options' call. The
  # general syntax is:
128
129
130
131
132
133
134
135

136
137
138
139
140
141
142
143
144
145
146
147



148
149
150
151
152
153
154
149
150
151
152
153
154
155

156
157
158
159
160
161
162
163
164
165
166
167

168
169
170
171
172
173
174
175
176
177







-
+











-
+
+
+







    # B) Vars and commands are NOT expanded, but we use a [subst] call
    # below which will replace (only) var refs.

    # Options for how to build the library
    build-modes {
      {*} {
        shared=1             => {Disable build of shared libary}
        static=1             => {Disable build of static library (mostly)}
        static=1             => {Disable build of static library}
      }
      {canonical} {
        amalgamation=1       => {Disable the amalgamation and instead build all files separately}
      }
    }

    # Library-level features and defaults
    lib-features {
      {*} {
        threadsafe=1         => {Disable mutexing}
        with-tempstore:=no   => {Use an in-RAM database for temporary tables: never,no,yes,always}
        largefile=1          => {Disable large file support}
        largefile=1
          => {This legacy flag has no effect on the library but may influence
              the contents of the generated sqlite_cfg.h}
        # ^^^ It's not clear that this actually does anything, as
        # HAVE_LFS is not checked anywhere in the .c/.h/.in files.
        load-extension=1     => {Disable loading of external extensions}
        math=1               => {Disable math functions}
        json=1               => {Disable JSON functions}
        memsys5              => {Enable MEMSYS5}
        memsys3              => {Enable MEMSYS3}
225
226
227
228
229
230
231


232
233

234
235
236

237
238
239
240
241
242
243

244

245
246


247
248
249
250
251
252
253
254







255
256

257
258





259
260
261
262
263
264
265
266
267



268
269
270
271
272
273
274
275
276
277

278
279
280
281
282









283
284

285


286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303

304
305
306

307

308








309




























































310

311
312
313
314
315
316
317
248
249
250
251
252
253
254
255
256
257
258
259
260
261

262
263
264
265
266
267
268
269
270

271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291

292
293

294
295
296
297
298
299
300
301
302
303
304
305


306
307
308
309
310
311
312
313
314
315
316
317
318
319





320
321
322
323
324
325
326
327
328
329
330
331

332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350

351
352
353
354
355

356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426

427
428
429
430
431
432
433
434







+
+


+


-
+







+
-
+


+
+








+
+
+
+
+
+
+

-
+

-
+
+
+
+
+







-
-
+
+
+










+
-
-
-
-
-
+
+
+
+
+
+
+
+
+


+
-
+
+

















-
+



+
-
+

+
+
+
+
+
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+







              or --with-icu-config}
      }
    }

    # Options for exotic/alternative build modes
    alternative-builds {
      {canonical} {
        # Potential TODO: add --with-wasi-sdk support to the autoconf
        # build
        with-wasi-sdk:=/opt/wasi-sdk
          => {Top-most dir of the wasi-sdk for a WASI build}

        with-emsdk:=auto
          => {Top-most dir of the Emscripten SDK installation.
              Default = EMSDK env var.}
              Needed only by ext/wasm build. Default=EMSDK env var.}
      }
    }

    # Options primarily for downstream packagers/package maintainers
    packaging {
      {autoconf} {
        # --disable-static-shell: https://sqlite.org/forum/forumpost/cc219ee704
        static-shell=1
        static-shell=1       => {Link the sqlite3 shell app against the DLL instead of embedding sqlite3.c}
          => {Link the sqlite3 shell app against the DLL instead of embedding sqlite3.c}
      }
      {*} {
        # A potential TODO without a current use case:
        #rpath=1 => {Disable use of the rpath linker flag}
        # soname: https://sqlite.org/src/forumpost/5a3b44f510df8ded
        soname:=legacy
          => {SONAME for libsqlite3.so. "none", or not using this flag, sets no
              soname. "legacy" sets it to its historical value of
              libsqlite3.so.0.  A value matching the glob "libsqlite3.*" sets
              it to that literal value. Any other value is assumed to be a
              suffix which gets applied to "libsqlite3.so.",
              e.g. --soname=9.10 equates to "libsqlite3.so.9.10".}
        # dll-basename: https://sqlite.org/forum/forumpost/828fdfe904
        dll-basename:=auto
          => {Specifies the base name of the resulting DLL file.
              If not provided, libsqlite3 is usually assumed but on some platforms
              a platform-dependent default is used. On some platforms this flag
              gets automatically enabled if it is not provided. Use "default" to
              explicitly disable platform-dependent activation on such systems.}
        # out-implib: https://sqlite.org/forum/forumpost/0c7fc097b2
        out-implib=0
        out-implib:=auto
          => {Enable use of --out-implib linker flag to generate an
              "import library" for the DLL}
              "import library" for the DLL. The output's base name name is
              specified by the value, with "auto" meaning to figure out a
              name automatically. On some platforms this flag gets
              automatically enabled if it is not provided. Use "none" to
              explicitly disable this feature on such platforms.}
      }
    }

    # Options mostly for sqlite's own development
    developer {
      {*} {
        # Note that using the --debug/--enable-debug flag here
        # requires patching autosetup/autosetup to rename the --debug
        # to --autosetup-debug.
        # requires patching autosetup/autosetup to rename its builtin
        # --debug to --autosetup-debug. See details in
        # autosetup/README.md#patching.
        with-debug=0
        debug=0
          => {Enable debug build flags. This option will impact performance by
              as much as 4x, as it includes large numbers of assert()s in
              performance-critical loops.  Never use --debug for production
              builds.}
        scanstatus
          => {Enable the SQLITE_ENABLE_STMT_SCANSTATUS feature flag}
      }
      {canonical} {
        dev
        dev                  => {Enable dev-mode build: automatically enables certain other flags}
        test-status          => {Enable status of tests}
        gcov=0               => {Enable coverage testing using gcov}
        linemacros           => {Enable #line macros in the amalgamation}
        dynlink-tools        => {Dynamically link libsqlite3 to certain tools which normally statically embed it}
          => {Enable dev-mode build: automatically enables certain other flags}
        test-status
          => {Enable status of tests}
        gcov=0
          => {Enable coverage testing using gcov}
        linemacros
          => {Enable #line macros in the amalgamation}
        dynlink-tools
          => {Dynamically link libsqlite3 to certain tools which normally statically embed it}
      }
      {*} {
        dump-defines=0
        dump-defines=0       => {Dump autosetup defines to $::sqliteConfig(dump-defines-txt) (for build debugging)}
          => {Dump autosetup defines to $::sqliteConfig(dump-defines-txt)
              (for build debugging)}
      }
    }
  }; # $allOpts

  # Filter allOpts to create the set of [options] legal for this build
  set opts {}
  foreach {group XY} [subst -nobackslashes -nocommands \
                        [proj-strip-hash-comments $allFlags]] {
    foreach {X Y} $XY {
      if { $buildMode in $X || "*" in $X } {
        foreach y $Y {
          lappend opts $y
        }
      }
    }
  }
  #lappend opts "soname:=duplicateEntry => {x}"; #just testing
  if {[catch {options $opts}]} {
  if {[catch {options $opts} msg opts]} {
    # Workaround for <https://github.com/msteveb/autosetup/issues/73>
    # where [options] behaves oddly on _some_ TCL builds when it's
    # called from deeper than the global scope.
    dict incr opts -level
    return -code break
    return {*}$opts $msg
  }
  sqlite-setup-package-info
  uplevel 1 {
    # The odd placement of this block is so that we can emit the
    # output from sqlite-setup-package-info after --help is processed
    # but before any other info is emitted, e.g. the host/target
    # system info and the C compiler check.
    use cc cc-db cc-shared cc-lib pkg-config
  }
  sqlite-post-options-init
  uplevel 1 $configScript
  sqlite-configure-finalize
}; # sqlite-configure

########################################################################
# Performs late-stage config steps common to both the canonical and
# autoconf bundle builds.
proc sqlite-configure-finalize {} {
  set buildMode $::sqliteConfig(build-mode)
  set isCanonical [expr {$buildMode eq "canonical"}]
  set isAutoconf [expr {$buildMode eq "autoconf"}]

  define HAVE_LFS 0
  if {[opt-bool largefile]} {
    #
    # Insofar as we can determine HAVE_LFS has no effect on the
    # library.  Perhaps it did back in the early 2000's. The
    # --enable/disable-largefile flag is retained because it's
    # harmless, but it doesn't do anything useful. It does have
    # visible side-effects, though: the generated sqlite_cfg.h may (or
    # may not) define HAVE_LFS.
    #
    cc-check-lfs
  }

  if {$isCanonical} {
    if {![opt-bool static]} {
      proj-indented-notice {
        NOTICE: static lib build may be implicitly re-activated by
        other components, e.g. some test apps.
      }
    }
  } else {
    proj-assert { $isAutoconf } "Invalid build mode"
    proj-define-for-opt static-shell ENABLE_STATIC_SHELL \
      "Link library statically into the CLI shell?"
    if {![opt-bool shared] && ![opt-bool static-shell]} {
      proj-opt-set shared 1
      proj-indented-notice {
        NOTICE: ignoring --disable-shared because --disable-static-shell
        was specified.
      }
    }
  }
  proj-define-for-opt shared ENABLE_LIB_SHARED "Build shared library?"
  proj-define-for-opt static ENABLE_LIB_STATIC "Build static library?"

  sqlite-handle-debug
  sqlite-handle-rpath
  sqlite-handle-soname
  sqlite-handle-threadsafe
  sqlite-handle-tempstore
  sqlite-handle-line-editing
  sqlite-handle-load-extension
  sqlite-handle-math
  sqlite-handle-icu
  sqlite-handle-env-quirks
  sqlite-process-dot-in-files
  sqlite-post-config-validation
  sqlite-dump-defines
}; # sqlite-config-bootstrap
}; # sqlite-configure-finalize

########################################################################
# Runs some common initialization which must happen immediately after
# autosetup's [options] function is called. This is also a convenient
# place to put some generic pieces common to both the canonical
# top-level build and the "autoconf" build, but it's not intended to
# be a catch-all dumping ground for such.
332
333
334
335
336
337
338
339

340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
449
450
451
452
453
454
455

456
















457
458
459
460
461
462
463







-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







    define SQLITE_OS_UNIX 0
    define SQLITE_OS_WIN 1
  } else {
    define SQLITE_OS_UNIX 1
    define SQLITE_OS_WIN 0
  }
  set ::sqliteConfig(msg-debug-enabled) [proj-val-truthy [get-env msg-debug 0]]
  sqlite-setup-package-info
  sqlite-setup-default-cflags
}

########################################################################
# Called by [sqlite-post-options-init] to set up PACKAGE_NAME and
# related defines.
proc sqlite-setup-package-info {} {
  set srcdir $::autosetup(srcdir)
  set PACKAGE_VERSION [proj-file-content -trim $srcdir/VERSION]
  define PACKAGE_NAME "sqlite"
  define PACKAGE_URL {https://sqlite.org}
  define PACKAGE_VERSION $PACKAGE_VERSION
  define PACKAGE_STRING "[get-define PACKAGE_NAME] $PACKAGE_VERSION"
  define PACKAGE_BUGREPORT [get-define PACKAGE_URL]/forum
  msg-result "Source dir = $srcdir"
  msg-result "Build dir  = $::autosetup(builddir)"
  msg-result "Configuring SQLite version $PACKAGE_VERSION"
}

########################################################################
# Internal config-time debugging output routine. It generates no
# output unless msg-debug=1 is passed to the configure script.
proc msg-debug {msg} {
  if {$::sqliteConfig(msg-debug-enabled)} {
966
967
968
969
970
971
972
973

974
975
976
977
978
979
980
1067
1068
1069
1070
1071
1072
1073

1074
1075
1076
1077
1078
1079
1080
1081







-
+







  # libedit typically require some other library which (according to
  # legacy autotools-generated tests) provides tgetent(3). On some
  # systems that's built into libreadline/edit, on some (most?) its in
  # lib[n]curses, and on some it's in libtermcap.
  set rlLib ""
  if {"" ne $rlInc} {
    set rlLib [opt-val with-readline-ldflags]
    if {"" eq $rlLib || "auto" eq $rlLib} {
    if {$rlLib eq "auto" || $rlLib eq ""} {
      set rlLib ""
      set libTerm ""
      if {[proj-check-function-in-lib tgetent "$editLibName ncurses curses termcap"]} {
        # ^^^ that libs list comes from the legacy configure script ^^^
        set libTerm [get-define lib_tgetent]
        undefine lib_tgetent
      }
1218
1219
1220
1221
1222
1223
1224
1225

1226
1227
1228
1229
1230
1231
1232
1319
1320
1321
1322
1323
1324
1325

1326
1327
1328
1329
1330
1331
1332
1333







-
+







# supported, else defines that to the linker flags and returns 1.
#
# We don't check this on non-Macs because this whole thing is a
# libtool compatibility kludge to account for a version stamp which
# libtool applied only on Mac platforms.
#
# Based on https://sqlite.org/forum/forumpost/9dfd5b8fd525a5d7.
proc sqlite-check-mac-cversion {} {
proc sqlite-handle-mac-cversion {} {
  define LDFLAGS_MAC_CVERSION ""
  set rc 0
  if {[proj-looks-like-mac]} {
    cc-with {-link 1} {
      # These version numbers are historical libtool-defined values, not
      # library-defined ones
      if {[cc-check-flags "-Wl,-current_version,9.6.0"]
1240
1241
1242
1243
1244
1245
1246
























1247

1248
1249
1250



1251
1252
1253
1254
1255
1256
1257
1258
1259
1260








1261

1262

1263
1264








1265
1266
1267
1268
1269
1270
1271
1272
1273
1274












1275
1276
1277
1278
1279
1280




















1281
1282
1283
1284
1285
1286
1287
1288




































































1289
1290
1291
1292
1293
1294
1295
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371

1372
1373
1374

1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395

1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408










1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446








1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+


-
+
+
+










+
+
+
+
+
+
+
+
-
+

+


+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+






+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







      }
    }
  }
  return $rc
}

########################################################################
# Handles the --dll-basename configure flag. [define]'s
# SQLITE_DLL_BASENAME to the DLL's preferred base name (minus
# extension). If --dll-basename is not provided then this is always
# "libsqlite3", otherwise it may use a different value based on the
# value of [get-define host].
proc sqlite-handle-dll-basename {} {
  if {[proj-opt-was-provided dll-basename]} {
    set dn [join [opt-val dll-basename] ""]
    if {$dn in {none default}} { set dn libsqlite3 }
  } else {
    set dn libsqlite3
  }
  if {$dn in {auto ""}} {
    switch -glob -- [get-define host] {
      *-*-cygwin  { set dn cygsqlite3-0 }
      *-*-ming*   { set dn libsqlite3-0 }
      *-*-msys    { set dn msys-sqlite3-0 }
      default     { set dn libsqlite3 }
    }
  }
  define SQLITE_DLL_BASENAME $dn
}

########################################################################
# Define LDFLAGS_OUT_IMPLIB to either an empty string or to a
# [define]s LDFLAGS_OUT_IMPLIB to either an empty string or to a
# -Wl,... flag for the platform-specific --out-implib flag, which is
# used for building an "import library .dll.a" file on some platforms
# (e.g. mingw). Returns 1 if supported, else 0.
# (e.g. msys2, mingw). Returns 1 if supported, else 0.
#
# The name of the import library is [define]d in SQLITE_OUT_IMPLIB.
#
# If the configure flag --out-implib is not used then this is a no-op.
# If that flag is used but the capability is not available, a fatal
# error is triggered.
#
# This feature is specifically opt-in because it's supported on far
# more platforms than actually need it and enabling it causes creation
# of libsqlite3.so.a files which are unnecessary in most environments.
#
# Added in response to: https://sqlite.org/forum/forumpost/0c7fc097b2
#
# Platform notes:
#
# - cygwin sqlite packages historically install no .dll.a file.
#
# - msys2 and mingw sqlite packages historically install
#   /usr/lib/libsqlite3.dll.a despite the DLL being in
#   /usr/bin/msys-sqlite3-0.dll.
proc sqlite-check-out-implib {} {
proc sqlite-handle-out-implib {} {
  define LDFLAGS_OUT_IMPLIB ""
  define SQLITE_OUT_IMPLIB ""
  set rc 0
  if {[proj-opt-was-provided out-implib]} {
    set olBaseName [join [opt-val out-implib] ""]
    if {$olBaseName in {auto ""}} {
      set olBaseName "libsqlite3" ;# [get-define SQLITE_DLL_BASENAME]
      # Based on discussions with mingw/msys users, the import lib
      # should always be called libsqlite3.dll.a even on platforms
      # which rename libsqlite3.dll to something else.
    }
    if {$olBaseName ne "none"} {
    cc-with {-link 1} {
      set dll "libsqlite3[get-define TARGET_DLLEXT]"
      set flags "-Wl,--out-implib,${dll}.a"
      if {[cc-check-flags $flags]} {
        define LDFLAGS_OUT_IMPLIB $flags
        set rc 1
      }
    }
    if {!$rc} {
      user-error "--out-implib is not supported on this platform"
      cc-with {-link 1} {
        set dll "${olBaseName}[get-define TARGET_DLLEXT]"
        set flags [proj-cc-check-Wl-flag --out-implib ${dll}.a]
        if {"" ne $flags} {
          define LDFLAGS_OUT_IMPLIB $flags
          define SQLITE_OUT_IMPLIB ${dll}.a
          set rc 1
        }
      }
      if {!$rc} {
        user-error "--out-implib is not supported on this platform"
      }
    }
  }
  return $rc
}

########################################################################
# If the given platform identifier (defaulting to [get-define host])
# appears to be one of the Unix-on-Windows environments, returns a
# brief symbolic name for that environment, else returns an empty
# string.
#
# It does not distinguish between msys and msys2, returning msys for
# both. The build does not, as of this writing, specifically support
# msys v1.
proc sqlite-env-is-unix-on-windows {{envTuple ""}} {
  if {"" eq $envTuple} {
    set envTuple [get-define host]
  }
  set name ""
  switch -glob -- $envTuple {
    *-*-cygwin { set name cygwin }
    *-*-ming*  { set name mingw }
    *-*-msys   { set name msys }
  }
  return $name;
}
# Performs late-stage config steps common to both the canonical and
# autoconf bundle builds.
proc sqlite-config-finalize {} {
  sqlite-check-mac-cversion
  sqlite-check-out-implib
  sqlite-process-dot-in-files
  sqlite-post-config-validation
  sqlite-dump-defines

########################################################################
# Performs various tweaks to the build which are only relevant on
# certain platforms, e.g. Mac and "Unix on Windows" platforms (msys2,
# cygwin, ...).
#
# 1) DLL installation:
#
# [define]s SQLITE_DLL_INSTALL_RULES to a symbolic name suffix for a
# set of "make install" rules to use for installation of the DLL
# deliverable. The makefile is tasked with with providing rules named
# install-dll-NAME which runs the installation for that set, as well
# as providing a rule named install-dll which resolves to
# install-dll-NAME (perhaps indirectly, depending on whether the DLL
# is (de)activated).
#
# The default value is "unix-generic".
#
# 2) --out-implib:
#
# On platforms where an "import library" is conventionally used but
# --out-implib was not explicitly used, automatically add that flag.
# This conventionally applies to the "Unix on Windows" environments
# like msys and cygwin.
#
# 3) --dll-basename:
#
# On the same platforms addressed by --out-implib, if --dll-basename
# is not specified, --dll-basename=auto is implied.
proc sqlite-handle-env-quirks {} {
  set instName unix-generic; # name of installation rules set
  set autoDll 0; # true if --out-implib/--dll-basename should be implied
  set host [get-define host]
  switch -glob -- $host {
    *apple* -
    *darwin*    { set instName darwin }
    default {
      set x [sqlite-env-is-unix-on-windows $host]
      if {"" ne $x} {
        set instName $x
        set autoDll 1
      }
    }
  }
  define SQLITE_DLL_INSTALL_RULES $instName
  if {$autoDll} {
    if {![proj-opt-was-provided out-implib]} {
      # Imply --out-implib=auto
      proj-indented-notice [subst -nocommands -nobackslashes {
        NOTICE: auto-enabling --out-implib for environment [$host].
        Use --out-implib=none to disable this special case
        or --out-implib=auto to squelch this notice.
      }]
      proj-opt-set out-implib auto
    }
    if {![proj-opt-was-provided dll-basename]} {
      # Imply --dll-basename=auto
      proj-indented-notice [subst -nocommands -nobackslashes {
        NOTICE: auto-enabling --dll-basename for environment [$host].
        Use --dll-basename=default to disable this special case
        or --dll-basename=auto to squelch this notice.
      }]
      proj-opt-set dll-basename auto
    }
  }
  sqlite-handle-dll-basename
  sqlite-handle-out-implib
  sqlite-handle-mac-cversion
}

########################################################################
# Perform some late-stage work and generate the configure-process
# output file(s).
proc sqlite-process-dot-in-files {} {
  ########################################################################
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544



1545
1546
1547
1548
1549
1550
1551
1761
1762
1763
1764
1765
1766
1767



1768
1769
1770
1771
1772
1773
1774
1775
1776
1777







-
-
-
+
+
+







          }
        }
      }
      if {"" eq $cfg} {
        proj-fatal "No tclConfig.sh found under ${with_tcl}"
      }
    } else {
      # If we have not yet found a tclConfig.sh file, look in
      # $libdir which is set automatically by autosetup or by the
      # --prefix command-line option.  See
      # If we have not yet found a tclConfig.sh file, look in $libdir
      # which is set automatically by autosetup or via the --prefix
      # command-line option.  See
      # https://sqlite.org/forum/forumpost/e04e693439a22457
      set libdir [get-define libdir]
      if {[file readable "${libdir}/tclConfig.sh"]} {
        set cfg "${libdir}/tclConfig.sh"
      } else {
        foreach i $tclSubdirs {
          if {[file readable "${libdir}/$i/tclConfig.sh"]} {
1723
1724
1725
1726
1727
1728
1729
1730

1731
1732
1733
1734
1735
1736
1737
1738
1739




















1740
1741
1742
1743
1744
1745
1746
1949
1950
1951
1952
1953
1954
1955

1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992







-
+









+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







      }
      set cgtcl [get-define TCLSH_CMD]
      if {![file-isexec $cgtcl]} {
        proj-fatal "Cannot find a tclsh to use for code generation."
      }
      define BTCLSH "\$(TCLSH_CMD)"
    }
  }; # CC swap-out
  }; # /define-push $flagsToRestore
  return $cgtcl
}; # sqlite-determine-codegen-tcl

########################################################################
# Runs sqlite-check-tcl and sqlite-determine-codegen-tcl.
proc sqlite-handle-tcl {} {
  sqlite-check-tcl
  msg-result "TCL for code generation: [sqlite-determine-codegen-tcl]"
}

########################################################################
# Handle the --enable/disable-rpath flag.
proc sqlite-handle-rpath {} {
  proj-check-rpath
  # autosetup/cc-chared.tcl sets the rpath flag definition in
  # [get-define SH_LINKRPATH], but it does so on a per-platform basis
  # rather than as a compiler check. Though we should do a proper
  # compiler check (as proj-check-rpath does), we may want to consider
  # adopting its approach of clearing the rpath flags for environments
  # for which sqlite-env-is-unix-on-windows returns a non-empty
  # string.

#  if {[proj-opt-truthy rpath]} {
#    proj-check-rpath
#  } else {
#    msg-result "Disabling use of rpath."
#    define LDFLAGS_RPATH ""
#  }
}

########################################################################
# If the --dump-defines configure flag is provided then emit a list of
# all [define] values to config.defines.txt, else do nothing.
proc sqlite-dump-defines {} {
  proj-if-opt-truthy dump-defines {
    make-config-header $::sqliteConfig(dump-defines-txt) \
Changes to main.mk.
185
186
187
188
189
190
191
192

193
194
195
196

197
198

199
200
201
202
203
204

205
206
207
208
209
210
211
185
186
187
188
189
190
191

192
193
194
195

196
197

198
199
200
201
202
203

204
205
206
207
208
209
210
211







-
+



-
+

-
+





-
+







# with conventional Unix /usr/bin/install. Note that libtool's
# install-sh is _not_ compatible with this because it _moves_ targets
# during installation, which may break the build of targets which are
# built after others are installed.
#
INSTALL ?= install
#
# $(ENABLE_SHARED) =
# $(ENABLE_LIB_SHARED) =
#
# 1 if libsqlite3$(T.dll) should be built.
#
ENABLE_SHARED ?= 1
ENABLE_LIB_SHARED ?= 1
#
# $(ENABLE_STATIC) =
# $(ENABLE_LIB_STATIC) =
#
# 1 if libsqlite3$(T.lib) should be built. Some components,
# e.g. libtclsqlite3 and some test apps, implicitly require the static
# library and will ignore this preference.
#
ENABLE_STATIC ?= 1
ENABLE_LIB_STATIC ?= 1
#
# $(USE_AMALGAMATION)
#
# 1 if the amalgamation (sqlite3.c/h) should be built/used, otherwise
# the library is built from all of its original source files.
# Certaint tools, like sqlite3$(T.exe), require the amalgamation and
# will ignore this preference.
1051
1052
1053
1054
1055
1056
1057
1058



1059
1060












1061
1062
1063
1064
1065

1066
1067


1068

1069
1070
1071
1072
1073
1074
1075
1051
1052
1053
1054
1055
1056
1057

1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078

1079

1080
1081
1082

1083
1084
1085
1086
1087
1088
1089
1090







-
+
+
+


+
+
+
+
+
+
+
+
+
+
+
+




-
+
-

+
+
-
+







	mv -f vdbe.new tsrc/vdbe.c
	cp fts5.c fts5.h tsrc
	touch .target_source

#
# libsqlite3.DLL.basename = the base name of the resulting DLL. This
# is typically libsqlite3 but varies wildly on Unix-like Windows
# environments (msys, cygwin, and friends).
# environments (msys, cygwin, and friends). Conversely, the base name
# of the static library ($(libsqlite3.LIB)) is constant on all tested
# platforms.
#
libsqlite3.DLL.basename ?= libsqlite3
#
# libsqlite3.DLL => the DLL library
#
libsqlite3.DLL = $(libsqlite3.DLL.basename)$(T.dll)
#
# libsqlite3.out.implib => "import library" file generated by the
# --out-implib linker flag. Not commonly used on Unix systems but is
# on the Windows-side Unix-esque environments and typically as a value
# of "libsqlite3.dll.a". It is expected to match the filename, if any,
# provided by the -Wl,--out-implib,FILENAME flag.
#
libsqlite3.out.implib ?=
#
# libsqlite3.LIB => the static library
#
libsqlite3.LIB = libsqlite3$(T.lib)
#

# libsqlite3.LIB => the DLL library
#
# libsqlite3.DLL.install-rules => the suffix of the symoblic name of
# the makefile rules for installing the DLL.
libsqlite3.DLL = $(libsqlite3.DLL.basename)$(T.dll)
libsqlite3.DLL.install-rules ?= unix-generic

# Rules to build the LEMON compiler generator
#
lemon$(B.exe): $(MAKE_SANITY_CHECK) $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
	$(B.cc) -o $@ $(TOP)/tool/lemon.c
	cp $(TOP)/tool/lempar.c .

1420
1421
1422
1423
1424
1425
1426
1427

1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438

1439
1440


1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451


1452
1453
1454
1455
1456
1457
1458
1459
1435
1436
1437
1438
1439
1440
1441

1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452

1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466


1467
1468

1469
1470
1471
1472
1473
1474
1475







-
+










-
+


+
+









-
-
+
+
-







#
# Static libsqlite3
#
$(libsqlite3.LIB): $(LIBOBJ)
	$(AR) $(AR.flags) $@ $(LIBOBJ)
$(libsqlite3.LIB)-1: $(libsqlite3.LIB)
$(libsqlite3.LIB)-0 $(libsqlite3.LIB)-:
lib: $(libsqlite3.LIB)-$(ENABLE_STATIC)
lib: $(libsqlite3.LIB)-$(ENABLE_LIB_STATIC)
all: lib

#
# Dynamic libsqlite3
#
$(libsqlite3.DLL):	$(LIBOBJ)
	$(T.link.shared) -o $@ $(LIBOBJ) $(LDFLAGS.libsqlite3) \
		$(LDFLAGS.libsqlite3.os-specific) $(LDFLAGS.libsqlite3.soname)
$(libsqlite3.DLL)-1: $(libsqlite3.DLL)
$(libsqlite3.DLL)-0 $(libsqlite3.DLL)-:
so: $(libsqlite3.DLL)-$(ENABLE_SHARED)
so: $(libsqlite3.DLL)-$(ENABLE_LIB_SHARED)
all: so

#
# DLL installation...
#
# On most Unix-like platforms, install the $(libsqlite3.DLL) as
# $(libsqlite3.DLL).$(PACKAGE_VERSION) and create symlinks which point
# to it:
#
# - libsqlite3.so.$(PACKAGE_VERSION)
# - libsqlite3.so.0      =symlink-> libsqlite3.so.$(PACKAGE_VERSION) (see below)
# - libsqlite3.so        =symlink-> libsqlite3.so.3
#
# The symlinks are not added on platforms where $(T.dll) is ".dll",
# and different transformations take place on platforms where $(T.dll)
# Different rules apply for platforms where $(T.dll)==.dylib and for
# the "Unix on Windows" environments.
# is ".dylib".
#
# The link named libsqlite3.so.0 is provided in an attempt to reduce
# downstream disruption when performing upgrades from pre-3.48 to a
# version 3.48 or higher.  That name is considered a legacy remnant
# and will eventually be removed from this installation process.
#
# Historically libtool installed the library like so:
1481
1482
1483
1484
1485
1486
1487

1488

1489
1490
1491


1492
1493

1494
1495
1496
1497

1498
1499
1500
1501


1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
















1521
1522
1523





1524
1525
1526
















1527
1528
1529
1530
1531
1532
1533
1534

1535
1536
1537
1538
1539
1540
1541
1497
1498
1499
1500
1501
1502
1503
1504

1505



1506
1507
1508

1509




1510




1511
1512



















1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528

1529
1530
1531
1532
1533
1534
1535



1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558

1559
1560
1561
1562
1563
1564
1565
1566







+
-
+
-
-
-
+
+

-
+
-
-
-
-
+
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-


+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







-
+







#    remove sqlite3-3.47.0 && apt install sqlite3-3.48.0). In such
#    cases, condition (1) would never trigger but applications might
#    still expect to see the legacy file names.
#
# In either case, libsqlite3.la, if found, is deleted because it would
# contain stale state, refering to non-libtool-generated libraries.
#

install-so-1: $(install-dir.lib) $(libsqlite3.DLL)
install-dll-out-implib: $(install-dir.lib) $(libsqlite3.DLL)
	$(INSTALL) $(libsqlite3.DLL) "$(install-dir.lib)"
	@if [ -f $(libsqlite3.DLL).a ]; then \
		$(INSTALL) $(libsqlite3.DLL).a "$(install-dir.lib)"; \
	if [ x != "x$(libsqlite3.out.implib)" ] && [ -f "$(libsqlite3.out.implib)" ]; then \
		$(INSTALL) $(libsqlite3.out.implib) "$(install-dir.lib)"; \
	fi
	@echo "Setting up $(libsqlite3.DLL) version symlinks..."; \

	if [ x.dll = x$(T.dll) ]; then \
		echo "No library symlinks needed on this platform"; \
	elif [ x.dylib = x$(T.dll) ]; then \
		cd "$(install-dir.lib)" || exit $$?; \
install-dll-unix-generic: install-dll-out-implib
		rm -f libsqlite3.0$(T.dll) libsqlite3.$(PACKAGE_VERSION)$(T.dll) || exit $$?; \
		dllname=libsqlite3.$(PACKAGE_VERSION)$(T.dll); \
		mv $(libsqlite3.DLL) $$dllname || exit $$?; \
		ln -s $$dllname $(libsqlite3.DLL) || exit $$?; \
	$(INSTALL) $(libsqlite3.DLL) "$(install-dir.lib)"
	@echo "Setting up $(libsqlite3.DLL) version symlinks..."; \
		ln -s $$dllname libsqlite3.0$(T.dll) || exit $$?; \
		ls -la $$dllname $(libsqlite3.DLL) libsqlite3.0$(T.dll); \
	else \
		cd "$(install-dir.lib)" || exit $$?; \
		rm -f $(libsqlite3.DLL).0 $(libsqlite3.DLL).$(PACKAGE_VERSION) || exit $$?; \
		mv $(libsqlite3.DLL) $(libsqlite3.DLL).$(PACKAGE_VERSION) || exit $$?; \
		ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL) || exit $$?; \
		ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL).0 || exit $$?; \
		ls -la $(libsqlite3.DLL) $(libsqlite3.DLL).[a03]*; \
		if [ -e $(libsqlite3.DLL).0.8.6 ]; then \
			echo "ACHTUNG: legacy libtool-compatible install found. Re-linking it..."; \
			rm -f libsqlite3.la $(libsqlite3.DLL).0.8.6 || exit $$?; \
			ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL).0.8.6 || exit $$?; \
			ls -la $(libsqlite3.DLL).0.8.6; \
		elif [ x1 = "x$(INSTALL_SO_086_LINK)" ]; then \
			echo "ACHTUNG: installing legacy libtool-style links because INSTALL_SO_086_LINK=1"; \
			rm -f libsqlite3.la $(libsqlite3.DLL).0.8.6 || exit $$?; \
			ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL).0.8.6 || exit $$?; \
			ls -la $(libsqlite3.DLL).0.8.6; \
	cd "$(install-dir.lib)" || exit $$?; \
	rm -f $(libsqlite3.DLL).0 $(libsqlite3.DLL).$(PACKAGE_VERSION) || exit $$?; \
	mv $(libsqlite3.DLL) $(libsqlite3.DLL).$(PACKAGE_VERSION) || exit $$?; \
	ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL) || exit $$?; \
	ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL).0 || exit $$?; \
	ls -la $(libsqlite3.DLL) $(libsqlite3.DLL).[a03]*; \
	if [ -e $(libsqlite3.DLL).0.8.6 ]; then \
		echo "ACHTUNG: legacy libtool-compatible install found. Re-linking it..."; \
		rm -f libsqlite3.la $(libsqlite3.DLL).0.8.6 || exit $$?; \
		ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL).0.8.6 || exit $$?; \
		ls -la $(libsqlite3.DLL).0.8.6; \
	elif [ x1 = "x$(INSTALL_SO_086_LINK)" ]; then \
		echo "ACHTUNG: installing legacy libtool-style links because INSTALL_SO_086_LINK=1"; \
		rm -f libsqlite3.la $(libsqlite3.DLL).0.8.6 || exit $$?; \
		ln -s $(libsqlite3.DLL).$(PACKAGE_VERSION) $(libsqlite3.DLL).0.8.6 || exit $$?; \
		ls -la $(libsqlite3.DLL).0.8.6; \
		fi; \
	fi

install-dll-msys: install-dll-out-implib $(install-dir.bin)
	$(INSTALL) $(libsqlite3.DLL) "$(install-dir.bin)"
# ----------------------------------------------^^^ yes, bin
install-dll-mingw:  install-dll-msys
install-dll-cygwin: install-dll-msys
install-so-0 install-so-:
install-so: install-so-$(ENABLE_SHARED)
install: install-so

install-dll-darwin: $(install-dir.lib) $(libsqlite3.DLL)
	$(INSTALL) $(libsqlite3.DLL) "$(install-dir.lib)"
	@echo "Setting up $(libsqlite3.DLL) version symlinks..."; \
	cd "$(install-dir.lib)" || exit $$?; \
	rm -f libsqlite3.0$(T.dll) libsqlite3.$(PACKAGE_VERSION)$(T.dll) || exit $$?; \
	dllname=libsqlite3.$(PACKAGE_VERSION)$(T.dll); \
	mv $(libsqlite3.DLL) $$dllname || exit $$?; \
	ln -s $$dllname $(libsqlite3.DLL) || exit $$?; \
	ln -s $$dllname libsqlite3.0$(T.dll) || exit $$?; \
	ls -la $$dllname $(libsqlite3.DLL) libsqlite3.0$(T.dll)

install-dll-1: install-dll-$(libsqlite3.DLL.install-rules)
install-dll-0 install-dll-:
install-dll: install-dll-$(ENABLE_LIB_SHARED)
install: install-dll

#
# Install $(libsqlite3.LIB)
#
install-lib-1: $(install-dir.lib) $(libsqlite3.LIB)
	$(INSTALL.noexec) $(libsqlite3.LIB) "$(install-dir.lib)"
install-lib-0 install-lib-:
install-lib: install-lib-$(ENABLE_STATIC)
install-lib: install-lib-$(ENABLE_LIB_STATIC)
install: install-lib

#
# Install C header files
#
install-headers: sqlite3.h $(install-dir.include)
	$(INSTALL.noexec) sqlite3.h "$(TOP)/src/sqlite3ext.h" "$(install-dir.include)"
2352
2353
2354
2355
2356
2357
2358
2359

2360
2361
2362
2363
2364
2365
2366
2377
2378
2379
2380
2381
2382
2383

2384
2385
2386
2387
2388
2389
2390
2391







-
+







tidy: tidy-.
	rm -f *.o *.c *.da *.bb *.bbg gmon.* *.rws sqlite3$(T.exe)
	rm -f fts5.h keywordhash.h opcodes.h sqlite3.h sqlite3ext.h sqlite3session.h
	rm -rf .libs .deps tsrc .target_source
	rm -f lemon$(B.exe) sqlite*.tar.gz
	rm -f mkkeywordhash$(B.exe) mksourceid$(B.exe)
	rm -f parse.* fts5parse.*
	rm -f $(libsqlite3.DLL) $(libsqlite3.LIB) $(libtclsqlite3.SO) $(libsqlite3.DLL).a
	rm -f $(libsqlite3.DLL) $(libsqlite3.LIB) $(libtclsqlite3.SO) libsqlite3$(T.dll).a
	rm -f tclsqlite3$(T.exe) $(TESTPROGS)
	rm -f LogEst$(T.exe) fts3view$(T.exe) rollback-test$(T.exe) showdb$(T.exe)
	rm -f showjournal$(T.exe) showstat4$(T.exe) showwal$(T.exe) speedtest1$(T.exe)
	rm -f wordcount$(T.exe) changeset$(T.exe) version-info$(T.exe)
	rm -f *.exp *.vsix pkgIndex.tcl
	rm -f sqlite3_analyzer$(T.exe) sqlite3_rsync$(T.exe) sqlite3_expert$(T.exe)
	rm -f mptester$(T.exe) rbu$(T.exe)	srcck1$(T.exe)
Changes to tool/mksqlite3h.tcl.
78
79
80
81
82
83
84






85

86
87
88
89
90
91
92
78
79
80
81
82
83
84
85
86
87
88
89
90

91
92
93
94
95
96
97
98







+
+
+
+
+
+
-
+







set nVersion [eval format "%d%03d%03d" [split $zVersion .]]

# Get the source-id
#
set PWD [pwd]
cd $TOP
set tmpfile $PWD/tmp-[clock millisec]-[expr {int(rand()*100000000000)}].txt
set mksourceid $PWD/mksourceid
if {![file exists $mksourceid] && [file exists ${mksourceid}.exe]} {
  # Workaround for Windows-based Unix-like environments
  # https://sqlite.org/forum/forumpost/41ba710dd9943453
  set mksourceid ${mksourceid}.exe
}
exec $PWD/mksourceid manifest > $tmpfile
exec $mksourceid manifest > $tmpfile
set fd [open $tmpfile rb]
set zSourceId [string trim [read $fd]]
close $fd
file delete -force $tmpfile
cd $PWD

# Set up patterns for recognizing API declarations.