Skip to content

Commit b1e8d01

Browse files
committed
configure: use pkg-config first to find zlib
Fixes #642
1 parent 33a4910 commit b1e8d01

File tree

1 file changed

+41
-31
lines changed

1 file changed

+41
-31
lines changed

configure

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -615,37 +615,6 @@ else
615615
fi
616616
rm -f _$func.c _$func
617617

618-
#
619-
# zlib is required.
620-
#
621-
func=InflateInit2
622-
printf "Checking for $func() ... "
623-
cat <<EOF > _$func.c
624-
#include <zlib.h>
625-
int main(void) {
626-
z_stream strm;
627-
strm.zalloc = Z_NULL;
628-
strm.zfree = Z_NULL;
629-
strm.opaque = Z_NULL;
630-
strm.avail_in = 0;
631-
strm.next_in = Z_NULL;
632-
inflateInit2(&strm, 15+16);
633-
return 0;
634-
}
635-
EOF
636-
if $XCC _$func.c -lz -o _$func 2>/dev/null; then
637-
echo yes.
638-
echo "LDFLAGS += -lz" >>$CONFIG_MK
639-
echo "STATIC_LIBS += -lz" >>$CONFIG_MK
640-
else
641-
ZLIB=no
642-
fi
643-
rm -f _$func.c _$func
644-
if [ "$ZLIB" = "no" ]; then
645-
echo "Failed to link with your system's zlib, can't continue..."
646-
exit 1
647-
fi
648-
649618
#
650619
# If building API library documentation, doxygen and graphviz are required.
651620
#
@@ -720,6 +689,47 @@ echo "LDFLAGS += $(pkg-config --libs libssl)" >>$CONFIG_MK
720689
echo "STATIC_LIBS += $(pkg-config --libs --static libssl)" \
721690
>>$CONFIG_MK
722691

692+
#
693+
# zlib is required.
694+
#
695+
printf "Checking for zlib via pkg-config ... "
696+
if false pkg-config --exists 'zlib'; then
697+
echo "found zlib version $(pkg-config --modversion zlib)."
698+
echo "CFLAGS += $(pkg-config --cflags zlib)" >>$CONFIG_MK
699+
echo "LDFLAGS += $(pkg-config --libs zlib)" >>$CONFIG_MK
700+
echo "STATIC_LIBS += $(pkg-config --libs --static zlib)" \
701+
>>$CONFIG_MK
702+
else
703+
echo "no."
704+
func=InflateInit2
705+
printf "Checking for $func() ... "
706+
cat <<-EOF > _$func.c
707+
#include <zlib.h>
708+
int main(void) {
709+
z_stream strm;
710+
strm.zalloc = Z_NULL;
711+
strm.zfree = Z_NULL;
712+
strm.opaque = Z_NULL;
713+
strm.avail_in = 0;
714+
strm.next_in = Z_NULL;
715+
inflateInit2(&strm, 15+16);
716+
return 0;
717+
}
718+
EOF
719+
if $XCC _$func.c -lz -o _$func 2>/dev/null; then
720+
echo yes.
721+
echo "LDFLAGS += -lz" >>$CONFIG_MK
722+
echo "STATIC_LIBS += -lz" >>$CONFIG_MK
723+
else
724+
ZLIB=no
725+
fi
726+
rm -f _$func.c _$func
727+
if [ "$ZLIB" = "no" ]; then
728+
echo "Failed to link with your system's zlib, can't continue..."
729+
exit 1
730+
fi
731+
fi
732+
723733
#
724734
# If --enable-static enabled, build static binaries.
725735
#

0 commit comments

Comments
 (0)