configure: add workaround for systems without zlib.pc

Some systems (e.g. FreeBSD) might not have installed the appropriate
pkg-config file as they should. We can workaround the issue by creating
the .pc file they should have distributed.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
This commit is contained in:
Felipe Contreras 2014-05-11 22:09:32 -05:00 committed by David Bremner
parent dc64ab6720
commit 0c698ef037
3 changed files with 28 additions and 0 deletions

1
compat/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
zlib.pc

18
compat/gen_zlib_pc.c Normal file
View file

@ -0,0 +1,18 @@
#include <stdio.h>
#include <zlib.h>
static const char *template =
"prefix=/usr\n"
"exec_prefix=${prefix}\n"
"libdir=${exec_prefix}/lib\n"
"\n"
"Name: zlib\n"
"Description: zlib compression library\n"
"Version: %s\n"
"Libs: -lz\n";
int main(void)
{
printf(template, ZLIB_VERSION);
return 0;
}

9
configure vendored
View file

@ -340,6 +340,15 @@ else
errors=$((errors + 1))
fi
if ! pkg-config --exists zlib; then
${CC} ${zlib_cflags} -o compat/gen_zlib_pc \
"$srcdir"/compat/gen_zlib_pc.c ${zlib_ldflags} > /dev/null 2>&1 &&
compat/gen_zlib_pc > compat/zlib.pc &&
PKG_CONFIG_PATH="$PKG_CONFIG_PATH":compat &&
export PKG_CONFIG_PATH
rm -f compat/gen_zlib_pc
fi
printf "Checking for zlib (>= 1.2.5.2)... "
have_zlib=0
if pkg-config --atleast-version=1.2.5.2 zlib; then