Beispiel #1
0
    def _build_zlib_autotools(self):
        env_build = AutoToolsBuildEnvironment(self)

        # configure passes CFLAGS to linker, should be LDFLAGS
        tools.replace_in_file("../configure", "$LDSHARED $SFLAGS",
                              "$LDSHARED $LDFLAGS")
        # same thing in Makefile.in, when building tests/example executables
        tools.replace_in_file("../Makefile.in", "$(CC) $(CFLAGS) -o",
                              "$(CC) $(LDFLAGS) -o")

        # we need to build only libraries without test example and minigzip
        if self.options.shared:
            make_target = "libz.%s.dylib" % self.version \
                if tools.is_apple_os(self.settings.os) else "libz.so.%s" % self.version
        else:
            make_target = "libz.a"

        if tools.is_apple_os(
                self.settings.os) and self.settings.get_safe("os.version"):
            target = tools.apple_deployment_target_flag(
                self.settings.os, self.settings.os.version)
            env_build.flags.append(target)

        env = {}
        if "clang" in str(self.settings.compiler) and tools.get_env(
                "CC") is None and tools.get_env("CXX") is None:
            env = {"CC": "clang", "CXX": "clang++"}
        with tools.environment_append(env):
            env_build.configure("../", build=False, host=False, target=False)
            env_build.make(target=make_target)
    def build(self):
        for filename in glob.glob("patches/*.patch"):
            self.output.info('applying patch "%s"' % filename)
            tools.patch(base_path=self._source_subfolder, patch_file=filename)

        if self._is_msvc:
            run_configure_icu_file = os.path.join(self._source_subfolder,
                                                  'source', 'runConfigureICU')

            flags = "-%s" % self.settings.compiler.runtime
            if self.settings.get_safe("build_type") in [
                    'Debug', 'RelWithDebInfo'
            ] and Version(self.settings.compiler.version) >= "12":
                flags += " -FS"
            tools.replace_in_file(run_configure_icu_file, "-MDd", flags)
            tools.replace_in_file(run_configure_icu_file, "-MD", flags)

        self._workaround_icu_20545()

        self._env_build = AutoToolsBuildEnvironment(self)
        if not self.options.get_safe("shared"):
            self._env_build.defines.append("U_STATIC_IMPLEMENTATION")
        if tools.is_apple_os(self.settings.os):
            self._env_build.defines.append("_DARWIN_C_SOURCE")
            if self.settings.get_safe("os.version"):
                self._env_build.flags.append(
                    tools.apple_deployment_target_flag(
                        self.settings.os, self.settings.os.version))

        if "msys2" in self.deps_user_info:
            self._env_build.vars["PYTHON"] = tools.unix_path(
                os.path.join(self.deps_env_info["msys2"].MSYS_BIN, "python"),
                tools.MSYS2)

        build_dir = os.path.join(self.build_folder, self._source_subfolder,
                                 'build')
        os.mkdir(build_dir)

        with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():
            with tools.environment_append(self._env_build.vars):
                with tools.chdir(build_dir):
                    # workaround for https://unicode-org.atlassian.net/browse/ICU-20531
                    os.makedirs(os.path.join("data", "out", "tmp"))

                    self.run(self._build_config_cmd,
                             win_bash=tools.os_info.is_windows)
                    if self.options.get_safe("silent"):
                        silent = '--silent' if self.options.silent else 'VERBOSE=1'
                    else:
                        silent = '--silent'
                    command = "make {silent} -j {cpu_count}".format(
                        silent=silent, cpu_count=tools.cpu_count())
                    self.run(command, win_bash=tools.os_info.is_windows)
                    if self.options.get_safe("with_unit_tests"):
                        command = "make {silent} check".format(silent=silent)
                        self.run(command, win_bash=tools.os_info.is_windows)
                    command = "make {silent} install".format(silent=silent)
                    self.run(command, win_bash=tools.os_info.is_windows)

        self._install_name_tool()
Beispiel #3
0
    def _configure_autotools(self):
        if not self._autotools:
            args = []
            cwd = os.getcwd()
            win_bash = self._is_msvc or self._is_mingw_windows
            self._autotools = AutoToolsBuildEnvironment(self, win_bash=win_bash)
            if self._is_msvc:
                args.extend(["CC={}/build-aux/compile cl -nologo".format(cwd),
                            "CFLAGS=-{}".format(self.settings.compiler.runtime),
                            "CXX={}/build-aux/compile cl -nologo".format(cwd),
                            "CXXFLAGS=-{}".format(self.settings.compiler.runtime),
                            "CPPFLAGS=-D_WIN32_WINNT=_WIN32_WINNT_WIN8",
                            "LD=link",
                            "NM=dumpbin -symbols",
                            "STRIP=:",
                            "AR={}/build-aux/ar-lib lib".format(cwd),
                            "RANLIB=:"])
            elif self.settings.compiler == "gcc" and self.settings.os == "Windows":
                self._autotools.link_flags.extend(["-static", "-static-libgcc"])
            elif tools.is_apple_os(self.settings.os) and self.settings.get_safe("os.version"):
                target = tools.apple_deployment_target_flag(self.settings.os, self.settings.os.version)
                self._autotools.flags.append(target)

            self._autotools.configure(args=args)
        return self._autotools
Beispiel #4
0
    def package_info(self):
        darwin_arch = tools.to_apple_arch(self.settings.arch)

        if self.settings.os == "watchOS" and self.settings.arch == "armv8":
            darwin_arch = "arm64_32"

        xcrun = tools.XCRun(self.settings)
        sysroot = xcrun.sdk_path

        self.cpp_info.sysroot = sysroot

        common_flags = ["-isysroot%s" % sysroot]

        if self.settings.get_safe("os.version"):
            common_flags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))

        if not self.settings.os == "Macos" and self.options.bitcode:
            if self.settings.build_type == "Debug":
                bitcode_flag = "-fembed-bitcode-marker"
            else:
                bitcode_flag = "-fembed-bitcode"
            common_flags.append(bitcode_flag)

        # CMake issue, for details look https://github.com/conan-io/conan/issues/2378
        cflags = copy.copy(common_flags)
        cflags.extend(["-arch", darwin_arch])
        self.cpp_info.cflags = cflags
        link_flags = copy.copy(common_flags)
        link_flags.append("-arch %s" % darwin_arch)

        self.cpp_info.sharedlinkflags.extend(link_flags)
        self.cpp_info.exelinkflags.extend(link_flags)

        # Set flags in environment too, so that CMake Helper finds them
        cflags_str = " ".join(cflags)
        ldflags_str = " ".join(link_flags)
        self.env_info.CC = xcrun.cc
        self.env_info.CPP = "%s -E" % xcrun.cc
        self.env_info.CXX = xcrun.cxx
        self.env_info.AR = xcrun.ar
        self.env_info.RANLIB = xcrun.ranlib
        self.env_info.STRIP = xcrun.strip

        self.env_info.CFLAGS = cflags_str
        self.env_info.ASFLAGS = cflags_str
        self.env_info.CPPFLAGS = cflags_str
        self.env_info.CXXFLAGS = cflags_str
        self.env_info.LDFLAGS = ldflags_str

        self.env_info.CONAN_CMAKE_SYSTEM_NAME = self.cmake_system_name
        if self.settings.get_safe("os.version"):
            self.env_info.CONAN_CMAKE_OSX_DEPLOYMENT_TARGET = str(
                self.settings.os.version)
        self.env_info.CONAN_CMAKE_OSX_ARCHITECTURES = str(darwin_arch)
        self.env_info.CONAN_CMAKE_SYSROOT = sysroot
        self.env_info.CONAN_CMAKE_TOOLCHAIN_FILE = os.path.join(
            self.package_folder, "darwin-toolchain.cmake")
    def _configure_autotools(self):
        if not self._autotools:
            prefix = tools.unix_path(self.package_folder)
            args = ['--disable-cli', '--prefix={}'.format(prefix)]
            if self.options.shared:
                args.append('--enable-shared')
            else:
                args.append('--enable-static')
            if self.settings.os != 'Windows' and self.options.fPIC:
                args.append('--enable-pic')
            if self.settings.build_type == 'Debug':
                args.append('--enable-debug')
            args.append('--bit-depth=%s' % str(self.options.bit_depth))

            if tools.cross_building(self.settings):
                if self.settings.os == "Android":
                    # the as of ndk does not work well for building libx264
                    self._override_env["AS"] = os.environ["CC"]
                    ndk_root = tools.unix_path(os.environ["NDK_ROOT"])
                    arch = {
                        'armv7': 'arm',
                        'armv8': 'aarch64',
                        'x86': 'i686',
                        'x86_64': 'x86_64'
                    }.get(str(self.settings.arch))
                    abi = 'androideabi' if self.settings.arch == 'armv7' else 'android'
                    cross_prefix = "%s/bin/%s-linux-%s-" % (ndk_root, arch,
                                                            abi)
                    args.append('--cross-prefix=%s' % cross_prefix)

            if self._is_msvc:
                self._override_env['CC'] = 'cl'
            self._autotools = AutoToolsBuildEnvironment(
                self, win_bash=tools.os_info.is_windows)
            if self._is_msvc:
                self._autotools.flags.append(
                    '-%s' % str(self.settings.compiler.runtime))
                # cannot open program database ... if multiple CL.EXE write to the same .PDB file, please use /FS
                self._autotools.flags.append('-FS')
            if tools.is_apple_os(
                    self.settings.os) and self.settings.get_safe("os.version"):
                self._autotools.flags.append(
                    tools.apple_deployment_target_flag(
                        self.settings.os, self.settings.os.version))
            build_canonical_name = None
            host_canonical_name = None
            if self.settings.compiler == "Visual Studio":
                # autotools does not know about the msvc canonical name(s)
                build_canonical_name = False
                host_canonical_name = False
            self._autotools.configure(args=args,
                                      vars=self._override_env,
                                      configure_dir=self._source_subfolder,
                                      build=build_canonical_name,
                                      host=host_canonical_name)

        return self._autotools
 def _get_env_build(self):
     if not self._env_build:
         self._env_build = AutoToolsBuildEnvironment(self)
         if self.settings.compiler == "apple-clang":
             self._env_build.flags.append("-arch %s" % tools.to_apple_arch(self.settings.arch))
             self._env_build.flags.append("-isysroot %s" % tools.XCRun(self.settings).sdk_path)
             if self.settings.get_safe("os.version"):
                 self._env_build.flags.append(tools.apple_deployment_target_flag(self.settings.os,
                                                                           self.settings.os.version))
     return self._env_build
 def _get_env_build(self):
     if not self._env_build:
         self._env_build = AutoToolsBuildEnvironment(self)
         if self.settings.compiler == "apple-clang":
             # add flags only if not already specified, avoid breaking Catalyst which needs very special flags
             flags = " ".join(self._env_build.flags)
             if "-arch" not in flags:
                 self._env_build.flags.append("-arch %s" % tools.to_apple_arch(self.settings.arch))
             if "-isysroot" not in flags:
                 self._env_build.flags.append("-isysroot %s" % tools.XCRun(self.settings).sdk_path)
             if self.settings.get_safe("os.version") and "-version-min=" not in flags and "-target" not in flags:
                 self._env_build.flags.append(tools.apple_deployment_target_flag(self.settings.os,
                                                                           self.settings.os.version))
     return self._env_build
