This patch allows the bdb headers and libs to be shared by multiple
working copies on windows.
Chris
Log:
Add a windows specific option to gen-make so that the user can specify
a path to the Berkely DB headers and libs.
* gen-make.py:
  (_usage_exit): Add --with-berkely-db option.
  (__main__): ditto.
* build/generator/gen_win.py: 
  (parse_options): Add --with-berkely-db option.
  (__init__): Search for libdb4? in the specified dir and then
  the default dirs.
  (map_rootpath): If the path is absolute then use it, else
  prepend the root path.
Index: build/generator/gen_win.py
===================================================================
--- build/generator/gen_win.py (revision 7081)
+++ build/generator/gen_win.py (working copy)
@@ -49,6 +49,7 @@
       os.unlink(src)
 
   def parse_options(self, options):
+    self.bdb_path = None
     self.httpd_path = None
     self.zlib_path = None
     self.openssl_path = None
@@ -60,7 +61,9 @@
     self.instrument_purify_quantify = None
 
     for opt, val in options:
-      if opt == '--with-httpd':
+      if opt == '--with-berkeley-db':
+        self.bdb_path = os.path.abspath(val)
+      elif opt == '--with-httpd':
         self.httpd_path = os.path.abspath(val)
         del self.skip_sections['mod_dav_svn']
         del self.skip_sections['mod_authz_svn']
@@ -100,23 +103,29 @@
     self.parse_options(options)
 
     #Find db-4.0.x or db-4.1.x
+    self.dblibname = None
+
     #We translate all slashes to windows format later on
-    db41 = self.search_for("libdb41.lib", ["db4-win32/lib"])
-    if db41:
-      sys.stderr.write("Found libdb41.lib in %s\n" % db41)
-      self.dblibname = "libdb41"
-      self.dblibpath = db41
-    else:
-      db40 = self.search_for("libdb40.lib", ["db4-win32/lib"])
-      if db40:
-        sys.stderr.write("Found libdb40.lib in %s\n" % db40)
-        self.dblibname = "libdb40"
-        self.dblibpath = db40
-      else:
-        sys.stderr.write("DB not found; assuming db-4.0.X in db4-win32 "
-                         "by default\n")
-        self.dblibname = "libdb40"
-        self.dblibpath = os.path.join("db4-win32","lib")
+    search = [("libdb41", "db4-win32/lib"),
+              ("libdb40", "db4-win32/lib")]
+
+    if self.bdb_path:
+      search = [("libdb41", self.bdb_path + "/lib"),
+                ("libdb40", self.bdb_path + "/lib")] + search
+
+    for libname, path in search:
+      libpath = self.search_for(libname + ".lib", [path])
+      if libpath:
+        sys.stderr.write("Found %s.lib in %s\n" % (libname, libpath))
+        self.dblibname = libname
+        self.dblibpath = libpath
+
+    if not self.dblibname:
+      sys.stderr.write("DB not found; assuming db-4.0.X in db4-win32 "
+                       "by default\n")
+      self.dblibname = "libdb40"
+      self.dblibpath = os.path.join("db4-win32","lib")
+
     self.dbincpath = string.replace(self.dblibpath, "lib", "include")
     self.dbbindll = "%s//%s.dll" % (string.replace(self.dblibpath,
                                                    "lib", "bin"),
@@ -213,7 +222,10 @@
 
     result = [ ]
     for item in list:
-      result.append(rootpath + '\\' + item)
+      if os.path.isabs(item):
+        result.append(item)
+      else:
+        result.append(rootpath + '\\' + item)
     return result
 
   def make_windirs(self, list):
Index: gen-make.py
===================================================================
--- gen-make.py (revision 7081)
+++ gen-make.py (working copy)
@@ -64,6 +64,10 @@
   print
   print "  Windows-specific options:"
   print
+  print "  --with-berkeley-db=DIR"
+  print "           look for Berkley DB headers and libs in"
+  print "           DIR"
+  print
   print "  --with-httpd=DIR"
   print "           the httpd sources and binaries required"
   print "           for building mod_dav_svn are in DIR"
@@ -90,7 +94,8 @@
 if __name__ == '__main__':
   try:
     opts, args = getopt.getopt(sys.argv[1:], 'st:',
-                               ['with-httpd=',
+                               ['with-berkeley-db=',
+                                'with-httpd=',
                                 'with-openssl=',
                                 'with-zlib=',
                                 'enable-pool-debug',
Received on Fri Sep 19 01:07:02 2003