xref: /sqlite-3.40.0/main.mk (revision ef5ecb41)
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 = attach.o auth.o btree.o build.o date.o delete.o \
58         expr.o func.o hash.o insert.o \
59         main.o opcodes.o os_mac.o os_unix.o os_win.o \
60         pager.o parse.o pragma.o printf.o random.o \
61         select.o table.o tokenize.o trigger.o update.o util.o vacuum.o \
62         vdbe.o vdbeapi.o vdbeaux.o vdbemem.o \
63         where.o utf.o legacy.o
64
65# All of the source code files.
66#
67SRC = \
68  $(TOP)/src/attach.c \
69  $(TOP)/src/auth.c \
70  $(TOP)/src/btree.c \
71  $(TOP)/src/btree.h \
72  $(TOP)/src/build.c \
73  $(TOP)/src/date.c \
74  $(TOP)/src/delete.c \
75  $(TOP)/src/encode.c \
76  $(TOP)/src/expr.c \
77  $(TOP)/src/func.c \
78  $(TOP)/src/hash.c \
79  $(TOP)/src/hash.h \
80  $(TOP)/src/insert.c \
81  $(TOP)/src/legacy.c \
82  $(TOP)/src/main.c \
83  $(TOP)/src/os_mac.c \
84  $(TOP)/src/os_unix.c \
85  $(TOP)/src/os_win.c \
86  $(TOP)/src/pager.c \
87  $(TOP)/src/pager.h \
88  $(TOP)/src/parse.y \
89  $(TOP)/src/pragma.c \
90  $(TOP)/src/printf.c \
91  $(TOP)/src/random.c \
92  $(TOP)/src/select.c \
93  $(TOP)/src/shell.c \
94  $(TOP)/src/sqlite.h.in \
95  $(TOP)/src/sqliteInt.h \
96  $(TOP)/src/table.c \
97  $(TOP)/src/tclsqlite.c \
98  $(TOP)/src/tokenize.c \
99  $(TOP)/src/trigger.c \
100  $(TOP)/src/utf.c \
101  $(TOP)/src/update.c \
102  $(TOP)/src/util.c \
103  $(TOP)/src/vacuum.c \
104  $(TOP)/src/vdbe.c \
105  $(TOP)/src/vdbe.h \
106  $(TOP)/src/vdbeapi.c \
107  $(TOP)/src/vdbeaux.c \
108  $(TOP)/src/vdbemem.c \
109  $(TOP)/src/vdbeInt.h \
110  $(TOP)/src/where.c
111
112# Source code to the test files.
113#
114TESTSRC = \
115  $(TOP)/src/btree.c \
116  $(TOP)/src/func.c \
117  $(TOP)/src/os_mac.c \
118  $(TOP)/src/os_unix.c \
119  $(TOP)/src/os_win.c \
120  $(TOP)/src/pager.c \
121  $(TOP)/src/test1.c \
122  $(TOP)/src/test2.c \
123  $(TOP)/src/test3.c \
124  $(TOP)/src/test4.c \
125  $(TOP)/src/test5.c \
126  $(TOP)/src/vdbe.c \
127  $(TOP)/src/md5.c
128
129# Header files used by all library source files.
130#
131HDR = \
132   sqlite3.h  \
133   $(TOP)/src/btree.h \
134   config.h \
135   $(TOP)/src/hash.h \
136   opcodes.h \
137   $(TOP)/src/os.h \
138   $(TOP)/src/os_common.h \
139   $(TOP)/src/os_mac.h \
140   $(TOP)/src/os_unix.h \
141   $(TOP)/src/os_win.h \
142   $(TOP)/src/sqliteInt.h  \
143   $(TOP)/src/vdbe.h \
144   parse.h
145
146# Header files used by the VDBE submodule
147#
148VDBEHDR = \
149   $(HDR) \
150   $(TOP)/src/vdbeInt.h
151
152# This is the default Makefile target.  The objects listed here
153# are what get build when you type just "make" with no arguments.
154#
155all:	sqlite3.h config.h libsqlite3.a sqlite3$(EXE)
156
157# Generate the file "last_change" which contains the date of change
158# of the most recently modified source code file
159#
160last_change:	$(SRC)
161	cat $(SRC) | grep '$$Id: ' | sort +4 | tail -1 \
162          | awk '{print $$5,$$6}' >last_change
163
164libsqlite3.a:	$(LIBOBJ)
165	$(AR) libsqlite3.a $(LIBOBJ)
166	$(RANLIB) libsqlite3.a
167
168sqlite3$(EXE):	$(TOP)/src/shell.c libsqlite3.a sqlite3.h
169	$(TCCX) $(READLINE_FLAGS) -o sqlite3$(EXE) $(TOP)/src/shell.c \
170		libsqlite3.a $(LIBREADLINE) $(THREADLIB)
171
172objects: $(LIBOBJ_ORIG)
173
174# This target creates a directory named "tsrc" and fills it with
175# copies of all of the C source code and header files needed to
176# build on the target system.  Some of the C source code and header
177# files are automatically generated.  This target takes care of
178# all that automatic generation.
179#
180target_source:	$(SRC) $(VDBEHDR) opcodes.c
181	rm -rf tsrc
182	mkdir tsrc
183	cp $(SRC) $(VDBEHDR) tsrc
184	rm tsrc/sqlite.h.in tsrc/parse.y
185	cp parse.c opcodes.c tsrc
186
187# Rules to build the LEMON compiler generator
188#
189lemon:	$(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
190	$(BCC) -o lemon $(TOP)/tool/lemon.c
191	cp $(TOP)/tool/lempar.c .
192
193# Rules to build individual files
194#
195attach.o:	$(TOP)/src/attach.c $(HDR)
196	$(TCCX) -c $(TOP)/src/attach.c
197
198auth.o:	$(TOP)/src/auth.c $(HDR)
199	$(TCCX) -c $(TOP)/src/auth.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
207# The config.h file will contain a single #define that tells us how
208# many bytes are in a pointer.  This only works if a pointer is the
209# same size on the host as it is on the target.  If you are cross-compiling
210# to a target with a different pointer size, you'll need to manually
211# configure the config.h file.
212#
213config.h:
214	echo '#include <stdio.h>' >temp.c
215	echo 'int main(){printf(' >>temp.c
216	echo '"#define SQLITE_PTR_SZ %d",sizeof(char*));' >>temp.c
217	echo 'exit(0);}' >>temp.c
218	$(BCC) -o temp temp.c
219	./temp >config.h
220	echo >>config.h
221	rm -f temp.c temp
222
223date.o:	$(TOP)/src/date.c $(HDR)
224	$(TCCX) -c $(TOP)/src/date.c
225
226delete.o:	$(TOP)/src/delete.c $(HDR)
227	$(TCCX) -c $(TOP)/src/delete.c
228
229encode.o:	$(TOP)/src/encode.c
230	$(TCCX) -c $(TOP)/src/encode.c
231
232expr.o:	$(TOP)/src/expr.c $(HDR)
233	$(TCCX) -c $(TOP)/src/expr.c
234
235func.o:	$(TOP)/src/func.c $(HDR)
236	$(TCCX) -c $(TOP)/src/func.c
237
238hash.o:	$(TOP)/src/hash.c $(HDR)
239	$(TCCX) -c $(TOP)/src/hash.c
240
241insert.o:	$(TOP)/src/insert.c $(HDR)
242	$(TCCX) -c $(TOP)/src/insert.c
243
244legacy.o:	$(TOP)/src/legacy.c $(HDR)
245	$(TCCX) -c $(TOP)/src/legacy.c
246
247main.o:	$(TOP)/src/main.c $(HDR)
248	$(TCCX) -c $(TOP)/src/main.c
249
250pager.o:	$(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
251	$(TCCX) -c $(TOP)/src/pager.c
252
253opcodes.o:	opcodes.c
254	$(TCCX) -c opcodes.c
255
256opcodes.c:	$(TOP)/src/vdbe.c
257	echo '/* Automatically generated file.  Do not edit */' >opcodes.c
258	echo 'char *sqlite3OpcodeNames[] = { "???", ' >>opcodes.c
259	grep '^case OP_' $(TOP)/src/vdbe.c | \
260	  sed -e 's/^.*OP_/  "/' -e 's/:.*$$/", /' >>opcodes.c
261	echo '};' >>opcodes.c
262
263opcodes.h:	$(TOP)/src/vdbe.h
264	echo '/* Automatically generated file.  Do not edit */' >opcodes.h
265	grep '^case OP_' $(TOP)/src/vdbe.c | \
266	  sed -e 's/://' | \
267	  awk '{printf "#define %-30s %3d\n", $$2, ++cnt}' >>opcodes.h
268
269os_mac.o:	$(TOP)/src/os_mac.c $(HDR)
270	$(TCCX) -c $(TOP)/src/os_mac.c
271
272os_unix.o:	$(TOP)/src/os_unix.c $(HDR)
273	$(TCCX) -c $(TOP)/src/os_unix.c
274
275os_win.o:	$(TOP)/src/os_win.c $(HDR)
276	$(TCCX) -c $(TOP)/src/os_win.c
277
278parse.o:	parse.c $(HDR)
279	$(TCCX) -c parse.c
280
281parse.h:	parse.c
282
283parse.c:	$(TOP)/src/parse.y lemon
284	cp $(TOP)/src/parse.y .
285	./lemon parse.y
286
287pragma.o:	$(TOP)/src/pragma.c $(HDR)
288	$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/pragma.c
289
290printf.o:	$(TOP)/src/printf.c $(HDR)
291	$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/printf.c
292
293random.o:	$(TOP)/src/random.c $(HDR)
294	$(TCCX) -c $(TOP)/src/random.c
295
296select.o:	$(TOP)/src/select.c $(HDR)
297	$(TCCX) -c $(TOP)/src/select.c
298
299sqlite3.h:	$(TOP)/src/sqlite.h.in
300	sed -e s/--VERS--/`cat ${TOP}/VERSION`/ \
301            -e s/--ENCODING--/$(ENCODING)/ \
302                 $(TOP)/src/sqlite.h.in >sqlite3.h
303
304table.o:	$(TOP)/src/table.c $(HDR)
305	$(TCCX) -c $(TOP)/src/table.c
306
307tclsqlite.o:	$(TOP)/src/tclsqlite.c $(HDR)
308	$(TCCX) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c
309
310tokenize.o:	$(TOP)/src/tokenize.c $(HDR)
311	$(TCCX) -c $(TOP)/src/tokenize.c
312
313trigger.o:	$(TOP)/src/trigger.c $(HDR)
314	$(TCCX) -c $(TOP)/src/trigger.c
315
316update.o:	$(TOP)/src/update.c $(HDR)
317	$(TCCX) -c $(TOP)/src/update.c
318
319utf.o:	$(TOP)/src/utf.c $(HDR)
320	$(TCCX) -c $(TOP)/src/utf.c
321
322util.o:	$(TOP)/src/util.c $(HDR)
323	$(TCCX) -c $(TOP)/src/util.c
324
325vacuum.o:	$(TOP)/src/vacuum.c $(HDR)
326	$(TCCX) -c $(TOP)/src/vacuum.c
327
328vdbe.o:	$(TOP)/src/vdbe.c $(VDBEHDR)
329	$(TCCX) -c $(TOP)/src/vdbe.c
330
331vdbeapi.o:	$(TOP)/src/vdbeapi.c $(VDBEHDR)
332	$(TCCX) -c $(TOP)/src/vdbeapi.c
333
334vdbeaux.o:	$(TOP)/src/vdbeaux.c $(VDBEHDR)
335	$(TCCX) -c $(TOP)/src/vdbeaux.c
336
337vdbemem.o:	$(TOP)/src/vdbemem.c $(VDBEHDR)
338	$(TCCX) -c $(TOP)/src/vdbemem.c
339
340where.o:	$(TOP)/src/where.c $(HDR)
341	$(TCCX) -c $(TOP)/src/where.c
342
343# Rules for building test programs and for running tests
344#
345tclsqlite3:	$(TOP)/src/tclsqlite.c libsqlite3.a
346	$(TCCX) $(TCL_FLAGS) -DTCLSH=1 -o tclsqlite3 \
347		$(TOP)/src/tclsqlite.c libsqlite3.a $(LIBTCL)
348
349testfixture$(EXE):	$(TOP)/src/tclsqlite.c libsqlite3.a $(TESTSRC)
350	$(TCCX) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1 -o testfixture$(EXE) \
351		$(TESTSRC) $(TOP)/src/tclsqlite.c \
352		libsqlite3.a $(LIBTCL) $(THREADLIB)
353
354fulltest:	testfixture$(EXE) sqlite3$(EXE)
355	./testfixture$(EXE) $(TOP)/test/all.test
356
357test:	testfixture$(EXE) sqlite3$(EXE)
358	./testfixture$(EXE) $(TOP)/test/quick.test
359
360# Rules used to build documentation
361#
362arch.html:	$(TOP)/www/arch.tcl
363	tclsh $(TOP)/www/arch.tcl >arch.html
364
365arch.png:	$(TOP)/www/arch.png
366	cp $(TOP)/www/arch.png .
367
368c_interface.html:	$(TOP)/www/c_interface.tcl
369	tclsh $(TOP)/www/c_interface.tcl >c_interface.html
370
371capi3.html:	$(TOP)/www/capi3.tcl
372	tclsh $(TOP)/www/capi3.tcl >capi3.html
373
374capi3ref.html:	$(TOP)/www/capi3ref.tcl
375	tclsh $(TOP)/www/capi3ref.tcl >capi3ref.html
376
377changes.html:	$(TOP)/www/changes.tcl
378	tclsh $(TOP)/www/changes.tcl >changes.html
379
380copyright.html:	$(TOP)/www/copyright.tcl
381	tclsh $(TOP)/www/copyright.tcl >copyright.html
382
383copyright-release.html:	$(TOP)/www/copyright-release.html
384	cp $(TOP)/www/copyright-release.html .
385
386copyright-release.pdf:	$(TOP)/www/copyright-release.pdf
387	cp $(TOP)/www/copyright-release.pdf .
388
389common.tcl:	$(TOP)/www/common.tcl
390	cp $(TOP)/www/common.tcl .
391
392conflict.html:	$(TOP)/www/conflict.tcl
393	tclsh $(TOP)/www/conflict.tcl >conflict.html
394
395datatypes.html:	$(TOP)/www/datatypes.tcl
396	tclsh $(TOP)/www/datatypes.tcl >datatypes.html
397
398datatype3.html:	$(TOP)/www/datatype3.tcl
399	tclsh $(TOP)/www/datatype3.tcl >datatype3.html
400
401docs.html:	$(TOP)/www/docs.tcl
402	tclsh $(TOP)/www/docs.tcl >docs.html
403
404download.html:	$(TOP)/www/download.tcl
405	tclsh $(TOP)/www/download.tcl >download.html
406
407faq.html:	$(TOP)/www/faq.tcl
408	tclsh $(TOP)/www/faq.tcl >faq.html
409
410fileformat.html:	$(TOP)/www/fileformat.tcl
411	tclsh $(TOP)/www/fileformat.tcl >fileformat.html
412
413formatchng.html:	$(TOP)/www/formatchng.tcl
414	tclsh $(TOP)/www/formatchng.tcl >formatchng.html
415
416index.html:	$(TOP)/www/index.tcl last_change
417	tclsh $(TOP)/www/index.tcl >index.html
418
419lang.html:	$(TOP)/www/lang.tcl
420	tclsh $(TOP)/www/lang.tcl >lang.html
421
422omitted.html:	$(TOP)/www/omitted.tcl
423	tclsh $(TOP)/www/omitted.tcl >omitted.html
424
425opcode.html:	$(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c
426	tclsh $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c >opcode.html
427
428mingw.html:	$(TOP)/www/mingw.tcl
429	tclsh $(TOP)/www/mingw.tcl >mingw.html
430
431nulls.html:	$(TOP)/www/nulls.tcl
432	tclsh $(TOP)/www/nulls.tcl >nulls.html
433
434quickstart.html:	$(TOP)/www/quickstart.tcl
435	tclsh $(TOP)/www/quickstart.tcl >quickstart.html
436
437speed.html:	$(TOP)/www/speed.tcl
438	tclsh $(TOP)/www/speed.tcl >speed.html
439
440sqlite.gif:	$(TOP)/art/SQLite.gif
441	cp $(TOP)/art/SQLite.gif sqlite.gif
442
443sqlite.html:	$(TOP)/www/sqlite.tcl
444	tclsh $(TOP)/www/sqlite.tcl >sqlite.html
445
446support.html:	$(TOP)/www/support.tcl
447	tclsh $(TOP)/www/support.tcl >support.html
448
449tclsqlite.html:	$(TOP)/www/tclsqlite.tcl
450	tclsh $(TOP)/www/tclsqlite.tcl >tclsqlite.html
451
452vdbe.html:	$(TOP)/www/vdbe.tcl
453	tclsh $(TOP)/www/vdbe.tcl >vdbe.html
454
455
456# Files to be published on the website.
457#
458DOC = \
459  arch.html \
460  arch.png \
461  c_interface.html \
462  capi3.html \
463  capi3ref.html \
464  changes.html \
465  copyright.html \
466  copyright-release.html \
467  copyright-release.pdf \
468  conflict.html \
469  datatypes.html \
470  datatype3.html \
471  docs.html \
472  download.html \
473  faq.html \
474  fileformat.html \
475  formatchng.html \
476  index.html \
477  lang.html \
478  mingw.html \
479  nulls.html \
480  omitted.html \
481  opcode.html \
482  quickstart.html \
483  speed.html \
484  sqlite.gif \
485  sqlite.html \
486  support.html \
487  tclsqlite.html \
488  vdbe.html
489
490doc:	common.tcl $(DOC)
491	mkdir -p doc
492	mv $(DOC) doc
493
494# Standard install and cleanup targets
495#
496install:	sqlite3 libsqlite3.a sqlite3.h
497	mv sqlite3 /usr/bin
498	mv libsqlite3.a /usr/lib
499	mv sqlite3.h /usr/include
500
501clean:
502	rm -f *.o sqlite3 libsqlite3.a sqlite3.h opcodes.*
503	rm -f lemon lempar.c parse.* sqlite*.tar.gz
504	rm -f $(PUBLISH)
505	rm -f *.da *.bb *.bbg gmon.out
506	rm -rf tsrc
507