Index: /gs2-extensions/tdb/trunk/disable_tdb.sh
===================================================================
--- /gs2-extensions/tdb/trunk/disable_tdb.sh	(revision 30238)
+++ /gs2-extensions/tdb/trunk/disable_tdb.sh	(revision 30239)
@@ -10,64 +10,73 @@
 
 # Test that GSDLHOME is set otherwise we won't be able to find the required files
-if [ "$GSDLHOME" == "" ] ; then echo 'Error! GSDLHOME not set. Please source setup.bash before running.' ; echo ; exit 0 ; fi
+if [ "${GSDLHOME}x" == "x" ] ; then echo 'Error! GSDLHOME not set. Please source setup.bash before running.' ; echo ; exit 0 ; fi
+if [ "${GSDLOS}x" == "x" ] ; then echo 'Error! GSDLOS not set. Please source setup.bash before running.' ; echo ; exit 0 ; fi
 
+# Black magic to determine the actual name of the extension folder (in case I
+# change from tdb-edit to tdb in the future (writing in hindsight))
+EXTNAME=${PWD##*/}
 
 echo ' - removing TDB support from common function library'
 # - Makefile.in
-sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' $GSDLHOME/common-src/src/lib/Makefile.in
-sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/tdb-edit/linux/include\s*-I$(GSDL_DIR)/ext/tdb-edit/darwin/include\s*-I$(GSDL_DIR)/ext/tdb-edit/src/lib\(.*\):\1\2:' $GSDLHOME/common-src/src/lib/Makefile.in
-sed -i 's:\(EXT_SOURCES\s*=.*\)\stdbclass.cpp\(.*\):\1\2:' $GSDLHOME/common-src/src/lib/Makefile.in
-sed -i 's:\(EXT_OBJECTS\s*=.*\)\stdbclass.o\(.*\):\1\2:' $GSDLHOME/common-src/src/lib/Makefile.in
-rm -f $GSDLHOME/common-src/src/lib/Makefile
+MAKEFILE="${GSDLHOME}/common-src/src/lib/Makefile.in"
+sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' "${MAKEFILE}"
+sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include\s*-I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\(.*\):\1\2:' "${MAKEFILE}"
+sed -i 's:\(EXT_SOURCES\s*=.*\)\stdbclass.cpp\(.*\):\1\2:' "${MAKEFILE}"
+sed -i 's:\(EXT_OBJECTS\s*=.*\)\stdbclass.o\(.*\):\1\2:' "${MAKEFILE}"
+# (note - NOT Makefile.in ...)
+rm -f "${GSDLHOME}/common-src/src/lib/Makefile"
 # - Remove symlink
-rm -f $GSDLHOME/common-src/src/lib/tdbclass.h
-rm -f $GSDLHOME/common-src/src/lib/tdbclass.cpp
+rm -f "${GSDLHOME}/common-src/src/lib/tdbclass.h"
+rm -f "${GSDLHOME}/common-src/src/lib/tdbclass.cpp"
 # - Remove compiled files
-rm -f $GSDLHOME/common-src/src/lib/tdbclass.o
-rm -f $GSDLHOME/common-src/src/lib/gsdllib.a
+rm -f "${GSDLHOME}/common-src/src/lib/tdbclass.o"
+rm -f "${GSDLHOME}/common-src/src/lib/gsdllib.a"
 
 
 echo ' - removing TDB support from collection server'
 # - Makefile.in
-sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' $GSDLHOME/runtime-src/src/colservr/Makefile.in
-sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/tdb-edit/linux/include\s*-I$(GSDL_DIR)/ext/tdb-edit/darwin/include\s*-I$(GSDL_DIR)/ext/tdb-edit/src/lib\(.*\):\1\2:' $GSDLHOME/runtime-src/src/colservr/Makefile.in
-rm -f $GSDLHOME/runtime-src/src/colservr/Makefile
+MAKEFILE="${GSDLHOME}/runtime-src/src/colservr/Makefile.in"
+sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' "${MAKEFILE}"
+sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include\s*-I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\(.*\):\1\2:' "${MAKEFILE}"
+rm -f "${GSDLHOME}/runtime-src/src/colservr/Makefile"
 # - collectset.cpp
 # BUG: leaves behind the newlines...
-sed -i '/^#include "tdbclass.h" \/\/TDB/ d' $GSDLHOME/runtime-src/src/colservr/collectset.cpp
-sed -i '/^[ ]*if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} \/\/TDB/ d' $GSDLHOME/runtime-src/src/colservr/collectset.cpp
-sed -i '/^[ ]*if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} \/\/TDBServer/ d' $GSDLHOME/runtime-src/src/colservr/collectset.cpp
+SRCFILE="${GSDLHOME}/runtime-src/src/colservr/collectset.cpp"
+sed -i '/^#include "tdbclass.h" \/\/TDB/ d' "${SRCFILE}"
+sed -i '/^[ ]*if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} \/\/TDB/ d' "${SRCFILE}"
+sed -i '/^[ ]*if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} \/\/TDBServer/ d' "${SRCFILE}"
 # - collectserver.cpp
-sed -i '/^if (infodbtype == "tdb") { } \/\/ TDB Do nothing/ d' $GSDLHOME/runtime-src/src/colservr/collectset.cpp
-sed -i '/^if (infodbtype == "tdbserver") { } \/\/ TDBServer Do nothing/ d' $GSDLHOME/runtime-src/src/colservr/collectset.cpp
+SRCFILE="${GSDLHOME}/runtime-src/src/colservr/collectserver.cpp"
+sed -i '/^if (infodbtype == "tdb") { } \/\/ TDB Do nothing/ d' "${SRCFILE}"
+sed -i '/^if (infodbtype == "tdbserver") { } \/\/ TDBServer Do nothing/ d' "${SRCFILE}"
 # - Remove compiled files
-rm -f $GSDLHOME/runtime-src/src/colservr/gsdlcolservr.a
-
-
+rm -f "${GSDLHOME}/runtime-src/src/colservr/gsdlcolservr.a"
 
 
 echo ' - removing TDB support from Greenstone receptionist'
 # - Makefile.in
-sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' $GSDLHOME/runtime-src/src/recpt/Makefile.in
-sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/tdb-edit/linux/include\s*-I$(GSDL_DIR)/ext/tdb-edit/darwin/include\s*-I$(GSDL_DIR)/ext/tdb-edit/src/lib\(.*\):\1\2:' $GSDLHOME/runtime-src/src/recpt/Makefile.in
-sed -i 's:\(EXT_LDFLAGS\s*=.*\)\s-L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib\(.*\):\1\2:' $GSDLHOME/runtime-src/src/recpt/Makefile.in
-sed -i 's:\(EXT_LIBS\s*=.*\)\s-ltdb\(.*\):\1\2:' $GSDLHOME/runtime-src/src/recpt/Makefile.in
-rm -f $GSDLHOME/runtime-src/src/recpt/Makefile
+MAKEFILE="${GSDLHOME}/runtime-src/src/recpt/Makefile.in"
+sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' "${MAKEFILE}"
+sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include\s*-I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\(.*\):\1\2:' "${MAKEFILE}"
+sed -i 's:\(EXT_LDFLAGS\s*=.*\)\s-L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib\(.*\):\1\2:' "${MAKEFILE}"
+sed -i 's:\(EXT_LIBS\s*=.*\)\s-ltdb\(.*\):\1\2:' "${MAKEFILE}"
+rm -f "${GSDLHOME}/runtime-src/src/recpt/Makefile"
 # - Remove compiled files
-rm -f $GSDLHOME/runtime-src/src/recpt/gsdlrecpt.a
-rm -f $GSDLHOME/runtime-src/src/recpt/library.cgi
-rm -f $GSDLHOME/cgi-bin/library.cgi
+rm -f "${GSDLHOME}/runtime-src/src/recpt/gsdlrecpt.a"
+rm -f "${GSDLHOME}/runtime-src/src/recpt/library.cgi"
+rm -f "${GSDLHOME}/cgi-bin/library.cgi"
 
 
 echo ' - removing TDB support from OAI Server receptionist'
 # - Makefile.in
-sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in
-sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/tdb-edit/linux/include\s*-I$(GSDL_DIR)/ext/tdb-edit/darwin/include\s*-I$(GSDL_DIR)/ext/tdb-edit/src/lib\(.*\):\1\2:' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in
-sed -i 's:\(EXT_LDFLAGS\s*=.*\)\s-L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib\(.*\):\1\2:' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in
-sed -i 's:\(EXT_LIBS\s*=.*\)\s-ltdb\(.*\):\1\2:' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in
-rm -f $GSDLHOME/runtime-src/src/oaiservr/Makefile
+MAKEFILE="${GSDLHOME}/runtime-src/src/oaiservr/Makefile.in"
+sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' "${MAKEFILE}"
+sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include\s*-I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\(.*\):\1\2:' "${MAKEFILE}"
+sed -i 's:\(EXT_LDFLAGS\s*=.*\)\s-L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib\(.*\):\1\2:' "${MAKEFILE}"
+sed -i 's:\(EXT_LIBS\s*=.*\)\s-ltdb\(.*\):\1\2:' "${MAKEFILE}"
+rm -f "${GSDLHOME}/runtime-src/src/oaiservr/Makefile"
 # - Remove compiled files
-rm -f $GSDLHOME/runtime-src/src/oaiservr/oaiserver.cgi
-rm -f $GSDLHOME/cgi-bin/oaiserver.cgi
+rm -f "${GSDLHOME}/runtime-src/src/oaiservr/oaiserver.cgi"
+rm -f "${GSDLHOME}/cgi-bin/oaiserver.cgi"
 
 echo
@@ -84,4 +93,8 @@
 echo 'to complete TDB removal.'
 echo
+echo 'Should you later wish to restore TDB support rerun:'
+echo
+echo ' ./enable_tdb.sh'
+echo
 echo '====================================================='
 echo
Index: /gs2-extensions/tdb/trunk/enable_tdb.sh
===================================================================
--- /gs2-extensions/tdb/trunk/enable_tdb.sh	(revision 30238)
+++ /gs2-extensions/tdb/trunk/enable_tdb.sh	(revision 30239)
@@ -10,39 +10,44 @@
 
 # Test that GSDLHOME is set otherwise we won't be able to find the required files
-if [ "$GSDLHOME" == "" ] ; then echo 'Error! GSDLHOME not set. Please source setup.bash before running.' ; echo ; exit 0 ; fi
+if [ "${GSDLHOME}x" == "x" ] ; then echo 'Error! GSDLHOME not set. Please source setup.bash before running.' ; echo ; exit 0 ; fi
+if [ "${GSDLOS}x" == "x" ] ; then echo 'Error! GSDLOS not set. Please source setup.bash before running.' ; echo ; exit 0 ; fi
+
+# Black magic to determine the actual name of the extension folder (in case I
+# change from tdb-edit to tdb in the future (writing in hindsight))
+EXTNAME=${PWD##*/}
 
 echo ' - enabling TDB support in common function library'
 # - Symlink the source file into place
-ln -f -s $GSDLHOME/ext/tdb-edit/src/lib/tdbclass.h $GSDLHOME/common-src/src/lib/tdbclass.h
-ln -f -s $GSDLHOME/ext/tdb-edit/src/lib/tdbclass.cpp $GSDLHOME/common-src/src/lib/tdbclass.cpp
-# - Makefile.in
-MAKEFILE=$GSDLHOME/common-src/src/lib/Makefile.in
+ln -f -s "${GSDLHOME}/ext/${EXTNAME}/src/lib/tdbclass.h" "${GSDLHOME}/common-src/src/lib/tdbclass.h"
+ln -f -s "${GSDLHOME}/ext/${EXTNAME}/src/lib/tdbclass.cpp" "${GSDLHOME}/common-src/src/lib/tdbclass.cpp"
+# - Makefile.in
+MAKEFILE="${GSDLHOME}/common-src/src/lib/Makefile.in"
 # - I have no idea why this is commented out in the Makefile
-sed -i 's:#GSDL_DIR = ../../..:GSDL_DIR = ../../..:' ${MAKEFILE}
-grep -q 'DUSE_TDB' ${MAKEFILE}
+sed -i 's:#GSDL_DIR = ../../..:GSDL_DIR = ../../..:' "${MAKEFILE}"
+grep -q 'DUSE_TDB' "${MAKEFILE}"
 if [ $? -eq 1 ]
 then
   # - Test for extension support in the makefile
-  grep -q 'EXT_DEFINES' ${MAKEFILE}
+  grep -q 'EXT_DEFINES' "${MAKEFILE}"
   if [ $? -eq 1 ]
   then
     # - No Extension variables yet - add them in with TDB parts
-    sed -i 's:AR = ar:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib\nEXT_SOURCES = tdbclass.cpp\nEXT_OBJECTS = tdbclass.o\n\n&:' ${MAKEFILE}
-    sed -i 's:DEFS = @DEFS@ .*:& $(EXT_DEFINES):' ${MAKEFILE}
-    sed -i 's:INCLUDES = -I. .*:& $(EXT_INCLUDES):' ${MAKEFILE}
-    sed -i 's:unitool.cpp:& \\\n        $(EXT_SOURCES):' ${MAKEFILE}
-    sed -i 's:unitool.o:& \\\n        $(EXT_OBJECTS):' ${MAKEFILE}
+    sed -i 's:AR = ar:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\nEXT_SOURCES = tdbclass.cpp\nEXT_OBJECTS = tdbclass.o\n\n&:' "${MAKEFILE}"
+    sed -i 's:DEFS = @DEFS@ .*:& $(EXT_DEFINES):' "${MAKEFILE}"
+    sed -i 's:INCLUDES = -I. .*:& $(EXT_INCLUDES):' "${MAKEFILE}"
+    sed -i 's:unitool.cpp:& \\\n        $(EXT_SOURCES):' "${MAKEFILE}"
+    sed -i 's:unitool.o:& \\\n        $(EXT_OBJECTS):' "${MAKEFILE}"
   else
     # - Extension support already present - add TDB parts
-    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' ${MAKEFILE}
-    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib:' ${MAKEFILE}
-    sed -i 's:EXT_SOURCES =.*:& tdbclass.cpp:' ${MAKEFILE}
-    sed -i 's:EXT_OBJECTS =.*:& tdbclass.o:' ${MAKEFILE}
-  fi
-fi
-grep -q 'DUSE_TDB' ${MAKEFILE}
-if [ $? -eq 1 ]
-then
-  echo Error! Update of ${MAKEFILE} failed.
+    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' "${MAKEFILE}"
+    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib:' "${MAKEFILE}"
+    sed -i 's:EXT_SOURCES =.*:& tdbclass.cpp:' "${MAKEFILE}"
+    sed -i 's:EXT_OBJECTS =.*:& tdbclass.o:' "${MAKEFILE}"
+  fi
+fi
+grep -q 'DUSE_TDB' "${MAKEFILE}"
+if [ $? -eq 1 ]
+then
+  echo "Error! Update of ${MAKEFILE} failed."
   exit
 fi
@@ -50,46 +55,46 @@
 echo ' - enabling TDB support in collection server'
 # - Makefile.in
-MAKEFILE=$GSDLHOME/runtime-src/src/colservr/Makefile.in
-grep -q 'DUSE_TDB' ${MAKEFILE}
+MAKEFILE="${GSDLHOME}/runtime-src/src/colservr/Makefile.in"
+grep -q 'DUSE_TDB' "${MAKEFILE}"
 if [ $? -eq 1 ]
 then
   # - Test for extension support in the makefile
-  grep -q 'EXT_DEFINES' ${MAKEFILE}
-  if [ $? -eq 1 ]
-  then
-    sed -i 's:AR = ar:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib\n\n&:' ${MAKEFILE}
-    sed -i 's:DEFS = @DEFS@:& $(EXT_DEFINES):' ${MAKEFILE}
-    sed -i 's:INCLUDES = -I. -I$(GSDL_DIR):& $(EXT_INCLUDES):' ${MAKEFILE}
-  else
-    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' ${MAKEFILE}
-    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib:' ${MAKEFILE}
-  fi
-fi
-grep -q 'DUSE_TDB' ${MAKEFILE}
-if [ $? -eq 1 ]
-then
-  echo Error! Update of ${MAKEFILE} failed.
+  grep -q 'EXT_DEFINES' "${MAKEFILE}"
+  if [ $? -eq 1 ]
+  then
+    sed -i 's:AR = ar:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\n\n&:' "${MAKEFILE}"
+    sed -i 's:DEFS = @DEFS@:& $(EXT_DEFINES):' "${MAKEFILE}"
+    sed -i 's:INCLUDES = -I. -I$(GSDL_DIR):& $(EXT_INCLUDES):' "${MAKEFILE}"
+  else
+    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' "${MAKEFILE}"
+    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib:' "${MAKEFILE}"
+  fi
+fi
+grep -q 'DUSE_TDB' "${MAKEFILE}"
+if [ $? -eq 1 ]
+then
+  echo "Error! Update of ${MAKEFILE} failed."
   exit
 fi
 
 # - collectset.cpp
-SRCFILE=$GSDLHOME/runtime-src/src/colservr/collectset.cpp
-grep -q 'tdbclass.h' ${SRCFILE}
-if [ $? -eq 1 ]
-then
-  grep -q '@EXTENSION HEADERS@' ${SRCFILE}
-  if [ $? -eq 1 ]
-  then
-    sed -i 's:collectset\:\:collectset (text_t& gsdlhome, text_t& collecthome):// @EXTENSION HEADERS@\n#include "tdbclass.h //TDB\n\n&:' ${SRCFILE}
-    sed -i 's:    // Use GDBM if the infodb type is empty or not one of the values above:    // @EXTENSION DATASOURCES@\n    if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} //TDB\n    if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} //TDBServer\n\n&:' ${SRCFILE}
-  else
-    sed -i 's:// @EXTENSION HEADERS@:&\n#include "tdbclass.h" //TDB:' ${SRCFILE}
-    sed -i 's:// @EXTENSION DATASOURCES@:&\n    if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} //TDB\n    if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} //TDBServer:' ${SRCFILE}
-  fi
-fi
-grep -q 'tdbclass.h' ${SRCFILE}
-if [ $? -eq 1 ]
-then
-  echo Error! Update of ${SRCFILE} failed.
+SRCFILE="${GSDLHOME}/runtime-src/src/colservr/collectset.cpp"
+grep -q 'tdbclass.h' "${SRCFILE}"
+if [ $? -eq 1 ]
+then
+  grep -q '@EXTENSION HEADERS@' "${SRCFILE}"
+  if [ $? -eq 1 ]
+  then
+    sed -i 's:collectset\:\:collectset (text_t& gsdlhome, text_t& collecthome):// @EXTENSION HEADERS@\n#include "tdbclass.h //TDB\n\n&:' "${SRCFILE}"
+    sed -i 's:    // Use GDBM if the infodb type is empty or not one of the values above:    // @EXTENSION DATASOURCES@\n    if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} //TDB\n    if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} //TDBServer\n\n&:' "${SRCFILE}"
+  else
+    sed -i 's:// @EXTENSION HEADERS@:&\n#include "tdbclass.h" //TDB:' "${SRCFILE}"
+    sed -i 's:// @EXTENSION DATASOURCES@:&\n    if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} //TDB\n    if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} //TDBServer:' "${SRCFILE}"
+  fi
+fi
+grep -q 'tdbclass.h' "${SRCFILE}"
+if [ $? -eq 1 ]
+then
+  echo "Error! Update of ${SRCFILE} failed."
   exit
 fi
@@ -99,20 +104,20 @@
 # infodbtype are compiled into colservr. While not fatal to leave this as is,
 # it does cause vast amounts of error messages in (Apache) logs
-SRCFILE=$GSDLHOME/runtime-src/src/colservr/collectserver.cpp
-grep -q 'TDB' ${SRCFILE}
-if [ $? -eq 1 ]
-then
-  grep -q '@EXTENSION DATASOURCES@' ${SRCFILE}
-  if [ $? -eq 1 ]
-  then
-    sed -i 's:  if (infodbtype=="gdbm") {:  // @EXTENSION DATASOURCES@\n  if (infodbtype == "tdb") { return; } // TDB Do nothing\n  if (infodbtype == "tdbserver") { return; } // TDBServer Do nothing\n\n&:' ${SRCFILE}
-  else
-    sed -i 's:  // @EXTENSION DATASOURCES@:&\n  if (infodbtype == "tdb") { return; } // TDB Do nothing\n  if (infodbtype == "tdbserver") { return; } // TDBServer Do nothing:' ${SRCFILE}
-  fi
-fi
-grep -q 'TDB' ${SRCFILE}
-if [ $? -eq 1 ]
-then
-  echo Error! Update of ${SRCFILE} failed.
+SRCFILE="${GSDLHOME}/runtime-src/src/colservr/collectserver.cpp"
+grep -q 'TDB' "${SRCFILE}"
+if [ $? -eq 1 ]
+then
+  grep -q '@EXTENSION DATASOURCES@' "${SRCFILE}"
+  if [ $? -eq 1 ]
+  then
+    sed -i 's:  if (infodbtype=="gdbm") {:  // @EXTENSION DATASOURCES@\n  if (infodbtype == "tdb") { return; } // TDB Do nothing\n  if (infodbtype == "tdbserver") { return; } // TDBServer Do nothing\n\n&:' "${SRCFILE}"
+  else
+    sed -i 's:  // @EXTENSION DATASOURCES@:&\n  if (infodbtype == "tdb") { return; } // TDB Do nothing\n  if (infodbtype == "tdbserver") { return; } // TDBServer Do nothing:' "${SRCFILE}"
+  fi
+fi
+grep -q 'TDB' "${SRCFILE}"
+if [ $? -eq 1 ]
+then
+  echo "Error! Update of ${SRCFILE} failed."
   exit
 fi
@@ -120,27 +125,27 @@
 echo ' - enabling TDB support in Greenstone receptionist'
 # - Makefile.in
-MAKEFILE=$GSDLHOME/runtime-src/src/recpt/Makefile.in
-grep -q 'DUSE_TDB' ${MAKEFILE}
-if [ $? -eq 1 ]
-then
-  grep -q 'EXT_DEFINES' ${MAKEFILE}
-  if [ $? -eq 1 ]
-  then
-    sed -i 's:AR = ar:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib\nEXT_LDFLAGS = -L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib\nEXT_LIBS = -ltdb\n\n&:' ${MAKEFILE}
-    sed -i 's:DEFS = @DEFS@ -DNZDL -DQUIET -DSHORT_SUFFIX -DPARADOCNUM -DHAVE_CONFIG_H:& $(EXT_DEFINES):' ${MAKEFILE}
-    sed -i 's:INCLUDES = -I. -I$(GSDL_DIR):& $(EXT_INCLUDES):' ${MAKEFILE}
-    sed -i 's:LDFLAGS = @LDFLAGS@ @ARCH_DEP_FLAGS@:& $(EXT_LDFLAGS):' ${MAKEFILE}
-    sed -i 's:LIBS = @LIBS@ $(GDBM_LIBS):& $(EXT_LIBS):' ${MAKEFILE}
-  else
-    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' ${MAKEFILE}
-    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib:' ${MAKEFILE}
-    sed -i 's:EXT_LDFLAGS =.*:& -L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib:' ${MAKEFILE}
-    sed -i 's:EXT_LIBS =.*:& -ltdb:' ${MAKEFILE}
-  fi
-fi
-grep -q 'DUSE_TDB' ${MAKEFILE}
-if [ $? -eq 1 ]
-then
-  echo Error! Update of ${MAKEFILE} failed.
+MAKEFILE="${GSDLHOME}/runtime-src/src/recpt/Makefile.in"
+grep -q 'DUSE_TDB' "${MAKEFILE}"
+if [ $? -eq 1 ]
+then
+  grep -q 'EXT_DEFINES' "${MAKEFILE}"
+  if [ $? -eq 1 ]
+  then
+    sed -i 's:AR = ar:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\nEXT_LDFLAGS = -L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib\nEXT_LIBS = -ltdb\n\n&:' "${MAKEFILE}"
+    sed -i 's:DEFS = @DEFS@ -DNZDL -DQUIET -DSHORT_SUFFIX -DPARADOCNUM -DHAVE_CONFIG_H:& $(EXT_DEFINES):' "${MAKEFILE}"
+    sed -i 's:INCLUDES = -I. -I$(GSDL_DIR):& $(EXT_INCLUDES):' "${MAKEFILE}"
+    sed -i 's:LDFLAGS = @LDFLAGS@ @ARCH_DEP_FLAGS@:& $(EXT_LDFLAGS):' "${MAKEFILE}"
+    sed -i 's:LIBS = @LIBS@ $(GDBM_LIBS):& $(EXT_LIBS):' "${MAKEFILE}"
+  else
+    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' "${MAKEFILE}"
+    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib:' "${MAKEFILE}"
+    sed -i 's:EXT_LDFLAGS =.*:& -L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib:' "${MAKEFILE}"
+    sed -i 's:EXT_LIBS =.*:& -ltdb:' "${MAKEFILE}"
+  fi
+fi
+grep -q 'DUSE_TDB' "${MAKEFILE}"
+if [ $? -eq 1 ]
+then
+  echo "Error! Update of ${MAKEFILE} failed."
 fi
 
@@ -148,27 +153,27 @@
 echo ' - enabling TDB support in OAI Server receptionist'
 # - Makefile.in
-MAKEFILE=$GSDLHOME/runtime-src/src/oaiservr/Makefile.in
-grep -q 'DUSE_TDB' ${MAKEFILE}
-if [ $? -eq 1 ]
-then
-  grep -q 'EXT_DEFINES' ${MAKEFILE}
-  if [ $? -eq 1 ]
-  then
-    sed -i 's:CC = @CC@:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib\nEXT_LDFLAGS = -L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib\nEXT_LIBS = -ltdb\n\n&:' ${MAKEFILE}
-    sed -i 's:DEFS = @DEFS@:& $(EXT_DEFINES):' ${MAKEFILE}
-    sed -i 's:INCLUDES = -I$(COMMON_DIR)/src/lib:& $(EXT_INCLUDES):' ${MAKEFILE}
-    sed -i 's:LDFLAGS = @LDFLAGS@ @ARCH_DEP_FLAGS@:& $(EXT_LDFLAGS):' ${MAKEFILE}
-    sed -i 's:LIBS = @LIBS@ $(GDBM_LIBS):& $(EXT_LIBS):' ${MAKEFILE}
-  else
-    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' ${MAKEFILE}
-    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib:' ${MAKEFILE}
-    sed -i 's:EXT_LDFLAGS =.*:& -L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib:' ${MAKEFILE}
-    sed -i 's:EXT_LIBS =.*:& -ltdb:' ${MAKEFILE}
-  fi
-fi
-grep -q 'DUSE_TDB' ${MAKEFILE}
-if [ $? -eq 1 ]
-then
-  echo Error! Update of ${MAKEFILE} failed.
+MAKEFILE="${GSDLHOME}/runtime-src/src/oaiservr/Makefile.in"
+grep -q 'DUSE_TDB' "${MAKEFILE}"
+if [ $? -eq 1 ]
+then
+  grep -q 'EXT_DEFINES' "${MAKEFILE}"
+  if [ $? -eq 1 ]
+  then
+    sed -i 's:CC = @CC@:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\nEXT_LDFLAGS = -L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib\nEXT_LIBS = -ltdb\n\n&:' "${MAKEFILE}"
+    sed -i 's:DEFS = @DEFS@:& $(EXT_DEFINES):' "${MAKEFILE}"
+    sed -i 's:INCLUDES = -I$(COMMON_DIR)/src/lib:& $(EXT_INCLUDES):' "${MAKEFILE}"
+    sed -i 's:LDFLAGS = @LDFLAGS@ @ARCH_DEP_FLAGS@:& $(EXT_LDFLAGS):' "${MAKEFILE}"
+    sed -i 's:LIBS = @LIBS@ $(GDBM_LIBS):& $(EXT_LIBS):' "${MAKEFILE}"
+  else
+    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' "${MAKEFILE}"
+    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib:' "${MAKEFILE}"
+    sed -i 's:EXT_LDFLAGS =.*:& -L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib:' "${MAKEFILE}"
+    sed -i 's:EXT_LIBS =.*:& -ltdb:' "${MAKEFILE}"
+  fi
+fi
+grep -q 'DUSE_TDB' "${MAKEFILE}"
+if [ $? -eq 1 ]
+then
+  echo "Error! Update of ${MAKEFILE} failed."
 fi
 
@@ -186,4 +191,8 @@
 echo 'to complete TDB installation.'
 echo
+echo 'Should you later wish to remove TDB support run:'
+echo
+echo ' ./disable_tdb.sh'
+echo
 echo '===================================================='
 echo
