diff --git a/recipes/mpc/all/conandata.yml b/recipes/mpc/all/conandata.yml index 007c14f9a1cc4..26f5cb2ff79b2 100644 --- a/recipes/mpc/all/conandata.yml +++ b/recipes/mpc/all/conandata.yml @@ -1,11 +1,22 @@ sources: + "1.2.1": + url: "https://ftp.gnu.org/gnu/mpc/mpc-1.2.1.tar.gz" + sha256: "17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459" "1.2.0": - url: https://ftp.gnu.org/gnu/mpc/mpc-1.2.0.tar.gz - sha256: e90f2d99553a9c19911abdb4305bf8217106a957e3994436428572c8dfe8fda6 + url: "https://ftp.gnu.org/gnu/mpc/mpc-1.2.0.tar.gz" + sha256: "e90f2d99553a9c19911abdb4305bf8217106a957e3994436428572c8dfe8fda6" "1.1.0": - url: https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz - sha256: 6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e + url: "https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz" + sha256: "6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e" patches: + "1.2.1": + - base_path: "source_subfolder" + patch_file: "patches/1.2.0-0001-msvc-add-mpfr-libpath+shared.patch" "1.2.0": - - patch_file: "patches/1.2.0-0001-asin-missing-limits.patch" + - patch_file: "patches/1.2.0-0001-msvc-add-mpfr-libpath+shared.patch" base_path: "source_subfolder" + - patch_file: "patches/1.2.0-0002-asin-missing-limits.patch" + base_path: "source_subfolder" + "1.1.0": + - base_path: "source_subfolder" + patch_file: "patches/1.1.0-0001-msvc-add-mpfr-libpath+shared.patch" diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index 02124a3798aa9..55608cf57422a 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -12,8 +12,8 @@ class MpcConan(ConanFile): homepage = "http://www.multiprecision.org/mpc/home.html" license = "LGPL-3.0-or-later" settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = {"shared": [True, False], "fPIC": [True, False], "exact_int": ["gmp", "mpir"]} + default_options = {"shared": False, "fPIC": True, "exact_int": "gmp"} exports_sources = "patches/**" @property @@ -23,18 +23,27 @@ def _source_subfolder(self): _autotools = None def config_options(self): - if self.settings.os == 'Windows': + if self.settings.os == "Windows": del self.options.fPIC - def requirements(self): - self.requires("mpfr/4.1.0") - def configure(self): - if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("The mpc package cannot be built on Visual Studio.") + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + def requirements(self): + self.requires("mpfr/4.1.0") + # FIXME: DO AUTOTOOLS NEED GMP/MPIR??????? + if self.options.exact_int == "gmp": + self.requires("gmp/6.2.1") + elif self.options.exact_int == "mpir": + self.requires("mpir/3.0.0") + + def build_requirements(self): + if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH") and self.settings.compiler != "Visual Studio": + self.build_requires("msys2/20200517") + def source(self): tools.get(**self.conan_data["sources"][self.version]) extracted_dir = self.name + "-" + self.version @@ -43,27 +52,60 @@ def source(self): def _configure_autotools(self): if self._autotools: return self._autotools - self._autotools = AutoToolsBuildEnvironment(self) - args = [] + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) if self.options.shared: - args.extend(["--disable-static", "--enable-shared"]) - else: - args.extend(["--disable-shared", "--enable-static"]) + self._autotools.defines.append("MPC_SHARED") + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + ] self._autotools.configure(args=args, configure_dir=self._source_subfolder) return self._autotools + def _nmake_run(self): + autotools = AutoToolsBuildEnvironment(self) + autotools.libs = [] + autotools.flags.append("-EHs") + if self.options.shared: + autotools.defines.append("MPC_SHARED") + with tools.chdir(self._source_subfolder): + with tools.vcvars(self.settings): + self.run("nmake /f Makefile.vc STATIC={} GMPDIR=\"{}\" MPFR=\"{}\" CDEFAULTFLAGS=\"{}\" DESTDIR=\"{}\" GMPMUSTBEDLL=\"\"".format( + "0" if self.options.shared else "1", + self.deps_cpp_info[str(self.options.exact_int)].rootpath, + self.deps_cpp_info["mpfr"].rootpath, + "{} {}".format(autotools.vars["CPPFLAGS"], autotools.vars["CFLAGS"]), + self.package_folder, + ), run_environment=True) + def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) - autotools = self._configure_autotools() - autotools.make() + if self.options.exact_int == "mpir": + tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.vc"), + "libmpfr.lib", "mpfr.lib") + tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.vc"), + "gmp.lib", "mpir.lib") + if self.settings.compiler == "Visual Studio": + self._nmake_run() + else: + autotools = self._configure_autotools() + autotools.make() def package(self): self.copy(pattern="COPYING.LESSER", dst="licenses", src=self._source_subfolder) - autotools = self._configure_autotools() - autotools.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - os.unlink(os.path.join(self.package_folder, "lib", "libmpc.la")) + if self.settings.compiler == "Visual Studio": + self.copy("libmpc.lib", src=self._source_subfolder, dst="lib", keep_path=False) + os.rename(os.path.join(self.package_folder, "lib", "libmpc.lib"), + os.path.join(self.package_folder, "lib", "mpc.lib")) + self.copy("libmpc.dll", src=self._source_subfolder, dst="bin", keep_path=False) + self.copy("mpc.h", src=os.path.join(self._source_subfolder, "src"), dst="include") + else: + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + os.unlink(os.path.join(self.package_folder, "lib", "libmpc.la")) def package_info(self): self.cpp_info.libs = ["mpc"] diff --git a/recipes/mpc/all/patches/1.1.0-0001-msvc-add-mpfr-libpath+shared.patch b/recipes/mpc/all/patches/1.1.0-0001-msvc-add-mpfr-libpath+shared.patch new file mode 100644 index 0000000000000..22520eb2cf1df --- /dev/null +++ b/recipes/mpc/all/patches/1.1.0-0001-msvc-add-mpfr-libpath+shared.patch @@ -0,0 +1,23 @@ +--- Makefile.vc ++++ Makefile.vc +@@ -267,7 +267,7 @@ + # + + $(LIBRARY): $(DIRMPC)config.h $(CPPOBJECTS) +- $(LINKER) /out:$@ $(CPPLINKOBJECTS) /LIBPATH:"$(GMPDIR)\lib" libmpfr.lib libgmp.lib $(LIBS_LOGGING) ++ $(LINKER) /out:$@ $(CPPLINKOBJECTS) /LIBPATH:"$(MPFR)\lib" /LIBPATH:"$(GMPDIR)\lib" mpfr.lib gmp.lib $(LIBS_LOGGING) + + $(DIRMPC)config.h : + echo #define PACKAGE_STRING "mpc" >$(DIRMPC)\config.h +--- src/mpc.h ++++ src/mpc.h +@@ -109,7 +109,7 @@ + /* Support for WINDOWS DLL, see + http://lists.gforge.inria.fr/pipermail/mpc-discuss/2011-November/000990.html; + when building the DLL, export symbols, otherwise behave as GMP */ +-#if defined (__MPC_LIBRARY_BUILD) && __GMP_LIBGMP_DLL +-#define __MPC_DECLSPEC __GMP_DECLSPEC_EXPORT ++#if defined (__MPC_LIBRARY_BUILD) && defined(_WIN32) && defined(MPC_SHARED) ++#define __MPC_DECLSPEC __declspec(dllexport) + #else + #define __MPC_DECLSPEC __GMP_DECLSPEC diff --git a/recipes/mpc/all/patches/1.2.0-0001-msvc-add-mpfr-libpath+shared.patch b/recipes/mpc/all/patches/1.2.0-0001-msvc-add-mpfr-libpath+shared.patch new file mode 100644 index 0000000000000..2befb03aa6742 --- /dev/null +++ b/recipes/mpc/all/patches/1.2.0-0001-msvc-add-mpfr-libpath+shared.patch @@ -0,0 +1,23 @@ +--- Makefile.vc ++++ Makefile.vc +@@ -267,7 +267,7 @@ + # + + $(LIBRARY): $(DIRMPC)config.h $(CPPOBJECTS) +- $(LINKER) /out:$@ $(CPPLINKOBJECTS) /LIBPATH:"$(GMPDIR)\lib" libmpfr.lib libgmp.lib $(LIBS_LOGGING) ++ $(LINKER) /out:$@ $(CPPLINKOBJECTS) /LIBPATH:"$(MPFR)\lib" /LIBPATH:"$(GMPDIR)\lib" mpfr.lib gmp.lib $(LIBS_LOGGING) + + $(DIRMPC)config.h : + echo #define PACKAGE_STRING "mpc" >$(DIRMPC)\config.h +--- src/mpc.h ++++ src/mpc.h +@@ -111,7 +111,7 @@ + /* Support for WINDOWS DLL, see + http://lists.gforge.inria.fr/pipermail/mpc-discuss/2011-November/000990.html; + when building the DLL, export symbols, otherwise behave as GMP */ +-#if defined (__MPC_LIBRARY_BUILD) && __GMP_LIBGMP_DLL +-#define __MPC_DECLSPEC __GMP_DECLSPEC_EXPORT ++#if defined (__MPC_LIBRARY_BUILD) && defined(_WIN32) && defined(MPC_SHARED) ++#define __MPC_DECLSPEC __declspec(dllexport) + #else + #define __MPC_DECLSPEC __GMP_DECLSPEC diff --git a/recipes/mpc/all/patches/1.2.0-0001-asin-missing-limits.patch b/recipes/mpc/all/patches/1.2.0-0002-asin-missing-limits.patch similarity index 100% rename from recipes/mpc/all/patches/1.2.0-0001-asin-missing-limits.patch rename to recipes/mpc/all/patches/1.2.0-0002-asin-missing-limits.patch diff --git a/recipes/mpc/all/test_package/CMakeLists.txt b/recipes/mpc/all/test_package/CMakeLists.txt index 196188113685c..34af13462f44f 100644 --- a/recipes/mpc/all/test_package/CMakeLists.txt +++ b/recipes/mpc/all/test_package/CMakeLists.txt @@ -4,5 +4,5 @@ project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -add_executable(${PROJECT_NAME} test_package.cpp) +add_executable(${PROJECT_NAME} test_package.c) target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/mpc/all/test_package/test_package.cpp b/recipes/mpc/all/test_package/test_package.c similarity index 95% rename from recipes/mpc/all/test_package/test_package.cpp rename to recipes/mpc/all/test_package/test_package.c index 1d9915442f634..69291fef5dfa0 100644 --- a/recipes/mpc/all/test_package/test_package.cpp +++ b/recipes/mpc/all/test_package/test_package.c @@ -1,7 +1,7 @@ /* example was taken from https://www.gnu.org/ghm/2011/paris/slides/andreas-enge-mpc.pdf */ #include -#include +#include "mpc.h" int main (void) { mpc_t z; diff --git a/recipes/mpc/config.yml b/recipes/mpc/config.yml index d07c95e596619..34ab65d8a2f9e 100644 --- a/recipes/mpc/config.yml +++ b/recipes/mpc/config.yml @@ -1,4 +1,6 @@ versions: + "1.2.1": + folder: all "1.2.0": folder: all "1.1.0":