1 ###############################################################################
2 # The following macros should be defined before this script is
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.
9 # BCC C Compiler and options for use in building executables that
10 # will run on the platform that is doing the build.
12 # USLEEP If the target operating system supports the "usleep()" system
13 # call, then define the HAVE_USLEEP macro for all C modules.
15 # THREADSAFE If you want the SQLite library to be safe for use within a
16 # multi-threaded program, then define the following macro
19 # THREADLIB Specify any extra linker options needed to make the library
22 # OPTS Extra compiler command-line options.
24 # EXE The suffix to add to executable files. ".exe" for windows
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.
31 # AR Tools used to build a static library.
34 # TCL_FLAGS Extra compiler options needed for programs that use the
37 # LIBTCL Linker options needed to link against the TCL library.
39 # READLINE_FLAGS Compiler options needed for programs that use the
42 # LIBREADLINE Linker options needed by programs using readline() must
45 # ENCODING "UTF8" or "ISO8859"
47 # Once the macros above are defined, the rest of this make script will
48 # build the SQLite library and testing tools.
49 ################################################################################
51 # This is how we compile
53 TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src
55 # Object files for the SQLite library.
57 LIBOBJ = attach.o auth.o btree.o btree_rb.o build.o copy.o date.o delete.o \
58 expr.o func.o hash.o insert.o \
59 main.o opcodes.o os.o pager.o parse.o pragma.o printf.o random.o \
60 select.o table.o tokenize.o trigger.o update.o util.o \
61 vacuum.o vdbe.o vdbeaux.o where.o
63 # All of the source code files.
70 $(TOP)/src/btree_rb.c \
91 $(TOP)/src/sqlite.h.in \
92 $(TOP)/src/sqliteInt.h \
94 $(TOP)/src/tokenize.c \
95 $(TOP)/src/trigger.c \
101 $(TOP)/src/vdbeaux.c \
102 $(TOP)/src/vdbeInt.h \
105 # Source code to the test files.
119 # Header files used by all library source files.
128 $(TOP)/src/sqliteInt.h \
132 # Header files used by the VDBE submodule
138 # This is the default Makefile target. The objects listed here
139 # are what get build when you type just "make" with no arguments.
141 all: sqlite.h config.h libsqlite.so sqlite$(EXE)
143 # Generate the file "last_change" which contains the date of change
144 # of the most recently modified source code file
147 cat $(SRC) | grep '$$Id: ' | sort +4 | tail -1 \
148 | awk '{print $$5,$$6}' >last_change
150 libsqlite.so: $(LIBOBJ)
151 $(CC) -shared -o libsqlite.so -Wl,-soname,libsqlite.so.0 $(LIBOBJ)
153 sqlite$(EXE): $(TOP)/src/shell.c libsqlite.so sqlite.h
154 $(TCCX) $(READLINE_FLAGS) -o sqlite$(EXE) $(TOP)/src/shell.c \
155 -lsqlite $(LIBREADLINE) $(THREADLIB)
157 sqlite_analyzer$(EXE): $(TOP)/src/tclsqlite.c libsqlite.a $(TESTSRC) \
158 $(TOP)/tool/spaceanal.tcl
165 $(TOP)/tool/spaceanal.tcl >spaceanal_tcl.h
166 $(TCCX) $(TCL_FLAGS) -DTCLSH=2 -DSQLITE_TEST=1 -static -o \
167 sqlite_analyzer$(EXE) $(TESTSRC) $(TOP)/src/tclsqlite.c \
168 libsqlite.a $(LIBTCL)
171 # This target creates a directory named "tsrc" and fills it with
172 # copies of all of the C source code and header files needed to
173 # build on the target system. Some of the C source code and header
174 # files are automatically generated. This target takes care of
175 # all that automatic generation.
177 target_source: $(SRC) $(VDBEHDR) opcodes.c
180 cp $(SRC) $(VDBEHDR) tsrc
181 rm tsrc/sqlite.h.in tsrc/parse.y
182 cp parse.c opcodes.c tsrc
184 # Rules to build the LEMON compiler generator
186 lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
187 $(BCC) -o lemon $(TOP)/tool/lemon.c
188 cp $(TOP)/tool/lempar.c .
190 btree.o: $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
191 $(TCCX) -c $(TOP)/src/btree.c
193 btree_rb.o: $(TOP)/src/btree_rb.c $(HDR)
194 $(TCCX) -c $(TOP)/src/btree_rb.c
196 build.o: $(TOP)/src/build.c $(HDR)
197 $(TCCX) -c $(TOP)/src/build.c
199 main.o: $(TOP)/src/main.c $(HDR)
200 $(TCCX) -c $(TOP)/src/main.c
202 pager.o: $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
203 $(TCCX) -c $(TOP)/src/pager.c
208 opcodes.c: $(TOP)/src/vdbe.c
209 echo '/* Automatically generated file. Do not edit */' >opcodes.c
210 echo 'char *sqliteOpcodeNames[] = { "???", ' >>opcodes.c
211 grep '^case OP_' $(TOP)/src/vdbe.c | \
212 sed -e 's/^.*OP_/ "/' -e 's/:.*$$/", /' >>opcodes.c
213 echo '};' >>opcodes.c
215 opcodes.h: $(TOP)/src/vdbe.h
216 echo '/* Automatically generated file. Do not edit */' >opcodes.h
217 grep '^case OP_' $(TOP)/src/vdbe.c | \
219 awk '{printf "#define %-30s %3d\n", $$2, ++cnt}' >>opcodes.h
221 os.o: $(TOP)/src/os.c $(HDR)
222 $(TCCX) -c $(TOP)/src/os.c
224 parse.o: parse.c $(HDR)
229 parse.c: $(TOP)/src/parse.y lemon
230 cp $(TOP)/src/parse.y .
233 # The config.h file will contain a single #define that tells us how
234 # many bytes are in a pointer. This only works if a pointer is the
235 # same size on the host as it is on the target. If you are cross-compiling
236 # to a target with a different pointer size, you'll need to manually
237 # configure the config.h file.
240 echo '#include <stdio.h>' >temp.c
241 echo 'int main(){printf(' >>temp.c
242 echo '"#define SQLITE_PTR_SZ %d",sizeof(char*));' >>temp.c
243 echo 'exit(0);}' >>temp.c
244 $(BCC) -o temp temp.c
249 sqlite.h: $(TOP)/src/sqlite.h.in
250 sed -e s/--VERS--/`cat ${TOP}/VERSION`/ \
251 -e s/--ENCODING--/$(ENCODING)/ \
252 $(TOP)/src/sqlite.h.in >sqlite.h
254 tokenize.o: $(TOP)/src/tokenize.c $(HDR)
255 $(TCCX) -c $(TOP)/src/tokenize.c
257 trigger.o: $(TOP)/src/trigger.c $(HDR)
258 $(TCCX) -c $(TOP)/src/trigger.c
260 util.o: $(TOP)/src/util.c $(HDR)
261 $(TCCX) -c $(TOP)/src/util.c
263 vacuum.o: $(TOP)/src/vacuum.c $(HDR)
264 $(TCCX) -c $(TOP)/src/vacuum.c
266 vdbe.o: $(TOP)/src/vdbe.c $(VDBEHDR)
267 $(TCCX) -c $(TOP)/src/vdbe.c
269 vdbeaux.o: $(TOP)/src/vdbeaux.c $(VDBEHDR)
270 $(TCCX) -c $(TOP)/src/vdbeaux.c
272 where.o: $(TOP)/src/where.c $(HDR)
273 $(TCCX) -c $(TOP)/src/where.c
275 copy.o: $(TOP)/src/copy.c $(HDR)
276 $(TCCX) -c $(TOP)/src/copy.c
278 date.o: $(TOP)/src/date.c $(HDR)
279 $(TCCX) -c $(TOP)/src/date.c
281 delete.o: $(TOP)/src/delete.c $(HDR)
282 $(TCCX) -c $(TOP)/src/delete.c
284 encode.o: $(TOP)/src/encode.c
285 $(TCCX) -c $(TOP)/src/encode.c
287 expr.o: $(TOP)/src/expr.c $(HDR)
288 $(TCCX) -c $(TOP)/src/expr.c
290 func.o: $(TOP)/src/func.c $(HDR)
291 $(TCCX) -c $(TOP)/src/func.c
293 hash.o: $(TOP)/src/hash.c $(HDR)
294 $(TCCX) -c $(TOP)/src/hash.c
296 insert.o: $(TOP)/src/insert.c $(HDR)
297 $(TCCX) -c $(TOP)/src/insert.c
299 random.o: $(TOP)/src/random.c $(HDR)
300 $(TCCX) -c $(TOP)/src/random.c
302 select.o: $(TOP)/src/select.c $(HDR)
303 $(TCCX) -c $(TOP)/src/select.c
305 table.o: $(TOP)/src/table.c $(HDR)
306 $(TCCX) -c $(TOP)/src/table.c
308 update.o: $(TOP)/src/update.c $(HDR)
309 $(TCCX) -c $(TOP)/src/update.c
311 tclsqlite.o: $(TOP)/src/tclsqlite.c $(HDR)
312 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
314 pragma.o: $(TOP)/src/pragma.c $(HDR)
315 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/pragma.c
317 printf.o: $(TOP)/src/printf.c $(HDR)
318 $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/printf.c
320 attach.o: $(TOP)/src/attach.c $(HDR)
321 $(TCCX) -c $(TOP)/src/attach.c
323 auth.o: $(TOP)/src/auth.c $(HDR)
324 $(TCCX) -c $(TOP)/src/auth.c
326 tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.a
327 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -o tclsqlite \
328 $(TOP)/src/tclsqlite.c libsqlite.a $(LIBTCL)
330 testfixture$(EXE): $(TOP)/src/tclsqlite.c libsqlite.a $(TESTSRC)
331 $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1 -o testfixture$(EXE) \
332 $(TESTSRC) $(TOP)/src/tclsqlite.c \
333 libsqlite.a $(LIBTCL) $(THREADLIB)
335 fulltest: testfixture$(EXE) sqlite$(EXE)
336 ./testfixture$(EXE) $(TOP)/test/all.test
338 test: testfixture$(EXE) sqlite$(EXE)
339 ./testfixture$(EXE) $(TOP)/test/quick.test
341 index.html: $(TOP)/www/index.tcl last_change
342 tclsh $(TOP)/www/index.tcl `cat $(TOP)/VERSION` >index.html
344 sqlite.html: $(TOP)/www/sqlite.tcl
345 tclsh $(TOP)/www/sqlite.tcl >sqlite.html
347 c_interface.html: $(TOP)/www/c_interface.tcl
348 tclsh $(TOP)/www/c_interface.tcl >c_interface.html
350 changes.html: $(TOP)/www/changes.tcl
351 tclsh $(TOP)/www/changes.tcl >changes.html
353 lang.html: $(TOP)/www/lang.tcl
354 tclsh $(TOP)/www/lang.tcl >lang.html
356 vdbe.html: $(TOP)/www/vdbe.tcl
357 tclsh $(TOP)/www/vdbe.tcl >vdbe.html
359 arch.html: $(TOP)/www/arch.tcl
360 tclsh $(TOP)/www/arch.tcl >arch.html
362 arch.png: $(TOP)/www/arch.png
363 cp $(TOP)/www/arch.png .
365 opcode.html: $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c
366 tclsh $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c >opcode.html
368 mingw.html: $(TOP)/www/mingw.tcl
369 tclsh $(TOP)/www/mingw.tcl >mingw.html
371 tclsqlite.html: $(TOP)/www/tclsqlite.tcl
372 tclsh $(TOP)/www/tclsqlite.tcl >tclsqlite.html
374 speed.html: $(TOP)/www/speed.tcl
375 tclsh $(TOP)/www/speed.tcl >speed.html
377 faq.html: $(TOP)/www/faq.tcl
378 tclsh $(TOP)/www/faq.tcl >faq.html
380 formatchng.html: $(TOP)/www/formatchng.tcl
381 tclsh $(TOP)/www/formatchng.tcl >formatchng.html
383 conflict.html: $(TOP)/www/conflict.tcl
384 tclsh $(TOP)/www/conflict.tcl >conflict.html
386 download.html: $(TOP)/www/download.tcl
387 tclsh $(TOP)/www/download.tcl >download.html
389 omitted.html: $(TOP)/www/omitted.tcl
390 tclsh $(TOP)/www/omitted.tcl >omitted.html
392 datatypes.html: $(TOP)/www/datatypes.tcl
393 tclsh $(TOP)/www/datatypes.tcl >datatypes.html
395 quickstart.html: $(TOP)/www/quickstart.tcl
396 tclsh $(TOP)/www/quickstart.tcl >quickstart.html
398 fileformat.html: $(TOP)/www/fileformat.tcl
399 tclsh $(TOP)/www/fileformat.tcl >fileformat.html
401 nulls.html: $(TOP)/www/nulls.tcl
402 tclsh $(TOP)/www/nulls.tcl >nulls.html
405 # Files to be published on the website.
434 install: sqlite libsqlite.a sqlite.h
436 mv libsqlite.a /usr/lib
437 mv sqlite.h /usr/include
440 rm -f *.o sqlite libsqlite.a sqlite.h opcodes.*
441 rm -f lemon lempar.c parse.* sqlite*.tar.gz
443 rm -f *.da *.bb *.bbg gmon.out