Beispiel #8
0
    def _configure_autotools(self):
        if self._env_build:
            return self._env_build
        self._env_build = AutoToolsBuildEnvironment(self)
        if not self.options.shared:
            self._env_build.defines.append("U_STATIC_IMPLEMENTATION")
        if tools.is_apple_os(self.settings.os):
            self._env_build.defines.append("_DARWIN_C_SOURCE")
            if self.settings.get_safe("os.version"):
                self._env_build.flags.append(tools.apple_deployment_target_flag(self.settings.os,
                                                                            self.settings.os.version))

        if "msys2" in self.deps_user_info:
            self._env_build.vars["PYTHON"] = tools.unix_path(os.path.join(self.deps_env_info["msys2"].MSYS_BIN, "python"), tools.MSYS2)
        return self._env_build
    def _build_autotools(self):
        env_build = AutoToolsBuildEnvironment(self)
        if not self.options.shared:
            env_build.defines.append("U_STATIC_IMPLEMENTATION")
        if tools.is_apple_os(self.settings.os) and self.settings.get_safe("os.version"):
            env_build.flags.append(tools.apple_deployment_target_flag(self.settings.os,
                                                                      self.settings.os.version))

        with tools.environment_append(env_build.vars):
            if self.settings.os == 'Linux':
                self.cfg['platform'] = 'Linux/gcc' if str(self.settings.compiler).startswith('gcc') else 'Linux'
            elif self.settings.os == 'Macos':
                self.cfg['platform'] = 'MacOSX'
            if self.settings.os == 'Windows':
                self.cfg['platform'] = 'MinGW'

                if self.settings.arch == 'x86':
                    MINGW_CHOST = 'i686-w64-mingw32'
                else:
                    MINGW_CHOST = 'x86_64-w64-mingw32'

                self.cfg['host'] = '--build={MINGW_CHOST} ' \
                                   '--host={MINGW_CHOST} '.format(MINGW_CHOST=MINGW_CHOST)

            os.mkdir(self.cfg['build_dir'])

            config_cmd = self.build_config_cmd()

            # with tools.environment_append(env_build.vars):
            self.run("cd {builddir} && bash -c '{config_cmd}'".format(builddir=self.cfg['build_dir'],
                                                                      config_cmd=config_cmd))

            os.system("cd {builddir} && make {silent} -j {cpus_var}".format(builddir=self.cfg['build_dir'],
                                                                            cpus_var=tools.cpu_count(),
                                                                            silent=self.cfg['silent']))

            if self.options.with_unit_tests:
                os.system("cd {builddir} && make {silent} check".format(builddir=self.cfg['build_dir'],
                                                                        silent=self.cfg['silent']))

            os.system("cd {builddir} && make {silent} install".format(builddir=self.cfg['build_dir'],
                                                                      silent=self.cfg['silent']))

            if self.settings.os == 'Macos':
                with tools.chdir('output/lib'):
                    for dylib in glob.glob('*icu*.{0}.dylib'.format(self.version)):
                        self.run('install_name_tool -id {0} {1}'.format(
                            os.path.basename(dylib), dylib))
Beispiel #10
0
    def package_info(self):
        darwin_arch = tools.to_apple_arch(self.settings.arch)

        xcrun = tools.XCRun(self.settings)
        sysroot = xcrun.sdk_path

        self.cpp_info.sysroot = sysroot

        common_flags = ["-isysroot%s" % sysroot]

        if self.settings.get_safe("os.version"):
            common_flags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))

        if not self.settings.os == "Macos" and self.options.bitcode:
            if self.settings.build_type == "Debug":
                bitcode_flag = "-fembed-bitcode-marker"
            else:
                bitcode_flag = "-fembed-bitcode"
            common_flags.append(bitcode_flag)

        # CMake issue, for details look https://github.com/conan-io/conan/issues/2378
        cflags = copy.copy(common_flags)
        cflags.extend(["-arch", darwin_arch])
        self.cpp_info.cflags = cflags
        link_flags = copy.copy(common_flags)
        link_flags.append("-arch %s" % darwin_arch)

        self.cpp_info.sharedlinkflags.extend(link_flags)
        self.cpp_info.exelinkflags.extend(link_flags)

        # Set flags in environment too, so that CMake Helper finds them
        cflags_str = " ".join(cflags)
        ldflags_str = " ".join(link_flags)
        self.env_info.CC = xcrun.cc
        self.env_info.CXX = xcrun.cxx
        self.env_info.AR = xcrun.ar
        self.env_info.RANLIB = xcrun.ranlib
        self.env_info.STRIP = xcrun.strip

        self.env_info.CFLAGS = cflags_str
        self.env_info.CXXFLAGS = cflags_str
        self.env_info.LDFLAGS = ldflags_str
    def _build_autotools(self):
        env_build = AutoToolsBuildEnvironment(self)
        if not self.options.shared:
            env_build.defines.append("U_STATIC_IMPLEMENTATION")
        if tools.is_apple_os(
                self.settings.os) and self.settings.get_safe("os.version"):
            env_build.flags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))

        with tools.environment_append(env_build.vars):
            if self.settings.os == 'Linux':
                self.cfg['platform'] = 'Linux/gcc' if str(
                    self.settings.compiler).startswith('gcc') else 'Linux'
            elif self.settings.os == 'Macos':
                self.cfg['platform'] = 'MacOSX'
            if self.settings.os == 'Windows':
                self.cfg['platform'] = 'MinGW'

                if self.settings.arch == 'x86':
                    MINGW_CHOST = 'i686-w64-mingw32'
                else:
                    MINGW_CHOST = 'x86_64-w64-mingw32'

                self.cfg['host'] = '--build={MINGW_CHOST} ' \
                                   '--host={MINGW_CHOST} '.format(MINGW_CHOST=MINGW_CHOST)

            os.mkdir(self.cfg['build_dir'])

            config_cmd = self.build_config_cmd()

            # with tools.environment_append(env_build.vars):

            #Run only make to generate build folder for Cross compiling
            self.run("cd {builddir} && bash -c '{config_cmd}'".format(
                builddir=self.cfg['build_dir'], config_cmd=config_cmd))

            os.system("cd {builddir} && make {silent} -j {cpus_var}".format(
                builddir=self.cfg['build_dir'],
                cpus_var=tools.cpu_count(),
                silent=self.cfg['silent']))
