SQLite

Check-in [f778dfdd]
Login

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

Overview
Comment:Remove $prefix/include from the default -I path because it can cause the build to pick up an unintended copy of sqlite3.h. Extend the ICU configure support (the origin of -I$prefix/include) to enable fetching the -I path from icu-config and apply it only to those objects which need it.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f778dfdd6d6a4975c903d8ca0ebfb4fa917d543289136ea0ab740cb47d2510c1
User & Date: stephan 2024-11-14 19:25:23
Context
2024-11-14
19:34
Fix typo in the handling of the new --dev flag which caused it to set the --debug flag instead of the --with-debug flag (the former is for autosetup's internal use). (check-in: 81202d2a user: stephan tags: trunk)
19:25
Remove $prefix/include from the default -I path because it can cause the build to pick up an unintended copy of sqlite3.h. Extend the ICU configure support (the origin of -I$prefix/include) to enable fetching the -I path from icu-config and apply it only to those objects which need it. (check-in: f778dfdd user: stephan tags: trunk)
19:06
Add new makefile target "sqlite3d" (where the "d" means either "development" or "debug") that always uses separate source files, regardless of the --disable-amalgmation setting. (check-in: 91da205b user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to Makefile.in.
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
LDFLAGS.math = @LDFLAGS_MATH@
LDFLAGS.rpath = @LDFLAGS_RPATH@
LDFLAGS.pthread = @LDFLAGS_PTHREAD@
LDFLAGS.dlopen = @LDFLAGS_DLOPEN@
LDFLAGS.readline = @LDFLAGS_READLINE@
CFLAGS.readline = @CFLAGS_READLINE@
LDFLAGS.icu = @LDFLAGS_ICU@

LDFLAGS.soname.libsqlite3 = @LDFLAGS_SONAME_LIBSQLITE3@
ENABLE_SHARED = @ENABLE_SHARED@
ENABLE_STATIC = @ENABLE_STATIC@
HAVE_WASI_SDK = @HAVE_WASI_SDK@

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.
#
# main.mk will fill out T.cc.sqlite with additional flags common to
# all builds.
#
T.cc.sqlite += -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite
#
# -I$(prefix)/include is primarily so that the ICU
# headers can be found.
#
T.cc.sqlite += -I$(prefix)/include

#
# $(JIMSH) and $(CFLAGS.jimsh) are documented in main.mk.  $(JIMSH)
# must start with a path component so that it can be invoked as a
# shell command.
#
CFLAGS.jimsh = @CFLAGS_JIMSH@







>















<
<
<
<
<







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
LDFLAGS.math = @LDFLAGS_MATH@
LDFLAGS.rpath = @LDFLAGS_RPATH@
LDFLAGS.pthread = @LDFLAGS_PTHREAD@
LDFLAGS.dlopen = @LDFLAGS_DLOPEN@
LDFLAGS.readline = @LDFLAGS_READLINE@
CFLAGS.readline = @CFLAGS_READLINE@
LDFLAGS.icu = @LDFLAGS_ICU@
CFLAGS.icu = @CFLAGS_ICU@
LDFLAGS.soname.libsqlite3 = @LDFLAGS_SONAME_LIBSQLITE3@
ENABLE_SHARED = @ENABLE_SHARED@
ENABLE_STATIC = @ENABLE_STATIC@
HAVE_WASI_SDK = @HAVE_WASI_SDK@

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.
#
# main.mk will fill out T.cc.sqlite with additional flags common to
# all builds.
#
T.cc.sqlite += -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite






#
# $(JIMSH) and $(CFLAGS.jimsh) are documented in main.mk.  $(JIMSH)
# must start with a path component so that it can be invoked as a
# shell command.
#
CFLAGS.jimsh = @CFLAGS_JIMSH@
Changes to auto.def.
178
179
180
181
182
183
184


185
186
187
188
189
190
191
192
                       => {Full path to readline.h, from which --with-readline-cflags will be derived}
  with-linenoise:DIR   => {Source directory for linenoise.c and linenoise.h}
  editline=0           => {Enable BSD editline support}
  # </line-editing>
  # <icu>
  with-icu-ldflags:LDFLAGS
                        => {Enable SQLITE_ENABLE_ICU and add the given linker flags for the ICU libraries}


  with-icu-config:=auto => {Enable SQLITE_ENABLE_ICU and fetch linker flags from the given icu-config binary}
  icu-collations=0      => {Enable SQLITE_ENABLE_ICU_COLLATIONS. Requires --with-icu-ldflags=... or --with-icu-config}
  # </icu>
  # <alternative-builds>
  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.}
  # </alternative-builds>







>
>
|







178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
                       => {Full path to readline.h, from which --with-readline-cflags will be derived}
  with-linenoise:DIR   => {Source directory for linenoise.c and linenoise.h}
  editline=0           => {Enable BSD editline support}
  # </line-editing>
  # <icu>
  with-icu-ldflags:LDFLAGS
                        => {Enable SQLITE_ENABLE_ICU and add the given linker flags for the ICU libraries}
  with-icu-cflags:CFLAGS
                        => {Apply extra CFLAGS/CPPFLAGS necessary for building with ICU. e.g. -I/usr/local/include}
  with-icu-config:=auto => {Enable SQLITE_ENABLE_ICU and fetch ldflags and cflags flags from the given icu-config binary}
  icu-collations=0      => {Enable SQLITE_ENABLE_ICU_COLLATIONS. Requires --with-icu-ldflags=... or --with-icu-config}
  # </icu>
  # <alternative-builds>
  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.}
  # </alternative-builds>
