+
+ try:
+ os.mkdir(BUILD_GCC)
+ except OSError:
+ pass # Directory exists.
+
+ os.chdir(BUILD_GCC)
+ _sh(*(configure + ["--with-linux=/lib/modules/%s/build" % uname()]))
+
+ try:
+ _sh("clang --version", check=True)
+ clang = True
+ except subprocess.CalledProcessError:
+ clang = False
+
+ try:
+ _sh("sparse --version", check=True)
+ sparse = True
+ except subprocess.CalledProcessError:
+ sparse = False
+
+ if clang:
+ try:
+ os.mkdir(BUILD_CLANG)
+ except OSError:
+ pass # Directory exists.
+
+ ENV["CC"] = "clang"
+ os.chdir(BUILD_CLANG)
+ _sh(*configure)
+
+ if sparse:
+ c1 = "C=1"
+ else:
+ c1 = ""
+
+ os.chdir(OVS_SRC)
+
+ make_str = "\t$(MAKE) -C %s $@\n"
+
+ mf = open(OVS_SRC + "/Makefile", "w")
+ mf.write("all:\n%:\n")
+ if clang:
+ mf.write(make_str % BUILD_CLANG)
+ mf.write("\t$(MAKE) -C %s %s $@\n" % (BUILD_GCC, c1))
+ mf.write("\ncheck:\n")
+ mf.write(make_str % BUILD_GCC)
+ mf.close()