/ Check-in [a0f3c960]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the amalgamation generator to the makefile. (CVS 3783)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a0f3c960fa3e958e12bc488451ee2d637562909b
User & Date: drh 2007-03-31 22:29:05
Context
2007-03-31
22:33
Remove unreachable code from util.c. (CVS 3784) check-in: 82b7a6f0 user: drh tags: trunk
22:29
Add the amalgamation generator to the makefile. (CVS 3783) check-in: a0f3c960 user: drh tags: trunk
16:29
Fix the amalgamation so that it can be compiled with REDEF_IO enabled. (CVS 3782) check-in: 6a3d6142 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to main.mk.

   245    245   # build on the target system.  Some of the C source code and header
   246    246   # files are automatically generated.  This target takes care of
   247    247   # all that automatic generation.
   248    248   #
   249    249   target_source:	$(SRC)
   250    250   	rm -rf tsrc
   251    251   	mkdir tsrc
   252         -	cp $(SRC) $(TOP)/src/*.h tsrc
          252  +	cp -f $(SRC) $(TOP)/src/*.h tsrc 2>/dev/null
   253    253   	rm tsrc/sqlite.h.in tsrc/parse.y
          254  +
          255  +sqlite3.c:	target_source $(TOP)/tool/mksqlite3c.tcl
          256  +	tclsh $(TOP)/tool/mksqlite3c.tcl
   254    257   
   255    258   # Rules to build the LEMON compiler generator
   256    259   #
   257    260   lemon:	$(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
   258    261   	$(BCC) -o lemon $(TOP)/tool/lemon.c
   259    262   	cp $(TOP)/tool/lempar.c .
   260    263   

Changes to tool/mksqlite3c.tcl.

     2      2   #
     3      3   # To build a single huge source file holding all of SQLite (or at
     4      4   # least the core components - the test harness, shell, and TCL 
     5      5   # interface are omitted.) first do
     6      6   #
     7      7   #      make target_source
     8      8   #
     9         -# Then run this script
            9  +# The make target above moves all of the source code files into
           10  +# a subdirectory named "tsrc".  (This script expects to find the files
           11  +# there and will not work if they are not found.)  There are a few
           12  +# generated C code files that are also added to the tsrc directory.
           13  +# For example, the "parse.c" and "parse.h" files to implement the
           14  +# the parser are derived from "parse.y" using lemon.  And the 
           15  +# "keywordhash.h" files is generated by a program named "mkkeywordhash".
           16  +#
           17  +# After the "tsrc" directory has been created and populated, run
           18  +# this script:
           19  +#
           20  +#      tclsh mksqlite3c.tcl
           21  +#
           22  +# The amalgamated SQLite code will be written into sqlite3.c
    10     23   #
    11         -#      tclsh mkonebigsourcefile.tcl
           24  +
           25  +# Begin by reading the "sqlite3.h" header file.  Count the number of lines
           26  +# in this file and extract the version number.  That information will be
           27  +# needed in order to generate the header of the amalgamation.
    12     28   #
    13         -# The combined SQLite source code will be written into sqlite3.c
    14         -#
           29  +set in [open tsrc/sqlite3.h]
           30  +set cnt 0
           31  +set VERSION ?????
           32  +while {![eof $in]} {
           33  +  set line [gets $in]
           34  +  if {$line=="" && [eof $in]} break
           35  +  incr cnt
           36  +  regexp {#define\s+SQLITE_VERSION\s+"(.*)"} $line all VERSION
           37  +}
           38  +close $in
    15     39   
    16     40   # Open the output file and write a header comment at the beginning
    17     41   # of the file.
    18     42   #
    19     43   set out [open sqlite3.c w]
    20         -puts $out \
    21         -"/******************************************************************************
    22         -** This file is a amalgamation of many separate source files from SQLite.  By
    23         -** pulling all the source files into this single unified source file, the
    24         -** entire code can be compiled as a single translation unit, which allows the
    25         -** compiler to do a better job of optimizing.
    26         -*/"
           44  +set today [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S UTC" -gmt 1]
           45  +puts $out [subst \
           46  +{/******************************************************************************
           47  +** This file is a amalgamation of many separate C source files from SQLite
           48  +** version $VERSION.  By combining all the individual C code files into this 
           49  +** single large file, the entire code can be compiled as a one translation
           50  +** unit.  This allows many compilers to do optimizations that would not be
           51  +** possible if the files were compiled separately.  Performance improvements
           52  +** of 5% are more are commonly seen when SQLite is compiled as a single
           53  +** translation unit.
           54  +**
           55  +** This file is all you need to compile SQLite.  To use SQLite in other
           56  +** programs, you need this file and the "sqlite3.h" header file that defines
           57  +** the programming interface to the SQLite library.  (If you do not have 
           58  +** the "sqlite3.h" header file at hand, you will find a copy in the first
           59  +** $cnt lines past the header of this amalgamation.)  Additional code
           60  +** files may be needed if you want a wrapper to interface SQLite with your
           61  +** choice of programming language.  The code for the "sqlite3" command-line
           62  +** shell is also in a separate file.  This file contains only code for the
           63  +** core SQLite library.
           64  +**
           65  +** This amalgamation was generated on $today.
           66  +*/}]
    27     67   
    28     68   # These are the header files used by SQLite.  The first time any of these 
    29     69   # files are seen in a #include statement in the C code, include the complete
    30     70   # text of the file in-line.  The file only needs to be included once.
    31     71   #
    32     72   foreach hdr {
    33     73      btree.h
................................................................................
    43     83      sqlite3.h
    44     84      sqliteInt.h
    45     85      vdbe.h
    46     86      vdbeInt.h
    47     87   } {
    48     88     set available_hdr($hdr) 1
    49     89   }
           90  +set available_hdr(sqlite3.h) 0
    50     91   
    51     92   # 78 stars used for comment formatting.
    52     93   set s78 \
    53     94   {*****************************************************************************}
    54     95   
    55     96   # Insert a comment into the code
    56     97   #
................................................................................
   101    142   
   102    143   
   103    144   # Process the source files.  Process files containing commonly
   104    145   # used subroutines first in order to help the compiler find
   105    146   # inlining opportunities.
   106    147   #
   107    148   foreach file {
          149  +   sqlite3.h
          150  +
   108    151      os.c
   109    152   
   110    153      printf.c
   111    154      random.c
   112    155      utf.c
   113    156      util.c
   114    157      hash.c