Repository: conan-io/conan-center-index

Issue:
[package] libiberty/9.1.0: library installed to lib64 instead of lib
<!-- 
  Please don't forget to update the issue title.
  Include all applicable information to help us reproduce your problem.
-->

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **libiberty/9.1.0**
  * Operating System+version: **Linux OpenSuse Tumbleweed**
  * Compiler+version: **GCC 11.1.1**
  * Conan version: **conan 1.36.0**
  * Python version: **Python 3.8.10**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=11.1
compiler.libcxx=libstdc++11
build_type=Debug
[options]
[build_requires]
[env]
CXXFLAGS=-std=c++20

```


### Steps to reproduce (Include if Applicable)
Create a `conanfile.txt` containing
```
[requires]
libiberty/9.1.0
```

Run `conan install . --build=missing` (assuming this does a build of the package)

Check package lib dir, (in my case it is `ls ~/.conan/data/libiberty/9.1.0/_/_/package/6f508e2ef672df19d5cbcb7d0f8c91b843655020/lib` and see that it is empty

Check the `lib64` dir in the package directory `ls ~/.conan/data/libiberty/9.1.0/_/_/package/6f508e2ef672df19d5cbcb7d0f8c91b843655020/lib64` and see that it contains a `libiberty.a`

Open `conanbuildinfo.txt` and `[libdirs]` will list the empty folder and not the one containing `libiberty.a`.



Discussion:

Resolving patch:
diff --git a/recipes/libiberty/all/conanfile.py b/recipes/libiberty/all/conanfile.py
--- a/recipes/libiberty/all/conanfile.py
+++ b/recipes/libiberty/all/conanfile.py
@@ -3,6 +3,9 @@
 import os
 
 
+required_conan_version = ">=1.33.0"
+
+
 class LibibertyConan(ConanFile):
     name = "libiberty"
     version = "9.1.0"
@@ -12,8 +15,13 @@ class LibibertyConan(ConanFile):
     homepage = "https://gcc.gnu.org/onlinedocs/libiberty"
     license = "LGPL-2.1"
     settings = "os", "arch", "compiler", "build_type"
-    options = {"fPIC": [True, False]}
-    default_options = {"fPIC": True}
+    options = {
+        "fPIC": [True, False],
+    }
+    default_options = {
+        "fPIC": True,
+    }
+
     _autotools = None
 
     @property
@@ -25,7 +33,7 @@ def _libiberty_folder(self):
         return os.path.join(self._source_subfolder, self.name)
 
     def config_options(self):
-        if self.settings.os == 'Windows':
+        if self.settings.os == "Windows":
             del self.options.fPIC
 
     def configure(self):
@@ -35,17 +43,19 @@ def configure(self):
         del self.settings.compiler.cppstd
 
     def source(self):
-        tools.get(**self.conan_data["sources"][self.version])
-        extracted_dir = "gcc-" + self.version
-        os.rename(extracted_dir, self._source_subfolder)
-        tools.rmdir(os.path.join(self._source_subfolder, 'gcc'))
-        tools.rmdir(os.path.join(self._source_subfolder, 'libstdc++-v3'))
+        tools.get(**self.conan_data["sources"][self.version],
+                  destination=self._source_subfolder, strip_root=True)
+        tools.rmdir(os.path.join(self._source_subfolder, "gcc"))
+        tools.rmdir(os.path.join(self._source_subfolder, "libstdc++-v3"))
 
     def _configure_autotools(self):
-        if not self._autotools:
-            args = ["--enable-install-libiberty"]
-            self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
-            self._autotools.configure(args=args, configure_dir=self._libiberty_folder)
+        if self._autotools:
+            return self._autotools
+        self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
+        conf_args = [
+            "--enable-install-libiberty",
+        ]
+        self._autotools.configure(args=conf_args, configure_dir=self._libiberty_folder)
         return self._autotools
 
     def build(self):
@@ -56,14 +66,15 @@ def package(self):
         self.copy(pattern="COPYING.LIB", src=self._libiberty_folder, dst="licenses")
         autotools = self._configure_autotools()
         autotools.install()
-        self._package_x86()
+        self._package_xx(32)
+        self._package_xx(64)
 
-    def _package_x86(self):
-        lib32dir = os.path.join(self.package_folder, "lib32")
-        if os.path.exists(lib32dir):
+    def _package_xx(self, arch):
+        lib_arch_dir = os.path.join(self.package_folder, "lib{}".format(arch))
+        if os.path.exists(lib_arch_dir):
             libdir = os.path.join(self.package_folder, "lib")
             tools.rmdir(libdir)
-            os.rename(lib32dir, libdir)
+            tools.rename(lib_arch_dir, libdir)
 
     def package_info(self):
-        self.cpp_info.libs = tools.collect_libs(self)
+        self.cpp_info.libs = ["iberty"]


Test patch:
diff --git a/recipes/libiberty/all/test_package/test_package.c b/recipes/libiberty/all/test_package/test_package.c
--- a/recipes/libiberty/all/test_package/test_package.c
+++ b/recipes/libiberty/all/test_package/test_package.c
@@ -1,6 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <libiberty/libiberty.h>
+#include "libiberty/libiberty.h"
 
 int main(void) {
     printf("GETPWD: %s\n", getpwd());