blob: 351ebf8850955b2bd97af83d3d85678340e70024 [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 \
drh74587e52002-08-13 00:01:16 +0000160 $(TOP)/src/func.c \
drh81a20f22001-10-12 17:30:04 +0000161 $(TOP)/src/os.c \
drh71eb93e2001-09-28 01:34:43 +0000162 $(TOP)/src/pager.c \
163 $(TOP)/src/test1.c \
164 $(TOP)/src/test2.c \
165 $(TOP)/src/test3.c \
166 $(TOP)/src/md5.c
167
168# Header files used by all library source files.
169#
170HDR = \
171 sqlite.h \
172 $(TOP)/src/btree.h \
173 $(TOP)/src/hash.h \
174 $(TOP)/src/os.h \
175 $(TOP)/src/sqliteInt.h \
176 $(TOP)/src/vdbe.h \
177 parse.h
178
179# This is the default Makefile target. The objects listed here
180# are what get build when you type just "make" with no arguments.
181#
182all: sqlite.h libsqlite.a sqlite$(EXE)
183
184# Generate the file "last_change" which contains the date of change
185# of the most recently modified source code file
186#
187last_change: $(SRC)
188 cat $(SRC) | grep '$$Id: ' | sort +4 | tail -1 \
189 | awk '{print $$5,$$6}' >last_change
190
191libsqlite.a: $(LIBOBJ) tclsqlite.o
192 $(AR) libsqlite.a $(LIBOBJ) tclsqlite.o
193 $(RANLIB) libsqlite.a
194
195sqlite$(EXE): $(TOP)/src/shell.c libsqlite.a sqlite.h
196 $(TCCX) $(READLINE_FLAGS) -o sqlite$(EXE) $(TOP)/src/shell.c \
drha297b5c2002-01-15 18:39:43 +0000197 libsqlite.a $(LIBREADLINE) $(THREADLIB)
drh71eb93e2001-09-28 01:34:43 +0000198
199# This target creates a directory named "tsrc" and fills it with
200# copies of all of the C source code and header files needed to
201# build on the target system. Some of the C source code and header
202# files are automatically generated. This target takes care of
203# all that automatic generation.
204#
205target_source: $(SRC) $(HDR)
206 rm -rf tsrc
207 mkdir tsrc
208 cp $(SRC) $(HDR) tsrc
209 rm tsrc/sqlite.h.in tsrc/parse.y
210 cp parse.c tsrc
211
212# Rules to build the LEMON compiler generator
213#
214lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
215 $(BCC) -o lemon $(TOP)/tool/lemon.c
216 cp $(TOP)/tool/lempar.c .
217
218btree.o: $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
219 $(TCCX) -c $(TOP)/src/btree.c
220
221build.o: $(TOP)/src/build.c $(HDR)
222 $(TCCX) -c $(TOP)/src/build.c
223
224main.o: $(TOP)/src/main.c $(HDR)
225 $(TCCX) -c $(TOP)/src/main.c
226
227pager.o: $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
228 $(TCCX) -c $(TOP)/src/pager.c
229
230os.o: $(TOP)/src/os.c $(HDR)
231 $(TCCX) -c $(TOP)/src/os.c
232
233parse.o: parse.c $(HDR)
234 $(TCCX) -c parse.c
235
236parse.h: parse.c
237
238parse.c: $(TOP)/src/parse.y lemon
239 cp $(TOP)/src/parse.y .
240 ./lemon parse.y
241
242sqlite.h: $(TOP)/src/sqlite.h.in
243 sed -e s/--VERS--/`cat ${TOP}/VERSION`/ \
244 -e s/--ENCODING--/$(ENCODING)/ \
245 $(TOP)/src/sqlite.h.in >sqlite.h
246
247tokenize.o: $(TOP)/src/tokenize.c $(HDR)
248 $(TCCX) -c $(TOP)/src/tokenize.c
249
drhdc379452002-05-15 12:45:43 +0000250trigger.o: $(TOP)/src/trigger.c $(HDR)
251 $(TCCX) -c $(TOP)/src/trigger.c
252
drh71eb93e2001-09-28 01:34:43 +0000253util.o: $(TOP)/src/util.c $(HDR)
254 $(TCCX) -c $(TOP)/src/util.c
255
256vdbe.o: $(TOP)/src/vdbe.c $(HDR)
257 $(TCCX) -c $(TOP)/src/vdbe.c
258
259where.o: $(TOP)/src/where.c $(HDR)
260 $(TCCX) -c $(TOP)/src/where.c
261
262delete.o: $(TOP)/src/delete.c $(HDR)
263 $(TCCX) -c $(TOP)/src/delete.c
264
265expr.o: $(TOP)/src/expr.c $(HDR)
266 $(TCCX) -c $(TOP)/src/expr.c
267
drhdc04c582002-02-24 01:55:15 +0000268func.o: $(TOP)/src/func.c $(HDR)
269 $(TCCX) -c $(TOP)/src/func.c
270
drh71eb93e2001-09-28 01:34:43 +0000271hash.o: $(TOP)/src/hash.c $(HDR)
272 $(TCCX) -c $(TOP)/src/hash.c
273
274insert.o: $(TOP)/src/insert.c $(HDR)
275 $(TCCX) -c $(TOP)/src/insert.c
276
277random.o: $(TOP)/src/random.c $(HDR)
278 $(TCCX) -c $(TOP)/src/random.c
279
280select.o: $(TOP)/src/select.c $(HDR)
281 $(TCCX) -c $(TOP)/src/select.c
282
283table.o: $(TOP)/src/table.c $(HDR)
284 $(TCCX) -c $(TOP)/src/table.c
285
286update.o: $(TOP)/src/update.c $(HDR)
287 $(TCCX) -c $(TOP)/src/update.c
288
289tclsqlite.o: $(TOP)/src/tclsqlite.c $(HDR)
290 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
291
292printf.o: $(TOP)/src/printf.c $(HDR)
293 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/printf.c
294
295tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.a
296 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -o tclsqlite \
297 $(TOP)/src/tclsqlite.c libsqlite.a $(LIBTCL)
298
299testfixture$(EXE): $(TOP)/src/tclsqlite.c libsqlite.a $(TESTSRC)
300 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1 -o testfixture$(EXE) \
301 $(TESTSRC) $(TOP)/src/tclsqlite.c \
302 libsqlite.a $(LIBTCL)
303
304fulltest: testfixture$(EXE) sqlite$(EXE)
305 ./testfixture$(EXE) $(TOP)/test/all.test
306
307test: testfixture$(EXE) sqlite$(EXE)
308 ./testfixture$(EXE) $(TOP)/test/quick.test
309
drh90ca9752001-09-28 17:47:14 +0000310index.html: $(TOP)/www/index.tcl last_change
drh71eb93e2001-09-28 01:34:43 +0000311 tclsh $(TOP)/www/index.tcl `cat $(TOP)/VERSION` >index.html
312
313sqlite.html: $(TOP)/www/sqlite.tcl
314 tclsh $(TOP)/www/sqlite.tcl >sqlite.html
315
316c_interface.html: $(TOP)/www/c_interface.tcl
317 tclsh $(TOP)/www/c_interface.tcl >c_interface.html
318
319changes.html: $(TOP)/www/changes.tcl
320 tclsh $(TOP)/www/changes.tcl >changes.html
321
322lang.html: $(TOP)/www/lang.tcl
323 tclsh $(TOP)/www/lang.tcl >lang.html
324
325vdbe.html: $(TOP)/www/vdbe.tcl
326 tclsh $(TOP)/www/vdbe.tcl >vdbe.html
327
328arch.html: $(TOP)/www/arch.tcl
329 tclsh $(TOP)/www/arch.tcl >arch.html
330
331arch.png: $(TOP)/www/arch.png
332 cp $(TOP)/www/arch.png .
333
334opcode.html: $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c
335 tclsh $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c >opcode.html
336
337crosscompile.html: $(TOP)/www/crosscompile.tcl
338 tclsh $(TOP)/www/crosscompile.tcl >crosscompile.html
339
340mingw.html: $(TOP)/www/mingw.tcl
341 tclsh $(TOP)/www/mingw.tcl >mingw.html
342
343tclsqlite.html: $(TOP)/www/tclsqlite.tcl
344 tclsh $(TOP)/www/tclsqlite.tcl >tclsqlite.html
345
346speed.html: $(TOP)/www/speed.tcl
347 tclsh $(TOP)/www/speed.tcl >speed.html
348
drh7a7c7392001-11-24 00:31:46 +0000349faq.html: $(TOP)/www/faq.tcl
350 tclsh $(TOP)/www/faq.tcl >faq.html
351
drhe7ec2202001-12-22 19:27:39 +0000352formatchng.html: $(TOP)/www/formatchng.tcl
353 tclsh $(TOP)/www/formatchng.tcl >formatchng.html
354
drhb419a922002-01-30 16:17:23 +0000355conflict.html: $(TOP)/www/conflict.tcl
356 tclsh $(TOP)/www/conflict.tcl >conflict.html
357
drh90ca9752001-09-28 17:47:14 +0000358download.html: $(TOP)/www/download.tcl
359 tclsh $(TOP)/www/download.tcl >download.html
360
drh71eb93e2001-09-28 01:34:43 +0000361
362# Files to be published on the website.
363#
drh90ca9752001-09-28 17:47:14 +0000364DOC = \
drh71eb93e2001-09-28 01:34:43 +0000365 index.html \
366 sqlite.html \
367 changes.html \
368 lang.html \
369 opcode.html \
370 arch.html \
371 arch.png \
372 vdbe.html \
373 c_interface.html \
374 crosscompile.html \
375 mingw.html \
376 tclsqlite.html \
drh90ca9752001-09-28 17:47:14 +0000377 download.html \
drh7a7c7392001-11-24 00:31:46 +0000378 speed.html \
drhe7ec2202001-12-22 19:27:39 +0000379 faq.html \
drhb419a922002-01-30 16:17:23 +0000380 formatchng.html \
381 conflict.html
drh71eb93e2001-09-28 01:34:43 +0000382
drh90ca9752001-09-28 17:47:14 +0000383doc: $(DOC)
384 mkdir -p doc
385 mv $(DOC) doc
drh71eb93e2001-09-28 01:34:43 +0000386
387install: sqlite libsqlite.a sqlite.h
388 mv sqlite /usr/bin
389 mv libsqlite.a /usr/lib
390 mv sqlite.h /usr/include
391
392clean:
393 rm -f *.o sqlite libsqlite.a sqlite.h
drh90ca9752001-09-28 17:47:14 +0000394 rm -f lemon lempar.c parse.* sqlite*.tar.gz
drh71eb93e2001-09-28 01:34:43 +0000395 rm -f $(PUBLISH)
396 rm -f *.da *.bb *.bbg gmon.out
397 rm -rf tsrc