#!/usr/bin/tclsh
#
# To build a single huge source file holding all of SQLite (or at
# least the core components - the test harness, shell, and TCL
# interface are omitted.) first do
#
# make target_source
#
# The make target above moves all of the source code files into
# a subdirectory named "tsrc". (This script expects to find the files
# there and will not work if they are not found.) There are a few
# generated C code files that are also added to the tsrc directory.
# For example, the "parse.c" and "parse.h" files to implement the
# the parser are derived from "parse.y" using lemon. And the
# "keywordhash.h" files is generated by a program named "mkkeywordhash".
#
# After the "tsrc" directory has been created and populated, run
# this script:
#
# tclsh mksqlite3c.tcl
#
# The amalgamated SQLite code will be written into sqlite3.c
#
# Begin by reading the "sqlite3.h" header file. Count the number of lines
# in this file and extract the version number. That information will be
# needed in order to generate the header of the amalgamation.
#
set in
set cnt 0
set VERSION ?????
while
close $in
# Open the output file and write a header comment at the beginning
# of the file.
#
set out
set today
puts $out
# These are the header files used by SQLite. The first time any of these
# files are seen in a #include statement in the C code, include the complete
# text of the file in-line. The file only needs to be included once.
#
foreach hdr
# 78 stars used for comment formatting.
set s78 \
# Insert a comment into the code
#
# Read the source file named $filename and write it into the
# sqlite3.c output file. If any #include statements are seen,
# process them approprately.
#
# Process the source files. Process files containing commonly
# used subroutines first in order to help the compiler find
# inlining opportunities.
#
foreach file
close $out