#!/usr/bin/tclsh
#
# This script constructs the "sqlite3.h" header file from the following
# sources:
#
# 1) The src/sqlite.h.in source file. This is the template for sqlite3.h.
# 2) The VERSION file containing the current SQLite version number.
# 3) The manifest file from the fossil SCM. This gives use the date.
# 4) The manifest.uuid file from the fossil SCM. This gives the SHA1 hash.
#
# Run this script by specifying the root directory of the source tree
# on the command-line.
#
# This script performs processing on src/sqlite.h.in. It:
#
# 1) Adds SQLITE_EXTERN in front of the declaration of global variables,
# 2) Adds SQLITE_API in front of the declaration of API functions,
# 3) Replaces the string --VERS-- with the current library version,
# formatted as a string (e.g. "3.6.17"), and
# 4) Replaces the string --VERSION-NUMBER-- with current library version,
# formatted as an integer (e.g. "3006017").
# 5) Replaces the string --SOURCE-ID-- with the date and time and sha1
# hash of the fossil-scm manifest for the source tree.
# 6) Adds the SQLITE_CALLBACK calling convention macro in front of all
# callback declarations.
#
# This script outputs to stdout.
#
# Example usage:
#
# tclsh mksqlite3h.tcl ../sqlite >sqlite3.h
#
# Get the source tree root directory from the command-line
#
set TOP
# Enable use of SQLITE_APICALL macros at the right points?
#
set useapicall 0
# Include sqlite3recover.h?
#
set enable_recover 0
if
if
# Get the SQLite version number (ex: 3.6.18) from the $TOP/VERSION file.
#
set in
set zVersion
close $in
set nVersion
# Get the source-id
#
set PWD
cd $TOP
set zSourceId
cd $PWD
# Set up patterns for recognizing API declarations.
#
set varpattern
set declpattern1
set declpattern2 \
set declpattern3 \
set declpattern4 \
set declpattern5 \
# Force the output to use unix line endings, even on Windows.
fconfigure stdout -translation lf
set filelist
if
# 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
# Process the source files.
#
foreach file $filelist