xref: /sqlite-3.40.0/main.mk (revision 4dcbdbff)
1###############################################################################
2# The following macros should be defined before this script is
3# invoked:
4#
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.
8#
9# BCC              C Compiler and options for use in building executables that
10#                  will run on the platform that is doing the build.
11#
12# USLEEP           If the target operating system supports the "usleep()" system
13#                  call, then define the HAVE_USLEEP macro for all C modules.
14#
15# THREADSAFE       If you want the SQLite library to be safe for use within a
16#                  multi-threaded program, then define the following macro
17#                  appropriately:
18#
19# THREADLIB        Specify any extra linker options needed to make the library
20#                  thread safe
21#
22# OPTS             Extra compiler command-line options.
23#
24# EXE              The suffix to add to executable files.  ".exe" for windows
25#                  and "" for Unix.
26#
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.
30#
31# AR               Tools used to build a static library.
32# RANLIB
33#
34# TCL_FLAGS        Extra compiler options needed for programs that use the
35#                  TCL library.
36#
37# LIBTCL           Linker options needed to link against the TCL library.
38#
39# READLINE_FLAGS   Compiler options needed for programs that use the
40#                  readline() library.
41#
42# LIBREADLINE      Linker options needed by programs using readline() must
43#                  link against.
44#
45# ENCODING         "UTF8" or "ISO8859"
46#
47# Once the macros above are defined, the rest of this make script will
48# build the SQLite library and testing tools.
49################################################################################
50
51# This is how we compile
52#
53TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src
54
55# Object files for the SQLite library.
56#
57LIBOBJ+= alter.o analyze.o attach.o auth.o btree.o build.o \
58         callback.o date.o delete.o \
59         expr.o func.o hash.o insert.o \
60         main.o opcodes.o os_unix.o os_win.o \
61         pager.o parse.o pragma.o prepare.o printf.o random.o \
62         select.o table.o tclsqlite.o tokenize.o trigger.o \
63         update.o util.o vacuum.o \
64         vdbe.o vdbeapi.o vdbeaux.o vdbefifo.o vdbemem.o \
65         where.o utf.o legacy.o
66
67# All of the source code files.
68#
69SRC = \
70  $(TOP)/src/alter.c \
71  $(TOP)/src/analyze.c \
72  $(TOP)/src/attach.c \
73  $(TOP)/src/auth.c \
74  $(TOP)/src/btree.c \
75  $(TOP)/src/btree.h \
76  $(TOP)/src/build.c \
77  $(TOP)/src/callback.c \
78  $(TOP)/src/date.c \
79  $(TOP)/src/delete.c \
80  $(TOP)/src/expr.c \
81  $(TOP)/src/func.c \
82  $(TOP)/src/hash.c \
83  $(TOP)/src/hash.h \
84  $(TOP)/src/insert.c \
85  $(TOP)/src/legacy.c \
86  $(TOP)/src/main.c \
87  $(TOP)/src/os_unix.c \
88  $(TOP)/src/os_win.c \
89  $(TOP)/src/pager.c \
90  $(TOP)/src/pager.h \
91  $(TOP)/src/parse.y \
92  $(TOP)/src/pragma.c \
93  $(TOP)/src/prepare.c \
94  $(TOP)/src/printf.c \
95  $(TOP)/src/random.c \
96  $(TOP)/src/select.c \
97  $(TOP)/src/shell.c \
98  $(TOP)/src/sqlite.h.in \
99  $(TOP)/src/sqliteInt.h \
100  $(TOP)/src/table.c \
101  $(TOP)/src/tclsqlite.c \
102  $(TOP)/src/tokenize.c \
103  $(TOP)/src/trigger.c \
104  $(TOP)/src/utf.c \
105  $(TOP)/src/update.c \
106  $(TOP)/src/util.c \
107  $(TOP)/src/vacuum.c \
108  $(TOP)/src/vdbe.c \
109  $(TOP)/src/vdbe.h \
110  $(TOP)/src/vdbeapi.c \
111  $(TOP)/src/vdbeaux.c \
112  $(TOP)/src/vdbefifo.c \
113  $(TOP)/src/vdbemem.c \
114  $(TOP)/src/vdbeInt.h \
115  $(TOP)/src/where.c
116
117# Source code to the test files.
118#
119TESTSRC = \
120  $(TOP)/src/btree.c \
121  $(TOP)/src/date.c \
122  $(TOP)/src/func.c \
123  $(TOP)/src/os_unix.c \
124  $(TOP)/src/os_win.c \
125  $(TOP)/src/pager.c \
126  $(TOP)/src/pragma.c \
127  $(TOP)/src/printf.c \
128  $(TOP)/src/test1.c \
129  $(TOP)/src/test2.c \
130  $(TOP)/src/test3.c \
131  $(TOP)/src/test4.c \
132  $(TOP)/src/test5.c \
133  $(TOP)/src/utf.c \
134  $(TOP)/src/util.c \
135  $(TOP)/src/vdbe.c \
136  $(TOP)/src/md5.c \
137  $(TOP)/src/where.c
138
139# Header files used by all library source files.
140#
141HDR = \
142   sqlite3.h  \
143   $(TOP)/src/btree.h \
144   $(TOP)/src/hash.h \
145   opcodes.h \
146   $(TOP)/src/os.h \
147   $(TOP)/src/os_common.h \
148   $(TOP)/src/os_unix.h \
149   $(TOP)/src/os_win.h \
150   $(TOP)/src/sqliteInt.h  \
151   $(TOP)/src/vdbe.h \
152   parse.h
153
154# Header files used by the VDBE submodule
155#
156VDBEHDR = \
157   $(HDR) \
158   $(TOP)/src/vdbeInt.h
159
160# This is the default Makefile target.  The objects listed here
161# are what get build when you type just "make" with no arguments.
162#
163all:	sqlite3.h libsqlite3.a sqlite3$(EXE)
164
165# Generate the file "last_change" which contains the date of change
166# of the most recently modified source code file
167#
168last_change:	$(SRC)
169	cat $(SRC) | grep '$$Id: ' | sort +4 | tail -1 \
170          | awk '{print $$5,$$6}' >last_change
171
172libsqlite3.a:	$(LIBOBJ)
173	$(AR) libsqlite3.a $(LIBOBJ)
174	$(RANLIB) libsqlite3.a
175
176sqlite3$(EXE):	$(TOP)/src/shell.c libsqlite3.a sqlite3.h
177	$(TCCX) $(READLINE_FLAGS) -o sqlite3$(EXE) $(TOP)/src/shell.c \
178		libsqlite3.a $(LIBREADLINE) $(THREADLIB)
179
180objects: $(LIBOBJ_ORIG)
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) $(VDBEHDR) opcodes.c keywordhash.h
189	rm -rf tsrc
190	mkdir tsrc
191	cp $(SRC) $(VDBEHDR) tsrc
192	rm tsrc/sqlite.h.in tsrc/parse.y
193	cp parse.c opcodes.c keywordhash.h tsrc
194	cp $(TOP)/sqlite3.def tsrc
195
196# Rules to build the LEMON compiler generator
197#
198lemon:	$(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
199	$(BCC) -o lemon $(TOP)/tool/lemon.c
200	cp $(TOP)/tool/lempar.c .
201
202# Rules to build individual files
203#
204alter.o:	$(TOP)/src/alter.c $(HDR)
205	$(TCCX) -c $(TOP)/src/alter.c
206
207analyze.o:	$(TOP)/src/analyze.c $(HDR)
208	$(TCCX) -c $(TOP)/src/analyze.c
209
210attach.o:	$(TOP)/src/attach.c $(HDR)
211	$(TCCX) -c $(TOP)/src/attach.c
212
213auth.o:	$(TOP)/src/auth.c $(HDR)
214	$(TCCX) -c $(TOP)/src/auth.c
215
216btree.o:	$(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
217	$(TCCX) -c $(TOP)/src/btree.c
218
219build.o:	$(TOP)/src/build.c $(HDR)
220	$(TCCX) -c $(TOP)/src/build.c
221
222callback.o:	$(TOP)/src/callback.c $(HDR)
223	$(TCCX) -c $(TOP)/src/callback.c
224
225date.o:	$(TOP)/src/date.c $(HDR)
226	$(TCCX) -c $(TOP)/src/date.c
227
228delete.o:	$(TOP)/src/delete.c $(HDR)
229	$(TCCX) -c $(TOP)/src/delete.c
230
231expr.o:	$(TOP)/src/expr.c $(HDR)
232	$(TCCX) -c $(TOP)/src/expr.c
233
234func.o:	$(TOP)/src/func.c $(HDR)
235	$(TCCX) -c $(TOP)/src/func.c
236
237hash.o:	$(TOP)/src/hash.c $(HDR)
238	$(TCCX) -c $(TOP)/src/hash.c
239
240insert.o:	$(TOP)/src/insert.c $(HDR)
241	$(TCCX) -c $(TOP)/src/insert.c
242
243legacy.o:	$(TOP)/src/legacy.c $(HDR)
244	$(TCCX) -c $(TOP)/src/legacy.c
245
246main.o:	$(TOP)/src/main.c $(HDR)
247	$(TCCX) -c $(TOP)/src/main.c
248
249pager.o:	$(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
250	$(TCCX) -c $(TOP)/src/pager.c
251
252opcodes.o:	opcodes.c
253	$(TCCX) -c opcodes.c
254
255opcodes.c:	opcodes.h $(TOP)/mkopcodec.awk
256	sort -n -b +2 opcodes.h | awk -f $(TOP)/mkopcodec.awk >opcodes.c
257
258opcodes.h:	parse.h $(TOP)/src/vdbe.c $(TOP)/mkopcodeh.awk
259	cat parse.h $(TOP)/src/vdbe.c | awk -f $(TOP)/mkopcodeh.awk >opcodes.h
260
261os_unix.o:	$(TOP)/src/os_unix.c $(HDR)
262	$(TCCX) -c $(TOP)/src/os_unix.c
263
264os_win.o:	$(TOP)/src/os_win.c $(HDR)
265	$(TCCX) -c $(TOP)/src/os_win.c
266
267parse.o:	parse.c $(HDR)
268	$(TCCX) -c parse.c
269
270parse.h:	parse.c
271
272parse.c:	$(TOP)/src/parse.y lemon
273	cp $(TOP)/src/parse.y .
274	./lemon $(OPTS) parse.y
275
276pragma.o:	$(TOP)/src/pragma.c $(HDR)
277	$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/pragma.c
278
279prepare.o:	$(TOP)/src/prepare.c $(HDR)
280	$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/prepare.c
281
282printf.o:	$(TOP)/src/printf.c $(HDR)
283	$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/printf.c
284
285random.o:	$(TOP)/src/random.c $(HDR)
286	$(TCCX) -c $(TOP)/src/random.c
287
288select.o:	$(TOP)/src/select.c $(HDR)
289	$(TCCX) -c $(TOP)/src/select.c
290
291sqlite3.h:	$(TOP)/src/sqlite.h.in
292	sed -e s/--VERS--/`cat ${TOP}/VERSION`/ \
293	    -e s/--VERSION-NUMBER--/`cat ${TOP}/VERSION | sed 's/[^0-9]/ /g' | awk '{printf "%d%03d%03d",$$1,$$2,$$3}'`/ \
294                 $(TOP)/src/sqlite.h.in >sqlite3.h
295
296table.o:	$(TOP)/src/table.c $(HDR)
297	$(TCCX) -c $(TOP)/src/table.c
298
299tclsqlite.o:	$(TOP)/src/tclsqlite.c $(HDR)
300	$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
301
302tokenize.o:	$(TOP)/src/tokenize.c keywordhash.h $(HDR)
303	$(TCCX) -c $(TOP)/src/tokenize.c
304
305keywordhash.h:	$(TOP)/tool/mkkeywordhash.c
306	$(BCC) -o mkkeywordhash $(OPTS) $(TOP)/tool/mkkeywordhash.c
307	./mkkeywordhash >keywordhash.h
308
309trigger.o:	$(TOP)/src/trigger.c $(HDR)
310	$(TCCX) -c $(TOP)/src/trigger.c
311
312update.o:	$(TOP)/src/update.c $(HDR)
313	$(TCCX) -c $(TOP)/src/update.c
314
315utf.o:	$(TOP)/src/utf.c $(HDR)
316	$(TCCX) -c $(TOP)/src/utf.c
317
318util.o:	$(TOP)/src/util.c $(HDR)
319	$(TCCX) -c $(TOP)/src/util.c
320
321vacuum.o:	$(TOP)/src/vacuum.c $(HDR)
322	$(TCCX) -c $(TOP)/src/vacuum.c
323
324vdbe.o:	$(TOP)/src/vdbe.c $(VDBEHDR)
325	$(TCCX) -c $(TOP)/src/vdbe.c
326
327vdbeapi.o:	$(TOP)/src/vdbeapi.c $(VDBEHDR)
328	$(TCCX) -c $(TOP)/src/vdbeapi.c
329
330vdbeaux.o:	$(TOP)/src/vdbeaux.c $(VDBEHDR)
331	$(TCCX) -c $(TOP)/src/vdbeaux.c
332
333vdbefifo.o:	$(TOP)/src/vdbefifo.c $(VDBEHDR)
334	$(TCCX) -c $(TOP)/src/vdbefifo.c
335
336vdbemem.o:	$(TOP)/src/vdbemem.c $(VDBEHDR)
337	$(TCCX) -c $(TOP)/src/vdbemem.c
338
339where.o:	$(TOP)/src/where.c $(HDR)
340	$(TCCX) -c $(TOP)/src/where.c
341
342# Rules for building test programs and for running tests
343#
344tclsqlite3:	$(TOP)/src/tclsqlite.c libsqlite3.a
345	$(TCCX) $(TCL_FLAGS) -DTCLSH=1 -o tclsqlite3 \
346		$(TOP)/src/tclsqlite.c libsqlite3.a $(LIBTCL) $(THREADLIB)
347
348testfixture$(EXE):	$(TOP)/src/tclsqlite.c libsqlite3.a $(TESTSRC)
349	$(TCCX) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1 -o testfixture$(EXE) \
350		$(TESTSRC) $(TOP)/src/tclsqlite.c \
351		libsqlite3.a $(LIBTCL) $(THREADLIB)
352
353crashtest:	$(TOP)/src/tclsqlite.c libsqlite3.a $(TESTSRC) $(TOP)/src/os_test.c
354	$(TCCX) $(TCL_FLAGS) -DOS_TEST=1 -DTCLSH=1 -DSQLITE_TEST=1 \
355		-o crashtest \
356		$(TESTSRC) $(TOP)/src/os_test.c $(TOP)/src/tclsqlite.c \
357		libsqlite3.a $(LIBTCL) $(THREADLIB)
358
359fulltest:	testfixture$(EXE) sqlite3$(EXE) crashtest
360	./testfixture$(EXE) $(TOP)/test/all.test
361
362test:	testfixture$(EXE) sqlite3$(EXE)
363	./testfixture$(EXE) $(TOP)/test/quick.test
364
365sqlite3_analyzer$(EXE):	$(TOP)/src/tclsqlite.c libsqlite3.a $(TESTSRC) \
366			$(TOP)/tool/spaceanal.tcl
367	sed \
368	  -e '/^#/d' \
369	  -e 's,\\,\\\\,g' \
370	  -e 's,",\\",g' \
371	  -e 's,^,",' \
372	  -e 's,$$,\\n",' \
373	  $(TOP)/tool/spaceanal.tcl >spaceanal_tcl.h
374	$(TCCX) $(TCL_FLAGS) -DTCLSH=2 -DSQLITE_TEST=1 -o \
375 		sqlite3_analyzer$(EXE) $(TESTSRC) $(TOP)/src/tclsqlite.c \
376		libsqlite3.a $(LIBTCL) $(THREADLIB)
377
378# Rules used to build documentation
379#
380arch.html:	$(TOP)/www/arch.tcl
381	tclsh $(TOP)/www/arch.tcl >arch.html
382
383arch.png:	$(TOP)/www/arch.png
384	cp $(TOP)/www/arch.png .
385
386arch2.gif:	$(TOP)/www/arch2.gif
387	cp $(TOP)/www/arch2.gif .
388
389autoinc.html:	$(TOP)/www/autoinc.tcl
390	tclsh $(TOP)/www/autoinc.tcl >autoinc.html
391
392c_interface.html:	$(TOP)/www/c_interface.tcl
393	tclsh $(TOP)/www/c_interface.tcl >c_interface.html
394
395capi3.html:	$(TOP)/www/capi3.tcl
396	tclsh $(TOP)/www/capi3.tcl >capi3.html
397
398capi3ref.html:	$(TOP)/www/capi3ref.tcl
399	tclsh $(TOP)/www/capi3ref.tcl >capi3ref.html
400
401changes.html:	$(TOP)/www/changes.tcl
402	tclsh $(TOP)/www/changes.tcl >changes.html
403
404compile.html:	$(TOP)/www/compile.tcl
405	tclsh $(TOP)/www/compile.tcl >compile.html
406
407copyright.html:	$(TOP)/www/copyright.tcl
408	tclsh $(TOP)/www/copyright.tcl >copyright.html
409
410copyright-release.html:	$(TOP)/www/copyright-release.html
411	cp $(TOP)/www/copyright-release.html .
412
413copyright-release.pdf:	$(TOP)/www/copyright-release.pdf
414	cp $(TOP)/www/copyright-release.pdf .
415
416common.tcl:	$(TOP)/www/common.tcl
417	cp $(TOP)/www/common.tcl .
418
419conflict.html:	$(TOP)/www/conflict.tcl
420	tclsh $(TOP)/www/conflict.tcl >conflict.html
421
422datatypes.html:	$(TOP)/www/datatypes.tcl
423	tclsh $(TOP)/www/datatypes.tcl >datatypes.html
424
425datatype3.html:	$(TOP)/www/datatype3.tcl
426	tclsh $(TOP)/www/datatype3.tcl >datatype3.html
427
428different.html:	$(TOP)/www/different.tcl
429	tclsh $(TOP)/www/different.tcl >different.html
430
431docs.html:	$(TOP)/www/docs.tcl
432	tclsh $(TOP)/www/docs.tcl >docs.html
433
434download.html:	$(TOP)/www/download.tcl
435	mkdir -p doc
436	tclsh $(TOP)/www/download.tcl >download.html
437
438faq.html:	$(TOP)/www/faq.tcl
439	tclsh $(TOP)/www/faq.tcl >faq.html
440
441fileformat.html:	$(TOP)/www/fileformat.tcl
442	tclsh $(TOP)/www/fileformat.tcl >fileformat.html
443
444formatchng.html:	$(TOP)/www/formatchng.tcl
445	tclsh $(TOP)/www/formatchng.tcl >formatchng.html
446
447index.html:	$(TOP)/www/index.tcl last_change
448	tclsh $(TOP)/www/index.tcl >index.html
449
450lang.html:	$(TOP)/www/lang.tcl
451	tclsh $(TOP)/www/lang.tcl doc >lang.html
452
453pragma.html:	$(TOP)/www/pragma.tcl
454	tclsh $(TOP)/www/pragma.tcl >pragma.html
455
456lockingv3.html:	$(TOP)/www/lockingv3.tcl
457	tclsh $(TOP)/www/lockingv3.tcl >lockingv3.html
458
459oldnews.html:	$(TOP)/www/oldnews.tcl
460	tclsh $(TOP)/www/oldnews.tcl >oldnews.html
461
462omitted.html:	$(TOP)/www/omitted.tcl
463	tclsh $(TOP)/www/omitted.tcl >omitted.html
464
465opcode.html:	$(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c
466	tclsh $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c >opcode.html
467
468mingw.html:	$(TOP)/www/mingw.tcl
469	tclsh $(TOP)/www/mingw.tcl >mingw.html
470
471nulls.html:	$(TOP)/www/nulls.tcl
472	tclsh $(TOP)/www/nulls.tcl >nulls.html
473
474quickstart.html:	$(TOP)/www/quickstart.tcl
475	tclsh $(TOP)/www/quickstart.tcl >quickstart.html
476
477speed.html:	$(TOP)/www/speed.tcl
478	tclsh $(TOP)/www/speed.tcl >speed.html
479
480sqlite.gif:	$(TOP)/art/SQLite.gif
481	cp $(TOP)/art/SQLite.gif sqlite.gif
482
483sqlite.html:	$(TOP)/www/sqlite.tcl
484	tclsh $(TOP)/www/sqlite.tcl >sqlite.html
485
486support.html:	$(TOP)/www/support.tcl
487	tclsh $(TOP)/www/support.tcl >support.html
488
489tclsqlite.html:	$(TOP)/www/tclsqlite.tcl
490	tclsh $(TOP)/www/tclsqlite.tcl >tclsqlite.html
491
492vdbe.html:	$(TOP)/www/vdbe.tcl
493	tclsh $(TOP)/www/vdbe.tcl >vdbe.html
494
495version3.html:	$(TOP)/www/version3.tcl
496	tclsh $(TOP)/www/version3.tcl >version3.html
497
498whentouse.html:	$(TOP)/www/whentouse.tcl
499	tclsh $(TOP)/www/whentouse.tcl >whentouse.html
500
501
502# Files to be published on the website.
503#
504DOC = \
505  arch.html \
506  arch.png \
507  arch2.gif \
508  autoinc.html \
509  c_interface.html \
510  capi3.html \
511  capi3ref.html \
512  changes.html \
513  compile.html \
514  copyright.html \
515  copyright-release.html \
516  copyright-release.pdf \
517  conflict.html \
518  datatypes.html \
519  datatype3.html \
520  different.html \
521  docs.html \
522  download.html \
523  faq.html \
524  fileformat.html \
525  formatchng.html \
526  index.html \
527  lang.html \
528  lockingv3.html \
529  mingw.html \
530  nulls.html \
531  oldnews.html \
532  omitted.html \
533  opcode.html \
534  pragma.html \
535  quickstart.html \
536  speed.html \
537  sqlite.gif \
538  sqlite.html \
539  support.html \
540  tclsqlite.html \
541  vdbe.html \
542  version3.html \
543  whentouse.html
544
545doc:	common.tcl $(DOC)
546	mkdir -p doc
547	mv $(DOC) doc
548
549# Standard install and cleanup targets
550#
551install:	sqlite3 libsqlite3.a sqlite3.h
552	mv sqlite3 /usr/bin
553	mv libsqlite3.a /usr/lib
554	mv sqlite3.h /usr/include
555
556clean:
557	rm -f *.o sqlite3 libsqlite3.a sqlite3.h opcodes.*
558	rm -f lemon lempar.c parse.* sqlite*.tar.gz mkkeywordhash keywordhash.h
559	rm -f $(PUBLISH)
560	rm -f *.da *.bb *.bbg gmon.out
561	rm -rf tsrc
562