Repository: conan-io/conan-center-index

Issue:
[package] gdbm/1.18.1: TODO should be addressed and readline enabled now that it's in CCI
cf this commit: https://github.com/conan-io/conan-center-index/commit/cf68d8242852b393316005994ad0ce69fac2ac74

https://github.com/conan-io/conan-center-index/blob/b7d4ce3ba5e14b29c5a2f6267677e6b75cd50d0c/recipes/gdbm/all/conanfile.py#L52-L53

readline is now in CCI: https://github.com/conan-io/conan-center-index/tree/master/recipes/readline

### Package and Environment Details (include every applicable attribute)

  * Package Name/Version: **gdbm/1.18.1**


Discussion:

Resolving patch:
diff --git a/recipes/gdbm/all/conanfile.py b/recipes/gdbm/all/conanfile.py
--- a/recipes/gdbm/all/conanfile.py
+++ b/recipes/gdbm/all/conanfile.py
@@ -22,6 +22,7 @@ class GdbmConan(ConanFile):
         "gdbmtool_debug": [True, False],
         "with_libiconv": [True, False],
         "with_readline": [True, False],
+        "with_nls": [True, False],
     }
     default_options = {
         "shared": False,
@@ -30,6 +31,7 @@ class GdbmConan(ConanFile):
         "gdbmtool_debug": True,
         "with_libiconv": False,
         "with_readline": False,
+        "with_nls": True,
     }
 
     _autotools = None
@@ -43,6 +45,14 @@ def config_options(self):
             raise ConanInvalidConfiguration("gdbm is not supported on Windows")
 
     def configure(self):
+        # Disabling NLS will render the dependency on libiconv and gettext moot
+        # as the configure script will no longer look for that
+        if not self.options.with_nls:
+            if self.options.with_libiconv:
+                raise ConanInvalidConfiguration(
+                    "with_libiconv=True when with_nls=False is not possible "
+                    "as it's NLS that requires libiconv")
+
         del self.settings.compiler.libcxx
         del self.settings.compiler.cppstd
 
@@ -50,8 +60,7 @@ def requirements(self):
         if self.options.with_libiconv:
             self.requires("libiconv/1.16")
         if self.options.with_readline:
-            raise ConanInvalidConfiguration("readline is not (yet) available on CCI")
-            # TODO - Add readline package when available
+            self.requires("readline/8.0")
 
     def build_requirements(self):
         self.build_requires("bison/3.5.3")
@@ -71,14 +80,28 @@ def _configure_autotools(self):
             "--with-readline" if self.options.with_readline else "--without-readline",
             "--enable-libgdbm-compat" if self.options.libgdbm_compat else "--disable-libgdbm-compat",
             "--enable-gdbmtool-debug" if self.options.gdbmtool_debug else "--disable-gdbmtool-debug",
-            "--with-libiconv-prefix={}".format(self.deps_cpp_info["libiconv"].lib_paths[0]) if self.options.with_libiconv else "--without-libiconv-prefix",
-            "--without-libintl-prefix",
             "--disable-rpath",
         ]
         if self.options.shared:
             conf_args.extend(["--enable-shared", "--disable-static"])
         else:
-            conf_args.extend(["--disable-shared", "--enable-static"])
+            conf_args.extend([
+                "--disable-shared", "--enable-static",
+                "--with-pic" if self.options.fPIC else "--without-pic"]
+            )
+
+        if not self.options.with_nls:
+            conf_args.extend(["--disable-nls"])
+
+        if self.options.with_libiconv:
+            conf_args.extend([
+                "--with-libiconv-prefix={}"
+                .format(self.deps_cpp_info["libiconv"].rootpath),
+                "--with-libintl-prefix"
+            ])
+        else:
+            conf_args.extend(['--without-libiconv-prefix',
+                              "--without-libintl-prefix"])
 
         self._autotools.configure(args=conf_args)
         return self._autotools
@@ -96,7 +119,17 @@ def package(self):
             autotools = self._configure_autotools()
             autotools.install()
         os.unlink(os.path.join(self.package_folder, "lib", "libgdbm.la"))
+        compat_la = os.path.join(self.package_folder, "lib",
+                                 "libgdbm_compat.la")
+        if (os.path.exists(compat_la)):
+            os.unlink(compat_la)
         tools.rmdir(os.path.join(self.package_folder, "share"))
 
     def package_info(self):
-        self.cpp_info.libs = ["gdbm"]
+        if self.options.libgdbm_compat:
+            self.cpp_info.libs.append("gdbm_compat")
+        self.cpp_info.libs.append("gdbm")
+
+        bin_path = os.path.join(self.package_folder, "bin")
+        self.output.info("Appending PATH environment variable: {}".format(bin_path))
+        self.env_info.PATH.append(bin_path)


Test patch: