This repository contains several snapshots of the build process of the Sqlite v. 3.29.0 database.
Understanding the low level structure of Sqlite is not trivial, and source files such as the ones found in the Fossil official repository do not help as many important pieces of C code are dinamically generated during the make process via AWK, TLC or custom C build tools such as the Lemon parser.
The result is an obscure code that refers to nonexisting libraries and functions.
Because of that, this repository retains the whole list of files, including the ones dinamically generated such as the amalgamation files and the parse.c and parse.h files.
The structure of the directories is the following:
- sqlite : contains the source files of the Sqlite release v. 3.29.0 as downloaded from the fossil repository
- build : contains all the build files, including the parse.c and parse.h and the amalgamation file sqlite3.c
- build-lemon-parser : contains all the files generated to build the parse.c and parse.h files
The make process requires gcc and tlc, which are easily installable via the common package manager of your distribution.
Makefiles are system-dependent, so to correctly compile sqlite from the source you cannot simply download this repository, go in the build directory and issue a make command. It will likely raise errors.
To obtain a buildable version on your computer, download the sqlite tarball file from the sqlite official repository and extract it (tar xzf sqlite.tar.gz), or pull the files from this archive.
In this repository, the folder 'sqlite' generated from the tarball was renamed sqlite3.29.0 for a correct identification of the release version used, and to avoid future conflicts with other releases.
You will now have a sqlite directory containing all the source files.
sqlite (or sqlite3.29.0)
(... some other stuff?...)
On the parent of the sqlite directory, create a custombuild directory, so that you have the following structure:
sqlite
custombuild
(... some other stuff?...)
Then issue the following commands:
cd custombuild
../sqlite/configure --enable-debug
make
The option --enable-debug activates the debugging options. Debugging options slow by a factor of 3 the performance of the database, but if your purpose is to set up a development environment rather than a production environment, clarity is to be preferred over performances.
The --enable-debug activates the following options: -DSQLITE_DEBUG=1, -DSQLITE_ENABLE_SELECTTRACE, -DSQLITE_ENABLE_WHERETRACE, -DSQLITE_ENABLE_EXPLAIN_COMMENTS. For a complete list and explanation of the available options at compile time, you can consult the relative sqlite manual page.
By running the lemon parser you obtain the files parse.c and parse.h which are referenced by the tokenize.c (sqlite3Parse function).
Those files can be obtained through the make options. From the root:
cd buildparser
../sqlite/configure --enable-debug
make parse.c
The Makefile generated by the configure will compile the sqlite3.29.0/tool/lemon.c file into an executable, and run the generated Lemon tool along with the template file sqlite3.29.0/tool/lempar.c and the dictionary of the parser sqlite3.29.0/src/parse.y to obtain both the parse.c and parse.h.