blob: 27593af659918f53ae3608b91122bf6c2352f8b6 [file] [log] [blame]
drh71eb93e2001-09-28 01:34:43 +00001###############################################################################
drh76800322002-08-13 20:45:39 +00002# The following macros should be defined before this script is
3# invoked:
4#
5# TOP The toplevel directory of the source tree. This is the
6# directory that contains this "Makefile.in" and the
7# "configure.in" script.
8#
9# BCC C Compiler and options for use in building executables that
10# will run on the platform that is doing the build.
11#
12# USLEEP If the target operating system supports the "usleep()" system
13# call, then define the HAVE_USLEEP macro for all C modules.
14#
15# THREADSAFE If you want the SQLite library to be safe for use within a
16# multi-threaded program, then define the following macro
17# appropriately:
18#
19# THREADLIB Specify any extra linker options needed to make the library
20# thread safe
21#
22# OPTS Extra compiler command-line options.
23#
24# EXE The suffix to add to executable files. ".exe" for windows
25# and "" for Unix.
26#
27# TCC C Compiler and options for use in building executables that
28# will run on the target platform. This is usually the same
29# as BCC, unless you are cross-compiling.
30#
31# AR Tools used to build a static library.
32# RANLIB
33#
34# TCL_FLAGS Extra compiler options needed for programs that use the
35# TCL library.
36#
37# LIBTCL Linker options needed to link against the TCL library.
38#
39# READLINE_FLAGS Compiler options needed for programs that use the
40# readline() library.
41#
42# LIBREADLINE Linker options needed by programs using readline() must
43# link against.
44#
45# ENCODING "UTF8" or "ISO8859"
46#
47# Once the macros above are defined, the rest of this make script will
48# build the SQLite library and testing tools.
49################################################################################
drh71eb93e2001-09-28 01:34:43 +000050
51# This is how we compile
52#
drha297b5c2002-01-15 18:39:43 +000053TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src
drh71eb93e2001-09-28 01:34:43 +000054
55# Object files for the SQLite library.
56#
drh58f391b2002-11-20 11:55:18 +000057LIBOBJ = btree.o build.o delete.o expr.o func.o hash.o insert.o \
58 main.o opcodes.o os.o pager.o parse.o printf.o random.o \
59 select.o table.o tokenize.o trigger.o update.o util.o \
60 vdbe.o where.o tclsqlite.o
drh71eb93e2001-09-28 01:34:43 +000061
62# All of the source code files.
63#
64SRC = \
65 $(TOP)/src/btree.c \
66 $(TOP)/src/btree.h \
67 $(TOP)/src/build.c \
68 $(TOP)/src/delete.c \
69 $(TOP)/src/expr.c \
drhdc04c582002-02-24 01:55:15 +000070 $(TOP)/src/func.c \
drh71eb93e2001-09-28 01:34:43 +000071 $(TOP)/src/hash.c \
72 $(TOP)/src/hash.h \
73 $(TOP)/src/insert.c \
74 $(TOP)/src/main.c \
75 $(TOP)/src/os.c \
76 $(TOP)/src/pager.c \
77 $(TOP)/src/pager.h \
78 $(TOP)/src/parse.y \
79 $(TOP)/src/printf.c \
80 $(TOP)/src/random.c \
81 $(TOP)/src/select.c \
82 $(TOP)/src/shell.c \
83 $(TOP)/src/sqlite.h.in \
84 $(TOP)/src/sqliteInt.h \
85 $(TOP)/src/table.c \
86 $(TOP)/src/tclsqlite.c \
87 $(TOP)/src/tokenize.c \
drhdc379452002-05-15 12:45:43 +000088 $(TOP)/src/trigger.c \
drh71eb93e2001-09-28 01:34:43 +000089 $(TOP)/src/update.c \
90 $(TOP)/src/util.c \
91 $(TOP)/src/vdbe.c \
92 $(TOP)/src/vdbe.h \
93 $(TOP)/src/where.c
94
95# Source code to the test files.
96#
97TESTSRC = \
98 $(TOP)/src/btree.c \
drh74587e52002-08-13 00:01:16 +000099 $(TOP)/src/func.c \
drh81a20f22001-10-12 17:30:04 +0000100 $(TOP)/src/os.c \
drh71eb93e2001-09-28 01:34:43 +0000101 $(TOP)/src/pager.c \
102 $(TOP)/src/test1.c \
103 $(TOP)/src/test2.c \
104 $(TOP)/src/test3.c \
105 $(TOP)/src/md5.c
106
107# Header files used by all library source files.
108#
109HDR = \
110 sqlite.h \
111 $(TOP)/src/btree.h \
drh58f391b2002-11-20 11:55:18 +0000112 config.h \
drh71eb93e2001-09-28 01:34:43 +0000113 $(TOP)/src/hash.h \
drh8f619cc2002-09-08 00:04:50 +0000114 opcodes.h \
drh71eb93e2001-09-28 01:34:43 +0000115 $(TOP)/src/os.h \
116 $(TOP)/src/sqliteInt.h \
117 $(TOP)/src/vdbe.h \
118 parse.h
119
120# This is the default Makefile target. The objects listed here
121# are what get build when you type just "make" with no arguments.
122#
drh58f391b2002-11-20 11:55:18 +0000123all: sqlite.h config.h libsqlite.a sqlite$(EXE)
drh71eb93e2001-09-28 01:34:43 +0000124
125# Generate the file "last_change" which contains the date of change
126# of the most recently modified source code file
127#
128last_change: $(SRC)
129 cat $(SRC) | grep '$$Id: ' | sort +4 | tail -1 \
130 | awk '{print $$5,$$6}' >last_change
131
drh4b59ab52002-08-24 18:24:51 +0000132libsqlite.a: $(LIBOBJ)
133 $(AR) libsqlite.a $(LIBOBJ)
drh71eb93e2001-09-28 01:34:43 +0000134 $(RANLIB) libsqlite.a
135
136sqlite$(EXE): $(TOP)/src/shell.c libsqlite.a sqlite.h
137 $(TCCX) $(READLINE_FLAGS) -o sqlite$(EXE) $(TOP)/src/shell.c \
drha297b5c2002-01-15 18:39:43 +0000138 libsqlite.a $(LIBREADLINE) $(THREADLIB)
drh71eb93e2001-09-28 01:34:43 +0000139
140# This target creates a directory named "tsrc" and fills it with
141# copies of all of the C source code and header files needed to
142# build on the target system. Some of the C source code and header
143# files are automatically generated. This target takes care of
144# all that automatic generation.
145#
drhac82fcf2002-09-08 17:23:41 +0000146target_source: $(SRC) $(HDR) opcodes.c
drh71eb93e2001-09-28 01:34:43 +0000147 rm -rf tsrc
148 mkdir tsrc
149 cp $(SRC) $(HDR) tsrc
150 rm tsrc/sqlite.h.in tsrc/parse.y
drhac82fcf2002-09-08 17:23:41 +0000151 cp parse.c opcodes.c tsrc
drh71eb93e2001-09-28 01:34:43 +0000152
153# Rules to build the LEMON compiler generator
154#
155lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
156 $(BCC) -o lemon $(TOP)/tool/lemon.c
157 cp $(TOP)/tool/lempar.c .
158
159btree.o: $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
160 $(TCCX) -c $(TOP)/src/btree.c
161
162build.o: $(TOP)/src/build.c $(HDR)
163 $(TCCX) -c $(TOP)/src/build.c
164
165main.o: $(TOP)/src/main.c $(HDR)
166 $(TCCX) -c $(TOP)/src/main.c
167
168pager.o: $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
169 $(TCCX) -c $(TOP)/src/pager.c
170
drh8f619cc2002-09-08 00:04:50 +0000171opcodes.o: opcodes.c
172 $(TCCX) -c opcodes.c
173
174opcodes.c: $(TOP)/src/vdbe.c
175 echo '/* Automatically generated file. Do not edit */' >opcodes.c
176 echo 'char *sqliteOpcodeNames[] = { "???", ' >>opcodes.c
177 grep '^case OP_' $(TOP)/src/vdbe.c | \
178 sed -e 's/^.*OP_/ "/' -e 's/:.*$$/", /' >>opcodes.c
179 echo '};' >>opcodes.c
180
181opcodes.h: $(TOP)/src/vdbe.h
182 echo '/* Automatically generated file. Do not edit */' >opcodes.h
183 grep '^case OP_' $(TOP)/src/vdbe.c | \
184 sed -e 's/://' | \
185 awk '{printf "#define %-30s %3d\n", $$2, ++cnt}' >>opcodes.h
186
drh71eb93e2001-09-28 01:34:43 +0000187os.o: $(TOP)/src/os.c $(HDR)
188 $(TCCX) -c $(TOP)/src/os.c
189
190parse.o: parse.c $(HDR)
191 $(TCCX) -c parse.c
192
193parse.h: parse.c
194
195parse.c: $(TOP)/src/parse.y lemon
196 cp $(TOP)/src/parse.y .
197 ./lemon parse.y
198
drh58f391b2002-11-20 11:55:18 +0000199# The config.h file will contain a single #define that tells us how
200# many bytes are in a pointer. This only works if a pointer is the
201# same size on the host as it is on the target. If you are cross-compiling
202# to a target with a different pointer size, you'll need to manually
203# configure the config.h file.
204#
205config.h:
206 echo '#include <stdio.h>' >temp.c
207 echo 'int main(){printf(' >>temp.c
208 echo '"#define SQLITE_PTR_SZ %d\n",sizeof(char*));' >>temp.c
209 echo 'exit(0);}' >>temp.c
210 $(BCC) -o temp temp.c
211 ./temp >config.h
212 rm -f temp.c temp
213
drh71eb93e2001-09-28 01:34:43 +0000214sqlite.h: $(TOP)/src/sqlite.h.in
215 sed -e s/--VERS--/`cat ${TOP}/VERSION`/ \
216 -e s/--ENCODING--/$(ENCODING)/ \
217 $(TOP)/src/sqlite.h.in >sqlite.h
218
219tokenize.o: $(TOP)/src/tokenize.c $(HDR)
220 $(TCCX) -c $(TOP)/src/tokenize.c
221
drhdc379452002-05-15 12:45:43 +0000222trigger.o: $(TOP)/src/trigger.c $(HDR)
223 $(TCCX) -c $(TOP)/src/trigger.c
224
drh71eb93e2001-09-28 01:34:43 +0000225util.o: $(TOP)/src/util.c $(HDR)
226 $(TCCX) -c $(TOP)/src/util.c
227
228vdbe.o: $(TOP)/src/vdbe.c $(HDR)
229 $(TCCX) -c $(TOP)/src/vdbe.c
230
231where.o: $(TOP)/src/where.c $(HDR)
232 $(TCCX) -c $(TOP)/src/where.c
233
234delete.o: $(TOP)/src/delete.c $(HDR)
235 $(TCCX) -c $(TOP)/src/delete.c
236
237expr.o: $(TOP)/src/expr.c $(HDR)
238 $(TCCX) -c $(TOP)/src/expr.c
239
drhdc04c582002-02-24 01:55:15 +0000240func.o: $(TOP)/src/func.c $(HDR)
241 $(TCCX) -c $(TOP)/src/func.c
242
drh71eb93e2001-09-28 01:34:43 +0000243hash.o: $(TOP)/src/hash.c $(HDR)
244 $(TCCX) -c $(TOP)/src/hash.c
245
246insert.o: $(TOP)/src/insert.c $(HDR)
247 $(TCCX) -c $(TOP)/src/insert.c
248
249random.o: $(TOP)/src/random.c $(HDR)
250 $(TCCX) -c $(TOP)/src/random.c
251
252select.o: $(TOP)/src/select.c $(HDR)
253 $(TCCX) -c $(TOP)/src/select.c
254
255table.o: $(TOP)/src/table.c $(HDR)
256 $(TCCX) -c $(TOP)/src/table.c
257
258update.o: $(TOP)/src/update.c $(HDR)
259 $(TCCX) -c $(TOP)/src/update.c
260
261tclsqlite.o: $(TOP)/src/tclsqlite.c $(HDR)
262 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
263
264printf.o: $(TOP)/src/printf.c $(HDR)
265 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/printf.c
266
267tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.a
268 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -o tclsqlite \
269 $(TOP)/src/tclsqlite.c libsqlite.a $(LIBTCL)
270
271testfixture$(EXE): $(TOP)/src/tclsqlite.c libsqlite.a $(TESTSRC)
272 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1 -o testfixture$(EXE) \
273 $(TESTSRC) $(TOP)/src/tclsqlite.c \
274 libsqlite.a $(LIBTCL)
275
276fulltest: testfixture$(EXE) sqlite$(EXE)
277 ./testfixture$(EXE) $(TOP)/test/all.test
278
279test: testfixture$(EXE) sqlite$(EXE)
280 ./testfixture$(EXE) $(TOP)/test/quick.test
281
drh90ca9752001-09-28 17:47:14 +0000282index.html: $(TOP)/www/index.tcl last_change
drh71eb93e2001-09-28 01:34:43 +0000283 tclsh $(TOP)/www/index.tcl `cat $(TOP)/VERSION` >index.html
284
285sqlite.html: $(TOP)/www/sqlite.tcl
286 tclsh $(TOP)/www/sqlite.tcl >sqlite.html
287
288c_interface.html: $(TOP)/www/c_interface.tcl
289 tclsh $(TOP)/www/c_interface.tcl >c_interface.html
290
291changes.html: $(TOP)/www/changes.tcl
292 tclsh $(TOP)/www/changes.tcl >changes.html
293
294lang.html: $(TOP)/www/lang.tcl
295 tclsh $(TOP)/www/lang.tcl >lang.html
296
297vdbe.html: $(TOP)/www/vdbe.tcl
298 tclsh $(TOP)/www/vdbe.tcl >vdbe.html
299
300arch.html: $(TOP)/www/arch.tcl
301 tclsh $(TOP)/www/arch.tcl >arch.html
302
303arch.png: $(TOP)/www/arch.png
304 cp $(TOP)/www/arch.png .
305
306opcode.html: $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c
307 tclsh $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c >opcode.html
308
309crosscompile.html: $(TOP)/www/crosscompile.tcl
310 tclsh $(TOP)/www/crosscompile.tcl >crosscompile.html
311
312mingw.html: $(TOP)/www/mingw.tcl
313 tclsh $(TOP)/www/mingw.tcl >mingw.html
314
315tclsqlite.html: $(TOP)/www/tclsqlite.tcl
316 tclsh $(TOP)/www/tclsqlite.tcl >tclsqlite.html
317
318speed.html: $(TOP)/www/speed.tcl
319 tclsh $(TOP)/www/speed.tcl >speed.html
320
drh7a7c7392001-11-24 00:31:46 +0000321faq.html: $(TOP)/www/faq.tcl
322 tclsh $(TOP)/www/faq.tcl >faq.html
323
drhe7ec2202001-12-22 19:27:39 +0000324formatchng.html: $(TOP)/www/formatchng.tcl
325 tclsh $(TOP)/www/formatchng.tcl >formatchng.html
326
drhb419a922002-01-30 16:17:23 +0000327conflict.html: $(TOP)/www/conflict.tcl
328 tclsh $(TOP)/www/conflict.tcl >conflict.html
329
drh90ca9752001-09-28 17:47:14 +0000330download.html: $(TOP)/www/download.tcl
331 tclsh $(TOP)/www/download.tcl >download.html
332
drh76800322002-08-13 20:45:39 +0000333omitted.html: $(TOP)/www/omitted.tcl
334 tclsh $(TOP)/www/omitted.tcl >omitted.html
335
drhfbe43752002-08-14 00:08:12 +0000336datatypes.html: $(TOP)/www/datatypes.tcl
337 tclsh $(TOP)/www/datatypes.tcl >datatypes.html
338
drhc2774132002-08-15 13:45:17 +0000339quickstart.html: $(TOP)/www/quickstart.tcl
340 tclsh $(TOP)/www/quickstart.tcl >quickstart.html
341
drhd8acdb32002-08-18 19:09:22 +0000342fileformat.html: $(TOP)/www/fileformat.tcl
343 tclsh $(TOP)/www/fileformat.tcl >fileformat.html
344
drh96f45312002-09-02 14:11:02 +0000345nulls.html: $(TOP)/www/nulls.tcl
346 tclsh $(TOP)/www/nulls.tcl >nulls.html
347
drh71eb93e2001-09-28 01:34:43 +0000348
349# Files to be published on the website.
350#
drh90ca9752001-09-28 17:47:14 +0000351DOC = \
drh71eb93e2001-09-28 01:34:43 +0000352 index.html \
353 sqlite.html \
354 changes.html \
355 lang.html \
356 opcode.html \
357 arch.html \
358 arch.png \
359 vdbe.html \
360 c_interface.html \
361 crosscompile.html \
362 mingw.html \
363 tclsqlite.html \
drh90ca9752001-09-28 17:47:14 +0000364 download.html \
drh7a7c7392001-11-24 00:31:46 +0000365 speed.html \
drhe7ec2202001-12-22 19:27:39 +0000366 faq.html \
drhb419a922002-01-30 16:17:23 +0000367 formatchng.html \
drh76800322002-08-13 20:45:39 +0000368 conflict.html \
drhfbe43752002-08-14 00:08:12 +0000369 omitted.html \
drhc2774132002-08-15 13:45:17 +0000370 datatypes.html \
drhd8acdb32002-08-18 19:09:22 +0000371 quickstart.html \
drh96f45312002-09-02 14:11:02 +0000372 fileformat.html \
373 nulls.html
drh71eb93e2001-09-28 01:34:43 +0000374
drh90ca9752001-09-28 17:47:14 +0000375doc: $(DOC)
376 mkdir -p doc
377 mv $(DOC) doc
drh71eb93e2001-09-28 01:34:43 +0000378
379install: sqlite libsqlite.a sqlite.h
380 mv sqlite /usr/bin
381 mv libsqlite.a /usr/lib
382 mv sqlite.h /usr/include
383
384clean:
drh8f619cc2002-09-08 00:04:50 +0000385 rm -f *.o sqlite libsqlite.a sqlite.h opcodes.*
drh90ca9752001-09-28 17:47:14 +0000386 rm -f lemon lempar.c parse.* sqlite*.tar.gz
drh71eb93e2001-09-28 01:34:43 +0000387 rm -f $(PUBLISH)
388 rm -f *.da *.bb *.bbg gmon.out
389 rm -rf tsrc