blob: 99c9451fdbdd304a5e78487b755b5075cfb50a7d [file] [log] [blame]
drh71eb93e2001-09-28 01:34:43 +00001#!/usr/make
2#
3# Makefile for SQLITE
4#
5# This is a template makefile for SQLite. Most people prefer to
6# use the autoconf generated "configure" script to generate the
7# makefile automatically. But that does not work for everybody
8# and in every situation. If you are having problems with the
9# "configure" script, you might want to try this makefile as an
10# alternative. Create a copy of this file, edit the parameters
11# below and type "make".
12#
13
14#### The toplevel directory of the source tree. This is the directory
15# that contains this "Makefile.in" and the "configure.in" script.
16#
17TOP = ../sqlite
18
19#### C Compiler and options for use in building executables that
20# will run on the platform that is doing the build.
21#
22BCC = gcc -g -O2
drh382c0242001-10-06 16:33:02 +000023#BCC = /opt/ancic/bin/c89 -0
drh71eb93e2001-09-28 01:34:43 +000024
25#### If the target operating system supports the "usleep()" system
26# call, then define the HAVE_USLEEP macro for all C modules.
27#
28#USLEEP =
29USLEEP = -DHAVE_USLEEP=1
30
drha297b5c2002-01-15 18:39:43 +000031#### If you want the SQLite library to be safe for use within a
32# multi-threaded program, then define the following macro
33# appropriately:
34#
35#THREADSAFE = -DTHREADSAFE=1
36THREADSAFE = -DTHREADSAFE=0
37
38#### Specify any extra linker options needed to make the library
39# thread safe
40#
41#THREADLIB = -lpthread
42THREADLIB =
43
drh71eb93e2001-09-28 01:34:43 +000044#### Leave MEMORY_DEBUG undefined for maximum speed. Use MEMORY_DEBUG=1
45# to check for memory leaks. Use MEMORY_DEBUG=2 to print a log of all
46# malloc()s and free()s in order to track down memory leaks.
47#
48# SQLite uses some expensive assert() statements in the inner loop.
49# You can make the library go almost twice as fast if you compile
50# with -DNDEBUG=1
51#
52#OPTS = -DMEMORY_DEBUG=2
53#OPTS = -DMEMORY_DEBUG=1
54#OPTS =
55OPTS = -DNDEBUG=1
56
drh71eb93e2001-09-28 01:34:43 +000057#### The suffix to add to executable files. ".exe" for windows.
58# Nothing for unix.
59#
60#EXE = .exe
61EXE =
62
63#### C Compile and options for use in building executables that
64# will run on the target platform. This is usually the same
65# as BCC, unless you are cross-compiling.
66#
67TCC = gcc -O6
68#TCC = gcc -g -O0 -Wall
drh1bee3d72001-10-15 00:44:35 +000069#TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage
drh71eb93e2001-09-28 01:34:43 +000070#TCC = /opt/mingw/bin/i386-mingw32-gcc -O6
drh382c0242001-10-06 16:33:02 +000071#TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive
drh71eb93e2001-09-28 01:34:43 +000072
73#### Tools used to build a static library.
74#
75AR = ar cr
76#AR = /opt/mingw/bin/i386-mingw32-ar cr
77RANLIB = ranlib
78#RANLIB = /opt/mingw/bin/i386-mingw32-ranlib
79
80#### Extra compiler options needed for programs that use the TCL library.
81#
82#TCL_FLAGS =
83#TCL_FLAGS = -DSTATIC_BUILD=1
84TCL_FLAGS = -I/home/drh/tcltk/8.4linux
85#TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1
drh382c0242001-10-06 16:33:02 +000086#TCL_FLAGS = -I/home/drh/tcltk/8.3hpux
drh71eb93e2001-09-28 01:34:43 +000087
88#### Linker options needed to link against the TCL library.
89#
90#LIBTCL = -ltcl -lm -ldl
91LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl
92#LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt
drh382c0242001-10-06 16:33:02 +000093#LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc
drh71eb93e2001-09-28 01:34:43 +000094
95#### Compiler options needed for programs that use the readline() library.
96#
97#READLINE_FLAGS =
98READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline
99
100#### Linker options needed by programs using readline() must link against.
101#
102#LIBREADLINE =
drh208611f2001-12-05 00:46:02 +0000103LIBREADLINE = -static -lreadline -ltermcap
drh71eb93e2001-09-28 01:34:43 +0000104
105#### Should the database engine assume text is coded as UTF-8 or iso8859?
106#
107# ENCODING = UTF8
108ENCODING = ISO8859
109
110# You should not have to change anything below this line
111###############################################################################
112
113# This is how we compile
114#
drha297b5c2002-01-15 18:39:43 +0000115TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src
drh71eb93e2001-09-28 01:34:43 +0000116
117# Object files for the SQLite library.
118#
drhdc04c582002-02-24 01:55:15 +0000119LIBOBJ = btree.o build.o delete.o expr.o func.o hash.o insert.o \
drh71eb93e2001-09-28 01:34:43 +0000120 main.o os.o pager.o parse.o printf.o random.o select.o table.o \
drhdc379452002-05-15 12:45:43 +0000121 tokenize.o trigger.o update.o util.o vdbe.o where.o tclsqlite.o
drh71eb93e2001-09-28 01:34:43 +0000122
123# All of the source code files.
124#
125SRC = \
126 $(TOP)/src/btree.c \
127 $(TOP)/src/btree.h \
128 $(TOP)/src/build.c \
129 $(TOP)/src/delete.c \
130 $(TOP)/src/expr.c \
drhdc04c582002-02-24 01:55:15 +0000131 $(TOP)/src/func.c \
drh71eb93e2001-09-28 01:34:43 +0000132 $(TOP)/src/hash.c \
133 $(TOP)/src/hash.h \
134 $(TOP)/src/insert.c \
135 $(TOP)/src/main.c \
136 $(TOP)/src/os.c \
137 $(TOP)/src/pager.c \
138 $(TOP)/src/pager.h \
139 $(TOP)/src/parse.y \
140 $(TOP)/src/printf.c \
141 $(TOP)/src/random.c \
142 $(TOP)/src/select.c \
143 $(TOP)/src/shell.c \
144 $(TOP)/src/sqlite.h.in \
145 $(TOP)/src/sqliteInt.h \
146 $(TOP)/src/table.c \
147 $(TOP)/src/tclsqlite.c \
148 $(TOP)/src/tokenize.c \
drhdc379452002-05-15 12:45:43 +0000149 $(TOP)/src/trigger.c \
drh71eb93e2001-09-28 01:34:43 +0000150 $(TOP)/src/update.c \
151 $(TOP)/src/util.c \
152 $(TOP)/src/vdbe.c \
153 $(TOP)/src/vdbe.h \
154 $(TOP)/src/where.c
155
156# Source code to the test files.
157#
158TESTSRC = \
159 $(TOP)/src/btree.c \
drh81a20f22001-10-12 17:30:04 +0000160 $(TOP)/src/os.c \
drh71eb93e2001-09-28 01:34:43 +0000161 $(TOP)/src/pager.c \
162 $(TOP)/src/test1.c \
163 $(TOP)/src/test2.c \
164 $(TOP)/src/test3.c \
165 $(TOP)/src/md5.c
166
167# Header files used by all library source files.
168#
169HDR = \
170 sqlite.h \
171 $(TOP)/src/btree.h \
172 $(TOP)/src/hash.h \
173 $(TOP)/src/os.h \
174 $(TOP)/src/sqliteInt.h \
175 $(TOP)/src/vdbe.h \
176 parse.h
177
178# This is the default Makefile target. The objects listed here
179# are what get build when you type just "make" with no arguments.
180#
181all: sqlite.h libsqlite.a sqlite$(EXE)
182
183# Generate the file "last_change" which contains the date of change
184# of the most recently modified source code file
185#
186last_change: $(SRC)
187 cat $(SRC) | grep '$$Id: ' | sort +4 | tail -1 \
188 | awk '{print $$5,$$6}' >last_change
189
190libsqlite.a: $(LIBOBJ) tclsqlite.o
191 $(AR) libsqlite.a $(LIBOBJ) tclsqlite.o
192 $(RANLIB) libsqlite.a
193
194sqlite$(EXE): $(TOP)/src/shell.c libsqlite.a sqlite.h
195 $(TCCX) $(READLINE_FLAGS) -o sqlite$(EXE) $(TOP)/src/shell.c \
drha297b5c2002-01-15 18:39:43 +0000196 libsqlite.a $(LIBREADLINE) $(THREADLIB)
drh71eb93e2001-09-28 01:34:43 +0000197
198# This target creates a directory named "tsrc" and fills it with
199# copies of all of the C source code and header files needed to
200# build on the target system. Some of the C source code and header
201# files are automatically generated. This target takes care of
202# all that automatic generation.
203#
204target_source: $(SRC) $(HDR)
205 rm -rf tsrc
206 mkdir tsrc
207 cp $(SRC) $(HDR) tsrc
208 rm tsrc/sqlite.h.in tsrc/parse.y
209 cp parse.c tsrc
210
211# Rules to build the LEMON compiler generator
212#
213lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
214 $(BCC) -o lemon $(TOP)/tool/lemon.c
215 cp $(TOP)/tool/lempar.c .
216
217btree.o: $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
218 $(TCCX) -c $(TOP)/src/btree.c
219
220build.o: $(TOP)/src/build.c $(HDR)
221 $(TCCX) -c $(TOP)/src/build.c
222
223main.o: $(TOP)/src/main.c $(HDR)
224 $(TCCX) -c $(TOP)/src/main.c
225
226pager.o: $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
227 $(TCCX) -c $(TOP)/src/pager.c
228
229os.o: $(TOP)/src/os.c $(HDR)
230 $(TCCX) -c $(TOP)/src/os.c
231
232parse.o: parse.c $(HDR)
233 $(TCCX) -c parse.c
234
235parse.h: parse.c
236
237parse.c: $(TOP)/src/parse.y lemon
238 cp $(TOP)/src/parse.y .
239 ./lemon parse.y
240
241sqlite.h: $(TOP)/src/sqlite.h.in
242 sed -e s/--VERS--/`cat ${TOP}/VERSION`/ \
243 -e s/--ENCODING--/$(ENCODING)/ \
244 $(TOP)/src/sqlite.h.in >sqlite.h
245
246tokenize.o: $(TOP)/src/tokenize.c $(HDR)
247 $(TCCX) -c $(TOP)/src/tokenize.c
248
drhdc379452002-05-15 12:45:43 +0000249trigger.o: $(TOP)/src/trigger.c $(HDR)
250 $(TCCX) -c $(TOP)/src/trigger.c
251
drh71eb93e2001-09-28 01:34:43 +0000252util.o: $(TOP)/src/util.c $(HDR)
253 $(TCCX) -c $(TOP)/src/util.c
254
255vdbe.o: $(TOP)/src/vdbe.c $(HDR)
256 $(TCCX) -c $(TOP)/src/vdbe.c
257
258where.o: $(TOP)/src/where.c $(HDR)
259 $(TCCX) -c $(TOP)/src/where.c
260
261delete.o: $(TOP)/src/delete.c $(HDR)
262 $(TCCX) -c $(TOP)/src/delete.c
263
264expr.o: $(TOP)/src/expr.c $(HDR)
265 $(TCCX) -c $(TOP)/src/expr.c
266
drhdc04c582002-02-24 01:55:15 +0000267func.o: $(TOP)/src/func.c $(HDR)
268 $(TCCX) -c $(TOP)/src/func.c
269
drh71eb93e2001-09-28 01:34:43 +0000270hash.o: $(TOP)/src/hash.c $(HDR)
271 $(TCCX) -c $(TOP)/src/hash.c
272
273insert.o: $(TOP)/src/insert.c $(HDR)
274 $(TCCX) -c $(TOP)/src/insert.c
275
276random.o: $(TOP)/src/random.c $(HDR)
277 $(TCCX) -c $(TOP)/src/random.c
278
279select.o: $(TOP)/src/select.c $(HDR)
280 $(TCCX) -c $(TOP)/src/select.c
281
282table.o: $(TOP)/src/table.c $(HDR)
283 $(TCCX) -c $(TOP)/src/table.c
284
285update.o: $(TOP)/src/update.c $(HDR)
286 $(TCCX) -c $(TOP)/src/update.c
287
288tclsqlite.o: $(TOP)/src/tclsqlite.c $(HDR)
289 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
290
291printf.o: $(TOP)/src/printf.c $(HDR)
292 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/printf.c
293
294tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.a
295 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -o tclsqlite \
296 $(TOP)/src/tclsqlite.c libsqlite.a $(LIBTCL)
297
298testfixture$(EXE): $(TOP)/src/tclsqlite.c libsqlite.a $(TESTSRC)
299 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1 -o testfixture$(EXE) \
300 $(TESTSRC) $(TOP)/src/tclsqlite.c \
301 libsqlite.a $(LIBTCL)
302
303fulltest: testfixture$(EXE) sqlite$(EXE)
304 ./testfixture$(EXE) $(TOP)/test/all.test
305
306test: testfixture$(EXE) sqlite$(EXE)
307 ./testfixture$(EXE) $(TOP)/test/quick.test
308
drh90ca9752001-09-28 17:47:14 +0000309index.html: $(TOP)/www/index.tcl last_change
drh71eb93e2001-09-28 01:34:43 +0000310 tclsh $(TOP)/www/index.tcl `cat $(TOP)/VERSION` >index.html
311
312sqlite.html: $(TOP)/www/sqlite.tcl
313 tclsh $(TOP)/www/sqlite.tcl >sqlite.html
314
315c_interface.html: $(TOP)/www/c_interface.tcl
316 tclsh $(TOP)/www/c_interface.tcl >c_interface.html
317
318changes.html: $(TOP)/www/changes.tcl
319 tclsh $(TOP)/www/changes.tcl >changes.html
320
321lang.html: $(TOP)/www/lang.tcl
322 tclsh $(TOP)/www/lang.tcl >lang.html
323
324vdbe.html: $(TOP)/www/vdbe.tcl
325 tclsh $(TOP)/www/vdbe.tcl >vdbe.html
326
327arch.html: $(TOP)/www/arch.tcl
328 tclsh $(TOP)/www/arch.tcl >arch.html
329
330arch.png: $(TOP)/www/arch.png
331 cp $(TOP)/www/arch.png .
332
333opcode.html: $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c
334 tclsh $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c >opcode.html
335
336crosscompile.html: $(TOP)/www/crosscompile.tcl
337 tclsh $(TOP)/www/crosscompile.tcl >crosscompile.html
338
339mingw.html: $(TOP)/www/mingw.tcl
340 tclsh $(TOP)/www/mingw.tcl >mingw.html
341
342tclsqlite.html: $(TOP)/www/tclsqlite.tcl
343 tclsh $(TOP)/www/tclsqlite.tcl >tclsqlite.html
344
345speed.html: $(TOP)/www/speed.tcl
346 tclsh $(TOP)/www/speed.tcl >speed.html
347
drh7a7c7392001-11-24 00:31:46 +0000348faq.html: $(TOP)/www/faq.tcl
349 tclsh $(TOP)/www/faq.tcl >faq.html
350
drhe7ec2202001-12-22 19:27:39 +0000351formatchng.html: $(TOP)/www/formatchng.tcl
352 tclsh $(TOP)/www/formatchng.tcl >formatchng.html
353
drhb419a922002-01-30 16:17:23 +0000354conflict.html: $(TOP)/www/conflict.tcl
355 tclsh $(TOP)/www/conflict.tcl >conflict.html
356
drh90ca9752001-09-28 17:47:14 +0000357download.html: $(TOP)/www/download.tcl
358 tclsh $(TOP)/www/download.tcl >download.html
359
drh71eb93e2001-09-28 01:34:43 +0000360
361# Files to be published on the website.
362#
drh90ca9752001-09-28 17:47:14 +0000363DOC = \
drh71eb93e2001-09-28 01:34:43 +0000364 index.html \
365 sqlite.html \
366 changes.html \
367 lang.html \
368 opcode.html \
369 arch.html \
370 arch.png \
371 vdbe.html \
372 c_interface.html \
373 crosscompile.html \
374 mingw.html \
375 tclsqlite.html \
drh90ca9752001-09-28 17:47:14 +0000376 download.html \
drh7a7c7392001-11-24 00:31:46 +0000377 speed.html \
drhe7ec2202001-12-22 19:27:39 +0000378 faq.html \
drhb419a922002-01-30 16:17:23 +0000379 formatchng.html \
380 conflict.html
drh71eb93e2001-09-28 01:34:43 +0000381
drh90ca9752001-09-28 17:47:14 +0000382doc: $(DOC)
383 mkdir -p doc
384 mv $(DOC) doc
drh71eb93e2001-09-28 01:34:43 +0000385
386install: sqlite libsqlite.a sqlite.h
387 mv sqlite /usr/bin
388 mv libsqlite.a /usr/lib
389 mv sqlite.h /usr/include
390
391clean:
392 rm -f *.o sqlite libsqlite.a sqlite.h
drh90ca9752001-09-28 17:47:14 +0000393 rm -f lemon lempar.c parse.* sqlite*.tar.gz
drh71eb93e2001-09-28 01:34:43 +0000394 rm -f $(PUBLISH)
395 rm -f *.da *.bb *.bbg gmon.out
396 rm -rf tsrc