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 multithreaded compression support])
109 # Check for bz2 library.
110 AC_DEFUN([DPKG_LIB_BZ2], [
111 DPKG_WITH_COMPRESS_LIB([bz2], [bzlib.h], [BZ2_bzdopen])
116 # Check for selinux library.
117 AC_DEFUN([DPKG_LIB_SELINUX], [
118 AC_REQUIRE([PKG_PROG_PKG_CONFIG])
119 m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_fatal([missing pkg-config macros])])
120 AC_ARG_VAR([SELINUX_LIBS], [linker flags for selinux library])dnl
121 AC_ARG_WITH([libselinux],
122 [AS_HELP_STRING([--with-libselinux],
123 [use selinux library to set security contexts])],
124 [], [with_libselinux=check])
125 SELINUX_MIN_VERSION=2.3
127 AS_IF([test "x$with_libselinux" != "xno"], [
128 PKG_CHECK_MODULES([SELINUX], [libselinux >= $SELINUX_MIN_VERSION], [
129 AC_CHECK_HEADER([selinux/selinux.h], [
130 AC_DEFINE([WITH_LIBSELINUX], [1],
131 [Define to 1 to compile in SELinux support])
132 have_libselinux="yes"
134 AS_IF([test "x$with_libselinux" != "xcheck"], [
135 AC_MSG_FAILURE([libselinux header not found])
138 AC_CHECK_LIB([selinux], [setexecfilecon], [], [
139 AC_MSG_FAILURE([libselinux does not support setexecfilecon()])
142 AS_IF([test "x$with_libselinux" != "xcheck"], [
143 AC_MSG_FAILURE([libselinux at least $SELINUX_MIN_VERSION not found])
147 AM_CONDITIONAL([WITH_LIBSELINUX], [test "x$have_libselinux" = "xyes"])
150 # _DPKG_CHECK_LIB_CURSES_NARROW
151 # -----------------------------
152 # Check for narrow curses library.
153 AC_DEFUN([_DPKG_CHECK_LIB_CURSES_NARROW], [
154 AC_CHECK_LIB([ncurses], [initscr], [
155 CURSES_LIBS="${CURSES_LIBS:+$CURSES_LIBS }-lncurses"
157 AC_CHECK_LIB([curses], [initscr], [
158 CURSES_LIBS="${CURSES_LIBS:+$CURSES_LIBS }-lcurses"
160 AC_MSG_ERROR([no curses library found])
163 ])# DPKG_CHECK_LIB_CURSES_NARROW
167 # Check for curses library.
168 AC_DEFUN([DPKG_LIB_CURSES], [
169 AC_REQUIRE([DPKG_UNICODE])
170 AC_ARG_VAR([CURSES_LIBS], [linker flags for curses library])dnl
171 AC_CHECK_HEADERS([ncurses/ncurses.h ncurses.h curses.h ncurses/term.h term.h],
172 [have_curses_header=yes])
173 AS_IF([test "x$USE_UNICODE" = "xyes"], [
174 AC_CHECK_HEADERS([ncursesw/ncurses.h ncursesw/term.h],
175 [have_curses_header=yes])
176 AC_CHECK_LIB([ncursesw], [initscr], [
177 CURSES_LIBS="${CURSES_LIBS:+$CURSES_LIBS }-lncursesw"
179 _DPKG_CHECK_LIB_CURSES_NARROW()
182 _DPKG_CHECK_LIB_CURSES_NARROW()
184 AS_IF([test "x$have_curses_header" != "xyes"], [
185 AC_MSG_FAILURE([curses header not found])
192 # Check for socket library
193 AC_DEFUN([DPKG_LIB_SOCKET], [
194 AC_ARG_VAR([SOCKET_LIBS], [linker flags for socket library])dnl
196 dpkg_save_libsocket_LIBS=$LIBS
197 AC_SEARCH_LIBS([bind], [socket])
198 LIBS=$dpkg_save_libsocket_LIBS
199 AS_IF([test "x$ac_cv_search_bind" = "xnone required"], [
200 have_libsocket="builtin"
201 ], [test "x$ac_cv_search_bind" != "xno"], [
203 SOCKET_LIBS="$ac_cv_search_bind"
209 # Check for GNU/Hurd ps library
210 AC_DEFUN([DPKG_LIB_PS], [
211 AC_ARG_VAR([PS_LIBS], [linker flags for ps library])dnl
212 AC_CHECK_LIB([ps], [proc_stat_list_create], [
220 # Check for BSD kvm library
221 AC_DEFUN([DPKG_LIB_KVM], [
222 AC_ARG_VAR([KVM_LIBS], [linker flags for kvm library])dnl
223 AC_CHECK_LIB([kvm], [kvm_openfiles], [