Beispiel #12
0
    def _configure_autotools_vars(self):
        autotools_vars = self._autotools.vars
        # tweaks for mingw
        if self._is_mingw:
            autotools_vars["RCFLAGS"] = "-O COFF"
            if self.settings.arch == "x86":
                autotools_vars["RCFLAGS"] += " --target=pe-i386"
            else:
                autotools_vars["RCFLAGS"] += " --target=pe-x86-64"

            del autotools_vars["LIBS"]
            self.output.info("Autotools env vars: " + repr(autotools_vars))

        if tools.cross_building(self.settings):
            if self.settings.os == "iOS":
                iphoneos = tools.apple_sdk_name(self.settings)
                ios_dev_target = str(self.settings.os.version).split(".")[0]

                env_cppflags = tools.get_env("CPPFLAGS", "")
                socket_flags = " -DHAVE_SOCKET -DHAVE_FCNTL_O_NONBLOCK"
                if self.settings.arch in ["x86", "x86_64"]:
                    autotools_vars[
                        "CPPFLAGS"] = "-D__IPHONE_OS_VERSION_MIN_REQUIRED={}0000 {} {}".format(
                            ios_dev_target, socket_flags, env_cppflags)
                elif self.settings.arch in ["armv7", "armv7s", "armv8"]:
                    autotools_vars["CPPFLAGS"] = "{} {}".format(
                        socket_flags, env_cppflags)
                else:
                    raise ConanInvalidConfiguration(
                        "Unsuported iOS arch {}".format(self.settings.arch))

                cc = tools.XCRun(self.settings, iphoneos).cc
                sysroot = "-isysroot {}".format(
                    tools.XCRun(self.settings, iphoneos).sdk_path)

                if self.settings.arch == "armv8":
                    configure_arch = "arm64"
                    configure_host = "arm"  #unused, autodetected
                else:
                    configure_arch = self.settings.arch
                    configure_host = self.settings.arch  #unused, autodetected

                arch_flag = "-arch {}".format(configure_arch)
                ios_min_version = tools.apple_deployment_target_flag(
                    self.settings.os, self.settings.os.version)
                extra_flag = "-Werror=partial-availability"

                # if we debug, maybe add a -gdwarf-2 , but why would we want that?

                autotools_vars["CC"] = cc
                autotools_vars["IPHONEOS_DEPLOYMENT_TARGET"] = ios_dev_target
                env_cflags = tools.get_env("CFLAGS", "")
                autotools_vars["CFLAGS"] = "{} {} {} {}".format(
                    sysroot, arch_flag, ios_min_version, env_cflags)

                if self.options.with_openssl:
                    openssl_path = self.deps_cpp_info["openssl"].rootpath
                    openssl_libdir = self.deps_cpp_info["openssl"].libdirs[0]
                    autotools_vars["LDFLAGS"] = "{} {} -L{}/{}".format(
                        arch_flag, sysroot, openssl_path, openssl_libdir)
                elif self.options.with_wolfssl:
                    wolfssl_path = self.deps_cpp_info["wolfssl"].rootpath
                    wolfssl_libdir = self.deps_cpp_info["wolfssl"].libdirs[0]
                    autotools_vars["LDFLAGS"] = "{} {} -L{}/{}".format(
                        arch_flag, sysroot, wolfssl_path, wolfssl_libdir)
                else:
                    autotools_vars["LDFLAGS"] = "{} {}".format(
                        arch_flag, sysroot)

            elif self.settings.os == "Android":
                # nothing do to at the moment, this seems to just work
                pass

        return autotools_vars
    def _build_flags(self):
        flags = self._build_cross_flags

        # https://www.boost.org/doc/libs/1_70_0/libs/context/doc/html/context/architectures.html
        if self._b2_os:
            flags.append("target-os=%s" % self._b2_os)
        if self._b2_architecture:
            flags.append("architecture=%s" % self._b2_architecture)
        if self._b2_address_model:
            flags.append("address-model=%s" % self._b2_address_model)
        if self._b2_binary_format:
            flags.append("binary-format=%s" % self._b2_binary_format)
        if self._b2_abi:
            flags.append("abi=%s" % self._b2_abi)

        if self.options.layout is not "b2-default":
            flags.append("--layout=%s" % self.options.layout)
        flags.append("--user-config=%s" %
                     os.path.join(self._boost_build_dir, 'user-config.jam'))
        flags.append("-sNO_ZLIB=%s" % ("0" if self.options.zlib else "1"))
        flags.append("-sNO_BZIP2=%s" % ("0" if self.options.bzip2 else "1"))
        flags.append("-sNO_LZMA=%s" % ("0" if self.options.lzma else "1"))
        flags.append("-sNO_ZSTD=%s" % ("0" if self.options.zstd else "1"))

        if self.options.i18n_backend == 'icu':
            flags.append("-sICU_PATH={}".format(
                self.deps_cpp_info["icu"].rootpath))
            flags.append("boost.locale.iconv=off boost.locale.icu=on")
        elif self.options.i18n_backend == 'iconv':
            flags.append("boost.locale.iconv=on boost.locale.icu=off")
        else:
            flags.append("boost.locale.iconv=off boost.locale.icu=off")
            flags.append("--disable-icu --disable-iconvv")

        def add_defines(option, library):
            if option:
                for define in self.deps_cpp_info[library].defines:
                    flags.append("define=%s" % define)

        if self._zip_bzip2_requires_needed:
            add_defines(self.options.zlib, "zlib")
            add_defines(self.options.bzip2, "bzip2")
            add_defines(self.options.lzma, "xz_utils")
            add_defines(self.options.zstd, "zstd")

        if self._is_msvc and self.settings.compiler.runtime:
            flags.append("runtime-link=%s" % ("static" if "MT" in str(
                self.settings.compiler.runtime) else "shared"))

        # For details https://boostorg.github.io/build/manual/master/index.html
        flags.append(
            "threading=%s" %
            ("single" if not self.options.multithreading else "multi"))

        flags.append("link=%s" %
                     ("static" if not self.options.shared else "shared"))
        if self.settings.build_type == "Debug":
            flags.append("variant=debug")
        else:
            flags.append("variant=release")

        for libname in lib_list:
            if getattr(self.options, "without_%s" % libname):
                flags.append("--without-%s" % libname)

        flags.append("toolset=%s" % self._toolset)

        if self.settings.get_safe("compiler.cppstd"):
            flags.append("cxxflags=%s" % cppstd_flag(self.settings))

        # CXX FLAGS
        cxx_flags = []
        # fPIC DEFINITION
        if self.settings.os != "Windows":
            if self.options.fPIC:
                cxx_flags.append("-fPIC")
        if self.settings.build_type == "RelWithDebInfo":
            if self.settings.compiler == "gcc" or "clang" in str(
                    self.settings.compiler):
                cxx_flags.append("-g")
            elif self.settings.compiler == "Visual Studio":
                cxx_flags.append("/Z7")

        # Standalone toolchain fails when declare the std lib
        if self.settings.os != "Android" and self.settings.os != "Emscripten":
            try:
                if self._gnu_cxx11_abi:
                    flags.append("define=_GLIBCXX_USE_CXX11_ABI=%s" %
                                 self._gnu_cxx11_abi)

                if "clang" in str(self.settings.compiler):
                    if str(self.settings.compiler.libcxx) == "libc++":
                        cxx_flags.append("-stdlib=libc++")
                        flags.append('linkflags="-stdlib=libc++"')
                    else:
                        cxx_flags.append("-stdlib=libstdc++")
            except:
                pass

        if self.options.error_code_header_only:
            flags.append("define=BOOST_ERROR_CODE_HEADER_ONLY=1")
        if self.options.system_no_deprecated:
            flags.append("define=BOOST_SYSTEM_NO_DEPRECATED=1")
        if self.options.asio_no_deprecated:
            flags.append("define=BOOST_ASIO_NO_DEPRECATED=1")
        if self.options.filesystem_no_deprecated:
            flags.append("define=BOOST_FILESYSTEM_NO_DEPRECATED=1")
        if self.options.segmented_stacks:
            flags.extend([
                "segmented-stacks=on", "define=BOOST_USE_SEGMENTED_STACKS=1",
                "define=BOOST_USE_UCONTEXT=1"
            ])
        flags.append("pch=on" if self.options.pch else "pch=off")

        if tools.is_apple_os(self.settings.os):
            if self.settings.get_safe("os.version"):
                cxx_flags.append(
                    tools.apple_deployment_target_flag(
                        self.settings.os, self.settings.os.version))

        if self.settings.os == "iOS":
            if self.options.multithreading:
                cxx_flags.append("-DBOOST_AC_USE_PTHREADS")
                cxx_flags.append("-DBOOST_SP_USE_PTHREADS")

            cxx_flags.append("-fvisibility=hidden")
            cxx_flags.append("-fvisibility-inlines-hidden")
            cxx_flags.append("-fembed-bitcode")

        cxx_flags = 'cxxflags="%s"' % " ".join(cxx_flags) if cxx_flags else ""
        flags.append(cxx_flags)

        if self.options.extra_b2_flags:
            flags.append(str(self.options.extra_b2_flags))

        flags.extend([
            "install",
            "--prefix=%s" % self.package_folder,
            "-j%s" % tools.cpu_count(), "--abbreviate-paths"
        ])
        if self.options.debug_level:
            flags.append("-d%d" % self.options.debug_level)
        return flags
Beispiel #14
0
    def _configure_autotools(self):
        if self._autotools:
            return self._autotools
        self._autotools = AutoToolsBuildEnvironment(
            self, win_bash=tools.os_info.is_windows)
        self._autotools.libs = []
        opt_enable_disable = lambda what, v: "--{}-{}".format(
            "enable" if v else "disable", what)
        args = [
            "--pkg-config-flags=--static",
            "--disable-doc",
            "--disable-programs",
            opt_enable_disable("cross-compile", tools.cross_building(self)),
            # Libraries
            opt_enable_disable("shared", self.options.shared),
            opt_enable_disable("static", not self.options.shared),
            opt_enable_disable("pic", self.options.get_safe("fPIC", True)),
            opt_enable_disable("postproc", self.options.postproc),
            # Dependencies
            opt_enable_disable("bzlib", self.options.with_bzip2),
            opt_enable_disable("zlib", self.options.with_zlib),
            opt_enable_disable("lzma", self.options.with_lzma),
            opt_enable_disable("iconv", self.options.with_libiconv),
            opt_enable_disable("libopenjpeg", self.options.with_openjpeg),
            opt_enable_disable("libopenh264", self.options.with_openh264),
            opt_enable_disable("libvorbis", self.options.with_vorbis),
            opt_enable_disable("libopus", self.options.with_opus),
            opt_enable_disable("libzmq", self.options.with_zeromq),
            opt_enable_disable("sdl2", self.options.with_sdl),
            opt_enable_disable("libx264", self.options.with_libx264),
            opt_enable_disable("libx265", self.options.with_libx265),
            opt_enable_disable("libvpx", self.options.with_libvpx),
            opt_enable_disable("libmp3lame", self.options.with_libmp3lame),
            opt_enable_disable("libfdk-aac", self.options.with_libfdk_aac),
            opt_enable_disable("libwebp", self.options.with_libwebp),
            opt_enable_disable("openssl", self.options.with_ssl == "openssl"),
            opt_enable_disable("alsa", self.options.get_safe("with_libalsa")),
            opt_enable_disable("libpulse",
                               self.options.get_safe("with_pulse")),
            opt_enable_disable("vaapi", self.options.get_safe("with_vaapi")),
            opt_enable_disable("vdpau", self.options.get_safe("with_vdpau")),
            opt_enable_disable("libxcb", self.options.get_safe("with_xcb")),
            opt_enable_disable("libxcb-shm",
                               self.options.get_safe("with_xcb")),
            opt_enable_disable("libxcb-shape",
                               self.options.get_safe("with_xcb")),
            opt_enable_disable("libxcb-xfixes",
                               self.options.get_safe("with_xcb")),
            opt_enable_disable("appkit", self.options.get_safe("with_appkit")),
            opt_enable_disable("avfoundation",
                               self.options.get_safe("with_avfoundation")),
            opt_enable_disable("coreimage",
                               self.options.get_safe("with_coreimage")),
            opt_enable_disable("audiotoolbox",
                               self.options.get_safe("with_audiotoolbox")),
            opt_enable_disable("videotoolbox",
                               self.options.get_safe("with_videotoolbox")),
            opt_enable_disable("securetransport",
                               self.options.with_ssl == "securetransport"),
            "--disable-cuda",  # FIXME: CUDA support
            "--disable-cuvid",  # FIXME: CUVID support
            # Licenses
            opt_enable_disable("nonfree", self.options.with_libfdk_aac),
            opt_enable_disable(
                "gpl", self.options.with_libx264 or self.options.with_libx265
                or self.options.postproc)
        ]
        args.append("--arch={}".format(self._target_arch))
        if self.settings.build_type == "Debug":
            args.extend([
                "--disable-optimizations",
                "--disable-mmx",
                "--disable-stripping",
                "--enable-debug",
            ])
        # since ffmpeg"s build system ignores CC and CXX
        if tools.get_env("AS"):
            args.append("--as={}".format(tools.get_env("AS")))
        if tools.get_env("CC"):
            args.append("--cc={}".format(tools.get_env("CC")))
        if tools.get_env("CXX"):
            args.append("--cxx={}".format(tools.get_env("CXX")))
        extra_cflags = []
        extra_ldflags = []
        if tools.is_apple_os(self.settings.os) and self.settings.os.version:
            extra_cflags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))
            extra_ldflags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))
        if self.settings.compiler == "Visual Studio":
            args.append("--pkg-config={}".format(tools.get_env("PKG_CONFIG")))
            args.append("--toolchain=msvc")
            if tools.Version(str(self.settings.compiler.version)) <= 12:
                # Visual Studio 2013 (and earlier) doesn't support "inline" keyword for C (only for C++)
                self._autotools.defines.append("inline=__inline")
        if tools.cross_building(self):
            args.append("--target-os={}".format(self._target_os))
            if tools.is_apple_os(self.settings.os):
                xcrun = tools.XCRun(self.settings)
                apple_arch = tools.to_apple_arch(str(self.settings.arch))
                extra_cflags.extend([
                    "-arch {}".format(apple_arch),
                    "-isysroot {}".format(xcrun.sdk_path)
                ])
                extra_ldflags.extend([
                    "-arch {}".format(apple_arch),
                    "-isysroot {}".format(xcrun.sdk_path)
                ])

        args.append("--extra-cflags={}".format(" ".join(extra_cflags)))
        args.append("--extra-ldflags={}".format(" ".join(extra_ldflags)))

        self._autotools.configure(args=args,
                                  configure_dir=self._source_subfolder,
                                  build=False,
                                  host=False,
                                  target=False)
        return self._autotools
