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