358
359
360
361
362
363
364

365
366
367
368
369
370
371
    }
  }
  # Non-boolean flags which need to be cleared:
  foreach opt {
    with-emsdk
    with-icu-config
    with-icu-ldflags

    with-linenoise
    with-tcl
  } {
    if {[proj-opt-was-provided $opt]} {
      msg-result "  removing --$opt"
      proj-opt-set $opt ""
    }







>







360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
    }
  }
  # Non-boolean flags which need to be cleared:
  foreach opt {
    with-emsdk
    with-icu-config
    with-icu-ldflags
    with-icu-cflags
    with-linenoise
    with-tcl
  } {
    if {[proj-opt-was-provided $opt]} {
      msg-result "  removing --$opt"
      proj-opt-set $opt ""
    }
1118
1119
1120
1121
1122
1123
1124

1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136

1137
1138
1139
1140
1141
1142
1143

########################################################################
# ICU - International Components for Unicode
#
# Handles these flags:
#
#  --with-icu-ldflags=LDFLAGS

#  --with-icu-config[=/path/to/icu-config]
#  --enable-icu-collations
#
# If both icu-ldflags and icu-config are provided, they are
# cumulative.  If neither are provided, icu-collations is not honored
# and a warning is emitted if it is provided.
#
# Design note: though we can automatically enable ICU if the
# icu-config binary is found, we specifically do not. ICU is always an
# opt-in feature.
proc sqlite-check-icu {} {
  define LDFLAGS_ICU [join [opt-val with-icu-ldflags ""]]

  # Flags sets seen in the wild for ICU:
  # - -licui18n -licuuc -licudata
  # - -licui18n -licuuc
  # - /usr/local/bin/icu-config --ldflags
  if {[proj-opt-was-provided with-icu-config]} {
    set bin [opt-val with-icu-config]
    if {"auto" eq $bin} {







>












>







1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148

########################################################################
# ICU - International Components for Unicode
#
# Handles these flags:
#
#  --with-icu-ldflags=LDFLAGS
#  --with-icu-cflags=CFLAGS
#  --with-icu-config[=/path/to/icu-config]
#  --enable-icu-collations
#
# If both icu-ldflags and icu-config are provided, they are
# cumulative.  If neither are provided, icu-collations is not honored
# and a warning is emitted if it is provided.
#
# Design note: though we can automatically enable ICU if the
# icu-config binary is found, we specifically do not. ICU is always an
# opt-in feature.
proc sqlite-check-icu {} {
  define LDFLAGS_ICU [join [opt-val with-icu-ldflags ""]]
  define CFLAGS_ICU [join [opt-val with-icu-cflags ""]]
  # Flags sets seen in the wild for ICU:
  # - -licui18n -licuuc -licudata
  # - -licui18n -licuuc
  # - /usr/local/bin/icu-config --ldflags
  if {[proj-opt-was-provided with-icu-config]} {
    set bin [opt-val with-icu-config]
    if {"auto" eq $bin} {
1151
1152
1153
1154
1155
1156
1157


1158
1159
1160
1161
1162

1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
    }
    if {[file-isexec $bin]} {
      set x [exec $bin --ldflags]
      if {"" eq $x} {
        proj-fatal "$bin --ldflags returned no data"
      }
      define-append LDFLAGS_ICU $x


    } else {
      proj-fatal "--with-icu-config=$bin does not refer to an executable"
    }
  }
  set flags [define LDFLAGS_ICU [string trim [get-define LDFLAGS_ICU]]]

  if {"" ne $flags} {
    sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU
    msg-result "Enabling ICU support with libs: $flags"
    if {[opt-bool icu-collations]} {
      msg-result "Enabling ICU collations."
      sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU_COLLATIONS
      # Recall that shell.c builds with sqlite3.c
    }
  } elseif {[opt-bool icu-collations]} {
    proj-warn "ignoring --enable-icu-collations because neither --with-icu-ldflags nor --with-icu-config provided any linker flags"







>
>




|
>
|

|







1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
    }
    if {[file-isexec $bin]} {
      set x [exec $bin --ldflags]
      if {"" eq $x} {
        proj-fatal "$bin --ldflags returned no data"
      }
      define-append LDFLAGS_ICU $x
      set x [exec $bin --cppflags]
      define-append CFLAGS_ICU $x
    } else {
      proj-fatal "--with-icu-config=$bin does not refer to an executable"
    }
  }
  set ldflags [define LDFLAGS_ICU [string trim [get-define LDFLAGS_ICU]]]
  set cflags [define CFLAGS_ICU [string trim [get-define CFLAGS_ICU]]]
  if {"" ne $ldflags} {
    sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU
    msg-result "Enabling ICU support with libs ($ldflags) and cflags ($cflags)"
    if {[opt-bool icu-collations]} {
      msg-result "Enabling ICU collations."
      sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU_COLLATIONS
      # Recall that shell.c builds with sqlite3.c
    }
  } elseif {[opt-bool icu-collations]} {
    proj-warn "ignoring --enable-icu-collations because neither --with-icu-ldflags nor --with-icu-config provided any linker flags"
Changes to main.mk.
158
159
160
161
162
163
164

165
166
167
168
169
170
171
LDFLAGS.zlib ?= -lz
LDFLAGS.math ?= -lm
LDFLAGS.rpath ?= -Wl,-rpath -Wl,$(prefix)/lib
LDFLAGS.pthread ?= -lpthread
LDFLAGS.dlopen ?= -ldl
LDFLAGS.shobj ?= -shared
LDFLAGS.icu ?= # -licui18n -licuuc -licudata

LDFLAGS.soname.libsqlite3 ?=
# libreadline (or a workalike):
# To activate readline in the shell: SHELL_OPT = -DHAVE_READLINE=1
LDFLAGS.readline ?= -lreadline # these vary across platforms
CFLAGS.readline ?= -I$(prefix)/include
# ^^^ When using linenoise instead of readline, do something like:
# SHELL_OPT += -DHAVE_LINENOISE=1







>







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
LDFLAGS.zlib ?= -lz
LDFLAGS.math ?= -lm
LDFLAGS.rpath ?= -Wl,-rpath -Wl,$(prefix)/lib
LDFLAGS.pthread ?= -lpthread
LDFLAGS.dlopen ?= -ldl
LDFLAGS.shobj ?= -shared
LDFLAGS.icu ?= # -licui18n -licuuc -licudata
CFLAGS.icu ?=
LDFLAGS.soname.libsqlite3 ?=
# libreadline (or a workalike):
# To activate readline in the shell: SHELL_OPT = -DHAVE_READLINE=1
LDFLAGS.readline ?= -lreadline # these vary across platforms
CFLAGS.readline ?= -I$(prefix)/include
# ^^^ When using linenoise instead of readline, do something like:
# SHELL_OPT += -DHAVE_LINENOISE=1
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
# The standard CLI is built using the amalgamation since it uses
# special compile-time options that are interpreted by individual
# source files within the amalgamation.
#
sqlite3$(T.exe):	shell.c sqlite3.c
	$(T.link) -o $@ \
		shell.c sqlite3.c \
		$(CFLAGS.readline) $(SHELL_OPT) \
		$(LDFLAGS.libsqlite3) $(LDFLAGS.readline)

# The "sqlite3d" CLI is build using separate source files.  This
# is useful during development and debugging.
#
sqlite3d$(T.exe):	shell.c $(LIBOBJS0)
	$(T.link) -o $@ \







|







1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
# The standard CLI is built using the amalgamation since it uses
# special compile-time options that are interpreted by individual
# source files within the amalgamation.
#
sqlite3$(T.exe):	shell.c sqlite3.c
	$(T.link) -o $@ \
		shell.c sqlite3.c \
		$(CFLAGS.readline) $(SHELL_OPT) $(CFLAGS.icu) \
		$(LDFLAGS.libsqlite3) $(LDFLAGS.readline)

# The "sqlite3d" CLI is build using separate source files.  This
# is useful during development and debugging.
#
sqlite3d$(T.exe):	shell.c $(LIBOBJS0)
	$(T.link) -o $@ \
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
	$(B.tclsh) $(TOP)/tool/mkshellc.tcl >shell.c

#
# Rules to build the extension objects.
#
DEPS_EXT_COMMON = $(DEPS_OBJ_COMMON) $(EXTHDR)
icu.o:	$(TOP)/ext/icu/icu.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/icu/icu.c

fts3.o:	$(TOP)/ext/fts3/fts3.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3.c

fts3_aux.o:	$(TOP)/ext/fts3/fts3_aux.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_aux.c

fts3_expr.o:	$(TOP)/ext/fts3/fts3_expr.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_expr.c

fts3_hash.o:	$(TOP)/ext/fts3/fts3_hash.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_hash.c

fts3_icu.o:	$(TOP)/ext/fts3/fts3_icu.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_icu.c

fts3_porter.o:	$(TOP)/ext/fts3/fts3_porter.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_porter.c

fts3_snippet.o:	$(TOP)/ext/fts3/fts3_snippet.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_snippet.c








|














|







2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
	$(B.tclsh) $(TOP)/tool/mkshellc.tcl >shell.c

#
# Rules to build the extension objects.
#
DEPS_EXT_COMMON = $(DEPS_OBJ_COMMON) $(EXTHDR)
icu.o:	$(TOP)/ext/icu/icu.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/icu/icu.c $(CFLAGS.icu)

fts3.o:	$(TOP)/ext/fts3/fts3.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3.c

fts3_aux.o:	$(TOP)/ext/fts3/fts3_aux.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_aux.c

fts3_expr.o:	$(TOP)/ext/fts3/fts3_expr.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_expr.c

fts3_hash.o:	$(TOP)/ext/fts3/fts3_hash.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_hash.c

fts3_icu.o:	$(TOP)/ext/fts3/fts3_icu.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_icu.c $(CFLAGS.icu)

fts3_porter.o:	$(TOP)/ext/fts3/fts3_porter.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_porter.c

fts3_snippet.o:	$(TOP)/ext/fts3/fts3_snippet.c $(DEPS_EXT_COMMON)
	$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_snippet.c