Beispiel #15
0
    def _configure_cmd(self):
        if self.settings.compiler in ('clang', 'apple-clang'):
            botan_compiler = 'clang'
        elif self.settings.compiler == 'gcc':
            botan_compiler = 'gcc'
        else:
            botan_compiler = 'msvc'

        botan_abi_flags = []
        botan_extra_cxx_flags = []
        build_flags = []

        if self._is_linux_clang_libcxx:
            botan_abi_flags.extend(["-stdlib=libc++", "-lc++abi"])

        if botan_compiler in ['clang', 'apple-clang', 'gcc']:
            if self.settings.arch == "x86":
                botan_abi_flags.append('-m32')
            elif self.settings.arch == "x86_64":
                botan_abi_flags.append('-m64')

        if self.settings.os != "Windows" and self.options.fPIC:
            botan_extra_cxx_flags.append('-fPIC')

        if self.settings.os == "Macos" and self.settings.os.version:
            macos_min_version = tools.apple_deployment_target_flag(
                self.settings.os, self.settings.os.version)
            macos_sdk_path = "-isysroot {}".format(
                tools.XCRun(self.settings).sdk_path)
            botan_extra_cxx_flags.extend([macos_min_version, macos_sdk_path])

        # This is to work around botan's configure script that *replaces* its
        # standard (platform dependent) flags in presence of an environment
        # variable ${CXXFLAGS}. Most notably, this would build botan with
        # disabled compiler optimizations.
        environment_cxxflags = tools.get_env("CXXFLAGS")
        if environment_cxxflags:
            del os.environ["CXXFLAGS"]
            botan_extra_cxx_flags.append(environment_cxxflags)

        if self.options.enable_modules:
            build_flags.append('--minimized-build')
            build_flags.append('--enable-modules={}'.format(
                self.options.enable_modules))

        if self.options.amalgamation:
            build_flags.append('--amalgamation')

        if self.options.single_amalgamation:
            build_flags.append('--single-amalgamation-file')

        if self.options.system_cert_bundle:
            build_flags.append('--system-cert-bundle={}'.format(
                self.options.system_cert_bundle))

        if self.options.bzip2:
            build_flags.append('--with-bzip2')
            build_flags.extend(self._dependency_build_flags("bzip2"))

        if self.options.openssl:
            build_flags.append('--with-openssl')
            build_flags.extend(self._dependency_build_flags("OpenSSL"))

        if self.options.quiet:
            build_flags.append('--quiet')

        if self.options.sqlite3:
            build_flags.append('--with-sqlite3')
            build_flags.extend(self._dependency_build_flags("sqlite3"))

        if self.options.zlib:
            build_flags.append('--with-zlib')
            build_flags.extend(self._dependency_build_flags("zlib"))

        if self.options.boost:
            build_flags.append('--with-boost')
            build_flags.extend(self._dependency_build_flags("boost"))
            # required boost libraries are listed in Botan's src/utils/boost/info.txt
            # under the <libs></libs> tag...
            # Note that boost_system is actually a header-only library as of
            # boost 1.69. We are linking this for compatibility with older boost
            # versions...
            boost_system = [
                lib for lib in self.deps_cpp_info["boost"].libs
                if "boost_system" in lib
            ]
            if len(boost_system) != 1:
                raise ConanException(
                    "did not find a comprehensive boost_system library name: "
                    + str(boost_system))
            boost_system_name = boost_system[
                0] + ".lib" if self.settings.os == "Windows" else boost_system[
                    0]
            build_flags.append(
                '--boost-library-name={}'.format(boost_system_name))

        if self.settings.build_type == 'RelWithDebInfo' or self.options.debug_info:
            build_flags.append('--with-debug-info')

        if str(self.settings.build_type).lower() == 'debug':
            build_flags.append('--debug-mode')

        build_targets = ["shared"] if self.options.shared else ["static"]

        if self._is_mingw_windows:
            build_flags.append('--without-stack-protector')

        if self.settings.compiler == 'Visual Studio':
            build_flags.append('--msvc-runtime=%s' %
                               str(self.settings.compiler.runtime))

        call_python = 'python' if self.settings.os == 'Windows' else ''

        prefix = tools.unix_path(
            self.package_folder
        ) if self._is_mingw_windows else self.package_folder

        botan_abi = ' '.join(botan_abi_flags) if botan_abi_flags else ' '
        botan_cxx_extras = ' '.join(
            botan_extra_cxx_flags) if botan_extra_cxx_flags else ' '

        configure_cmd = ('{python_call} ./configure.py'
                         ' --build-targets={targets}'
                         ' --distribution-info="Conan"'
                         ' --without-documentation'
                         ' --cc-abi-flags="{abi}"'
                         ' --extra-cxxflags="{cxxflags}"'
                         ' --cc={compiler}'
                         ' --cpu={cpu}'
                         ' --prefix={prefix}'
                         ' --os={os}'
                         ' {build_flags}').format(
                             python_call=call_python,
                             targets=",".join(build_targets),
                             abi=botan_abi,
                             cxxflags=botan_cxx_extras,
                             compiler=botan_compiler,
                             cpu=self.settings.arch,
                             prefix=prefix,
                             os=self._botan_os,
                             build_flags=' '.join(build_flags))

        return configure_cmd
Beispiel #16
0
    def _build_flags(self):
        flags = self._build_cross_flags

        # https://www.boost.org/doc/libs/1_70_0/libs/context/doc/html/context/architectures.html
        if self._b2_os:
            flags.append("target-os=%s" % self._b2_os)
        if self._b2_architecture:
            flags.append("architecture=%s" % self._b2_architecture)
        if self._b2_address_model:
            flags.append("address-model=%s" % self._b2_address_model)
        if self._b2_binary_format:
            flags.append("binary-format=%s" % self._b2_binary_format)
        if self._b2_abi:
            flags.append("abi=%s" % self._b2_abi)

        if self.options.layout is not "b2-default":
            flags.append("--layout=%s" % self.options.layout)

        flags.append("--user-config=%s" %
                     os.path.join(self._boost_build_dir, 'user-config.jam'))

        def add_defines(library):
            for define in self.deps_cpp_info[library].defines:
                flags.append("define=%s" % define)

        if self._zip_bzip2_requires_needed:
            add_defines('zlib')
            add_defines('bzip2')

        if self._is_msvc and self.settings.compiler.runtime:
            flags.append('runtime-link=%s' % ('static' if 'MT' in str(
                self.settings.compiler.runtime) else 'shared'))

        # For details https://boostorg.github.io/build/manual/master/index.html
        flags.append(
            "threading=%s" %
            ("single" if not self.options.multithreading else "multi"))
        flags.append("visibility=%s" % self.options.visibility)

        flags.append("link=%s" %
                     ("static" if not self.options.shared else "shared"))
        if self.settings.build_type == "Debug":
            flags.append("variant=debug")
        else:
            flags.append("variant=release")

        for libname in LIB_LIST:
            if getattr(self.options, "without_%s" % libname):
                flags.append("--without-%s" % libname)

        # flags.append("toolset=%s" % self._toolset)

        # CXX FLAGS
        cxx_flags = []
        if self.settings.get_safe("compiler.cppstd"):
            cxx_flags.append(cppstd_flag(self.settings))

        if self.options.multithreading and self.settings.os == 'Emscripten':
            # NOTE: I tried to compile boost for emscripten and failed. Here are some notes:
            # - source/source_subfolder/tools/build/src/tools/emscripten.jam needs a patch to fix SEARCHED_LIBS error:
            #   import generators;
            #   generators.override emscripten.searched-lib-generator : searched-lib-generator ;
            # - tests, coroutines and fibers components don't work
            # - we have to build shared libraries otherwise log won't link
            # cxx_flags.append('-pthread')
            # cxx_flags.append('-fexceptions')
            pass

        # fPIC DEFINITION
        if self.settings.os != "Windows":
            if self.options.fPIC:
                cxx_flags.append("-fPIC")

        if self.settings.build_type == "RelWithDebInfo":
            if self.settings.compiler == "gcc" or "clang" in str(
                    self.settings.compiler):
                cxx_flags.append("-g")
            elif self.settings.compiler == "Visual Studio":
                cxx_flags.append("/Z7")

        # Standalone toolchain fails when declare the std lib
        if self.settings.os not in ["Android", "Emscripten"]:
            try:
                if self._gnu_cxx11_abi:
                    flags.append("define=_GLIBCXX_USE_CXX11_ABI=%s" %
                                 self._gnu_cxx11_abi)

                if "clang" in str(self.settings.compiler):
                    if str(self.settings.compiler.libcxx) == "libc++":
                        cxx_flags.append("-stdlib=libc++")
                        flags.append('linkflags="-stdlib=libc++"')
                    else:
                        cxx_flags.append("-stdlib=libstdc++")
            except:
                pass

        if self.options.error_code_header_only:
            flags.append("define=BOOST_ERROR_CODE_HEADER_ONLY=1")
        if self.options.system_no_deprecated:
            flags.append("define=BOOST_SYSTEM_NO_DEPRECATED=1")
        if self.options.asio_no_deprecated:
            flags.append("define=BOOST_ASIO_NO_DEPRECATED=1")
        if self.options.filesystem_no_deprecated:
            flags.append("define=BOOST_FILESYSTEM_NO_DEPRECATED=1")
        if self.options.segmented_stacks:
            flags.extend([
                "segmented-stacks=on", "define=BOOST_USE_SEGMENTED_STACKS=1",
                "define=BOOST_USE_UCONTEXT=1"
            ])

        if tools.is_apple_os(self.settings.os):
            if self.settings.get_safe("os.version"):
                sdk = self.settings.get_safe('os.sdk')
                subsystem = self.settings.get_safe('os.subsystem')
                cxx_flags.append(
                    tools.apple_deployment_target_flag(
                        self.settings.os, self.settings.os.version, sdk,
                        subsystem, self.settings.arch))

        if self.settings.os == "iOS":
            # One of the *_USE_PTHREADS flags causes iOS applications to crash when using boost::log
            # if self.options.multithreading:
            #     cxx_flags.append("-DBOOST_AC_USE_PTHREADS")
            #     cxx_flags.append("-DBOOST_SP_USE_PTHREADS")

            # Bitcode flag will be added automatically in darwin-toolchain
            # cxx_flags.append("-fembed-bitcode")
            pass

        cxx_flags = 'cxxflags="%s"' % " ".join(cxx_flags) if cxx_flags else ""
        flags.append(cxx_flags)

        if self.options.extra_b2_flags:
            flags.append(str(self.options.extra_b2_flags))

        flags.extend([
            "install",
            "--prefix=%s" % self.package_folder,
            "-j%s" % tools.cpu_count(), "--abbreviate-paths"
        ])
        if self.options.debug_level:
            flags.append("-d%d" % self.options.debug_level)
        return flags
