]> jfr.im git - irc/quakenet/newserv.git/blobdiff - configure
BUILD: add require-all build mode
[irc/quakenet/newserv.git] / configure
index 6538c54e9eccf571cd0b6c15ec83900e46c55e83..e40f720ea2a5eef63d2a41523dac0f377e86197d 100755 (executable)
--- a/configure
+++ b/configure
@@ -7,6 +7,7 @@ import getopt
 
 LOG = None
 VERBOSE = False
+REQUIRE_ALL = False
 
 # standard line print
 def lprint(x):
@@ -24,7 +25,7 @@ def iprint(x):
   sys.stdout.write(x)
   sys.stdout.flush()
   LOG.write(x)
-  
+
 class IniParser:
   def __init__(self, file):
     self.__d = {}
@@ -68,7 +69,7 @@ class ConfigureIniParser(IniParser):
     self.buildorder = []
     self.updatemodules(self.keys("modules"))
 
-    self.selectlibs = {}    
+    self.selectlibs = {}
     for k, v in self.setdefault("selectlibs", {}).items():
       self.selectlibs[k] = v.split()
 
@@ -153,6 +154,7 @@ def librarycheck(libraries, includes, libs):
       for x in haystack:
         p = os.path.join(x, needle)
         if os.path.exists(p):
+          vprint("  found: %s" % p)
           return x
 
     found = []
@@ -325,9 +327,18 @@ def configure(config, selectoverrides, workspaces):
   lprint("configure: selected: %s" % " ".join(building))
   if len(notfound) > 0:
     lprint("configure: couldn't find: %s" % " ".join(notfound))
+    check_require_all()
 
   if len(cantbuild) > 0:
     lprint("configure: can't select: %s" % " ".join(cantbuild))
+    check_require_all()
+
+def check_require_all():
+  if REQUIRE_ALL:
+    lprint("configure: require-all selected, so failing")
+    sys.exit(1)
+
+validopts = {}
 
 def usage():
   print
@@ -336,41 +347,40 @@ def usage():
   print "  Additional options are:"
   for k, v in validopts.items():
     print "    --with-%s=[%s]" % (v[0], "|".join(v[1]))
-
-  print "    -L [additional lib dir]" 
+  print "    -L [additional lib dir]"
   print "    -I [additional include dir]"
   print "    -m [additional module]"
+  print "    -R: require everything"
   print "    -v: verbose"
 
-def main(workspacesfile):
-  global LOG, VERBOSE
+def main():
+  global LOG, VERBOSE, REQUIRE_ALL
 
-  workspacesconfig = IniParser(open(workspacesfile, "r"))
+  files, workspaces = [], []
+  for root, _, file_list in os.walk("."):
+    if "configure.ini" not in file_list:
+      continue
 
-  files = []
-  workspaces = []
+    print "found workspace: %s" % root
+    workspaces.append(root)
 
-  for workspace in ["."] + workspacesconfig["workspaces"].keys():
-    path = workspace + "/configure.ini"
-    if os.path.exists(path):
-      print "found workspace: %s" % workspace
-      workspaces.append(workspace)
-      files.append( (workspace, open(path, "r")) )
+    path = os.path.join(root, "configure.ini")
+    files.append( (root, open(path, "r")) )
 
-      local_path = workspace + "/configure.ini.local"
-      if os.path.exists(local_path):
-        files.append( (workspace, open(local_path, "r")) )
+    local_path = os.path.join(root, "configure.ini.local")
+    if os.path.exists(local_path):
+      files.append( (root, open(local_path, "r")) )
 
   config = MultiConfigureIniParser(files)
 
   mopts = []
-  validopts = {}
+
   for k, v in config.selectlibs.items():
     mopts.append("with-%s=" % k)
     validopts["--with-%s" % k] = (k, v)
 
   try:
-    opts, args = getopt.getopt(sys.argv[1:], "hvcI:L:m:", mopts)
+    opts, args = getopt.getopt(sys.argv[1:], "hvcI:L:m:R", mopts)
   except getopt.GetoptError, err:
     print str(err)
     usage()
@@ -393,6 +403,8 @@ def main(workspacesfile):
       return
     elif o == "-v":
       VERBOSE = True
+    elif o == "-R":
+      REQUIRE_ALL = True
     elif o == "-L":
       libs.append(a)
     elif o == "-I":
@@ -412,4 +424,4 @@ def main(workspacesfile):
   configure(config, overrides, workspaces)
 
 if __name__ == "__main__":
-  main("workspaces.ini")
+  main()