Makefile.template 10 KB

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