Beispiel #17
0
    def build(self):
        for filename in glob.glob("patches/*.patch"):
            self.output.info('applying patch "%s"' % filename)
            tools.patch(base_path=self._source_subfolder, patch_file=filename)

        if self._is_msvc:
            run_configure_icu_file = os.path.join(self._source_subfolder, 'source', 'runConfigureICU')

            flags = "-%s" % self.settings.compiler.runtime
            if self.settings.get_safe("build_type") == 'Debug':
                flags += " -FS"
            tools.replace_in_file(run_configure_icu_file, "-MDd", flags)
            tools.replace_in_file(run_configure_icu_file, "-MD", flags)

        # self._replace_pythonpath() # ICU 64.1
        # self._workaround_icu_20545()


        # self.output.info('******************************************************************')
        # conans.client.build.compiler_flags.libcxx_define = libcxx_define_replacement
        # self.output.info('******************************************************************')

        self._env_build = KnuthAutoToolsBuildEnvironment(self)

        # self.output.info('******************************************************************')
        # conans.client.build.compiler_flags.libcxx_define = libcxx_define_replacement
        # self.output.info('******************************************************************')

        # self.output.info(self.settings.compiler)
        # self.output.info(self.settings.compiler.libcxx)
        # abif = conans.client.build.compiler_flags.libcxx_define(self.settings.compiler, self.settings.compiler.libcxx)
        # self.output.info('------------------------------------------------------------------')
        # self.output.info(abif)
        self.output.info('------------------------------------------------------------------')
        self.output.info(self._env_build.cxx_flags)
        self.output.info('------------------------------------------------------------------')


        # if self.options.get_safe("glibcxx_supports_cxx11_abi"):
        #     self.output.info(self.options.glibcxx_supports_cxx11_abi)

        #     if self.options.glibcxx_supports_cxx11_abi:
        #         # self._env_build.cxx_flags.append('-D_GLIBCXX_USE_CXX11_ABI=1')
        #         self._env_build.cxx_flags.insert(0, '-D_GLIBCXX_USE_CXX11_ABI=1')
        #     else:
        #         # self._env_build.cxx_flags.append('-D_GLIBCXX_USE_CXX11_ABI=0')
        #         self._env_build.cxx_flags.insert(0, '-D_GLIBCXX_USE_CXX11_ABI=0')

        #     # if float(str(self.settings.compiler.version)) >= 5:
        #     #     cxx11_abi_str = '-D_GLIBCXX_USE_CXX11_ABI=1'
        #     # else:
        #     #     cxx11_abi_str = '-D_GLIBCXX_USE_CXX11_ABI=0'

        # self.output.info('------------------------------------------------------------------')
        # self.output.info(self._env_build.cxx_flags)
        # self.output.info('------------------------------------------------------------------')

        if not self.options.get_safe("shared"):
            self._env_build.defines.append("U_STATIC_IMPLEMENTATION")
        if tools.is_apple_os(self._the_os):
            self._env_build.defines.append("_DARWIN_C_SOURCE")
            if self.settings.get_safe("os.version"):
                self._env_build.flags.append(tools.apple_deployment_target_flag(self._the_os,
                                                                            self.settings.os.version))

        build_dir = os.path.join(self.build_folder, self._source_subfolder, 'build')
        os.mkdir(build_dir)

        with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():
            with tools.environment_append(self._env_build.vars):
                with tools.chdir(build_dir):
                    # workaround for https://unicode-org.atlassian.net/browse/ICU-20531
                    os.makedirs(os.path.join("data", "out", "tmp"))

                    self.run(self._build_config_cmd, win_bash=tools.os_info.is_windows)
                    if self._silent:
                        silent = '--silent' if self._silent else 'VERBOSE=1'
                    else:
                        silent = '--silent'
                    command = "make {silent} -j {cpu_count}".format(silent=silent,
                                                                    cpu_count=tools.cpu_count())
                    self.run(command, win_bash=tools.os_info.is_windows)
                    if self.options.get_safe("tests"):
                        command = "make {silent} check".format(silent=silent)
                        self.run(command, win_bash=tools.os_info.is_windows)
                    command = "make {silent} install".format(silent=silent)
                    self.run(command, win_bash=tools.os_info.is_windows)

        self._install_name_tool()
        self.output.info('------------------------------------------------------------------')
        self.output.info(self._env_build.cxx_flags)
        self.output.info('------------------------------------------------------------------')
    def _configure_cmd(self):
        if self.settings.compiler in ('clang', 'apple-clang'):
            botan_compiler = 'clang'
        elif self.settings.compiler == 'gcc':
            botan_compiler = 'gcc'
        else:
            botan_compiler = 'msvc'

        botan_abi_flags = []
        botan_extra_cxx_flags = []
        build_flags = []

        if self._is_linux_clang_libcxx:
            botan_abi_flags.extend(['-stdlib=libc++', '-lc++abi'])

        if botan_compiler in ['clang', 'apple-clang', 'gcc']:
            if self.settings.arch == 'x86':
                botan_abi_flags.append('-m32')
            elif self.settings.arch == 'x86_64':
                botan_abi_flags.append('-m64')

        if self.options.get_safe('fPIC', True):
            botan_extra_cxx_flags.append('-fPIC')

        if tools.is_apple_os(self.settings.os):
            if self.settings.get_safe('os.version'):
                # Required, see https://github.com/conan-io/conan-center-index/pull/3456
                macos_min_version = tools.apple_deployment_target_flag(
                    self.settings.os, self.settings.get_safe('os.version'),
                    self.settings.get_safe('os.sdk'),
                    self.settings.get_safe('os.subsystem'),
                    self.settings.get_safe('arch'))
                botan_extra_cxx_flags.append(macos_min_version)
            macos_sdk_path = '-isysroot {}'.format(
                tools.XCRun(self.settings).sdk_path)
            botan_extra_cxx_flags.append(macos_sdk_path)

        # This is to work around botan's configure script that *replaces* its
        # standard (platform dependent) flags in presence of an environment
        # variable ${CXXFLAGS}. Most notably, this would build botan with
        # disabled compiler optimizations.
        environment_cxxflags = tools.get_env('CXXFLAGS')
        if environment_cxxflags:
            del os.environ['CXXFLAGS']
            botan_extra_cxx_flags.append(environment_cxxflags)

        if self.options.enable_modules:
            build_flags.append('--minimized-build')
            build_flags.append('--enable-modules={}'.format(
                self.options.enable_modules))

        if self.options.amalgamation:
            build_flags.append('--amalgamation')

        if self.options.get_safe('single_amalgamation'):
            build_flags.append('--single-amalgamation-file')

        if self.options.system_cert_bundle:
            build_flags.append('--system-cert-bundle={}'.format(
                self.options.system_cert_bundle))

        if self.options.with_bzip2:
            build_flags.append('--with-bzip2')
            build_flags.extend(self._dependency_build_flags('bzip2'))

        if self.options.with_openssl:
            build_flags.append('--with-openssl')
            build_flags.extend(self._dependency_build_flags('openssl'))

        if self.options.with_sqlite3:
            build_flags.append('--with-sqlite3')
            build_flags.extend(self._dependency_build_flags('sqlite3'))

        if self.options.with_zlib:
            build_flags.append('--with-zlib')
            build_flags.extend(self._dependency_build_flags('zlib'))

        if self.options.with_boost:
            build_flags.append('--with-boost')
            build_flags.extend(self._dependency_build_flags('boost'))

        if self.options.module_policy:
            build_flags.append('--module-policy={}'.format(
                self.options.module_policy))

        if self.settings.build_type == 'RelWithDebInfo':
            build_flags.append('--with-debug-info')

        if self._is_x86:
            if not self.options.with_sse2:
                build_flags.append('--disable-sse2')

            if not self.options.with_ssse3:
                build_flags.append('--disable-ssse3')

            if not self.options.with_sse4_1:
                build_flags.append('--disable-sse4.1')

            if not self.options.with_sse4_2:
                build_flags.append('--disable-sse4.2')

            if not self.options.with_avx2:
                build_flags.append('--disable-avx2')

            if not self.options.with_bmi2:
                build_flags.append('--disable-bmi2')

            if not self.options.with_rdrand:
                build_flags.append('--disable-rdrand')

            if not self.options.with_rdseed:
                build_flags.append('--disable-rdseed')

            if not self.options.with_aes_ni:
                build_flags.append('--disable-aes-ni')

            if not self.options.with_sha_ni:
                build_flags.append('--disable-sha-ni')

        if self._is_ppc:
            if not self.options.with_powercrypto:
                build_flags.append('--disable-powercrypto')

            if not self.options.with_altivec:
                build_flags.append('--disable-altivec')

        if self._is_arm:
            if not self.options.with_neon:
                build_flags.append('--disable-neon')

            if not self.options.with_armv8crypto:
                build_flags.append('--disable-armv8crypto')

        if str(self.settings.build_type).lower() == 'debug':
            build_flags.append('--debug-mode')

        build_targets = ['shared'] if self.options.shared else ['static']

        if self._is_mingw_windows:
            build_flags.append('--without-stack-protector')

        if self.settings.compiler == 'Visual Studio':
            build_flags.append('--msvc-runtime=%s' %
                               str(self.settings.compiler.runtime))

        build_flags.append('--without-pkg-config')

        call_python = 'python' if self.settings.os == 'Windows' else ''

        prefix = tools.unix_path(
            self.package_folder
        ) if self._is_mingw_windows else self.package_folder

        botan_abi = ' '.join(botan_abi_flags) if botan_abi_flags else ' '
        botan_cxx_extras = ' '.join(
            botan_extra_cxx_flags) if botan_extra_cxx_flags else ' '

        configure_cmd = ('{python_call} ./configure.py'
                         ' --build-targets={targets}'
                         ' --distribution-info="Conan"'
                         ' --without-documentation'
                         ' --cc-abi-flags="{abi}"'
                         ' --extra-cxxflags="{cxxflags}"'
                         ' --cc={compiler}'
                         ' --cpu={cpu}'
                         ' --prefix={prefix}'
                         ' --os={os}'
                         ' {build_flags}').format(
                             python_call=call_python,
                             targets=','.join(build_targets),
                             abi=botan_abi,
                             cxxflags=botan_cxx_extras,
                             compiler=botan_compiler,
                             cpu=self.settings.arch,
                             prefix=prefix,
                             os=self._botan_os,
                             build_flags=' '.join(build_flags))

        return configure_cmd
    def _configure_autotools(self):
        if self._autotools:
            return self._autotools
        self._autotools = AutoToolsBuildEnvironment(
            self, win_bash=tools.os_info.is_windows)
        self._autotools.libs = []

        def opt_enable_disable(what, v):
            return "--{}-{}".format("enable" if v else "disable", what)

        def opt_append_disable_if_set(args, what, v):
            if v:
                args.append("--disable-{}".format(what))

        args = [
            "--pkg-config-flags=--static",
            "--disable-doc",
            opt_enable_disable("cross-compile", tools.cross_building(self)),
            opt_enable_disable("asm", self.options.with_asm),
            # Libraries
            opt_enable_disable("shared", self.options.shared),
            opt_enable_disable("static", not self.options.shared),
            opt_enable_disable("pic", self.options.get_safe("fPIC", True)),
            # Components
            opt_enable_disable("avdevice", self.options.avdevice),
            opt_enable_disable("avcodec", self.options.avcodec),
            opt_enable_disable("avformat", self.options.avformat),
            opt_enable_disable("swresample", self.options.swresample),
            opt_enable_disable("swscale", self.options.swscale),
            opt_enable_disable("postproc", self.options.postproc),
            opt_enable_disable("avfilter", self.options.avfilter),

            # Dependencies
            opt_enable_disable("bzlib", self.options.with_bzip2),
            opt_enable_disable("zlib", self.options.with_zlib),
            opt_enable_disable("lzma", self.options.with_lzma),
            opt_enable_disable("iconv", self.options.with_libiconv),
            opt_enable_disable("libopenjpeg", self.options.with_openjpeg),
            opt_enable_disable("libopenh264", self.options.with_openh264),
            opt_enable_disable("libvorbis", self.options.with_vorbis),
            opt_enable_disable("libopus", self.options.with_opus),
            opt_enable_disable("libzmq", self.options.with_zeromq),
            opt_enable_disable("sdl2", self.options.with_sdl),
            opt_enable_disable("libx264", self.options.with_libx264),
            opt_enable_disable("libx265", self.options.with_libx265),
            opt_enable_disable("libvpx", self.options.with_libvpx),
            opt_enable_disable("libmp3lame", self.options.with_libmp3lame),
            opt_enable_disable("libfdk-aac", self.options.with_libfdk_aac),
            opt_enable_disable("libwebp", self.options.with_libwebp),
            opt_enable_disable("openssl", self.options.with_ssl == "openssl"),
            opt_enable_disable("alsa", self.options.get_safe("with_libalsa")),
            opt_enable_disable("libpulse",
                               self.options.get_safe("with_pulse")),
            opt_enable_disable("vaapi", self.options.get_safe("with_vaapi")),
            opt_enable_disable("vdpau", self.options.get_safe("with_vdpau")),
            opt_enable_disable("libxcb", self.options.get_safe("with_xcb")),
            opt_enable_disable("libxcb-shm",
                               self.options.get_safe("with_xcb")),
            opt_enable_disable("libxcb-shape",
                               self.options.get_safe("with_xcb")),
            opt_enable_disable("libxcb-xfixes",
                               self.options.get_safe("with_xcb")),
            opt_enable_disable("appkit", self.options.get_safe("with_appkit")),
            opt_enable_disable("avfoundation",
                               self.options.get_safe("with_avfoundation")),
            opt_enable_disable("coreimage",
                               self.options.get_safe("with_coreimage")),
            opt_enable_disable("audiotoolbox",
                               self.options.get_safe("with_audiotoolbox")),
            opt_enable_disable("videotoolbox",
                               self.options.get_safe("with_videotoolbox")),
            opt_enable_disable("securetransport",
                               self.options.with_ssl == "securetransport"),
            "--disable-cuda",  # FIXME: CUDA support
            "--disable-cuvid",  # FIXME: CUVID support
            # Licenses
            opt_enable_disable(
                "nonfree", self.options.with_libfdk_aac
                or (self.options.with_ssl and
                    (self.options.with_libx264 or self.options.with_libx265
                     or self.options.postproc))),
            opt_enable_disable(
                "gpl", self.options.with_libx264 or self.options.with_libx265
                or self.options.postproc)
        ]

        # Individual Component Options
        opt_append_disable_if_set(args, "everything",
                                  self.options.disable_everything)
        opt_append_disable_if_set(args, "encoders",
                                  self.options.disable_all_encoders)
        opt_append_disable_if_set(args, "decoders",
                                  self.options.disable_all_decoders)
        opt_append_disable_if_set(
            args, "hwaccels", self.options.disable_all_hardware_accelerators)
        opt_append_disable_if_set(args, "muxers",
                                  self.options.disable_all_muxers)
        opt_append_disable_if_set(args, "demuxers",
                                  self.options.disable_all_demuxers)
        opt_append_disable_if_set(args, "parsers",
                                  self.options.disable_all_parsers)
        opt_append_disable_if_set(args, "bsfs",
                                  self.options.disable_all_bitstream_filters)
        opt_append_disable_if_set(args, "protocols",
                                  self.options.disable_all_protocols)
        opt_append_disable_if_set(args, "devices",
                                  self.options.disable_all_devices)
        opt_append_disable_if_set(args, "indevs",
                                  self.options.disable_all_input_devices)
        opt_append_disable_if_set(args, "outdevs",
                                  self.options.disable_all_output_devices)
        opt_append_disable_if_set(args, "filters",
                                  self.options.disable_all_filters)

        args.extend(
            self._split_and_format_options_string(
                "enable-encoder", self.options.enable_encoders))
        args.extend(
            self._split_and_format_options_string(
                "disable-encoder", self.options.disable_encoders))
        args.extend(
            self._split_and_format_options_string(
                "enable-decoder", self.options.enable_decoders))
        args.extend(
            self._split_and_format_options_string(
                "disable-decoder", self.options.disable_decoders))
        args.extend(
            self._split_and_format_options_string(
                "enable-hwaccel", self.options.enable_hardware_accelerators))
        args.extend(
            self._split_and_format_options_string(
                "disable-hwaccel", self.options.disable_hardware_accelerators))
        args.extend(
            self._split_and_format_options_string("enable-muxer",
                                                  self.options.enable_muxers))
        args.extend(
            self._split_and_format_options_string("disable-muxer",
                                                  self.options.disable_muxers))
        args.extend(
            self._split_and_format_options_string(
                "enable-demuxer", self.options.enable_demuxers))
        args.extend(
            self._split_and_format_options_string(
                "disable-demuxer", self.options.disable_demuxers))
        args.extend(
            self._split_and_format_options_string("enable-parser",
                                                  self.options.enable_parsers))
        args.extend(
            self._split_and_format_options_string(
                "disable-parser", self.options.disable_parsers))
        args.extend(
            self._split_and_format_options_string(
                "enable-bsf", self.options.enable_bitstream_filters))
        args.extend(
            self._split_and_format_options_string(
                "disable-bsf", self.options.disable_bitstream_filters))
        args.extend(
            self._split_and_format_options_string(
                "enable-protocol", self.options.enable_protocols))
        args.extend(
            self._split_and_format_options_string(
                "disable-protocol", self.options.disable_protocols))
        args.extend(
            self._split_and_format_options_string(
                "enable-indev", self.options.enable_input_devices))
        args.extend(
            self._split_and_format_options_string(
                "disable-indev", self.options.disable_input_devices))
        args.extend(
            self._split_and_format_options_string(
                "enable-outdev", self.options.enable_output_devices))
        args.extend(
            self._split_and_format_options_string(
                "disable-outdev", self.options.disable_output_devices))
        args.extend(
            self._split_and_format_options_string("enable-filter",
                                                  self.options.enable_filters))
        args.extend(
            self._split_and_format_options_string(
                "disable-filter", self.options.disable_filters))

        if self._version_supports_vulkan():
            args.append(
                opt_enable_disable("vulkan",
                                   self.options.get_safe("with_vulkan")))
        if tools.is_apple_os(self.settings.os):
            # relocatable shared libs
            args.append("--install-name-dir=@rpath")
        args.append("--arch={}".format(self._target_arch))
        if self.settings.build_type == "Debug":
            args.extend([
                "--disable-optimizations",
                "--disable-mmx",
                "--disable-stripping",
                "--enable-debug",
            ])
        if not self.options.with_programs:
            args.append("--disable-programs")
        # since ffmpeg"s build system ignores CC and CXX
        if tools.get_env("AS"):
            args.append("--as={}".format(tools.get_env("AS")))
        if tools.get_env("CC"):
            args.append("--cc={}".format(tools.get_env("CC")))
        if tools.get_env("CXX"):
            args.append("--cxx={}".format(tools.get_env("CXX")))
        extra_cflags = []
        extra_ldflags = []
        if tools.is_apple_os(self.settings.os) and self.settings.os.version:
            extra_cflags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))
            extra_ldflags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))
        if self._is_msvc:
            args.append("--pkg-config={}".format(tools.get_env("PKG_CONFIG")))
            args.append("--toolchain=msvc")
            if self.settings.compiler == "Visual Studio" and tools.Version(
                    self.settings.compiler.version) <= "12":
                # Visual Studio 2013 (and earlier) doesn't support "inline" keyword for C (only for C++)
                self._autotools.defines.append("inline=__inline")
        if tools.cross_building(self):
            if self._target_os == "emscripten":
                args.append("--target-os=none")
            else:
                args.append("--target-os={}".format(self._target_os))

            if tools.is_apple_os(self.settings.os):
                xcrun = tools.XCRun(self.settings)
                apple_arch = tools.to_apple_arch(str(self.settings.arch))
                extra_cflags.extend([
                    "-arch {}".format(apple_arch),
                    "-isysroot {}".format(xcrun.sdk_path)
                ])
                extra_ldflags.extend([
                    "-arch {}".format(apple_arch),
                    "-isysroot {}".format(xcrun.sdk_path)
                ])

        args.append("--extra-cflags={}".format(" ".join(extra_cflags)))
        args.append("--extra-ldflags={}".format(" ".join(extra_ldflags)))

        self._autotools.configure(args=args,
                                  configure_dir=self._source_subfolder,
                                  build=False,
                                  host=False,
                                  target=False)
        return self._autotools
