diff options
Diffstat (limited to 'BuildTools/SCons/SConstruct')
-rw-r--r-- | BuildTools/SCons/SConstruct | 100 |
1 files changed, 71 insertions, 29 deletions
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct index 25a1ad3..7bda9c1 100644 --- a/BuildTools/SCons/SConstruct +++ b/BuildTools/SCons/SConstruct @@ -5,19 +5,19 @@ Import("env", "conf_env") root = Dir("../..").abspath # Override SConscript to handle tests oldSConscript = SConscript def SConscript(*arguments, **keywords) : if not keywords.get("test_only", False) or env["TEST"] : return apply(oldSConscript, arguments, keywords) env.SConscript = SConscript - + ################################################################################ # Extend the default build environment (not affecting the configure env) # # Keeping both environments separated mostly because of SCons Issue 2391, # although it doesn't hurt to separate them (e.g. not have pretty printed # strings in config.log) ################################################################################ #if env["PLATFORM"] == "win32" : @@ -105,20 +105,39 @@ int main(int argc, char* argv[]) { conf = Configure(conf_env) if not conf.CheckCXX() or not conf.CheckCC() : print "Error: You need a working compiler" Exit(1) env["HAVE_ZLIB"] = True -if conf.CheckLib("z") : - env["ZLIB_FLAGS"] = {"LIBS": ["z"]} +zlib_flags = {} +zlib_okay = False +if env.get("zlib_libdir", None) : + zlib_flags["LIBPATH"] = [env["zlib_libdir"]] + zlib_okay = True +if env.get("zlib_includedir", None) : + zlib_flags["CPPPATH"] = [env["zlib_includedir"]] + zlib_okay = True +if env.get("zlib_libfile", None) : + zlib_flags["LIBS"] = [File(env["zlib_libfile"])] + zlib_okay = True +elif zlib_okay : + zlib_flags["LIBS"] = ["z"] +if (not zlib_okay) and conf.CheckLib("z") : + zlib_flags["LIBS"] = ["z"] + zlib_okay = True +if zlib_okay : + env["ZLIB_FLAGS"] = zlib_flags +elif not env.get("zlib_bundled_enable", True) : + print "Error: Zlib not found and zlib_bundled_enable is false" + Exit(1) else : env["ZLIB_BUNDLED"] = True if conf.CheckLib("resolv") : env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["resolv"] if env["PLATFORM"] != "win32" : if conf.CheckLib("pthread") : env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["pthread"] @@ -126,64 +145,68 @@ if env["PLATFORM"] != "win32" : if conf.CheckLib("dl") : env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["dl"] if conf.CheckLib("m") : env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["m"] if conf.CheckLib("c") : env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["c"] -if conf.CheckLib("stdc++") : - env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["stdc++"] - +# Even if you find stdc++ on HP-UX, it is the wrong one for aCC +if env["PLATFORM"] != "hpux" : + if conf.CheckLib("stdc++", language='CXX') : + env["PLATFORM_FLAGS"]["LIBS"] = env["PLATFORM_FLAGS"].get("LIBS", []) + ["stdc++"] conf.Finish() # Boost boost_conf_env = conf_env.Clone() boost_flags = {} if env.get("boost_libdir", None) : boost_flags["LIBPATH"] = [env["boost_libdir"]] if env.get("boost_includedir", None) : - if env["PLATFORM"] == "win32" : + if env["PLATFORM"] == "win32" or env["PLATFORM"] == "hpux" or env["PLATFORM"] == "sunos" : boost_flags["CPPPATH"] = [env["boost_includedir"]] else : # Using isystem to avoid getting warnings from a system boost # Unfortunately, this also disables dependency tracking boost_flags["CPPFLAGS"] = [("-isystem", env["boost_includedir"])] boost_conf_env.MergeFlags(boost_flags) conf = Configure(boost_conf_env) -boostLibs = [("signals", None), ("thread", None), ("regex", None), ("program_options", None), ("filesystem", None), ("serialization", "archive/text_oarchive.hpp"), ("system", "system/system_error.hpp"), ("date_time", "date_time/date.hpp")] +boostLibs = [("signals", None), ("system", "system/system_error.hpp"), ("thread", None), ("regex", None), ("program_options", None), ("filesystem", None), ("serialization", "archive/text_oarchive.hpp"), ("date_time", "date_time/date.hpp")] allLibsPresent = True libNames = [] for (lib, header) in boostLibs : if header : header = "boost/" + header else : header = "boost/" + lib + ".hpp" if not conf.CheckCXXHeader(header) : allLibsPresent = False break if env["PLATFORM"] != "win32" : libName = "boost_" + lib - if not conf.CheckLib(libName) : + if not conf.CheckLib(libName, language='CXX') : libName += "-mt" - if not conf.CheckLib(libName) : + if not conf.CheckLib(libName, language='CXX') : allLibsPresent = False break libNames.append(libName) if allLibsPresent : env["BOOST_FLAGS"] = boost_flags if env["PLATFORM"] != "win32" : env["BOOST_FLAGS"].update({"LIBS": libNames}) if not conf.CheckCXXHeader("boost/uuid/uuid.hpp") : # FIXME: Remove this workaround when UUID is available in most distros env["BOOST_BUNDLED_UUID_ONLY"] = True - env["BOOST_FLAGS"]["CPPDEFINES"] = ["BOOST_SIGNALS_NO_DEPRECATION_WARNING"] + env["BOOST_FLAGS"]["CPPDEFINES"] = ["BOOST_SIGNALS_NO_DEPRECATION_WARNING"] +elif not env.get("boost_bundled_enable", True) : + print "Error: Boost not found and boost_bundled_enable is false" + Exit(1) else : env["BOOST_BUNDLED"] = True conf.Finish() # Xss env["HAVE_XSS"] = 0 if env["PLATFORM"] != "win32" and env["PLATFORM"] != "darwin" : xss_flags = { @@ -194,19 +217,19 @@ if env["PLATFORM"] != "win32" and env["PLATFORM"] != "darwin" : xss_env.MergeFlags(xss_flags) conf = Configure(xss_env) if conf.CheckFunc("XScreenSaverQueryExtension") : env["HAVE_XSS"] = 1 env["XSS_FLAGS"] = xss_flags conf.Finish() # GConf env["HAVE_GCONF"] = 0 -if env["PLATFORM"] != "win32" and env["PLATFORM"] != "darwin" : +if env.get("try_gconf", True) and env["PLATFORM"] != "win32" and env["PLATFORM"] != "darwin" : gconf_env = conf_env.Clone() conf = Configure(gconf_env, custom_tests = {"CheckPKG": CheckPKG}) if conf.CheckPKG("gconf-2.0") : gconf_bare_env = Environment() gconf_bare_env.ParseConfig('pkg-config --cflags gconf-2.0 gobject-2.0 --libs gconf-2.0 gobject-2.0') gconf_flags = { "LIBS": gconf_bare_env["LIBS"], "CCFLAGS": gconf_bare_env["CCFLAGS"], "CPPPATH": gconf_bare_env["CPPPATH"], @@ -255,36 +278,36 @@ if env["PLATFORM"] == "darwin" : env["GROWL_FRAMEWORK"] = "/Library/Frameworks/Growl.framework" conf.Finish() # Snarl if env["PLATFORM"] == "win32" : env["HAVE_SNARL"] = True # LibXML conf = Configure(conf_env, custom_tests = {"CheckVersion": CheckVersion}) -if conf.CheckCHeader("libxml/parser.h") and conf.CheckLib("xml2") : +if env.get("try_libxml", True) and conf.CheckCHeader("libxml/parser.h") and conf.CheckLib("xml2") : #and conf.CheckVersion("LibXML", "2.6.23", "LIBXML_VERSION", "libxml/xmlversion.h", 20623) : env["HAVE_LIBXML"] = 1 env["LIBXML_FLAGS"] = { "LIBS": ["xml2"] } conf.Finish() -if not env.get("HAVE_LIBXML", 0) : +if env.get("try_libxml", True) and not env.get("HAVE_LIBXML", 0) : libxml_env = conf_env.Clone() libxml_env.Append(CPPPATH = ["/usr/include/libxml2"]) conf = Configure(libxml_env, custom_tests = {"CheckVersion": CheckVersion}) if conf.CheckCHeader("libxml/parser.h") and conf.CheckLib("xml2") : # and conf.CheckVersion("LibXML", "2.6.23", "LIBXML_VERSION", "libxml/xmlversion.h", 20623): env["HAVE_LIBXML"] = 1 env["LIBXML_FLAGS"] = { "CPPPATH": ["/usr/include/libxml2"], "LIBS": ["xml2"] } conf.Finish() # Expat -if not env.get("HAVE_LIBXML",0) : +if env.get("try_expat", True) and not env.get("HAVE_LIBXML",0) : expat_conf_env = conf_env.Clone() expat_flags = {} if env.get("expat_libdir", None) : expat_flags["LIBPATH"] = [env["expat_libdir"]] if env.get("expat_includedir", None) : expat_flags["CPPPATH"] = [env["expat_includedir"]] expat_conf_env.MergeFlags(expat_flags) conf = Configure(expat_conf_env) if conf.CheckCHeader("expat.h") and conf.CheckLib(env["expat_libname"]) : @@ -302,19 +325,21 @@ if not env.get("HAVE_EXPAT", 0) and not env.get("HAVE_LIBXML", 0) : env["EXPAT_BUNDLED"] = True ################################################################################ # IDN library ################################################################################ # ICU icu_env = conf_env.Clone() use_icu = bool(env["icu"]) -icu_prefix = env["icu"] if isinstance(env["icu"], str) else "" +icu_prefix = "" +if isinstance(env["icu"], str) : + icu_prefix = env["icu"] icu_flags = {} if icu_prefix : icu_flags = { "CPPPATH": [os.path.join(icu_prefix, "include")] } icu_flags["LIBPATH"] = [os.path.join(icu_prefix, "lib")] icu_env.MergeFlags(icu_flags) icu_conf = Configure(icu_env) if use_icu and icu_conf.CheckCHeader("unicode/usprep.h") : env["HAVE_ICU"] = 1 @@ -325,28 +350,32 @@ icu_conf.Finish() # LibIDN libidn_conf_env = conf_env.Clone() libidn_flags = {} if env.get("libidn_libdir", None) : libidn_flags["LIBPATH"] = [env["libidn_libdir"]] if env.get("libidn_includedir", None) : libidn_flags["CPPPATH"] = [env["libidn_includedir"]] libidn_conf_env.MergeFlags(libidn_flags) conf = Configure(libidn_conf_env) -if not env.get("HAVE_ICU") and conf.CheckCHeader("idna.h") and conf.CheckLib(env["libidn_libname"]) : +if env.get("try_libidn", True) and not env.get("HAVE_ICU") and conf.CheckCHeader("idna.h") and conf.CheckLib(env["libidn_libname"]) : env["HAVE_LIBIDN"] = 1 env["LIBIDN_FLAGS"] = { "LIBS": [env["libidn_libname"]] } env["LIBIDN_FLAGS"].update(libidn_flags) conf.Finish() # Fallback to bundled LibIDN if not env.get("HAVE_ICU", False) and not env.get("HAVE_LIBIDN", False) : - env["HAVE_LIBIDN"] = 1 - env["LIBIDN_BUNDLED"] = 1 + if env.get("libidn_bundled_enable", True) : + env["HAVE_LIBIDN"] = 1 + env["LIBIDN_BUNDLED"] = 1 + else : + print "Error: ICU and LIBIDN not found, and libidn_bundled_enable is false" + Exit(1) # Unbound if env["unbound"] : env["LDNS_BUNDLED"] = 1 env["UNBOUND_BUNDLED"] = 1 else : env["LDNS_FLAGS"] = {} env["UNBOUND_FLAGS"] = {} @@ -453,60 +482,73 @@ conf.Finish() # Avahi avahi_conf_env = conf_env.Clone() avahi_flags = {} if env.get("avahi_libdir", None) : avahi_flags["LIBPATH"] = [env["avahi_libdir"]] if env.get("avahi_includedir", None) : avahi_flags["CPPPATH"] = [env["avahi_includedir"]] avahi_conf_env.MergeFlags(avahi_flags) conf = Configure(avahi_conf_env) -if conf.CheckCHeader("avahi-client/client.h") and conf.CheckLib("avahi-client") and conf.CheckLib("avahi-common") : +if env.get("try_avahi", True) and conf.CheckCHeader("avahi-client/client.h") and conf.CheckLib("avahi-client") and conf.CheckLib("avahi-common") : env["HAVE_AVAHI"] = True env["AVAHI_FLAGS"] = { "LIBS": ["avahi-client", "avahi-common"] } env["AVAHI_FLAGS"].update(avahi_flags) conf.Finish() # Qt if env["qt"] : env["QTDIR"] = env["qt"] # OpenSSL openssl_env = conf_env.Clone() if env.get("openssl_force_bundled", False) or env["target"] in ("iphone-device", "iphone-simulator", "xcode", "android") : env["OPENSSL_BUNDLED"] = True env["HAVE_OPENSSL"] = True else : use_openssl = bool(env["openssl"]) - openssl_prefix = env["openssl"] if isinstance(env["openssl"], str) else "" + openssl_prefix = "" + if isinstance(env["openssl"], str) : + openssl_prefix = env["openssl"] openssl_flags = {} if openssl_prefix : - openssl_flags = { "CPPPATH": [os.path.join(openssl_prefix, "include")] } - if env["PLATFORM"] == "win32" : + openssl_include = env.get("openssl_include", None) + openssl_libdir = env.get("openssl_libdir", None) + if openssl_include: + openssl_flags = {"CPPPATH":[openssl_include]} + else: + openssl_flags = { "CPPPATH": [os.path.join(openssl_prefix, "include")] } + if openssl_libdir: + openssl_flags["LIBPATH"] = [openssl_libdir] + env["OPENSSL_DIR"] = openssl_prefix + elif env["PLATFORM"] == "win32" : openssl_flags["LIBPATH"] = [os.path.join(openssl_prefix, "lib", "VC")] env["OPENSSL_DIR"] = openssl_prefix else : openssl_flags["LIBPATH"] = [os.path.join(openssl_prefix, "lib")] openssl_env.MergeFlags(openssl_flags) openssl_conf = Configure(openssl_env) if use_openssl and openssl_conf.CheckCHeader("openssl/ssl.h") : env["HAVE_OPENSSL"] = 1 env["OPENSSL_FLAGS"] = openssl_flags - if env["PLATFORM"] == "win32" : + openssl_libnames = env.get("openssl_libnames", None) + if openssl_libnames: + env["OPENSSL_FLAGS"]["LIBS"] = openssl_libnames.split(',') + elif env["PLATFORM"] == "win32" : env["OPENSSL_FLAGS"]["LIBS"] = ["libeay32MD", "ssleay32MD"] else: env["OPENSSL_FLAGS"]["LIBS"] = ["ssl", "crypto"] if env["PLATFORM"] == "darwin" : if platform.mac_ver()[0].startswith("10.5") : env["OPENSSL_FLAGS"]["FRAMEWORKS"] = ["Security"] else : env["OPENSSL_FLAGS"] = {} - if env["PLATFORM"] == "win32" : + if env["PLATFORM"] == "win32" : env["HAVE_SCHANNEL"] = True # If we're compiling for Windows and OpenSSL isn't being used, use Schannel env.Append(LIBS = ["secur32"]) openssl_conf.Finish() #Hunspell hunspell_env = conf_env.Clone() hunspell_prefix = env["hunspell"] if isinstance(env.get("hunspell", False), str) else "" @@ -524,19 +566,19 @@ if hunspell_conf.CheckCXXHeader("hunspell/hunspell.hxx") and hunspell_conf.Check hunspell_conf.Finish() # Bonjour if env["PLATFORM"] == "darwin" and env["target"] == "native" : env["HAVE_BONJOUR"] = 1 elif env.get("bonjour", False) : bonjour_env = conf_env.Clone() bonjour_conf = Configure(bonjour_env) bonjour_flags = {} - if env.get("bonjour") != True : + if env.get("bonjour") != True : bonjour_prefix = env["bonjour"] bonjour_flags["CPPPATH"] = [os.path.join(bonjour_prefix, "include")] bonjour_flags["LIBPATH"] = [os.path.join(bonjour_prefix, "lib", "win32")] bonjour_env.MergeFlags(bonjour_flags) if bonjour_conf.CheckCHeader("dns_sd.h") and bonjour_conf.CheckLib("dnssd") : env["HAVE_BONJOUR"] = 1 env["BONJOUR_FLAGS"] = bonjour_flags env["BONJOUR_FLAGS"]["LIBS"] = ["dnssd"] bonjour_conf.Finish() @@ -566,19 +608,19 @@ if env.get("docbook_xsl") : env["DOCBOOK_XSL_DIR"] = env["docbook_xsl"] ################################################################################ # Set up git hooks ################################################################################ try: if env.Dir("#/.git").exists() : - if not env.GetOption("clean") : + if not env.GetOption("clean") and env.get("install_git_hooks", True) : env.Install("#/.git/hooks", Glob("#/BuildTools/Git/Hooks/*")) except TypeError: print "You seem to be using Swift in a Git submodule. Not installing hooks." ################################################################################ # Replace #pragma once with proper guards on platforms that require it ################################################################################ @@ -660,12 +702,12 @@ if env.get("HAVE_LIBXML", 0): parsers.append("LibXML") if env.get("HAVE_EXPAT", 0): parsers.append("Expat") if env.get("EXPAT_BUNDLED", False) : parsers.append("(Bundled)") print " Projects: " + ' '.join(env["PROJECTS"]) print "" print " XML Parsers: " + ' '.join(parsers) -print " TLS Support: " + ("OpenSSL" if env.get("HAVE_OPENSSL",0) else ("Schannel" if env.get("HAVE_SCHANNEL", 0) else "Disabled")) -print " DNSSD Support: " + ("Bonjour" if env.get("HAVE_BONJOUR") else ("Avahi" if env.get("HAVE_AVAHI") else "Disabled")) +print " TLS Support: " + (env.get("HAVE_OPENSSL",0) and "OpenSSL" or env.get("HAVE_SCHANNEL", 0) and "Schannel" or "Disabled") +print " DNSSD Support: " + (env.get("HAVE_BONJOUR") and "Bonjour" or (env.get("HAVE_AVAHI") and "Avahi" or "Disabled")) print |