That's easy enough but the goal is to have an SQLite command-line
interface that has exactly the same capabilities and behavior as the
sqlite that is built for tcl. This means it should be the same version
that is compiled and linked with the same flags. My current solution,
which is very sloppy and barely a workable solution, is to capture the
compiler flags for sqlite during the tcl build then use those flags to
compile the sqlite shell. It ends up looking like this:
tar xzf tcl8.6.8-src.tar.gz -C "$MAAPSS/bld/"
cd "$MAAPSS/bld/tcl8.6.8/unix"
./configure --prefix="$MAAPSS/usr" --enable-threads --enable-64bit --
enable-threadsafe --enable-dynamic-extensions --enable-fts5 --enable-rtree
\
PKG_CONFIG_PATH="$MAAPSS/usr/lib/pkgconfig" LDFLAGS="-L$MAAPSS/usr/lib"
CPPFLAGS="-I$MAAPSS/usr/include" \
CFLAGS="-march=native -O2" CXXFLAGS="-march=native -O2"
make
make install
cd "$MAAPSS/bld/tcl8.6.8/pkgs/sqlite3.21.0/compat/sqlite3"
gcc -DHAVE_READLINE=1 -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite
\" -DPACKAGE_VERSION=\"3.21.0\" -DPACKAGE_STRING=\"sqlite\ 3.21.0\" \
-DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DBUILD_sqlite=/\*\*/ -
DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
\
-DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 \
-DHAVE_SYS_PARAM_H=1 -DUSE_THREAD_ALLOC=1 -D_REENTRANT=1 -D_THREAD_SAFE=1
-DTCL_THREADS=1 -DSQLITE_THREADSAFE=1 -DUSE_TCL_STUBS=1 \
-DUSE_TCLOO_STUBS=1 -DMODULE_SCOPE=extern\ __attribute__\(\(__visibility__
\(\"hidden\"\)\)\) -DHAVE_HIDDEN=1 -DHAVE_CAST_TO_UNION=1 \
-D_LARGEFILE64_SOURCE=1 -DTCL_WIDE_INT_IS_LONG=1 -DUSE_TCL_STUBS=1 -
DHAVE_MALLOC_H=1 -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_STRCHRNUL=1 \
-DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_MALLOC_USABLE_SIZE=1 -
DHAVE_UTIME=1 -DHAVE_FLOCK=1 -DHAVE_READLINK=1 -DHAVE_LSTAT=1 \
-DHAVE_PREAD=1 -DHAVE_PREAD64=1 -DHAVE_PWRITE=1 -DHAVE_PWRITE64=1 -
DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1
\
-DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS4=1 -
DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -
DSQLITE_ENABLE_JSON1=1 \
-DSQLITE_3_SUFFIX_ONLY=1 -DSQLITE_ENABLE_RTREE=1 -
DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -
DSQLITE_UNTESTABLE=1 \
-DSQLITE_OMIT_DEPRECATED=1 -DSQLITE_OMIT_LOOKASIDE=1 -
DSQLITE_SECURE_DELETE=1 -DSQLITE_SOUNDEX=1 -DSQLITE_USE_ALLOCA=1 -
DSQLITE_WIN32_NO_ANSI=1 \
-DSQLITE_WIN32_GETVERSIONEX=0 -DSQLITE_API=MODULE_SCOPE -DSQLITE_EXTERN= -
I"$MAAPSS/bld/tcl8.6.8/pkgs/sqlite3.21.0/generic" \
-I"$MAAPSS/bld/tcl8.6.8/generic" -I"$MAAPSS/bld/tcl8.6.8/pkgs/
sqlite3.21.0/.." -march=native -O2 -pipe -m64 -O2 -fomit-frame-pointer \
-DNDEBUG -Wall -fPIC -I"$MAAPSS/usr/include" shell.c sqlite3.c -L"$MAAPSS/
usr/lib" -I"$MAAPSS/usr/include" -I"$MAAPSS/usr/include/readline" \
-I"$MAAPSS/usr/include/ncurses" -lpthread -ldl -lreadline -lncurses -lm -
o sqlite3
cp sqlite3 "$MAAPSS/usr/bin/"
cd "$MAAPSS/bld/tcl8.6.8/unix"
make clean
This works but it's very manual in the sense that if the Tcl ./configure
options for SQLite change then the compiler flags for building the sqlite
shell are no longer valid and will need to be manually extracted from the
tcl build log and inserted into the above script blurb. But it is
currently working and it does meet the very basic requirements that there
is an SQLite command-line interface that has the exact same behavior as
the Tcl-SQLite extensions.