Update makefiles to remove all uses of "awk" - to make building SQLite easier
on Windows systems. The only requirements now are tclsh, a C compiler, and
common file utilities.
check-in: 4bd0d43d user: drh tags: trunk

#!/usr/make## Makefile for SQLITE## This is a template makefile for SQLite. Most people prefer to# use the autoconf generated "configure" script to generate the# makefile automatically. But that does not work for everybody# and in every situation. If you are having problems with the# "configure" script, you might want to try this makefile as an# alternative. Create a copy of this file, edit the parameters# below and type "make".##### The directory where to find the mingw32ce toolsMINGW32CE = /opt/mingw32ce/bin#### The target prefix of the mingw32ce toolsTARGET = arm-wince-mingw32ce#### The toplevel directory of the source tree. This is the directory# that contains this "Makefile.in" and the "configure.in" script.#TOP = ../sqlite#### C Compiler and options for use in building executables that# will run on the platform that is doing the build.#BCC = gcc -g -O2#BCC = /opt/ancic/bin/c89 -0#### If the target operating system supports the "usleep()" system# call, then define the HAVE_USLEEP macro for all C modules.#USLEEP = #USLEEP = -DHAVE_USLEEP=1#### If you want the SQLite library to be safe for use within a # multi-threaded program, then define the following macro# appropriately:#THREADSAFE = -DTHREADSAFE=1#THREADSAFE = -DTHREADSAFE=0#### Specify any extra linker options needed to make the library# thread safe##THREADLIB = -lpthreadTHREADLIB = #### Specify any extra libraries needed to access required functions.##TLIBS = -lrt # fdatasync on Solaris 8TLIBS = #### Leave SQLITE_DEBUG undefined for maximum speed. Use SQLITE_DEBUG=1# to check for memory leaks. Use SQLITE_DEBUG=2 to print a log of all# malloc()s and free()s in order to track down memory leaks.# # SQLite uses some expensive assert() statements in the inner loop.# You can make the library go almost twice as fast if you compile# with -DNDEBUG=1##OPTS = -DSQLITE_DEBUG=2#OPTS = -DSQLITE_DEBUG=1#OPTS = OPTS = -DNDEBUG=1 -DSQLITE_OS_WIN=1 -D_WIN32_WCE=1#OPTS += -DHAVE_FDATASYNC=1#### The suffix to add to executable files. ".exe" for windows.# Nothing for unix.#EXE = .exe#EXE =#### C Compile and options for use in building executables that # will run on the target platform. This is usually the same# as BCC, unless you are cross-compiling.##TCC = gcc -O6#TCC = gcc -g -O0 -Wall#TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage#TCC = /opt/mingw/bin/i386-mingw32-gcc -O6TCC = $(MINGW32CE)/$(TARGET)-gcc -O2#TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive#### Tools used to build a static library.##AR = ar cr#AR = /opt/mingw/bin/i386-mingw32-ar crAR = $(MINGW32CE)/$(TARGET)-ar cr#RANLIB = ranlib#RANLIB = /opt/mingw/bin/i386-mingw32-ranlibRANLIB = $(MINGW32CE)/$(TARGET)-ranlib#MKSHLIB = gcc -shared#SO = so#SHPREFIX = libMKSHLIB = $(MINGW32CE)/$(TARGET)-gcc -sharedSO = dllSHPREFIX =#### Extra compiler options needed for programs that use the TCL library.##TCL_FLAGS =#TCL_FLAGS = -DSTATIC_BUILD=1TCL_FLAGS = -I/home/drh/tcltk/8.5linux#TCL_FLAGS = -I/home/drh/tcltk/8.5win -DSTATIC_BUILD=1#TCL_FLAGS = -I/home/drh/tcltk/8.3hpux#### Linker options needed to link against the TCL library.##LIBTCL = -ltcl -lm -ldlLIBTCL = /home/drh/tcltk/8.5linux/libtcl8.5g.a -lm -ldl#LIBTCL = /home/drh/tcltk/8.5win/libtcl85s.a -lmsvcrt#LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc#### Additional objects for SQLite library when TCL support is enabled.TCLOBJ =#TCLOBJ = tclsqlite.o#### Compiler options needed for programs that use the readline() library.#READLINE_FLAGS =#READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline#### Linker options needed by programs using readline() must link against.#LIBREADLINE =#LIBREADLINE = -static -lreadline -ltermcap#### Which "awk" program provides nawk compatibilty## NAWK = nawkNAWK = awk# You should not have to change anything below this line###############################################################################include $(TOP)/main.mk