Beispiel #20
0
    def get_build_flags(self):

        if tools.cross_building(self.settings):
            flags = self.get_build_cross_flags()
        else:
            flags = []

        # https://www.boost.org/doc/libs/1_69_0/libs/context/doc/html/context/architectures.html
        if self._b2_os:
            flags.append("target-os=%s" % self._b2_os)
        if self._b2_architecture:
            flags.append("architecture=%s" % self._b2_architecture)
        if self._b2_address_model:
            flags.append("address-model=%s" % self._b2_address_model)
        if self._b2_binary_format:
            flags.append("binary-format=%s" % self._b2_binary_format)
        if self._b2_abi:
            flags.append("abi=%s" % self._b2_abi)

        flags.append("-sBOOST_BUILD_PATH=%s" % self._boost_build_dir)
        if self.settings.compiler == "gcc":
            flags.append("--layout=system")

        if self._is_msvc and self.settings.compiler.runtime:
            flags.append("runtime-link=%s" % ("static" if "MT" in str(
                self.settings.compiler.runtime) else "shared"))

        flags.append("threading=multi")

        flags.append("link=%s" %
                     ("static" if not self.options.shared else "shared"))
        if self.settings.build_type == "Debug":
            flags.append("variant=debug")
        else:
            flags.append("variant=release")

        for libname in lib_list:
            if getattr(self.options, "without_%s" % libname):
                flags.append("--without-%s" % libname)

        toolset, _, _ = self.get_toolset_version_and_exe()
        flags.append("toolset=%s" % toolset)

        if self.settings.cppstd:
            flags.append(
                "cxxflags=%s" %
                cppstd_flag(self.settings.get_safe("compiler"),
                            self.settings.get_safe("compiler.version"),
                            self.settings.get_safe("cppstd")))

        # CXX FLAGS
        cxx_flags = []
        # fPIC DEFINITION
        if self.settings.os != "Windows":
            if self.options.fPIC:
                cxx_flags.append("-fPIC")

        # Standalone toolchain fails when declare the std lib
        if self.settings.os != "Android":
            try:
                if str(self.settings.compiler.libcxx) == "libstdc++":
                    flags.append("define=_GLIBCXX_USE_CXX11_ABI=0")
                elif str(self.settings.compiler.libcxx) == "libstdc++11":
                    flags.append("define=_GLIBCXX_USE_CXX11_ABI=1")
                if "clang" in str(self.settings.compiler):
                    if str(self.settings.compiler.libcxx) == "libc++":
                        cxx_flags.append("-stdlib=libc++")
                        flags.append('linkflags="-stdlib=libc++"')
                    else:
                        cxx_flags.append("-stdlib=libstdc++")
            except:
                pass

        if self.options.error_code_header_only:
            flags.append("define=BOOST_ERROR_CODE_HEADER_ONLY=1")
        if self.options.system_no_deprecated:
            flags.append("define=BOOST_SYSTEM_NO_DEPRECATED=1")
        if self.options.asio_no_deprecated:
            flags.append("define=BOOST_ASIO_NO_DEPRECATED=1")

        if tools.is_apple_os(self.settings.os):
            if self.settings.get_safe("os.version"):
                cxx_flags.append(
                    tools.apple_deployment_target_flag(
                        self.settings.os, self.settings.os.version))

        if self.settings.os == "iOS":
            cxx_flags.append("-DBOOST_AC_USE_PTHREADS")
            cxx_flags.append("-DBOOST_SP_USE_PTHREADS")
            cxx_flags.append("-fvisibility=hidden")
            cxx_flags.append("-fvisibility-inlines-hidden")
            cxx_flags.append("-fembed-bitcode")

        cxx_flags = 'cxxflags="%s"' % " ".join(cxx_flags) if cxx_flags else ""
        flags.append(cxx_flags)

        return flags
