2 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>
3 # Copyright © 2007 Nicolas François <nicolas.francois@centraliens.net>
4 # Copyright © 2006, 2009-2012, 2014-2015 Guillem Jover <guillem@debian.org>
8 # Check for the message digest library.
9 AC_DEFUN([DPKG_LIB_MD], [
10 AC_ARG_VAR([MD_LIBS], [linker flags for md library])
12 AC_CHECK_HEADERS([md5.h], [
13 dpkg_save_libmd_LIBS=$LIBS
14 AC_SEARCH_LIBS([MD5Init], [md])
15 LIBS=$dpkg_save_libmd_LIBS
16 AS_IF([test "x$ac_cv_search_MD5Init" = "xnone required"], [
18 ], [test "x$ac_cv_search_MD5Init" != "xno"], [
20 MD_LIBS="$ac_cv_search_MD5Init"
23 AS_IF([test "x$have_libmd" = "xno"], [
24 AC_MSG_FAILURE([md5 digest functions not found])
28 # DPKG_WITH_COMPRESS_LIB(NAME, HEADER, FUNC)
29 # -------------------------------------------------
30 # Check for availability of a compression library.
31 AC_DEFUN([DPKG_WITH_COMPRESS_LIB], [
32 AC_ARG_VAR(AS_TR_CPP([$1_LIBS]), [linker flags for $1 library])
34 [AS_HELP_STRING([--with-lib$1],
35 [use $1 library for compression and decompression])],
36 [], [AS_TR_SH([with_lib$1])=check])
37 AS_TR_SH([have_lib$1])="no"
38 AS_IF([test "x$AS_TR_SH([with_lib$1])" != "xno"], [
39 AC_CHECK_LIB([$1], [$3], [
40 AC_CHECK_HEADER([$2], [
41 AS_TR_SH([have_lib$1])="yes"
45 AS_IF([test "x$AS_TR_SH([with_lib$1])" != "xno"], [
46 AS_IF([test "x$AS_TR_SH([have_lib$1])" = "xyes"], [
47 AC_DEFINE(AS_TR_CPP([WITH_LIB$1]), 1,
48 [Define to 1 to use $1 library rather than console tool])
49 AS_IF([test "x$AS_TR_SH([with_lib$1])" = "xstatic"], [
50 AS_TR_SH([dpkg_$1_libs])="-Wl,-Bstatic -l$1 -Wl,-Bdynamic"
52 AS_TR_SH([dpkg_$1_libs])="-l$1"
54 AS_TR_CPP([$1_LIBS])="${AS_TR_CPP([$1_LIBS]):+$AS_TR_CPP([$1_LIBS]) }$AS_TR_SH([dpkg_$1_libs])"
56 AS_IF([test "x$AS_TR_SH([with_lib$1])" != "xcheck"], [
57 AC_MSG_FAILURE([lib$1 library or header not found])
62 ])# DPKG_WITH_COMPRESS_LIB
66 # Check for z-ng and z libraries.
67 AC_DEFUN([DPKG_LIB_Z], [
68 DPKG_WITH_COMPRESS_LIB([z], [zlib.h], [gzdopen])
69 DPKG_WITH_COMPRESS_LIB([z-ng], [zlib-ng.h], [zng_gzdopen])
71 AC_DEFINE([USE_LIBZ_IMPL_NONE], [0],
72 [Define none as 0 for the zlib implementation enum])
73 AC_DEFINE([USE_LIBZ_IMPL_ZLIB], [1],
74 [Define zlib as 1 for the zlib implementation enum])
75 AC_DEFINE([USE_LIBZ_IMPL_ZLIB_NG], [2],
76 [Define zlib-ng as 2 for the zlib implementation enum])
78 # If we have been requested the stock zlib, override the auto-detection.
79 AS_IF([test "x$with_libz" != "xyes" && test "x$have_libz_ng" = "xyes"], [
80 AC_DEFINE([WITH_GZFILEOP], [yes],
81 [Define to yes to use zlib-ng gzFile IO support])
83 use_libz_impl="USE_LIBZ_IMPL_ZLIB_NG"
84 have_libz_impl="yes (zlib-ng)"
85 ], [test "x$have_libz" = "xyes"], [
86 use_libz_impl="USE_LIBZ_IMPL_ZLIB"
87 have_libz_impl="yes (zlib)"
89 use_libz_impl="USE_LIBZ_IMPL_NONE"
92 AC_DEFINE_UNQUOTED([USE_LIBZ_IMPL], [$use_libz_impl],
93 [Define to the zlib implementation to use])
98 # Check for lzma library.
99 AC_DEFUN([DPKG_LIB_LZMA], [
100 DPKG_WITH_COMPRESS_LIB([lzma], [lzma.h], [lzma_alone_decoder])
101 AC_CHECK_LIB([lzma], [lzma_stream_encoder_mt], [
102 AC_DEFINE([HAVE_LZMA_MT_ENCODER], [1],
103 [xz multi-threaded compression support])
105 AC_CHECK_LIB([lzma], [lzma_stream_decoder_mt], [
106 AC_DEFINE([HAVE_LZMA_MT_DECODER], [1],
107 [xz multi-threaded decompression support])
113 # Check for zstd library.
114 AC_DEFUN([DPKG_LIB_ZSTD], [
115 DPKG_WITH_COMPRESS_LIB([zstd], [zstd.h], [ZSTD_compressStream2])
120 # Check for bz2 library.
121 AC_DEFUN([DPKG_LIB_BZ2], [
122 DPKG_WITH_COMPRESS_LIB([bz2], [bzlib.h], [BZ2_bzdopen])
127 # Check for selinux library.
128 AC_DEFUN([DPKG_LIB_SELINUX], [
129 AC_REQUIRE([PKG_PROG_PKG_CONFIG])
130 m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_fatal([missing pkg-config macros])])
131 AC_ARG_VAR([SELINUX_LIBS], [linker flags for selinux library])dnl
132 AC_ARG_WITH([libselinux],
133 [AS_HELP_STRING([--with-libselinux],
134 [use selinux library to set security contexts])],
135 [], [with_libselinux=check])
136 SELINUX_MIN_VERSION=2.3
138 AS_IF([test "x$with_libselinux" != "xno"], [
139 PKG_CHECK_MODULES([SELINUX], [libselinux >= $SELINUX_MIN_VERSION], [
140 AC_CHECK_HEADER([selinux/selinux.h], [
141 AC_DEFINE([WITH_LIBSELINUX], [1],
142 [Define to 1 to compile in SELinux support])
143 have_libselinux="yes"
145 AS_IF([test "x$with_libselinux" != "xcheck"], [
146 AC_MSG_FAILURE([libselinux header not found])
149 AC_CHECK_LIB([selinux], [setexecfilecon], [], [
150 AC_MSG_FAILURE([libselinux does not support setexecfilecon()])
153 AS_IF([test "x$with_libselinux" != "xcheck"], [
154 AC_MSG_FAILURE([libselinux at least $SELINUX_MIN_VERSION not found])
158 AM_CONDITIONAL([WITH_LIBSELINUX], [test "x$have_libselinux" = "xyes"])
161 # _DPKG_CHECK_LIB_CURSES_NARROW
162 # -----------------------------
163 # Check for narrow curses library.
164 AC_DEFUN([_DPKG_CHECK_LIB_CURSES_NARROW], [
165 AC_CHECK_LIB([ncurses], [initscr], [
166 CURSES_LIBS="${CURSES_LIBS:+$CURSES_LIBS }-lncurses"
168 AC_CHECK_LIB([curses], [initscr], [
169 CURSES_LIBS="${CURSES_LIBS:+$CURSES_LIBS }-lcurses"
171 AC_MSG_ERROR([no curses library found])
174 ])# DPKG_CHECK_LIB_CURSES_NARROW
178 # Check for curses library.
179 AC_DEFUN([DPKG_LIB_CURSES], [
180 AC_REQUIRE([DPKG_UNICODE])
181 AC_ARG_VAR([CURSES_LIBS], [linker flags for curses library])dnl
182 AC_CHECK_HEADERS([ncurses/ncurses.h ncurses.h curses.h ncurses/term.h term.h],
183 [have_curses_header=yes])
184 AS_IF([test "x$USE_UNICODE" = "xyes"], [
185 AC_CHECK_HEADERS([ncursesw/ncurses.h ncursesw/term.h],
186 [have_curses_header=yes])
187 AC_CHECK_LIB([ncursesw], [initscr], [
188 CURSES_LIBS="${CURSES_LIBS:+$CURSES_LIBS }-lncursesw"
190 _DPKG_CHECK_LIB_CURSES_NARROW()
193 _DPKG_CHECK_LIB_CURSES_NARROW()
195 AS_IF([test "x$have_curses_header" != "xyes"], [
196 AC_MSG_FAILURE([curses header not found])
203 # Check for rt library
204 AC_DEFUN([DPKG_LIB_RT], [
205 AC_ARG_VAR([RT_LIBS], [linker flags for rt library])dnl
207 dpkg_save_librt_LIBS=$LIBS
208 AC_SEARCH_LIBS([clock_gettime], [rt])
209 LIBS=$dpkg_save_librt_LIBS
210 AS_IF([test "x$ac_cv_search_clock_gettime" = "xnone required"], [
212 ], [test "x$ac_cv_search_clock_gettime" != "xno"], [
214 RT_LIBS="$ac_cv_search_clock_gettime"
220 # Check for socket library
221 AC_DEFUN([DPKG_LIB_SOCKET], [
222 AC_ARG_VAR([SOCKET_LIBS], [linker flags for socket library])dnl
224 dpkg_save_libsocket_LIBS=$LIBS
225 AC_SEARCH_LIBS([bind], [socket])
226 LIBS=$dpkg_save_libsocket_LIBS
227 AS_IF([test "x$ac_cv_search_bind" = "xnone required"], [
228 have_libsocket="builtin"
229 ], [test "x$ac_cv_search_bind" != "xno"], [
231 SOCKET_LIBS="$ac_cv_search_bind"
237 # Check for GNU/Hurd ps library
238 AC_DEFUN([DPKG_LIB_PS], [
239 AC_ARG_VAR([PS_LIBS], [linker flags for ps library])dnl
240 AC_CHECK_LIB([ps], [proc_stat_list_create], [
248 # Check for BSD kvm library
249 AC_DEFUN([DPKG_LIB_KVM], [
250 AC_ARG_VAR([KVM_LIBS], [linker flags for kvm library])dnl
251 AC_CHECK_LIB([kvm], [kvm_openfiles], [