Repository: conan-io/conan-center-index

Issue:
[package] fontconfig/2.13.93: build fails on macos with bzip2:shared=True
### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **fontconfig/2.13.93**
  * Operating System+version: **MacOS 10.15**
  * Compiler+version: **Apple clang 11.0**
  * Conan version: **conan 1.35.1**
  * Python version: **Python 3.9.4**


### Conan profile 
```
Configuration for profile macos-xcode11-x86_64:

[settings]
os=Macos
os_build=Macos
arch=x86_64
arch_build=x86_64
compiler=apple-clang
compiler.version=11.0
compiler.libcxx=libc++
build_type=Release
os.version=10.13
compiler.cppstd=17
[options]
boost:header_only=True
brotli:shared=True
bzip2:shared=True
cairo:enable_fc=True
cairo:enable_ft=True
cairo:enable_glib=False
cairo:shared=True
ccdcsqlite3:enable_explain_comments=True
ccdcsqlite3:enable_fts3=True
ccdcsqlite3:enable_fts4=True
ccdcsqlite3:enable_fts5=True
ccdcsqlite3:enable_json1=True
ccdcsqlite3:enable_null_trim=True
ccdcsqlite3:max_column=10000
ccdcsqlite3:shared=True
csdprotobufs:shared=True
expat:shared=True
fontconfig:shared=True
freetype:shared=True
gtest:shared=True
inchi:shared=True
jasper:shared=True
jbig:shared=True
lexactivator:shared=True
lexfloatclient:shared=True
libarchive:shared=True
libarchive:with_bzip2=True
libarchive:with_zlib=True
libarchive:with_zstd=True
libcurl:darwin_ssl=True
libcurl:shared=True
libcurl:with_openssl=False
libiconv:shared=False
libjpeg:shared=True
libpng:shared=True
libtiff:shared=True
libuuid:shared=True
libwebp:shared=True
libxl:shared=True
libxml2:shared=True
openscenegraph:shared=True
openssl:shared=True
protobuf:shared=True
protobuf:with_zlib=True
xz_utils:shared=True
zlib:shared=True
zstd:shared=True
[build_requires]
[env]

```


### Steps to reproduce (Include if Applicable)

build fails in conan package stage


### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
if [ -f source_subfolder/fonts.conf ]; then \
	  echo " /usr/bin/install -c -m 644 source_subfolder/fonts.conf /Users/vagrant/.conan/data/fontconfig/2.13.93/_/_/package/a1eeda7123576b54b8790256237bfc4e70516c86/bin/etc/fonts/fonts.conf"; \
	  /usr/bin/install -c -m 644 source_subfolder/fonts.conf /Users/vagrant/.conan/data/fontconfig/2.13.93/_/_/package/a1eeda7123576b54b8790256237bfc4e70516c86/bin/etc/fonts/fonts.conf; \
	else if [ -f fonts.conf ]; then \
	  echo " /usr/bin/install -c -m 644 fonts.conf /Users/vagrant/.conan/data/fontconfig/2.13.93/_/_/package/a1eeda7123576b54b8790256237bfc4e70516c86/bin/etc/fonts/fonts.conf"; \
	  /usr/bin/install -c -m 644 fonts.conf /Users/vagrant/.conan/data/fontconfig/2.13.93/_/_/package/a1eeda7123576b54b8790256237bfc4e70516c86/bin/etc/fonts/fonts.conf; \
	fi; fi
 /usr/bin/install -c -m 644 fonts.conf /Users/vagrant/.conan/data/fontconfig/2.13.93/_/_/package/a1eeda7123576b54b8790256237bfc4e70516c86/bin/etc/fonts/fonts.conf
fc-cache -s -f -v
 /usr/bin/install -c -m 644 fontconfig.pc '/Users/vagrant/.conan/data/fontconfig/2.13.93/_/_/package/a1eeda7123576b54b8790256237bfc4e70516c86/lib/pkgconfig'
 /usr/bin/install -c -m 644 source_subfolder/fonts.dtd '/Users/vagrant/.conan/data/fontconfig/2.13.93/_/_/package/a1eeda7123576b54b8790256237bfc4e70516c86/bin/share/xml/fontconfig'
dyld: Library not loaded: libbz2.1.dylib
  Referenced from: /Users/vagrant/.conan/data/fontconfig/2.13.93/_/_/build/a1eeda7123576b54b8790256237bfc4e70516c86/fc-cache/.libs/fc-cache
  Reason: image not found
/bin/sh: line 1: 35414 Abort trap: 6           fc-cache/fc-cache -s -f -v
make[2]: *** [install-data-local] Error 134
make[1]: *** [install-am] Error 2
make: *** [install-recursive] Error 1
ERROR: fontconfig/2.13.93: Error in package() method, line 87
	autotools.install()
	ConanException: Error 2 while executing make install -j12

```

</details>



Discussion:
The workaround above was not enough. I've got a small change to the Makefile.in that will sort this and help make the package cross-compilable

Resolving patch:
diff --git a/recipes/fontconfig/all/conanfile.py b/recipes/fontconfig/all/conanfile.py
--- a/recipes/fontconfig/all/conanfile.py
+++ b/recipes/fontconfig/all/conanfile.py
@@ -72,6 +72,12 @@ def _configure_autotools(self):
     def _patch_files(self):
         #  - fontconfig requires libtool version number, change it for the corresponding freetype one
         tools.replace_in_file(os.path.join(self._source_subfolder, 'configure'), '21.0.15', '2.8.1')
+        # disable fc-cache test to enable cross compilation but also builds with shared libraries on MacOS
+        tools.replace_in_file(
+            os.path.join(self._source_subfolder, 'Makefile.in'),
+            '@CROSS_COMPILING_TRUE@RUN_FC_CACHE_TEST = false',
+            'RUN_FC_CACHE_TEST=false'
+        )
 
     def build(self):
         # Patch files from dependencies


Test patch: