blob: 82f3a41ad6f8b099aae409e85902b182991183b6 [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#
danielk19774adee202004-05-08 08:23:19 +000057# LIBOBJ = btree.o hash.o os.o pager.o random.o \
58# util.o tclsqlite.o utf.o
drh3aac2dd2004-04-26 14:10:20 +000059
danielk19774adee202004-05-08 08:23:19 +000060
61LIBOBJ = attach.o auth.o btree.o build.o copy.o date.o delete.o \
drhc11d4f92003-04-06 21:08:24 +000062 expr.o func.o hash.o insert.o \
63 main.o opcodes.o os.o pager.o parse.o pragma.o printf.o random.o \
drh58f391b2002-11-20 11:55:18 +000064 select.o table.o tokenize.o trigger.o update.o util.o \
danielk19774adee202004-05-08 08:23:19 +000065 vacuum.o vdbe.o vdbeaux.o where.o tclsqlite.o utf.o
drh71eb93e2001-09-28 01:34:43 +000066
67# All of the source code files.
68#
69SRC = \
drhc11d4f92003-04-06 21:08:24 +000070 $(TOP)/src/attach.c \
drhed6c8672003-01-12 18:02:16 +000071 $(TOP)/src/auth.c \
drh71eb93e2001-09-28 01:34:43 +000072 $(TOP)/src/btree.c \
73 $(TOP)/src/btree.h \
74 $(TOP)/src/build.c \
drhc11d4f92003-04-06 21:08:24 +000075 $(TOP)/src/copy.c \
drh7014aff2003-11-01 01:53:53 +000076 $(TOP)/src/date.c \
drh71eb93e2001-09-28 01:34:43 +000077 $(TOP)/src/delete.c \
drh6da834a2004-03-14 22:11:59 +000078 $(TOP)/src/encode.c \
drh71eb93e2001-09-28 01:34:43 +000079 $(TOP)/src/expr.c \
drhdc04c582002-02-24 01:55:15 +000080 $(TOP)/src/func.c \
drh71eb93e2001-09-28 01:34:43 +000081 $(TOP)/src/hash.c \
82 $(TOP)/src/hash.h \
83 $(TOP)/src/insert.c \
84 $(TOP)/src/main.c \
85 $(TOP)/src/os.c \
86 $(TOP)/src/pager.c \
87 $(TOP)/src/pager.h \
88 $(TOP)/src/parse.y \
drhc11d4f92003-04-06 21:08:24 +000089 $(TOP)/src/pragma.c \
drh71eb93e2001-09-28 01:34:43 +000090 $(TOP)/src/printf.c \
91 $(TOP)/src/random.c \
92 $(TOP)/src/select.c \
93 $(TOP)/src/shell.c \
94 $(TOP)/src/sqlite.h.in \
95 $(TOP)/src/sqliteInt.h \
96 $(TOP)/src/table.c \
97 $(TOP)/src/tclsqlite.c \
98 $(TOP)/src/tokenize.c \
drhdc379452002-05-15 12:45:43 +000099 $(TOP)/src/trigger.c \
drh1bbf5ee2004-05-11 01:18:24 +0000100 $(TOP)/src/utf.c \
drh71eb93e2001-09-28 01:34:43 +0000101 $(TOP)/src/update.c \
102 $(TOP)/src/util.c \
drhe1051c62003-04-06 20:52:32 +0000103 $(TOP)/src/vacuum.c \
drh71eb93e2001-09-28 01:34:43 +0000104 $(TOP)/src/vdbe.c \
105 $(TOP)/src/vdbe.h \
drh9a324642003-09-06 20:12:01 +0000106 $(TOP)/src/vdbeaux.c \
107 $(TOP)/src/vdbeInt.h \
drh71eb93e2001-09-28 01:34:43 +0000108 $(TOP)/src/where.c
109
110# Source code to the test files.
111#
112TESTSRC = \
113 $(TOP)/src/btree.c \
drh74587e52002-08-13 00:01:16 +0000114 $(TOP)/src/func.c \
drh81a20f22001-10-12 17:30:04 +0000115 $(TOP)/src/os.c \
drh71eb93e2001-09-28 01:34:43 +0000116 $(TOP)/src/pager.c \
117 $(TOP)/src/test1.c \
118 $(TOP)/src/test2.c \
119 $(TOP)/src/test3.c \
drha6064dc2003-12-19 02:52:05 +0000120 $(TOP)/src/test4.c \
danielk19774adee202004-05-08 08:23:19 +0000121 $(TOP)/src/test5.c \
drhf6038712004-02-08 18:07:34 +0000122 $(TOP)/src/vdbe.c \
drh71eb93e2001-09-28 01:34:43 +0000123 $(TOP)/src/md5.c
124
125# Header files used by all library source files.
126#
127HDR = \
128 sqlite.h \
129 $(TOP)/src/btree.h \
drh58f391b2002-11-20 11:55:18 +0000130 config.h \
drh71eb93e2001-09-28 01:34:43 +0000131 $(TOP)/src/hash.h \
drh8f619cc2002-09-08 00:04:50 +0000132 opcodes.h \
drh71eb93e2001-09-28 01:34:43 +0000133 $(TOP)/src/os.h \
134 $(TOP)/src/sqliteInt.h \
drh9a324642003-09-06 20:12:01 +0000135 $(TOP)/src/vdbe.h \
drh71eb93e2001-09-28 01:34:43 +0000136 parse.h
137
drh9a324642003-09-06 20:12:01 +0000138# Header files used by the VDBE submodule
139#
140VDBEHDR = \
141 $(HDR) \
142 $(TOP)/src/vdbeInt.h
143
drh71eb93e2001-09-28 01:34:43 +0000144# This is the default Makefile target. The objects listed here
145# are what get build when you type just "make" with no arguments.
146#
drh58f391b2002-11-20 11:55:18 +0000147all: sqlite.h config.h libsqlite.a sqlite$(EXE)
drh71eb93e2001-09-28 01:34:43 +0000148
149# Generate the file "last_change" which contains the date of change
150# of the most recently modified source code file
151#
152last_change: $(SRC)
153 cat $(SRC) | grep '$$Id: ' | sort +4 | tail -1 \
154 | awk '{print $$5,$$6}' >last_change
155
drh4b59ab52002-08-24 18:24:51 +0000156libsqlite.a: $(LIBOBJ)
157 $(AR) libsqlite.a $(LIBOBJ)
drh71eb93e2001-09-28 01:34:43 +0000158 $(RANLIB) libsqlite.a
159
160sqlite$(EXE): $(TOP)/src/shell.c libsqlite.a sqlite.h
161 $(TCCX) $(READLINE_FLAGS) -o sqlite$(EXE) $(TOP)/src/shell.c \
drha297b5c2002-01-15 18:39:43 +0000162 libsqlite.a $(LIBREADLINE) $(THREADLIB)
drh71eb93e2001-09-28 01:34:43 +0000163
danielk19774adee202004-05-08 08:23:19 +0000164objects: $(LIBOBJ_ORIG)
165
drh71eb93e2001-09-28 01:34:43 +0000166# This target creates a directory named "tsrc" and fills it with
167# copies of all of the C source code and header files needed to
168# build on the target system. Some of the C source code and header
169# files are automatically generated. This target takes care of
170# all that automatic generation.
171#
drh9a324642003-09-06 20:12:01 +0000172target_source: $(SRC) $(VDBEHDR) opcodes.c
drh71eb93e2001-09-28 01:34:43 +0000173 rm -rf tsrc
174 mkdir tsrc
drh9a324642003-09-06 20:12:01 +0000175 cp $(SRC) $(VDBEHDR) tsrc
drh71eb93e2001-09-28 01:34:43 +0000176 rm tsrc/sqlite.h.in tsrc/parse.y
drhac82fcf2002-09-08 17:23:41 +0000177 cp parse.c opcodes.c tsrc
drh71eb93e2001-09-28 01:34:43 +0000178
179# Rules to build the LEMON compiler generator
180#
181lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
182 $(BCC) -o lemon $(TOP)/tool/lemon.c
183 cp $(TOP)/tool/lempar.c .
184
185btree.o: $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
186 $(TCCX) -c $(TOP)/src/btree.c
187
drh70ce3f02003-04-15 19:22:22 +0000188btree_rb.o: $(TOP)/src/btree_rb.c $(HDR)
189 $(TCCX) -c $(TOP)/src/btree_rb.c
190
drh71eb93e2001-09-28 01:34:43 +0000191build.o: $(TOP)/src/build.c $(HDR)
192 $(TCCX) -c $(TOP)/src/build.c
193
194main.o: $(TOP)/src/main.c $(HDR)
195 $(TCCX) -c $(TOP)/src/main.c
196
197pager.o: $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
198 $(TCCX) -c $(TOP)/src/pager.c
199
drh8f619cc2002-09-08 00:04:50 +0000200opcodes.o: opcodes.c
201 $(TCCX) -c opcodes.c
202
203opcodes.c: $(TOP)/src/vdbe.c
204 echo '/* Automatically generated file. Do not edit */' >opcodes.c
danielk19774adee202004-05-08 08:23:19 +0000205 echo 'char *sqlite3OpcodeNames[] = { "???", ' >>opcodes.c
drh8f619cc2002-09-08 00:04:50 +0000206 grep '^case OP_' $(TOP)/src/vdbe.c | \
207 sed -e 's/^.*OP_/ "/' -e 's/:.*$$/", /' >>opcodes.c
208 echo '};' >>opcodes.c
209
210opcodes.h: $(TOP)/src/vdbe.h
211 echo '/* Automatically generated file. Do not edit */' >opcodes.h
212 grep '^case OP_' $(TOP)/src/vdbe.c | \
213 sed -e 's/://' | \
214 awk '{printf "#define %-30s %3d\n", $$2, ++cnt}' >>opcodes.h
215
drh71eb93e2001-09-28 01:34:43 +0000216os.o: $(TOP)/src/os.c $(HDR)
217 $(TCCX) -c $(TOP)/src/os.c
218
219parse.o: parse.c $(HDR)
220 $(TCCX) -c parse.c
221
222parse.h: parse.c
223
224parse.c: $(TOP)/src/parse.y lemon
225 cp $(TOP)/src/parse.y .
226 ./lemon parse.y
227
drh58f391b2002-11-20 11:55:18 +0000228# The config.h file will contain a single #define that tells us how
229# many bytes are in a pointer. This only works if a pointer is the
230# same size on the host as it is on the target. If you are cross-compiling
231# to a target with a different pointer size, you'll need to manually
232# configure the config.h file.
233#
234config.h:
235 echo '#include <stdio.h>' >temp.c
236 echo 'int main(){printf(' >>temp.c
drh89715272003-05-17 02:27:21 +0000237 echo '"#define SQLITE_PTR_SZ %d",sizeof(char*));' >>temp.c
drh58f391b2002-11-20 11:55:18 +0000238 echo 'exit(0);}' >>temp.c
239 $(BCC) -o temp temp.c
240 ./temp >config.h
drh89715272003-05-17 02:27:21 +0000241 echo >>config.h
drh58f391b2002-11-20 11:55:18 +0000242 rm -f temp.c temp
243
drh71eb93e2001-09-28 01:34:43 +0000244sqlite.h: $(TOP)/src/sqlite.h.in
245 sed -e s/--VERS--/`cat ${TOP}/VERSION`/ \
246 -e s/--ENCODING--/$(ENCODING)/ \
247 $(TOP)/src/sqlite.h.in >sqlite.h
248
249tokenize.o: $(TOP)/src/tokenize.c $(HDR)
250 $(TCCX) -c $(TOP)/src/tokenize.c
251
drhdc379452002-05-15 12:45:43 +0000252trigger.o: $(TOP)/src/trigger.c $(HDR)
253 $(TCCX) -c $(TOP)/src/trigger.c
254
danielk19774adee202004-05-08 08:23:19 +0000255utf.o: $(TOP)/src/utf.c $(HDR)
256 $(TCCX) -c $(TOP)/src/utf.c
257
drh71eb93e2001-09-28 01:34:43 +0000258util.o: $(TOP)/src/util.c $(HDR)
259 $(TCCX) -c $(TOP)/src/util.c
260
drhe1051c62003-04-06 20:52:32 +0000261vacuum.o: $(TOP)/src/vacuum.c $(HDR)
262 $(TCCX) -c $(TOP)/src/vacuum.c
263
drh9a324642003-09-06 20:12:01 +0000264vdbe.o: $(TOP)/src/vdbe.c $(VDBEHDR)
drh71eb93e2001-09-28 01:34:43 +0000265 $(TCCX) -c $(TOP)/src/vdbe.c
266
drh9a324642003-09-06 20:12:01 +0000267vdbeaux.o: $(TOP)/src/vdbeaux.c $(VDBEHDR)
268 $(TCCX) -c $(TOP)/src/vdbeaux.c
269
drh71eb93e2001-09-28 01:34:43 +0000270where.o: $(TOP)/src/where.c $(HDR)
271 $(TCCX) -c $(TOP)/src/where.c
272
drhc11d4f92003-04-06 21:08:24 +0000273copy.o: $(TOP)/src/copy.c $(HDR)
274 $(TCCX) -c $(TOP)/src/copy.c
275
drh7014aff2003-11-01 01:53:53 +0000276date.o: $(TOP)/src/date.c $(HDR)
277 $(TCCX) -c $(TOP)/src/date.c
278
drh71eb93e2001-09-28 01:34:43 +0000279delete.o: $(TOP)/src/delete.c $(HDR)
280 $(TCCX) -c $(TOP)/src/delete.c
281
drh6da834a2004-03-14 22:11:59 +0000282encode.o: $(TOP)/src/encode.c
283 $(TCCX) -c $(TOP)/src/encode.c
284
drh71eb93e2001-09-28 01:34:43 +0000285expr.o: $(TOP)/src/expr.c $(HDR)
286 $(TCCX) -c $(TOP)/src/expr.c
287
drhdc04c582002-02-24 01:55:15 +0000288func.o: $(TOP)/src/func.c $(HDR)
289 $(TCCX) -c $(TOP)/src/func.c
290
drh71eb93e2001-09-28 01:34:43 +0000291hash.o: $(TOP)/src/hash.c $(HDR)
292 $(TCCX) -c $(TOP)/src/hash.c
293
294insert.o: $(TOP)/src/insert.c $(HDR)
295 $(TCCX) -c $(TOP)/src/insert.c
296
297random.o: $(TOP)/src/random.c $(HDR)
298 $(TCCX) -c $(TOP)/src/random.c
299
300select.o: $(TOP)/src/select.c $(HDR)
301 $(TCCX) -c $(TOP)/src/select.c
302
303table.o: $(TOP)/src/table.c $(HDR)
304 $(TCCX) -c $(TOP)/src/table.c
305
306update.o: $(TOP)/src/update.c $(HDR)
307 $(TCCX) -c $(TOP)/src/update.c
308
309tclsqlite.o: $(TOP)/src/tclsqlite.c $(HDR)
310 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
311
drhc11d4f92003-04-06 21:08:24 +0000312pragma.o: $(TOP)/src/pragma.c $(HDR)
313 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/pragma.c
314
drh71eb93e2001-09-28 01:34:43 +0000315printf.o: $(TOP)/src/printf.c $(HDR)
316 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/printf.c
317
drhc11d4f92003-04-06 21:08:24 +0000318attach.o: $(TOP)/src/attach.c $(HDR)
319 $(TCCX) -c $(TOP)/src/attach.c
320
drhed6c8672003-01-12 18:02:16 +0000321auth.o: $(TOP)/src/auth.c $(HDR)
322 $(TCCX) -c $(TOP)/src/auth.c
323
drh71eb93e2001-09-28 01:34:43 +0000324tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.a
325 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -o tclsqlite \
326 $(TOP)/src/tclsqlite.c libsqlite.a $(LIBTCL)
327
328testfixture$(EXE): $(TOP)/src/tclsqlite.c libsqlite.a $(TESTSRC)
329 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1 -o testfixture$(EXE) \
330 $(TESTSRC) $(TOP)/src/tclsqlite.c \
drha6064dc2003-12-19 02:52:05 +0000331 libsqlite.a $(LIBTCL) $(THREADLIB)
drh71eb93e2001-09-28 01:34:43 +0000332
333fulltest: testfixture$(EXE) sqlite$(EXE)
334 ./testfixture$(EXE) $(TOP)/test/all.test
335
336test: testfixture$(EXE) sqlite$(EXE)
337 ./testfixture$(EXE) $(TOP)/test/quick.test
338
drh90ca9752001-09-28 17:47:14 +0000339index.html: $(TOP)/www/index.tcl last_change
drh71eb93e2001-09-28 01:34:43 +0000340 tclsh $(TOP)/www/index.tcl `cat $(TOP)/VERSION` >index.html
341
342sqlite.html: $(TOP)/www/sqlite.tcl
343 tclsh $(TOP)/www/sqlite.tcl >sqlite.html
344
345c_interface.html: $(TOP)/www/c_interface.tcl
346 tclsh $(TOP)/www/c_interface.tcl >c_interface.html
347
348changes.html: $(TOP)/www/changes.tcl
349 tclsh $(TOP)/www/changes.tcl >changes.html
350
351lang.html: $(TOP)/www/lang.tcl
352 tclsh $(TOP)/www/lang.tcl >lang.html
353
354vdbe.html: $(TOP)/www/vdbe.tcl
355 tclsh $(TOP)/www/vdbe.tcl >vdbe.html
356
357arch.html: $(TOP)/www/arch.tcl
358 tclsh $(TOP)/www/arch.tcl >arch.html
359
360arch.png: $(TOP)/www/arch.png
361 cp $(TOP)/www/arch.png .
362
363opcode.html: $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c
364 tclsh $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c >opcode.html
365
drh71eb93e2001-09-28 01:34:43 +0000366mingw.html: $(TOP)/www/mingw.tcl
367 tclsh $(TOP)/www/mingw.tcl >mingw.html
368
369tclsqlite.html: $(TOP)/www/tclsqlite.tcl
370 tclsh $(TOP)/www/tclsqlite.tcl >tclsqlite.html
371
372speed.html: $(TOP)/www/speed.tcl
373 tclsh $(TOP)/www/speed.tcl >speed.html
374
drh7a7c7392001-11-24 00:31:46 +0000375faq.html: $(TOP)/www/faq.tcl
376 tclsh $(TOP)/www/faq.tcl >faq.html
377
drhe7ec2202001-12-22 19:27:39 +0000378formatchng.html: $(TOP)/www/formatchng.tcl
379 tclsh $(TOP)/www/formatchng.tcl >formatchng.html
380
drhb419a922002-01-30 16:17:23 +0000381conflict.html: $(TOP)/www/conflict.tcl
382 tclsh $(TOP)/www/conflict.tcl >conflict.html
383
drh90ca9752001-09-28 17:47:14 +0000384download.html: $(TOP)/www/download.tcl
385 tclsh $(TOP)/www/download.tcl >download.html
386
drh76800322002-08-13 20:45:39 +0000387omitted.html: $(TOP)/www/omitted.tcl
388 tclsh $(TOP)/www/omitted.tcl >omitted.html
389
drhfbe43752002-08-14 00:08:12 +0000390datatypes.html: $(TOP)/www/datatypes.tcl
391 tclsh $(TOP)/www/datatypes.tcl >datatypes.html
392
drhc2774132002-08-15 13:45:17 +0000393quickstart.html: $(TOP)/www/quickstart.tcl
394 tclsh $(TOP)/www/quickstart.tcl >quickstart.html
395
drhd8acdb32002-08-18 19:09:22 +0000396fileformat.html: $(TOP)/www/fileformat.tcl
397 tclsh $(TOP)/www/fileformat.tcl >fileformat.html
398
drh96f45312002-09-02 14:11:02 +0000399nulls.html: $(TOP)/www/nulls.tcl
400 tclsh $(TOP)/www/nulls.tcl >nulls.html
401
drh71eb93e2001-09-28 01:34:43 +0000402
403# Files to be published on the website.
404#
drh90ca9752001-09-28 17:47:14 +0000405DOC = \
drh71eb93e2001-09-28 01:34:43 +0000406 index.html \
407 sqlite.html \
408 changes.html \
409 lang.html \
410 opcode.html \
411 arch.html \
412 arch.png \
413 vdbe.html \
414 c_interface.html \
drh71eb93e2001-09-28 01:34:43 +0000415 mingw.html \
416 tclsqlite.html \
drh90ca9752001-09-28 17:47:14 +0000417 download.html \
drh7a7c7392001-11-24 00:31:46 +0000418 speed.html \
drhe7ec2202001-12-22 19:27:39 +0000419 faq.html \
drhb419a922002-01-30 16:17:23 +0000420 formatchng.html \
drh76800322002-08-13 20:45:39 +0000421 conflict.html \
drhfbe43752002-08-14 00:08:12 +0000422 omitted.html \
drhc2774132002-08-15 13:45:17 +0000423 datatypes.html \
drhd8acdb32002-08-18 19:09:22 +0000424 quickstart.html \
drh96f45312002-09-02 14:11:02 +0000425 fileformat.html \
426 nulls.html
drh71eb93e2001-09-28 01:34:43 +0000427
drh90ca9752001-09-28 17:47:14 +0000428doc: $(DOC)
429 mkdir -p doc
430 mv $(DOC) doc
drh71eb93e2001-09-28 01:34:43 +0000431
432install: sqlite libsqlite.a sqlite.h
433 mv sqlite /usr/bin
434 mv libsqlite.a /usr/lib
435 mv sqlite.h /usr/include
436
437clean:
drh8f619cc2002-09-08 00:04:50 +0000438 rm -f *.o sqlite libsqlite.a sqlite.h opcodes.*
drh90ca9752001-09-28 17:47:14 +0000439 rm -f lemon lempar.c parse.* sqlite*.tar.gz
drh71eb93e2001-09-28 01:34:43 +0000440 rm -f $(PUBLISH)
441 rm -f *.da *.bb *.bbg gmon.out
442 rm -rf tsrc