Beispiel #21
0
    def _build_zlib(self):
        with tools.chdir(self._source_subfolder):
            for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']:
                tools.replace_in_file(
                    filename,
                    '#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */',
                    '#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)')
                tools.replace_in_file(
                    filename,
                    '#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */',
                    '#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)')
            tools.mkdir("_build")
            with tools.chdir("_build"):
                if not tools.os_info.is_windows:
                    env_build = AutoToolsBuildEnvironment(self)

                    if tools.is_apple_os(
                            self.settings.os) and self.settings.get_safe(
                                "os.version"):
                        env_build.flags.append(
                            tools.apple_deployment_target_flag(
                                self.settings.os, self.settings.os.version))

                    if self.settings.os == "Macos":
                        old_str = '-install_name $libdir/$SHAREDLIBM'
                        new_str = '-install_name $SHAREDLIBM'
                        tools.replace_in_file("../configure", old_str, new_str)

                    # https://github.com/madler/zlib/issues/268
                    tools.replace_in_file(
                        '../gzguts.h',
                        '#if defined(_WIN32) || defined(__CYGWIN__)',
                        '#if defined(_WIN32) || defined(__MINGW32__)')

                    if self.settings.os == "Windows":  # Cross building to Linux
                        tools.replace_in_file(
                            "../configure",
                            'LDSHAREDLIBC="${LDSHAREDLIBC--lc}"',
                            'LDSHAREDLIBC=""')
                    # Zlib configure doesnt allow this parameters

                    if self.settings.os == "iOS":
                        tools.replace_in_file(
                            "../gzguts.h", '#ifdef _LARGEFILE64_SOURCE',
                            '#include <unistd.h>\n\n#ifdef _LARGEFILE64_SOURCE'
                        )

                    # configure passes CFLAGS to linker, should be LDFLAGS
                    tools.replace_in_file("../configure", "$LDSHARED $SFLAGS",
                                          "$LDSHARED $LDFLAGS")
                    # same thing in Makefile.in, when building tests/example executables
                    tools.replace_in_file("../Makefile.in",
                                          "$(CC) $(CFLAGS) -o",
                                          "$(CC) $(LDFLAGS) -o")

                    env_build_vars = env_build.vars
                    if tools.is_apple_os(self.settings.os):
                        # force macOS ranlib because ranlib from binutils produced malformed ar archives
                        env_build_vars['RANLIB'] = tools.XCRun(
                            self.settings).ranlib

                    if self.settings.os == "Windows" and tools.os_info.is_linux:
                        # we need to build only libraries without test example and minigzip
                        if self.options.shared:
                            make_target = "zlib1.dll"
                        else:
                            make_target = "libz.a"
                        # Let our profile to declare what is needed.
                        tools.replace_in_file("../win32/Makefile.gcc",
                                              'LDFLAGS = $(LOC)', '')
                        tools.replace_in_file("../win32/Makefile.gcc",
                                              'AS = $(CC)', '')
                        tools.replace_in_file("../win32/Makefile.gcc",
                                              'AR = $(PREFIX)ar', '')
                        tools.replace_in_file("../win32/Makefile.gcc",
                                              'CC = $(PREFIX)gcc', '')
                        tools.replace_in_file("../win32/Makefile.gcc",
                                              'RC = $(PREFIX)windres', '')
                        self.run("cd .. && make -f win32/Makefile.gcc %s" %
                                 make_target)
                    else:
                        # we need to build only libraries without test example and minigzip
                        if self.options.shared:
                            if self.settings.os == "Macos":
                                make_target = "libz.%s.dylib" % self.version
                            else:
                                make_target = "libz.so.%s" % self.version
                        else:
                            make_target = "libz.a"
                        env_build.configure("../",
                                            build=False,
                                            host=False,
                                            target=False,
                                            vars=env_build_vars)
                        env_build.make(target=make_target)
                else:
                    cmake = CMake(self)
                    cmake.configure(build_dir=".")
                    # we need to build only libraries without test example/example64 and minigzip/minigzip64
                    if self.options.shared:
                        make_target = "zlib"
                    else:
                        make_target = "zlibstatic"
                    cmake.build(build_dir=".", target=make_target)
