blob: f4fa081ad6f6827dee1272741079ab38fed86952 [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
31#### Leave MEMORY_DEBUG undefined for maximum speed. Use MEMORY_DEBUG=1
32# to check for memory leaks. Use MEMORY_DEBUG=2 to print a log of all
33# malloc()s and free()s in order to track down memory leaks.
34#
35# SQLite uses some expensive assert() statements in the inner loop.
36# You can make the library go almost twice as fast if you compile
37# with -DNDEBUG=1
38#
39#OPTS = -DMEMORY_DEBUG=2
40#OPTS = -DMEMORY_DEBUG=1
41#OPTS =
42OPTS = -DNDEBUG=1
43
44#### Compiler flags that change according to the operating system.
45#
46#OSFLAGS = -DOS_UNIX=0 -DOS_WIN=1
47OSFLAGS = -DOS_UNIX=1 -DOS_WIN=0
48
49#### The suffix to add to executable files. ".exe" for windows.
50# Nothing for unix.
51#
52#EXE = .exe
53EXE =
54
55#### C Compile and options for use in building executables that
56# will run on the target platform. This is usually the same
57# as BCC, unless you are cross-compiling.
58#
59TCC = gcc -O6
60#TCC = gcc -g -O0 -Wall
drh1bee3d72001-10-15 00:44:35 +000061#TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage
drh71eb93e2001-09-28 01:34:43 +000062#TCC = /opt/mingw/bin/i386-mingw32-gcc -O6
drh382c0242001-10-06 16:33:02 +000063#TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive
drh71eb93e2001-09-28 01:34:43 +000064
65#### Tools used to build a static library.
66#
67AR = ar cr
68#AR = /opt/mingw/bin/i386-mingw32-ar cr
69RANLIB = ranlib
70#RANLIB = /opt/mingw/bin/i386-mingw32-ranlib
71
72#### Extra compiler options needed for programs that use the TCL library.
73#
74#TCL_FLAGS =
75#TCL_FLAGS = -DSTATIC_BUILD=1
76TCL_FLAGS = -I/home/drh/tcltk/8.4linux
77#TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1
drh382c0242001-10-06 16:33:02 +000078#TCL_FLAGS = -I/home/drh/tcltk/8.3hpux
drh71eb93e2001-09-28 01:34:43 +000079
80#### Linker options needed to link against the TCL library.
81#
82#LIBTCL = -ltcl -lm -ldl
83LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl
84#LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt
drh382c0242001-10-06 16:33:02 +000085#LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc
drh71eb93e2001-09-28 01:34:43 +000086
87#### Compiler options needed for programs that use the readline() library.
88#
89#READLINE_FLAGS =
90READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline
91
92#### Linker options needed by programs using readline() must link against.
93#
94#LIBREADLINE =
drh208611f2001-12-05 00:46:02 +000095LIBREADLINE = -static -lreadline -ltermcap
drh71eb93e2001-09-28 01:34:43 +000096
97#### Should the database engine assume text is coded as UTF-8 or iso8859?
98#
99# ENCODING = UTF8
100ENCODING = ISO8859
101
102# You should not have to change anything below this line
103###############################################################################
104
105# This is how we compile
106#
107TCCX = $(TCC) $(OPTS) $(OSFLAGS) $(USLEEP) -I. -I$(TOP)/src
108
109# Object files for the SQLite library.
110#
111LIBOBJ = btree.o build.o delete.o expr.o hash.o insert.o \
112 main.o os.o pager.o parse.o printf.o random.o select.o table.o \
113 tokenize.o update.o util.o vdbe.o where.o tclsqlite.o
114
115# All of the source code files.
116#
117SRC = \
118 $(TOP)/src/btree.c \
119 $(TOP)/src/btree.h \
120 $(TOP)/src/build.c \
121 $(TOP)/src/delete.c \
122 $(TOP)/src/expr.c \
123 $(TOP)/src/hash.c \
124 $(TOP)/src/hash.h \
125 $(TOP)/src/insert.c \
126 $(TOP)/src/main.c \
127 $(TOP)/src/os.c \
128 $(TOP)/src/pager.c \
129 $(TOP)/src/pager.h \
130 $(TOP)/src/parse.y \
131 $(TOP)/src/printf.c \
132 $(TOP)/src/random.c \
133 $(TOP)/src/select.c \
134 $(TOP)/src/shell.c \
135 $(TOP)/src/sqlite.h.in \
136 $(TOP)/src/sqliteInt.h \
137 $(TOP)/src/table.c \
138 $(TOP)/src/tclsqlite.c \
139 $(TOP)/src/tokenize.c \
140 $(TOP)/src/update.c \
141 $(TOP)/src/util.c \
142 $(TOP)/src/vdbe.c \
143 $(TOP)/src/vdbe.h \
144 $(TOP)/src/where.c
145
146# Source code to the test files.
147#
148TESTSRC = \
149 $(TOP)/src/btree.c \
drh81a20f22001-10-12 17:30:04 +0000150 $(TOP)/src/os.c \
drh71eb93e2001-09-28 01:34:43 +0000151 $(TOP)/src/pager.c \
152 $(TOP)/src/test1.c \
153 $(TOP)/src/test2.c \
154 $(TOP)/src/test3.c \
155 $(TOP)/src/md5.c
156
157# Header files used by all library source files.
158#
159HDR = \
160 sqlite.h \
161 $(TOP)/src/btree.h \
162 $(TOP)/src/hash.h \
163 $(TOP)/src/os.h \
164 $(TOP)/src/sqliteInt.h \
165 $(TOP)/src/vdbe.h \
166 parse.h
167
168# This is the default Makefile target. The objects listed here
169# are what get build when you type just "make" with no arguments.
170#
171all: sqlite.h libsqlite.a sqlite$(EXE)
172
173# Generate the file "last_change" which contains the date of change
174# of the most recently modified source code file
175#
176last_change: $(SRC)
177 cat $(SRC) | grep '$$Id: ' | sort +4 | tail -1 \
178 | awk '{print $$5,$$6}' >last_change
179
180libsqlite.a: $(LIBOBJ) tclsqlite.o
181 $(AR) libsqlite.a $(LIBOBJ) tclsqlite.o
182 $(RANLIB) libsqlite.a
183
184sqlite$(EXE): $(TOP)/src/shell.c libsqlite.a sqlite.h
185 $(TCCX) $(READLINE_FLAGS) -o sqlite$(EXE) $(TOP)/src/shell.c \
186 libsqlite.a $(LIBREADLINE)
187
188# This target creates a directory named "tsrc" and fills it with
189# copies of all of the C source code and header files needed to
190# build on the target system. Some of the C source code and header
191# files are automatically generated. This target takes care of
192# all that automatic generation.
193#
194target_source: $(SRC) $(HDR)
195 rm -rf tsrc
196 mkdir tsrc
197 cp $(SRC) $(HDR) tsrc
198 rm tsrc/sqlite.h.in tsrc/parse.y
199 cp parse.c tsrc
200
201# Rules to build the LEMON compiler generator
202#
203lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
204 $(BCC) -o lemon $(TOP)/tool/lemon.c
205 cp $(TOP)/tool/lempar.c .
206
207btree.o: $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
208 $(TCCX) -c $(TOP)/src/btree.c
209
210build.o: $(TOP)/src/build.c $(HDR)
211 $(TCCX) -c $(TOP)/src/build.c
212
213main.o: $(TOP)/src/main.c $(HDR)
214 $(TCCX) -c $(TOP)/src/main.c
215
216pager.o: $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
217 $(TCCX) -c $(TOP)/src/pager.c
218
219os.o: $(TOP)/src/os.c $(HDR)
220 $(TCCX) -c $(TOP)/src/os.c
221
222parse.o: parse.c $(HDR)
223 $(TCCX) -c parse.c
224
225parse.h: parse.c
226
227parse.c: $(TOP)/src/parse.y lemon
228 cp $(TOP)/src/parse.y .
229 ./lemon parse.y
230
231sqlite.h: $(TOP)/src/sqlite.h.in
232 sed -e s/--VERS--/`cat ${TOP}/VERSION`/ \
233 -e s/--ENCODING--/$(ENCODING)/ \
234 $(TOP)/src/sqlite.h.in >sqlite.h
235
236tokenize.o: $(TOP)/src/tokenize.c $(HDR)
237 $(TCCX) -c $(TOP)/src/tokenize.c
238
239util.o: $(TOP)/src/util.c $(HDR)
240 $(TCCX) -c $(TOP)/src/util.c
241
242vdbe.o: $(TOP)/src/vdbe.c $(HDR)
243 $(TCCX) -c $(TOP)/src/vdbe.c
244
245where.o: $(TOP)/src/where.c $(HDR)
246 $(TCCX) -c $(TOP)/src/where.c
247
248delete.o: $(TOP)/src/delete.c $(HDR)
249 $(TCCX) -c $(TOP)/src/delete.c
250
251expr.o: $(TOP)/src/expr.c $(HDR)
252 $(TCCX) -c $(TOP)/src/expr.c
253
254hash.o: $(TOP)/src/hash.c $(HDR)
255 $(TCCX) -c $(TOP)/src/hash.c
256
257insert.o: $(TOP)/src/insert.c $(HDR)
258 $(TCCX) -c $(TOP)/src/insert.c
259
260random.o: $(TOP)/src/random.c $(HDR)
261 $(TCCX) -c $(TOP)/src/random.c
262
263select.o: $(TOP)/src/select.c $(HDR)
264 $(TCCX) -c $(TOP)/src/select.c
265
266table.o: $(TOP)/src/table.c $(HDR)
267 $(TCCX) -c $(TOP)/src/table.c
268
269update.o: $(TOP)/src/update.c $(HDR)
270 $(TCCX) -c $(TOP)/src/update.c
271
272tclsqlite.o: $(TOP)/src/tclsqlite.c $(HDR)
273 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
274
275printf.o: $(TOP)/src/printf.c $(HDR)
276 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/printf.c
277
278tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.a
279 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -o tclsqlite \
280 $(TOP)/src/tclsqlite.c libsqlite.a $(LIBTCL)
281
282testfixture$(EXE): $(TOP)/src/tclsqlite.c libsqlite.a $(TESTSRC)
283 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1 -o testfixture$(EXE) \
284 $(TESTSRC) $(TOP)/src/tclsqlite.c \
285 libsqlite.a $(LIBTCL)
286
287fulltest: testfixture$(EXE) sqlite$(EXE)
288 ./testfixture$(EXE) $(TOP)/test/all.test
289
290test: testfixture$(EXE) sqlite$(EXE)
291 ./testfixture$(EXE) $(TOP)/test/quick.test
292
drh90ca9752001-09-28 17:47:14 +0000293index.html: $(TOP)/www/index.tcl last_change
drh71eb93e2001-09-28 01:34:43 +0000294 tclsh $(TOP)/www/index.tcl `cat $(TOP)/VERSION` >index.html
295
296sqlite.html: $(TOP)/www/sqlite.tcl
297 tclsh $(TOP)/www/sqlite.tcl >sqlite.html
298
299c_interface.html: $(TOP)/www/c_interface.tcl
300 tclsh $(TOP)/www/c_interface.tcl >c_interface.html
301
302changes.html: $(TOP)/www/changes.tcl
303 tclsh $(TOP)/www/changes.tcl >changes.html
304
305lang.html: $(TOP)/www/lang.tcl
306 tclsh $(TOP)/www/lang.tcl >lang.html
307
308vdbe.html: $(TOP)/www/vdbe.tcl
309 tclsh $(TOP)/www/vdbe.tcl >vdbe.html
310
311arch.html: $(TOP)/www/arch.tcl
312 tclsh $(TOP)/www/arch.tcl >arch.html
313
314arch.png: $(TOP)/www/arch.png
315 cp $(TOP)/www/arch.png .
316
317opcode.html: $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c
318 tclsh $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c >opcode.html
319
320crosscompile.html: $(TOP)/www/crosscompile.tcl
321 tclsh $(TOP)/www/crosscompile.tcl >crosscompile.html
322
323mingw.html: $(TOP)/www/mingw.tcl
324 tclsh $(TOP)/www/mingw.tcl >mingw.html
325
326tclsqlite.html: $(TOP)/www/tclsqlite.tcl
327 tclsh $(TOP)/www/tclsqlite.tcl >tclsqlite.html
328
329speed.html: $(TOP)/www/speed.tcl
330 tclsh $(TOP)/www/speed.tcl >speed.html
331
drh7a7c7392001-11-24 00:31:46 +0000332faq.html: $(TOP)/www/faq.tcl
333 tclsh $(TOP)/www/faq.tcl >faq.html
334
drh90ca9752001-09-28 17:47:14 +0000335download.html: $(TOP)/www/download.tcl
336 tclsh $(TOP)/www/download.tcl >download.html
337
drh71eb93e2001-09-28 01:34:43 +0000338
339# Files to be published on the website.
340#
drh90ca9752001-09-28 17:47:14 +0000341DOC = \
drh71eb93e2001-09-28 01:34:43 +0000342 index.html \
343 sqlite.html \
344 changes.html \
345 lang.html \
346 opcode.html \
347 arch.html \
348 arch.png \
349 vdbe.html \
350 c_interface.html \
351 crosscompile.html \
352 mingw.html \
353 tclsqlite.html \
drh90ca9752001-09-28 17:47:14 +0000354 download.html \
drh7a7c7392001-11-24 00:31:46 +0000355 speed.html \
356 faq.html
drh71eb93e2001-09-28 01:34:43 +0000357
drh90ca9752001-09-28 17:47:14 +0000358doc: $(DOC)
359 mkdir -p doc
360 mv $(DOC) doc
drh71eb93e2001-09-28 01:34:43 +0000361
362install: sqlite libsqlite.a sqlite.h
363 mv sqlite /usr/bin
364 mv libsqlite.a /usr/lib
365 mv sqlite.h /usr/include
366
367clean:
368 rm -f *.o sqlite libsqlite.a sqlite.h
drh90ca9752001-09-28 17:47:14 +0000369 rm -f lemon lempar.c parse.* sqlite*.tar.gz
drh71eb93e2001-09-28 01:34:43 +0000370 rm -f $(PUBLISH)
371 rm -f *.da *.bb *.bbg gmon.out
372 rm -rf tsrc