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