diff --git a/recipes/libgpg-error/all/conandata.yml b/recipes/libgpg-error/all/conandata.yml new file mode 100644 index 0000000000000..0de00e71015c7 --- /dev/null +++ b/recipes/libgpg-error/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.36": + url: "https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.36.tar.gz" + sha256: "493a3a5e0ac0eb4df8501039f351459d8901d213a834d8c5a453a8ed94858ba5" +patches: + "1.36": + - patch_file: "patches/0001-gawk-namespace.patch" + base_path: "source_subfolder" diff --git a/recipes/libgpg-error/all/conanfile.py b/recipes/libgpg-error/all/conanfile.py new file mode 100644 index 0000000000000..e47574eef0fcf --- /dev/null +++ b/recipes/libgpg-error/all/conanfile.py @@ -0,0 +1,83 @@ +import os +from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + +class GPGErrorConan(ConanFile): + name = "libgpg-error" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gnupg.org/software/libgpg-error/index.html" + topics = ("gpg", "gnupg", "encrypt", "pgp", "openpgp") + description = "Libgpg-error is a small library that originally defined common error values for all GnuPG " \ + "components." + license = "GPL-2.0-or-later" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": False, + } + exports_sources = "patches/**" + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def configure(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("This recipe only support Linux. You can contribute Windows and/or Macos support.") + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure(self): + if self._autotools: + return self._autotools + host = None + args = ["--disable-dependency-tracking", + "--disable-nls", + "--disable-languages", + "--disable-doc", + "--disable-tests"] + if self.options.get_safe("fPIC", True): + args.append("--with-pic") + if self.options.shared: + args.extend(["--disable-static", "--enable-shared"]) + else: + args.extend(["--disable-shared", "--enable-static"]) + if self.settings.os == "Linux" and self.settings.arch == "x86": + host = "i686-linux-gnu" + + self._autotools = AutoToolsBuildEnvironment(self) + self._autotools.configure(args=args, host=host, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) + env_build = self._configure() + env_build.make() + + def package(self): + env_build = self._configure() + env_build.install() + self.copy(pattern="COPYING*", dst="licenses", src=self._source_subfolder) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*la") + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = ["gpg-error"] + self.cpp_info.names["pkg_config"] = "gpg-error" + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["pthread"] diff --git a/recipes/libgpg-error/all/patches/0001-gawk-namespace.patch b/recipes/libgpg-error/all/patches/0001-gawk-namespace.patch new file mode 100644 index 0000000000000..a9e25cf6acf3f --- /dev/null +++ b/recipes/libgpg-error/all/patches/0001-gawk-namespace.patch @@ -0,0 +1,53 @@ +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -293,7 +293,7 @@ + + errnos-sym.h: Makefile mkstrtable.awk errnos.in + $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \ +- -v prefix=GPG_ERR_ -v namespace=errnos_ \ ++ -v prefix=GPG_ERR_ -v pkg_namespace=errnos_ \ + $(srcdir)/errnos.in >$@ + + + +--- a/src/Makefile.in ++++ b/src/Makefile.in +@@ -1615,7 +1615,7 @@ + + errnos-sym.h: Makefile mkstrtable.awk errnos.in + $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \ +- -v prefix=GPG_ERR_ -v namespace=errnos_ \ ++ -v prefix=GPG_ERR_ -v pkg_namespace=errnos_ \ + $(srcdir)/errnos.in >$@ + + mkheader$(EXEEXT_FOR_BUILD): mkheader.c Makefile +diff --color -Naur libgpg-error-1.36/src/mkstrtable.awk libgpg-error-1.36.new/src/mkstrtable.awk +--- a/src/mkstrtable.awk ++++ b/src/mkstrtable.awk +@@ -102,7 +102,7 @@ + print "/* The purpose of this complex string table is to produce"; + print " optimal code with a minimum of relocations. */"; + print ""; +- print "static const char " namespace "msgstr[] = "; ++ print "static const char " pkg_namespace "msgstr[] = "; + header = 0; + } + else +@@ -150,7 +150,7 @@ + else + print " gettext_noop (\"" last_msgstr "\");"; + print ""; +- print "static const int " namespace "msgidx[] ="; ++ print "static const int " pkg_namespace "msgidx[] ="; + print " {"; + for (i = 0; i < coded_msgs; i++) + print " " pos[i] ","; +@@ -158,7 +158,7 @@ + print " };"; + print ""; + print "static GPG_ERR_INLINE int"; +- print namespace "msgidxof (int code)"; ++ print pkg_namespace "msgidxof (int code)"; + print "{"; + print " return (0 ? 0"; + diff --git a/recipes/libgpg-error/all/test_package/CMakeLists.txt b/recipes/libgpg-error/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7b9b613cbb24a --- /dev/null +++ b/recipes/libgpg-error/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libgpg-error/all/test_package/conanfile.py b/recipes/libgpg-error/all/test_package/conanfile.py new file mode 100644 index 0000000000000..ea57a464900be --- /dev/null +++ b/recipes/libgpg-error/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os + +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libgpg-error/all/test_package/test_package.c b/recipes/libgpg-error/all/test_package/test_package.c new file mode 100644 index 0000000000000..241b49be7ac6d --- /dev/null +++ b/recipes/libgpg-error/all/test_package/test_package.c @@ -0,0 +1,6 @@ +#include "gpg-error.h" + +int main() { + gpgrt_printf(""); + return 0; +} diff --git a/recipes/libgpg-error/config.yml b/recipes/libgpg-error/config.yml new file mode 100644 index 0000000000000..f10713a7746e2 --- /dev/null +++ b/recipes/libgpg-error/config.yml @@ -0,0 +1,3 @@ +versions: + "1.36": + folder: all