Beispiel #22
0
    def get_build_flags(self):

        if tools.cross_building(self.settings):
            flags = self.get_build_cross_flags()
        else:
            flags = []

        # https://www.boost.org/doc/libs/1_70_0/libs/context/doc/html/context/architectures.html
        if self._b2_os:
            flags.append("target-os=%s" % self._b2_os)
        if self._b2_architecture:
            flags.append("architecture=%s" % self._b2_architecture)
        if self._b2_address_model:
            flags.append("address-model=%s" % self._b2_address_model)
        if self._b2_binary_format:
            flags.append("binary-format=%s" % self._b2_binary_format)
        if self._b2_abi:
            flags.append("abi=%s" % self._b2_abi)

        flags.append("--layout=%s" % self.options.layout)
        flags.append("-sBOOST_BUILD_PATH=%s" % self._boost_build_dir)
        flags.append("-sNO_ZLIB=%s" % ("0" if self.options.zlib else "1"))
        flags.append("-sNO_BZIP2=%s" % ("0" if self.options.bzip2 else "1"))
        flags.append("-sNO_LZMA=%s" % ("0" if self.options.lzma else "1"))
        flags.append("-sNO_ZSTD=%s" % ("0" if self.options.zstd else "1"))

        def add_defines(option, library):
            if option:
                for define in self.deps_cpp_info[library].defines:
                    flags.append("define=%s" % define)

        if self.zip_bzip2_requires_needed:
            add_defines(self.options.zlib, "zlib")
            add_defines(self.options.bzip2, "bzip2")
            add_defines(self.options.lzma, "lzma")
            add_defines(self.options.zstd, "zstd")

        if self._is_msvc and self.settings.compiler.runtime:
            flags.append("runtime-link=%s" % ("static" if "MT" in str(self.settings.compiler.runtime) else "shared"))

        flags.append("threading=multi")

        flags.append("link=%s" % ("static" if not self.options.shared else "shared"))
        if self.settings.build_type == "Debug":
            flags.append("variant=debug")
        else:
            flags.append("variant=release")

        for libname in lib_list:
            if getattr(self.options, "without_%s" % libname):
                flags.append("--without-%s" % libname)

        toolset, _, _ = self.get_toolset_version_and_exe()
        flags.append("toolset=%s" % toolset)

        if self.settings.get_safe("compiler.cppstd"):
            flags.append("cxxflags=%s" % cppstd_flag(
                    self.settings.get_safe("compiler"),
                    self.settings.get_safe("compiler.version"),
                    self.settings.get_safe("compiler.cppstd")
                )
            )

        # CXX FLAGS
        cxx_flags = []
        # fPIC DEFINITION
        if self.settings.os != "Windows":
            if self.options.fPIC:
                cxx_flags.append("-fPIC")

        # Standalone toolchain fails when declare the std lib
        if self.settings.os != "Android":
            try:
                if self._gnu_cxx11_abi:
                    flags.append("define=_GLIBCXX_USE_CXX11_ABI=%s" % self._gnu_cxx11_abi)

                if "clang" in str(self.settings.compiler):
                    if str(self.settings.compiler.libcxx) == "libc++":
                        cxx_flags.append("-stdlib=libc++")
                        flags.append('linkflags="-stdlib=libc++"')
                    else:
                        cxx_flags.append("-stdlib=libstdc++")
            except:
                pass

        if self.options.error_code_header_only:
            flags.append("define=BOOST_ERROR_CODE_HEADER_ONLY=1")
        if self.options.system_no_deprecated:
            flags.append("define=BOOST_SYSTEM_NO_DEPRECATED=1")
        if self.options.asio_no_deprecated:
            flags.append("define=BOOST_ASIO_NO_DEPRECATED=1")
        if self.options.filesystem_no_deprecated:
            flags.append("define=BOOST_FILESYSTEM_NO_DEPRECATED=1")
        if self.options.segmented_stacks:
            flags.extend(["segmented-stacks=on",
                          "define=BOOST_USE_SEGMENTED_STACKS=1",
                          "define=BOOST_USE_UCONTEXT=1"])

        if tools.is_apple_os(self.settings.os):
            if self.settings.get_safe("os.version"):
                cxx_flags.append(tools.apple_deployment_target_flag(self.settings.os,
                                                                    self.settings.os.version))

        if self.settings.os == "iOS":
            cxx_flags.append("-DBOOST_AC_USE_PTHREADS")
            cxx_flags.append("-DBOOST_SP_USE_PTHREADS")
            cxx_flags.append("-fvisibility=hidden")
            cxx_flags.append("-fvisibility-inlines-hidden")
            cxx_flags.append("-fembed-bitcode")

        cxx_flags = 'cxxflags="%s"' % " ".join(cxx_flags) if cxx_flags else ""
        flags.append(cxx_flags)

        if self.options.extra_b2_flags:
            flags.append(str(self.options.extra_b2_flags))

        return flags
    def _configure_cmd(self):
        if self.settings.compiler in ('clang', 'apple-clang'):
            botan_compiler = 'clang'
        elif self.settings.compiler == 'gcc':
            botan_compiler = 'gcc'
        else:
            botan_compiler = 'msvc'

        botan_abi_flags = []
        botan_extra_cxx_flags = []
        build_flags = []

        if self._is_linux_clang_libcxx:
            botan_abi_flags.extend(["-stdlib=libc++", "-lc++abi"])

        if botan_compiler in ['clang', 'apple-clang', 'gcc']:
            if self.settings.arch == "x86":
                botan_abi_flags.append('-m32')
            elif self.settings.arch == "x86_64":
                botan_abi_flags.append('-m64')

        if self.settings.os != "Windows" and self.options.fPIC:
            botan_extra_cxx_flags.append('-fPIC')

        if self.settings.os == "Macos" and self.settings.os.version:
            macos_min_version = tools.apple_deployment_target_flag(
                self.settings.os, self.settings.os.version)
            macos_sdk_path = "-isysroot {}".format(
                tools.XCRun(self.settings).sdk_path)
            botan_extra_cxx_flags.extend([macos_min_version, macos_sdk_path])

        # This is to work around botan's configure script that *replaces* its
        # standard (platform dependent) flags in presence of an environment
        # variable ${CXXFLAGS}. Most notably, this would build botan with
        # disabled compiler optimizations.
        environment_cxxflags = tools.get_env("CXXFLAGS")
        if environment_cxxflags:
            del os.environ["CXXFLAGS"]
            botan_extra_cxx_flags.append(environment_cxxflags)

        if self.options.enable_modules:
            build_flags.append('--minimized-build')
            build_flags.append('--enable-modules={}'.format(
                self.options.enable_modules))

        if self.options.amalgamation:
            build_flags.append('--amalgamation')

        if self.options.single_amalgamation:
            build_flags.append('--single-amalgamation-file')

        if self.options.system_cert_bundle:
            build_flags.append('--system-cert-bundle={}'.format(
                self.options.system_cert_bundle))

        if self.options.with_bzip2:
            build_flags.append('--with-bzip2')
            build_flags.extend(self._dependency_build_flags("bzip2"))

        if self.options.with_openssl:
            build_flags.append('--with-openssl')
            build_flags.extend(self._dependency_build_flags("OpenSSL"))

        if self.options.with_sqlite3:
            build_flags.append('--with-sqlite3')
            build_flags.extend(self._dependency_build_flags("sqlite3"))

        if self.options.with_zlib:
            build_flags.append('--with-zlib')
            build_flags.extend(self._dependency_build_flags("zlib"))

        if self.options.with_boost:
            build_flags.append('--with-boost')
            build_flags.extend(self._dependency_build_flags("boost"))

        if self.settings.build_type == 'RelWithDebInfo':
            build_flags.append('--with-debug-info')

        if str(self.settings.build_type).lower() == 'debug':
            build_flags.append('--debug-mode')

        build_targets = ["shared"] if self.options.shared else ["static"]

        if self._is_mingw_windows:
            build_flags.append('--without-stack-protector')

        if self.settings.compiler == 'Visual Studio':
            build_flags.append('--msvc-runtime=%s' %
                               str(self.settings.compiler.runtime))

        build_flags.append('--without-pkg-config')

        call_python = 'python' if self.settings.os == 'Windows' else ''

        prefix = tools.unix_path(
            self.package_folder
        ) if self._is_mingw_windows else self.package_folder

        botan_abi = ' '.join(botan_abi_flags) if botan_abi_flags else ' '
        botan_cxx_extras = ' '.join(
            botan_extra_cxx_flags) if botan_extra_cxx_flags else ' '

        configure_cmd = ('{python_call} ./configure.py'
                         ' --build-targets={targets}'
                         ' --distribution-info="Conan"'
                         ' --without-documentation'
                         ' --cc-abi-flags="{abi}"'
                         ' --extra-cxxflags="{cxxflags}"'
                         ' --cc={compiler}'
                         ' --cpu={cpu}'
                         ' --prefix={prefix}'
                         ' --os={os}'
                         ' {build_flags}').format(
                             python_call=call_python,
                             targets=",".join(build_targets),
                             abi=botan_abi,
                             cxxflags=botan_cxx_extras,
                             compiler=botan_compiler,
                             cpu=self.settings.arch,
                             prefix=prefix,
                             os=self._botan_os,
                             build_flags=' '.join(build_flags))

        return configure_cmd