114
115
116
117
118
119
120
121
122
123
124
125
126
127
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
155
156
157
158
|
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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
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
|
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
|
} else {
msg-result "no"
}
return $found
}
if {![opt-bool internal-sqlite]} {
proc find_internal_sqlite {} {
proc find_system_sqlite {} {
# On some systems (slackware), libsqlite3 requires -ldl to link. So
# search for the system SQLite once with -ldl, and once without. If
# the library can only be found with $extralibs set to -ldl, then
# the code below will append -ldl to LIBS.
#
foreach extralibs {{} {-ldl}} {
# Locate the system SQLite by searching for sqlite3_open(). Then check
# if sqlite3_stmt_isexplain can be found as well. If we can find open() but
# not stmt_isexplain(), then the system SQLite is too old to link against
# fossil.
#
if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
if {![check-function-in-lib sqlite3_stmt_isexplain sqlite3 $extralibs]} {
user-error "system sqlite3 too old (require >= 3.28.0)"
}
# Success. Update symbols and return.
#
define USE_SYSTEM_SQLITE 1
define-append LIBS -lsqlite3
define-append LIBS $extralibs
return
}
}
user-error "system sqlite3 not found"
}
find_system_sqlite
proc test_system_sqlite {} {
# Check compatibility of the system SQLite library by running the sqlcompttest.c
# program in the source tree
#
set cmdline {}
lappend cmdline {*}[get-define CCACHE]
lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
lappend cmdline $::autosetup(dir)/../src/sqlcompattest.c -o conftest__
lappend cmdline {*}[get-define LIBS]
set ok 1
set err [catch {exec-with-stderr {*}$cmdline} result errinfo]
if {$err} {
configlog "Failed: [join $cmdline]"
if {[string length $result]>0} {configlog $result}
configlog "============"
set ok 0
} elseif {$::autosetup(debug)} {
configlog "Compiled OK: [join $cmdline]"
configlog "============"
}
if {!$ok} {
user-error "unable to compile SQLite compatibility test program"
}
set err [catch {exec-with-stderr ./conftest__} result errinfo]
if {$err} {
user-error $result
}
file delete ./conftest__
}
find_internal_sqlite
test_system_sqlite
}
proc is_mingw {} {
return [string match *mingw* [get-define host]]
}
if {[is_mingw]} {
|