** May you share freely, never taking more than you give.
**
******************************************************************************
*/
#include "fts5Int.h"
#include <math.h>
/*
** Object used to iterate through all "coalesced phrase instances" in
** a single column of the current row. If the phrase instances in the
** column being considered do not overlap, this object simply iterates
** through them. Or, if they do overlap (share one or more tokens in
** common), each set of overlapping instances is treated as a single

|

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

** May you share freely, never taking more than you give.
**
******************************************************************************
*/
#include "fts5Int.h"
#include <math.h> /* amalgamator: keep */
/*
** Object used to iterate through all "coalesced phrase instances" in
** a single column of the current row. If the phrase instances in the
** column being considered do not overlap, this object simply iterates
** through them. Or, if they do overlap (share one or more tokens in
** common), each set of overlapping instances is treated as a single

sqlite3_result_text64,
sqlite3_strglob,
/* Version 3.8.11 and later */
(sqlite3_value*(*)(const sqlite3_value*))sqlite3_value_dup,
sqlite3_value_free,
sqlite3_result_zeroblob64,
sqlite3_bind_zeroblob64,
/* Version 3.9.0 and later */
sqlite3_value_subtype,
sqlite3_result_subtype
};
/*
** Attempt to load an SQLite extension library contained in the file
** zFile. The entry point is zProc. zProc may be 0 in which case a
................................................................................
/*
** The auto-extension code added regardless of whether or not extension
** loading is supported. We need a dummy sqlite3Apis pointer for that
** code if regular extension loading is not available. This is that
** dummy pointer.
*/
#ifdef SQLITE_OMIT_LOAD_EXTENSION
static const sqlite3_api_routines sqlite3Apis;
#endif
/*
** The following object holds the list of automatically loaded
** extensions.
**

const void *sqlite3_value_text16(sqlite3_value*);
const void *sqlite3_value_text16le(sqlite3_value*);
const void *sqlite3_value_text16be(sqlite3_value*);
int sqlite3_value_type(sqlite3_value*);
int sqlite3_value_numeric_type(sqlite3_value*);
/*
** CAPI3REF: Obtaining SQL Values
** METHOD: sqlite3_value
**
** The sqlite3_value_subtype(V) function returns the subtype for
** an [application-defined SQL function] argument V. The subtype
** information can be used to pass a limited amount of context from
** one SQL function to another. Use the [sqlite3_result_subtype()]
** routine to set the subtype for the return value of an SQL function.
................................................................................
** strategy. A cost of N indicates that the cost of the strategy is similar
** to a linear scan of an SQLite table with N rows. A cost of log(N)
** indicates that the expense of the operation is similar to that of a
** binary search on a unique indexed field of an SQLite table with N rows.
**
** ^The estimatedRows value is an estimate of the number of rows that
** will be returned by the strategy.
**
** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
** structure for SQLite version 3.8.2. If a virtual table extension is
** used with an SQLite version earlier than 3.8.2, the results of attempting
** to read or write the estimatedRows field are undefined (but are likely
** to included crashing the application). The estimatedRows field should
** therefore only be used if [sqlite3_libversion_number()] returns a
** value greater than or equal to 3008002.
*/
struct sqlite3_index_info {
/* Inputs */
int nConstraint; /* Number of entries in aConstraint */
struct sqlite3_index_constraint {
int iColumn; /* Column on left-hand side of constraint */
unsigned char op; /* Constraint operator */
................................................................................
int idxNum; /* Number used to identify the index */
char *idxStr; /* String, possibly obtained from sqlite3_malloc */
int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */
int orderByConsumed; /* True if output is already ordered */
double estimatedCost; /* Estimated cost of using this index */
/* Fields below are only available in SQLite 3.8.2 and later */
sqlite3_int64 estimatedRows; /* Estimated number of rows returned */
};
/*
** CAPI3REF: Virtual Table Constraint Operator Codes
**
** These macros defined the allowed values for the
** [sqlite3_index_info].aConstraint[].op field. Each value represents
** an operator that is part of a constraint term in the wHERE clause of
** a query that uses a [virtual table].

const void *sqlite3_value_text16(sqlite3_value*);
const void *sqlite3_value_text16le(sqlite3_value*);
const void *sqlite3_value_text16be(sqlite3_value*);
int sqlite3_value_type(sqlite3_value*);
int sqlite3_value_numeric_type(sqlite3_value*);
/*
** CAPI3REF: Finding The Subtype Of SQL Values
** METHOD: sqlite3_value
**
** The sqlite3_value_subtype(V) function returns the subtype for
** an [application-defined SQL function] argument V. The subtype
** information can be used to pass a limited amount of context from
** one SQL function to another. Use the [sqlite3_result_subtype()]
** routine to set the subtype for the return value of an SQL function.
................................................................................
** strategy. A cost of N indicates that the cost of the strategy is similar
** to a linear scan of an SQLite table with N rows. A cost of log(N)
** indicates that the expense of the operation is similar to that of a
** binary search on a unique indexed field of an SQLite table with N rows.
**
** ^The estimatedRows value is an estimate of the number of rows that
** will be returned by the strategy.
**** The xBestIndex method may optionally populate the idxFlags field with a ** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite** assumes that the strategy may visit at most one row. **** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then** SQLite also assumes that if a call to the xUpdate() method is made as** part of the same statement to delete or update a virtual table row and the** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback** any database changes. In other words, if the xUpdate() returns** SQLITE_CONSTRAINT, the database contents must be exactly as they were** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by** the xUpdate method are automatically rolled back by SQLite.
**
** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
** structure for SQLite version 3.8.2. If a virtual table extension is
** used with an SQLite version earlier than 3.8.2, the results of attempting
** to read or write the estimatedRows field are undefined (but are likely
** to included crashing the application). The estimatedRows field should
** therefore only be used if [sqlite3_libversion_number()] returns a
** value greater than or equal to 3008002. Similarly, the idxFlags field** was added for version 3.9.0. It may therefore only be used if** sqlite3_libversion_number() returns a value greater than or equal to** 3009000.
*/
struct sqlite3_index_info {
/* Inputs */
int nConstraint; /* Number of entries in aConstraint */
struct sqlite3_index_constraint {
int iColumn; /* Column on left-hand side of constraint */
unsigned char op; /* Constraint operator */
................................................................................
int idxNum; /* Number used to identify the index */
char *idxStr; /* String, possibly obtained from sqlite3_malloc */
int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */
int orderByConsumed; /* True if output is already ordered */
double estimatedCost; /* Estimated cost of using this index */
/* Fields below are only available in SQLite 3.8.2 and later */
sqlite3_int64 estimatedRows; /* Estimated number of rows returned */
/* Fields below are only available in SQLite 3.9.0 and later */ int idxFlags; /* Mask of SQLITE_INDEX_SCAN_* flags */
};
/*** CAPI3REF: Virtual Table Scan Flags*/#define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
/*
** CAPI3REF: Virtual Table Constraint Operator Codes
**
** These macros defined the allowed values for the
** [sqlite3_index_info].aConstraint[].op field. Each value represents
** an operator that is part of a constraint term in the wHERE clause of
** a query that uses a [virtual table].

#
# NOTE: Due to limits on legal characters for file names imposed by
# Windows, we must skip the final two tests here (i.e. the
# question mark is illegal in a file name on Windows).
#
if {$tn>14} break
#
# NOTE: On Windows, we need to account for the fact that the current
# directory does not start with a forward slash.
#
set uri [string map [list PWD/ /[test_pwd /]] $uri]
} else {
set uri [string map [list PWD/ [test_pwd /]] $uri]

>
>
>
>
>
>
>
>

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

#
# NOTE: Due to limits on legal characters for file names imposed by
# Windows, we must skip the final two tests here (i.e. the
# question mark is illegal in a file name on Windows).
#
if {$tn>14} break
# # NOTE: When running on Tcl 8.6 (or higher?) on Windows, a colon within # the file name no longer tries to access an alternate data stream # (ADS) named "test.db" for the "http" file, causing some spurious # failures of this test. # if {$tn==12 && $::tcl_version>=8.6} continue
#
# NOTE: On Windows, we need to account for the fact that the current
# directory does not start with a forward slash.
#
set uri [string map [list PWD/ /[test_pwd /]] $uri]
} else {
set uri [string map [list PWD/ [test_pwd /]] $uri]

REM tool\build-all-msvc.bat C:\Temp
REM
REM In the example above, "C:\dev\sqlite\core" represents the root of the
REM source tree for SQLite and "C:\Temp" represents the final destination
REM directory for the generated output files.
REM
REM Please note that the SQLite build process performed by the Makefile
REM associated with this batch script requires both Gawk ^(gawk.exe^) and Tcl
REM 8.5 ^(tclsh85.exe^) to be present in a directory contained in the PATH
REM environment variable unless a pre-existing amalgamation file is used.
REM
REM There are several environment variables that may be set to modify the
REM behavior of this batch script and its associated Makefile. The list of
REM platforms to build may be overriden by using the PLATFORMS environment
REM variable, which should contain a list of platforms ^(e.g. x86 x86_amd64
REM x86_arm^). All platforms must be supported by the version of Visual Studio
REM being used. The list of configurations to build may be overridden by
................................................................................
%_VECHO% x86_x64_Name = '%x86_x64_NAME%'
REM
REM NOTE: Check for the external tools needed during the build process ^(i.e.
REM those that do not get compiled as part of the build process itself^)
REM along the PATH.
REM
FOR %%T IN (gawk.exe tclsh85.exe) DO (
SET %%T_PATH=%%~dp$PATH:T
)
REM
REM NOTE: The Gawk executable "gawk.exe" is required during the SQLite build
REM process unless a pre-existing amalgamation file is used.
REM
IF NOT DEFINED gawk.exe_PATH (
ECHO The Gawk executable "gawk.exe" is required to be in the PATH.
GOTO errors)REMREM NOTE: The Tcl 8.5 executable "tclsh85.exe" is required during the SQLiteREM build process unless a pre-existing amalgamation file is used.REMIF NOT DEFINED tclsh85.exe_PATH ( ECHO The Tcl 8.5 executable "tclsh85.exe" is required to be in the PATH.
GOTO errors
)
REM
REM NOTE: Set the TOOLPATH variable to contain all the directories where the
REM external tools were found in the search above.
REM
SET TOOLPATH=%gawk.exe_PATH%;%tclsh85.exe_PATH%
%_VECHO% ToolPath = '%TOOLPATH%'
REM
REM NOTE: Setting the Windows SDK library path is only required for MSVC
REM 2012, 2013, and 2015.
REM

REM tool\build-all-msvc.bat C:\Temp
REM
REM In the example above, "C:\dev\sqlite\core" represents the root of the
REM source tree for SQLite and "C:\Temp" represents the final destination
REM directory for the generated output files.
REM
REM Please note that the SQLite build process performed by the Makefile
REM associated with this batch script requires a Tcl shell to be present
REM in a directory contained in the PATH environment variable unless a
REM pre-existing amalgamation file is used.
REM
REM There are several environment variables that may be set to modify the
REM behavior of this batch script and its associated Makefile. The list of
REM platforms to build may be overriden by using the PLATFORMS environment
REM variable, which should contain a list of platforms ^(e.g. x86 x86_amd64
REM x86_arm^). All platforms must be supported by the version of Visual Studio
REM being used. The list of configurations to build may be overridden by
................................................................................
%_VECHO% x86_x64_Name = '%x86_x64_NAME%'
REM
REM NOTE: Check for the external tools needed during the build process ^(i.e.
REM those that do not get compiled as part of the build process itself^)
REM along the PATH.
REM
IF DEFINED TCLSH_CMD (
SET TCLSH_FILE=%TCLSH_CMD%) ELSE ( SET TCLSH_FILE=tclsh85.exe)FOR %%T IN (%TCLSH_FILE%) DO (
SET %%T_PATH=%%~dp$PATH:T
)
REM
REM NOTE: A Tcl shell executable is required during the SQLite build process
REM unless a pre-existing amalgamation file is used.
REM
IF NOT DEFINED %TCLSH_FILE%_PATH (
ECHO The Tcl shell executable "%TCLSH_FILE%" is required to be in the PATH.
GOTO errors
)
REM
REM NOTE: Set the TOOLPATH variable to contain all the directories where the
REM external tools were found in the search above.
REM
CALL :fn_CopyVariable %TCLSH_FILE%_PATH TOOLPATH
%_VECHO% ToolPath = '%TOOLPATH%'
REM
REM NOTE: Setting the Windows SDK library path is only required for MSVC
REM 2012, 2013, and 2015.
REM

# Force the output to use unix line endings, even on Windows.
fconfigure stdout -translation lf
set filelist [subst {
$TOP/src/sqlite.h.in
$TOP/ext/rtree/sqlite3rtree.h
}]
# These are the functions that accept a variable number of arguments. They
# always need to use the "cdecl" calling convention even when another calling
# convention (e.g. "stcall") is being used for the rest of the library.
set cdecllist {
sqlite3_config

>

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

# Force the output to use unix line endings, even on Windows.
fconfigure stdout -translation lf
set filelist [subst {
$TOP/src/sqlite.h.in
$TOP/ext/rtree/sqlite3rtree.h
$TOP/ext/fts5/fts5.h
}]
# These are the functions that accept a variable number of arguments. They
# always need to use the "cdecl" calling convention even when another calling
# convention (e.g. "stcall") is being used for the rest of the library.
set cdecllist {
sqlite3_config