1 # nbd client library in userspace
2 # Copyright (C) 2013-2019 Red Hat Inc.
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 AC_INIT([libnbd],[0.9.7])
20 AC_CONFIG_MACRO_DIR([m4])
21 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],[],
22 [m4_define([AC_USE_SYSTEM_EXTENSIONS],[])])
23 AC_USE_SYSTEM_EXTENSIONS
26 dnl NB: Do not [quote] this parameter.
27 AM_INIT_AUTOMAKE(foreign)
35 dnl Check for basic C environment.
41 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
47 dnl Check for C++ (optional, we just use this to test the header
48 dnl can be included from C++ code).
51 dnl The C++ compiler test is pretty useless because even if it fails
52 dnl it sets CXX=g++. So test the compiler actually works.
53 AC_MSG_CHECKING([if the C++ compiler really really works])
54 AS_IF([$CXX --version >&AS_MESSAGE_LOG_FD 2>&1],[have_cxx=yes],[have_cxx=no])
55 AC_MSG_RESULT([$have_cxx])
56 AM_CONDITIONAL([HAVE_CXX], [test "$have_cxx" = "yes"])
58 AC_ARG_ENABLE([gcc-warnings],
59 [AS_HELP_STRING([--enable-gcc-warnings],
60 [turn on lots of GCC warnings (for developers)])],
63 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
65 gcc_warnings=$enableval],
68 if test "x$gcc_warnings" = "xyes"; then
69 WARNINGS_CFLAGS="-Wall -Werror"
70 AC_SUBST([WARNINGS_CFLAGS])
73 dnl Check for other headers, all optional.
79 dnl Check for GnuTLS (optional, for TLS support).
81 [AS_HELP_STRING([--without-gnutls],
82 [disable use of gnutls @<:@default=check@:>@])],
85 AS_IF([test "$with_gnutls" != "no"],[
86 PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3.0], [
87 AC_SUBST([GNUTLS_CFLAGS])
88 AC_SUBST([GNUTLS_LIBS])
89 AC_DEFINE([HAVE_GNUTLS],[1],[gnutls found at compile time.])
91 AC_MSG_WARN([gnutls not found or < 3.3.0, TLS support will be disabled.])
94 AM_CONDITIONAL([HAVE_GNUTLS], [test "x$GNUTLS_LIBS" != "x"])
96 AS_IF([test "$GNUTLS_LIBS" != ""],[
97 AC_MSG_CHECKING([for default TLS session priority string])
98 AC_ARG_WITH([tls-priority],
99 [AS_HELP_STRING([--with-tls-priority],
100 [default TLS session priority string @<:@default=NORMAL@:>@])],
101 [tls_priority=$withval],
102 [tls_priority=NORMAL])
103 AC_MSG_RESULT([$tls_priority])
104 AC_DEFINE_UNQUOTED([TLS_PRIORITY],["$tls_priority"],
105 [Default TLS session priority string])
107 # Check for APIs which may not be present.
109 LIBS="$GNUTLS_LIBS $LIBS"
111 gnutls_session_set_verify_cert])
115 dnl certtool (part of GnuTLS) for testing TLS with certificates.
116 AC_CHECK_PROG([CERTTOOL], [certtool], [certtool])
117 AM_CONDITIONAL([HAVE_CERTTOOL], [test "x$CERTTOOL" != "x"])
119 dnl psktool (part of GnuTLS) for testing Pre-Shared Keys (PSK).
120 AC_CHECK_PROG([PSKTOOL], [psktool], [psktool])
121 AM_CONDITIONAL([HAVE_PSKTOOL], [test "x$PSKTOOL" != "x"])
123 dnl Check for libxml2 (optional, for NBD URI support)
124 AC_ARG_WITH([libxml2],
125 [AS_HELP_STRING([--without-libxml2],
126 [disable use of libxml2 for URI support @<:@default=check@:>@])],
128 [with_libxml2=check])
129 AS_IF([test "$with_libxml2" != "no"],[
130 PKG_CHECK_MODULES([LIBXML2], [libxml-2.0], [
131 AC_SUBST([LIBXML2_CFLAGS])
132 AC_SUBST([LIBXML2_LIBS])
133 AC_DEFINE([HAVE_LIBXML2],[1],[libxml2 found at compile time.])
135 AC_MSG_WARN([libxml2 not found, NBD URI support will be disabled.])
139 dnl nbdkit, nbdkit-sh-plugin and development headers are only needed
140 dnl to run the test suite.
141 AC_CHECK_PROG([NBDKIT], [nbdkit], [nbdkit])
142 AS_IF([test "x$NBDKIT" != "x"], [
143 PKG_CHECK_MODULES([NBDKIT], [nbdkit >= 1.12], [
144 AC_SUBST([NBDKIT_CFLAGS])
145 AC_SUBST([NBDKIT_LIBS])
146 have_nbdkit_devel=yes
148 AC_MSG_WARN([nbdkit development package is not installed, tests will be disabled])
151 AC_MSG_CHECKING([for nbdkit-sh-plugin])
152 AS_IF([$NBDKIT sh --version >&AS_MESSAGE_LOG_FD 2>&1], [
154 have_nbdkit_sh_plugin=yes
159 AM_CONDITIONAL([HAVE_NBDKIT], [test "x$NBDKIT" != "x" && test "x$have_nbdkit_devel" = "xyes" && test "x$have_nbdkit_sh_plugin" = "xyes"])
161 dnl nbd-server and qemu-nbd for interop testing.
162 AC_CHECK_PROG([NBD_SERVER], [nbd-server], [nbd-server])
163 AM_CONDITIONAL([HAVE_NBD_SERVER], [test "x$NBD_SERVER" != "x"])
164 AC_CHECK_PROG([QEMU_NBD], [qemu-nbd], [qemu-nbd])
165 AM_CONDITIONAL([HAVE_QEMU_NBD], [test "x$QEMU_NBD" != "x"])
167 dnl glib2 main loop for examples that interoperate with the glib main loop.
168 PKG_CHECK_MODULES([GLIB], [glib-2.0], [
169 AC_SUBST([GLIB_CFLAGS])
170 AC_SUBST([GLIB_LIBS])
172 AC_MSG_WARN([glib2 not found, some examples will not be compiled])
174 AM_CONDITIONAL([HAVE_GLIB], [test "x$GLIB_LIBS" != "x"])
176 dnl Check we have enough to run podwrapper.
177 AC_CHECK_PROG([PERL],[perl],[perl],[no])
178 AS_IF([test "x$PERL" != "xno"],[
179 AC_MSG_CHECKING([if we have perl Pod::Man and Pod::Simple])
180 AS_IF([$PERL -MPod::Man -MPod::Simple -e 1 >&AS_MESSAGE_LOG_FD 2>&1],[
185 AC_MSG_RESULT([$enable_pod])
187 AM_CONDITIONAL([HAVE_POD],
188 [test "x$PERL" != "xno" && test "x$enable_pod" = "xyes"])
190 dnl Define the path to the podwrapper program.
191 PODWRAPPER="$PERL $(pwd)/podwrapper.pl"
192 AC_SUBST([PODWRAPPER])
194 dnl OCaml, required for running the generator when building from git,
195 dnl optional the rest of the time unless you want to build the OCaml
199 AM_CONDITIONAL([HAVE_OCAML_TOPLEVEL],[test "x$OCAML" != "xno"])
201 dnl Flags we want to pass to every OCaml compiler call.
202 OCAML_WARN_ERROR="-warn-error CDEFLMPSUVYZX+52-3"
203 AC_SUBST([OCAML_WARN_ERROR])
204 OCAML_FLAGS="-g -annot -safe-string"
205 AC_SUBST([OCAML_FLAGS])
207 dnl Note this only disables the OCaml bindings.
208 AC_ARG_ENABLE([ocaml],
209 AS_HELP_STRING([--disable-ocaml], [disable OCaml language bindings]),
212 AM_CONDITIONAL([HAVE_OCAML],
213 [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && \
214 test "x$enable_ocaml" = "xyes"])
215 AM_CONDITIONAL([HAVE_OCAMLOPT],
216 [test "x$OCAMLOPT" != "xno" && test "x$OCAMLFIND" != "xno" && \
217 test "x$enable_ocaml" = "xyes"])
219 dnl Python, optional for the Python bindings and shell.
224 AC_ARG_ENABLE([python],
225 AS_HELP_STRING([--disable-python], [disable Python 3 language bindings]),
228 AS_IF([test "x$enable_python" != "xno"],[
229 AC_CHECK_PROG([PYTHON],[python3],[python3],[no])
231 if test "x$PYTHON" != "xno"; then
232 AC_MSG_CHECKING([Python version])
233 PYTHON_VERSION_MAJOR=`$PYTHON -c "import sys; print (sys.version_info@<:@0@:>@)"`
234 PYTHON_VERSION_MINOR=`$PYTHON -c "import sys; print (sys.version_info@<:@1@:>@)"`
235 PYTHON_VERSION="$PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR"
236 AC_MSG_RESULT([$PYTHON_VERSION])
238 # Debian: python-3.2.pc
239 PKG_CHECK_MODULES([PYTHON], [python-"$PYTHON_VERSION"],[
241 AC_SUBST([PYTHON_CFLAGS])
242 AC_SUBST([PYTHON_LIBS])
243 AC_SUBST([PYTHON_VERSION])
244 AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
246 PKG_CHECK_MODULES([PYTHON], [python],[
248 AC_SUBST([PYTHON_CFLAGS])
249 AC_SUBST([PYTHON_LIBS])
250 AC_SUBST([PYTHON_VERSION])
251 AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
253 AC_MSG_WARN([python $PYTHON_VERSION not found])
257 AC_MSG_CHECKING([Python prefix])
258 PYTHON_PREFIX=`$PYTHON -c "import sys; print (sys.prefix)"`
259 AC_MSG_RESULT([$PYTHON_PREFIX])
261 AC_ARG_WITH([python-installdir],
262 [AS_HELP_STRING([--with-python-installdir],
263 [directory to install python modules @<:@default=check@:>@])],
264 [PYTHON_INSTALLDIR="$withval"
265 AC_MSG_NOTICE([Python install dir $PYTHON_INSTALLDIR])],
266 [PYTHON_INSTALLDIR=check])
268 if test "x$PYTHON_INSTALLDIR" = "xcheck"; then
270 AC_MSG_CHECKING([for Python site-packages path])
271 if test -z "$PYTHON_INSTALLDIR"; then
272 PYTHON_INSTALLDIR=`$PYTHON -c "import distutils.sysconfig; \
273 print (distutils.sysconfig.get_python_lib(1,0));"`
275 AC_MSG_RESULT([$PYTHON_INSTALLDIR])
278 AC_MSG_CHECKING([for Python extension suffix (PEP-3149)])
279 if test -z "$PYTHON_EXT_SUFFIX"; then
280 python_ext_suffix=`$PYTHON -c "import distutils.sysconfig; \
281 print (distutils.sysconfig.get_config_var('EXT_SUFFIX') or distutils.sysconfig.get_config_var('SO'))"`
282 PYTHON_EXT_SUFFIX=$python_ext_suffix
284 AC_MSG_RESULT([$PYTHON_EXT_SUFFIX])
287 AC_SUBST(PYTHON_PREFIX)
288 AC_SUBST(PYTHON_VERSION)
289 AC_SUBST(PYTHON_INSTALLDIR)
290 AC_SUBST(PYTHON_EXT_SUFFIX)
292 AM_CONDITIONAL([HAVE_PYTHON],
293 [test "x$PYTHON" != "xno" && test "x$have_python_module" = "x1" ])
295 dnl Produce output files.
296 AC_CONFIG_HEADERS([config.h])
298 AC_CONFIG_FILES([podwrapper.pl],
299 [chmod +x,-w podwrapper.pl])
300 AC_CONFIG_FILES([python/run-python-tests],
301 [chmod +x,-w python/run-python-tests])
302 AC_CONFIG_FILES([run],
304 AC_CONFIG_FILES([sh/nbdsh],
305 [chmod +x,-w sh/nbdsh])
307 AC_CONFIG_FILES([Makefile
308 common/include/Makefile
318 ocaml/examples/Makefile