Index: Makefile.linux-gcc
===================================================================
--- Makefile.linux-gcc	2009-09-03 13:32:06.000000000 -0700
+++ Makefile.linux-gcc	2009-07-01 12:08:39.000000000 -0700
@@ -14,7 +14,7 @@
 #### The toplevel directory of the source tree.  This is the directory
 #    that contains this "Makefile.in" and the "configure.in" script.
 #
-TOP = ../sqlite
+TOP = ..
 
 #### C Compiler and options for use in building executables that
 #    will run on the platform that is doing the build.
@@ -33,13 +33,13 @@
 #    appropriately:
 #
 #THREADSAFE = -DTHREADSAFE=1
-THREADSAFE = -DTHREADSAFE=0
+THREADSAFE = -DTHREADSAFE=1
 
 #### Specify any extra linker options needed to make the library
 #    thread safe
 #
 #THREADLIB = -lpthread
-THREADLIB = 
+THREADLIB = -lpthread
 
 #### Specify any extra libraries needed to access required functions.
 #
@@ -57,8 +57,28 @@
 #OPTS = -DSQLITE_DEBUG=2
 #OPTS = -DSQLITE_DEBUG=1
 #OPTS = 
-OPTS = -DNDEBUG=1
-OPTS += -DHAVE_FDATASYNC=1
+
+# These flags match those for SQLITE_CFLAGS in config.mk.  
+
+OPTS += -DNDEBUG
+OPTS += -DSQLITE_CORE
+OPTS += -DSQLITE_ENABLE_FTS2 -DSQLITE_ENABLE_BROKEN_FTS2
+OPTS += -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600
+OPTS += -DHAVE_USLEEP=1
+
+# Additional SQLite tests.
+OPTS += -DSQLITE_MEMDEBUG=1
+
+# Don't include these ones, they break the SQLite tests.
+#  -DSQLITE_OMIT_ATTACH=1 \
+#  -DSQLITE_OMIT_LOAD_EXTENSION=1 \
+#  -DSQLITE_OMIT_VACUUM=1 \
+#  -DSQLITE_TRANSACTION_DEFAULT_IMMEDIATE=1 \
+
+SHELL_ICU = $(TOP)/src/shell_icu_linux.c -licuuc
+
+# TODO(shess) I can't see why I need this setting.
+OPTS += -DOS_UNIX=1
 
 #### The suffix to add to executable files.  ".exe" for windows.
 #    Nothing for unix.
@@ -91,16 +111,16 @@
 
 #### Extra compiler options needed for programs that use the TCL library.
 #
-#TCL_FLAGS =
+TCL_FLAGS = -I/usr/include/tcl8.5
 #TCL_FLAGS = -DSTATIC_BUILD=1
-TCL_FLAGS = -I/home/drh/tcltk/8.5linux
+#TCL_FLAGS = -I/home/drh/tcltk/8.5linux
 #TCL_FLAGS = -I/home/drh/tcltk/8.5win -DSTATIC_BUILD=1
 #TCL_FLAGS = -I/home/drh/tcltk/8.3hpux
 
 #### Linker options needed to link against the TCL library.
 #
-#LIBTCL = -ltcl -lm -ldl
-LIBTCL = /home/drh/tcltk/8.5linux/libtcl8.5g.a -lm -ldl
+LIBTCL = -ltcl8.5 -lm -ldl
+#LIBTCL = /home/drh/tcltk/8.5linux/libtcl8.5g.a -lm -ldl
 #LIBTCL = /home/drh/tcltk/8.5win/libtcl85s.a -lmsvcrt
 #LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc
 
Index: main.mk
===================================================================
--- main.mk	2009-09-10 12:18:17.000000000 -0700
+++ main.mk	2009-09-15 11:45:21.000000000 -0700
@@ -69,6 +69,12 @@
          walker.o where.o utf.o vtab.o
 
 
+LIBOBJ += fts2.o \
+	  fts2_hash.o \
+	  fts2_icu.o \
+	  fts2_porter.o \
+          fts2_tokenizer.o \
+	  fts2_tokenizer1.o
 
 # All of the source code files.
 #
@@ -243,6 +253,17 @@
   $(TOP)/src/test_thread.c \
   $(TOP)/src/test_wsd.c
 
+TESTSRC += \
+  $(TOP)/ext/fts2/fts2.c \
+  $(TOP)/ext/fts2/fts2.h \
+  $(TOP)/ext/fts2/fts2_hash.c \
+  $(TOP)/ext/fts2/fts2_hash.h \
+  $(TOP)/ext/fts2/fts2_icu.c \
+  $(TOP)/ext/fts2/fts2_porter.c \
+  $(TOP)/ext/fts2/fts2_tokenizer.h \
+  $(TOP)/ext/fts2/fts2_tokenizer.c \
+  $(TOP)/ext/fts2/fts2_tokenizer1.c
+
 #TESTSRC += $(TOP)/ext/fts2/fts2_tokenizer.c
 #TESTSRC += $(TOP)/ext/fts3/fts3_tokenizer.c
 
@@ -314,8 +343,8 @@
 
 sqlite3$(EXE):	$(TOP)/src/shell.c libsqlite3.a sqlite3.h
 	$(TCCX) $(READLINE_FLAGS) -o sqlite3$(EXE)                  \
-		$(TOP)/src/shell.c                                  \
-		libsqlite3.a $(LIBREADLINE) $(TLIBS) $(THREADLIB)
+		$(TOP)/src/shell.c $(SHELL_ICU)                     \
+		libsqlite3.a $(LIBREADLINE) $(TLIBS) $(THREADLIB) -ldl
 
 objects: $(LIBOBJ_ORIG)
 
@@ -484,6 +527,9 @@
 test:	testfixture$(EXE) sqlite3$(EXE)
 	./testfixture$(EXE) $(TOP)/test/veryquick.test
 
+fts2test:	testfixture$(EXE) sqlite3$(EXE)
+	./testfixture$(EXE) $(TOP)/test/fts2.test
+
 sqlite3_analyzer$(EXE):	$(TOP)/src/tclsqlite.c sqlite3.c $(TESTSRC) \
 			$(TOP)/tool/spaceanal.tcl
 	sed \
diff --git a/third_party/sqlite/src/test/permutations.test b/third_party/sqlite/
index 9c48d9a..283cebf 100644
--- test/permutations.test
+++ test/permutations.test
@@ -96,6 +96,7 @@ if {$::tcl_platform(platform)!="unix"} {
 set alltests [test_set $alltests -exclude {
   all.test        async.test         quick.test  veryquick.test
   memleak.test    permutations.test  soak.test   fts3.test
+  fts2.test
   mallocAll.test  rtree.test
 }]