SQLite

Check-in [a0f3c960fa]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a0f3c960fa3e958e12bc488451ee2d637562909b
User & Date: drh 2007-03-31 22:29:05.000
Context
2007-03-31
22:33
Remove unreachable code from util.c. (CVS 3784) (check-in: 82b7a6f05c user: drh tags: trunk)
22:29
Add the amalgamation generator to the makefile. (CVS 3783) (check-in: a0f3c960fa user: drh tags: trunk)
16:29
Fix the amalgamation so that it can be compiled with REDEF_IO enabled. (CVS 3782) (check-in: 6a3d6142d8 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to main.mk.
245
246
247
248
249
250
251
252
253



254
255
256
257
258
259
260
# build on the target system.  Some of the C source code and header
# files are automatically generated.  This target takes care of
# all that automatic generation.
#
target_source:	$(SRC)
	rm -rf tsrc
	mkdir tsrc
	cp $(SRC) $(TOP)/src/*.h tsrc
	rm tsrc/sqlite.h.in tsrc/parse.y




# Rules to build the LEMON compiler generator
#
lemon:	$(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
	$(BCC) -o lemon $(TOP)/tool/lemon.c
	cp $(TOP)/tool/lempar.c .








|

>
>
>







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

sqlite3.c:	target_source $(TOP)/tool/mksqlite3c.tcl
	tclsh $(TOP)/tool/mksqlite3c.tcl

# Rules to build the LEMON compiler generator
#
lemon:	$(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
	$(BCC) -o lemon $(TOP)/tool/lemon.c
	cp $(TOP)/tool/lempar.c .

Changes to tool/mksqlite3c.tcl.
1
2
3
4
5
6
7
8









9
10
11
12
13
14
15















16
17
18
19

20
21
22
23




24









25


26
27
28
29
30
31
32
33
#!/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
#









# Then run this script
#
#      tclsh mkonebigsourcefile.tcl
#
# The combined SQLite source code will be written into sqlite3.c
#
















# Open the output file and write a header comment at the beginning
# of the file.
#
set out [open sqlite3.c w]

puts $out \
"/******************************************************************************
** This file is a amalgamation of many separate source files from SQLite.  By
** pulling all the source files into this single unified source file, the




** entire code can be compiled as a single translation unit, which allows the









** compiler to do a better job of optimizing.


*/"

# 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 {
   btree.h








>
>
>
>
>
>
>
>
>
|

|

|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




>
|
|
|
|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
|
>
>
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/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 [open tsrc/sqlite3.h]
set cnt 0
set VERSION ?????
while {![eof $in]} {
  set line [gets $in]
  if {$line=="" && [eof $in]} break
  incr cnt
  regexp {#define\s+SQLITE_VERSION\s+"(.*)"} $line all VERSION
}
close $in

# Open the output file and write a header comment at the beginning
# of the file.
#
set out [open sqlite3.c w]
set today [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S UTC" -gmt 1]
puts $out [subst \
{/******************************************************************************
** This file is a amalgamation of many separate C source files from SQLite
** version $VERSION.  By combining all the individual C code files into this 
** single large file, the entire code can be compiled as a one translation
** unit.  This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately.  Performance improvements
** of 5% are more are commonly seen when SQLite is compiled as a single
** translation unit.
**
** This file is all you need to compile SQLite.  To use SQLite in other
** programs, you need this file and the "sqlite3.h" header file that defines
** the programming interface to the SQLite library.  (If you do not have 
** the "sqlite3.h" header file at hand, you will find a copy in the first
** $cnt lines past the header of this amalgamation.)  Additional code
** files may be needed if you want a wrapper to interface SQLite with your
** choice of programming language.  The code for the "sqlite3" command-line
** shell is also in a separate file.  This file contains only code for the
** core SQLite library.
**
** This amalgamation was generated on $today.
*/}]

# 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 {
   btree.h
43
44
45
46
47
48
49

50
51
52
53
54
55
56
   sqlite3.h
   sqliteInt.h
   vdbe.h
   vdbeInt.h
} {
  set available_hdr($hdr) 1
}


# 78 stars used for comment formatting.
set s78 \
{*****************************************************************************}

# Insert a comment into the code
#







>







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
   sqlite3.h
   sqliteInt.h
   vdbe.h
   vdbeInt.h
} {
  set available_hdr($hdr) 1
}
set available_hdr(sqlite3.h) 0

# 78 stars used for comment formatting.
set s78 \
{*****************************************************************************}

# Insert a comment into the code
#
101
102
103
104
105
106
107


108
109
110
111
112
113
114


# Process the source files.  Process files containing commonly
# used subroutines first in order to help the compiler find
# inlining opportunities.
#
foreach file {


   os.c

   printf.c
   random.c
   utf.c
   util.c
   hash.c







>
>







142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157


# Process the source files.  Process files containing commonly
# used subroutines first in order to help the compiler find
# inlining opportunities.
#
foreach file {
   sqlite3.h

   os.c

   printf.c
   random.c
   utf.c
   util.c
   hash.c