]> git.proxmox.com Git - mirror_lxc.git/blob - configure.ac
Merge pull request #2114 from brauner/2018-01-27/make_name_arg_optional
[mirror_lxc.git] / configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 m4_define([lxc_devel], 1)
5 m4_define([lxc_version_major], 2)
6 m4_define([lxc_version_minor], 1)
7 m4_define([lxc_version_micro], 0)
8 m4_define([lxc_version_beta], [])
9
10 m4_define([lxc_abi_major], 1)
11 m4_define([lxc_abi_minor], 3)
12 m4_define([lxc_abi_micro], 0)
13 m4_define([lxc_abi], [lxc_abi_major.lxc_abi_minor.lxc_abi_micro])
14
15 m4_define([lxc_version_base], [lxc_version_major.lxc_version_minor.lxc_version_micro])
16 m4_define([lxc_version],
17 [ifelse(lxc_devel, 1,
18 ifelse(lxc_version_beta, [], [lxc_version_base], [lxc_version_base.lxc_version_beta])-devel,
19 ifelse(lxc_version_beta, [], [lxc_version_base], [lxc_version_base.lxc_version_beta]))])
20
21 AC_INIT([lxc], [lxc_version])
22
23 # We need pkg-config
24 PKG_PROG_PKG_CONFIG
25
26 AC_SUBST(LXC_VERSION_BASE, lxc_version_base)
27 AC_SUBST(LXC_VERSION_BETA, lxc_version_beta)
28
29 AC_SUBST([LXC_VERSION_MAJOR], [lxc_version_major])
30 AC_SUBST([LXC_VERSION_MINOR], [lxc_version_minor])
31 AC_SUBST([LXC_VERSION_MICRO], [lxc_version_micro])
32 AC_SUBST([LXC_VERSION], [lxc_version])
33 AC_SUBST([LXC_DEVEL], [lxc_devel])
34
35 AC_SUBST([LXC_ABI_MAJOR], [lxc_abi_major])
36 AC_SUBST([LXC_ABI_MINOR], [lxc_abi_minor])
37 AC_SUBST([LXC_ABI_MICRO], [lxc_abi_micro])
38 AC_SUBST([LXC_ABI], [lxc_abi])
39
40 AC_CONFIG_SRCDIR([configure.ac])
41 AC_CONFIG_AUX_DIR([config])
42 AC_CONFIG_HEADERS([src/config.h])
43 AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability subdir-objects])
44 AC_CANONICAL_HOST
45 AM_PROG_CC_C_O
46 AC_GNU_SOURCE
47
48 # libtool
49 LT_INIT
50 AC_SUBST([LIBTOOL_DEPS])
51
52 # Detect the distribution. This is used for the default configuration and
53 # for some distro-specific build options.
54 AC_MSG_CHECKING([host distribution])
55 AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: One of redhat, oracle, centos, fedora, suse, gentoo, debian, arch, slackware, plamo, paldo, openmandriva, pardus, sparclinux, altlinux.]))
56 if type lsb_release >/dev/null 2>&1 && test "z$with_distro" = "z"; then
57 with_distro=`lsb_release -is`
58 fi
59 if test "z$with_distro" = "z"; then
60 AC_CHECK_FILE(/etc/redhat-release,with_distro="redhat")
61 AC_CHECK_FILE(/etc/oracle-release,with_distro="oracle")
62 AC_CHECK_FILE(/etc/sparclinux-release,with_distro="sparclinux")
63 AC_CHECK_FILE(/etc/centos-release,with_distro="centos")
64 AC_CHECK_FILE(/etc/fedora-release,with_distro="fedora")
65 AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
66 AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
67 AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
68 AC_CHECK_FILE(/etc/arch-release,with_distro="arch")
69 AC_CHECK_FILE(/etc/slackware-version,with_distro="slackware")
70 AC_CHECK_FILE(/etc/plamo-version,with_distro="plamo")
71 AC_CHECK_FILE(/etc/frugalware-release,with_distro="frugalware")
72 AC_CHECK_FILE(/etc/mandrakelinux-release, with_distro="openmandriva")
73 AC_CHECK_FILE(/etc/mandriva-release,with_distro="openmandriva")
74 AC_CHECK_FILE(/etc/pardus-release,with_distro="pardus")
75 AC_CHECK_FILE(/etc/altlinux-release,with_distro="altlinux")
76 AC_CHECK_FILE(/etc/pld-release,with_distro="pld")
77 fi
78 with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]'`
79
80 if test "z$with_distro" = "zforsparc"; then
81 with_distro="sparclinux"
82 fi
83
84 if test "z$with_distro" = "z"; then
85 with_distro="unknown"
86 fi
87 case $with_distro in
88 ubuntu|raspbian)
89 distroconf=default.conf.lxcbr
90 distrosysconf="$sysconfdir/default"
91 ;;
92 redhat|centos|fedora|oracle|oracleserver|sparclinux|altlinux|suse|opensuse*|plamo|pld)
93 distroconf=default.conf.lxcbr
94 distrosysconf="$sysconfdir/sysconfig"
95 ;;
96 *)
97 distroconf=default.conf.unknown
98 distrosysconf="$sysconfdir/default"
99 ;;
100 esac
101 AC_MSG_RESULT([$with_distro])
102 AM_CONDITIONAL([HAVE_DEBIAN], [test x"$with_distro" = "xdebian" -o x"$with_distro" = "xubuntu" -o x"$with_distro" = "xraspbian"])
103 AM_CONDITIONAL([DISTRO_UBUNTU], [test "x$with_distro" = "xubuntu"])
104
105 AC_CONFIG_LINKS([config/etc/default.conf:config/etc/${distroconf}])
106
107 # Check for init system type
108 AC_MSG_CHECKING([for init system type])
109 AC_ARG_WITH([init-script],
110 [AC_HELP_STRING([--with-init-script@<:@=TYPE@<:@,TYPE,...@:>@@:>@],
111 [Type(s) of init script to install: sysvinit, systemd, upstart,
112 distro @<:@default=distro@:>@])],[],[with_init_script=distro])
113 case "$with_init_script" in
114 distro)
115 case $with_distro in
116 fedora|altlinux|opensuse*)
117 init_script=systemd
118 ;;
119 redhat|oracle|oracleserver|sparclinux|plamo)
120 init_script=sysvinit
121 ;;
122 centos)
123 init_script=sysvinit,systemd
124 ;;
125 debian|raspbian|ubuntu)
126 init_script=upstart,systemd
127 ;;
128 pld)
129 init_script=sysvinit,upstart,systemd
130 ;;
131 *)
132 echo -n "Linux distribution init system unknown."
133 init_script=
134 ;;
135 esac
136 ;;
137 *)
138 init_script=$with_init_script
139 ;;
140 esac
141
142 # Check valid init systems were given, run in subshell so we don't mess up IFS
143 (IFS="," ; for init_sys in $init_script;
144 do
145 case "$init_sys" in
146 none|sysvinit|systemd|upstart)
147 ;;
148 *)
149 exit 1
150 ;;
151 esac
152 done) || AC_MSG_ERROR([Unknown init system type in $init_script])
153
154 AM_CONDITIONAL([INIT_SCRIPT_SYSV], [echo "$init_script" |grep -q "sysvinit"])
155 AM_CONDITIONAL([INIT_SCRIPT_SYSTEMD], [echo "$init_script" |grep -q "systemd"])
156 AM_CONDITIONAL([INIT_SCRIPT_UPSTART], [echo "$init_script" |grep -q "upstart"])
157 AC_MSG_RESULT($init_script)
158
159 # systemd unit dir
160 AC_ARG_WITH([systemdsystemunitdir],
161 AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
162 [],
163 [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
164 if test -z "$with_systemdsystemunitdir"; then
165 with_systemdsystemunitdir=/lib/systemd/system
166 fi
167 if test "x$with_systemdsystemunitdir" != "xno"; then
168 AC_SUBST([SYSTEMD_UNIT_DIR], [$with_systemdsystemunitdir])
169 fi
170
171 AC_ARG_ENABLE([werror],
172 [AC_HELP_STRING([--disable-werror],
173 [do not treat warnings as errors])],
174 [], [enable_werror=yes])
175
176 # Allow enabling deprecated executables
177 AC_ARG_ENABLE([deprecated],
178 [AC_HELP_STRING([--enable-deprecated],
179 [enable deprecated executables [default=no]])],
180 [], [enable_deprecated=false])
181 AM_CONDITIONAL([ENABLE_DEPRECATED], [test "x$enable_deprecated" = "xyes"])
182
183 # Allow disabling rpath
184 AC_ARG_ENABLE([rpath],
185 [AC_HELP_STRING([--enable-rpath], [set rpath in executables [default=no]])],
186 [], [enable_rpath=no])
187 AM_CONDITIONAL([ENABLE_RPATH], [test "x$enable_rpath" = "xyes"])
188
189 # Documentation (manpages)
190 AC_ARG_ENABLE([doc],
191 [AC_HELP_STRING([--enable-doc], [make man pages [default=auto]])],
192 [], [enable_doc=auto])
193
194 if test "x$enable_doc" = "xyes" -o "x$enable_doc" = "xauto"; then
195 db2xman=""
196 dbparsers="docbook2X2man docbook2x-man db2x_docbook2man docbook2man docbook-to-man"
197
198 AC_MSG_CHECKING(for docbook2x-man)
199 for name in ${dbparsers}; do
200 if "$name" --help >/dev/null 2>&1; then
201 db2xman="$name"
202 break;
203 fi
204 done
205
206 if test -n "${db2xman}"; then
207 AC_MSG_RESULT([${db2xman}])
208 enable_doc="yes"
209 else
210 AC_MSG_RESULT([no])
211 if test "x$enable_doc" = "xyes"; then
212 AC_MSG_ERROR([docbook2x-man is required, but could not be found])
213 fi
214 enable_doc="no"
215 fi
216
217 AC_SUBST(db2xman)
218 fi
219 AM_CONDITIONAL([ENABLE_DOCBOOK], [test "x$db2xman" != "x"])
220 AM_CONDITIONAL([USE_DOCBOOK2X], [test "x$db2xman" != "xdocbook2man"])
221
222 if test "x$db2xman" = "xdocbook2man"; then
223 docdtd="\"-//Davenport//DTD DocBook V3.0//EN\""
224 else
225 docdtd="\"-//OASIS//DTD DocBook XML\" \"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd\""
226 fi
227 AC_SUBST(docdtd)
228
229 # Documentation (API)
230 AC_ARG_ENABLE([api-docs],
231 [AC_HELP_STRING([--enable-api-docs],
232 [make API documentation [default=auto]])],
233 [], [enable_api_docs=auto])
234
235 if test "x$enable_api_docs" = "xyes" -o "x$enable_api_docs" = "xauto"; then
236 AC_CHECK_PROGS([HAVE_DOXYGEN],[doxygen])
237 AC_SUBST([HAVE_DOXYGEN])
238
239 if test "x$HAVE_DOXYGEN" != "x"; then
240 enable_api_docs="yes"
241 else
242 if test "x$enable_api_docs" = "xyes"; then
243 AC_MSG_ERROR([doxygen is required, but could not be found])
244 fi
245 enable_api_docs="no"
246 fi
247 fi
248
249 AM_CONDITIONAL([ENABLE_API_DOCS], [test "x$HAVE_DOXYGEN" != "x"])
250
251 # Apparmor
252 AC_ARG_ENABLE([apparmor],
253 [AC_HELP_STRING([--enable-apparmor], [enable apparmor support [default=auto]])],
254 [], [enable_apparmor=auto])
255
256 if test "$enable_apparmor" = "auto" ; then
257 AC_CHECK_LIB([apparmor],[aa_change_profile],[enable_apparmor=yes], [enable_apparmor=no])
258 fi
259 AM_CONDITIONAL([ENABLE_APPARMOR], [test "x$enable_apparmor" = "xyes"])
260
261 # GnuTLS
262 AC_ARG_ENABLE([gnutls],
263 [AC_HELP_STRING([--enable-gnutls], [enable GnuTLS support [default=auto]])],
264 [], [enable_gnutls=auto])
265
266 if test "$enable_gnutls" = "auto" ; then
267 AC_CHECK_LIB([gnutls], [gnutls_hash_fast], [enable_gnutls=yes], [enable_gnutls=no])
268 fi
269 AM_CONDITIONAL([ENABLE_GNUTLS], [test "x$enable_gnutls" = "xyes"])
270
271 AM_COND_IF([ENABLE_GNUTLS],
272 [AC_CHECK_HEADER([gnutls/gnutls.h],[],[AC_MSG_ERROR([You must install the GnuTLS development package in order to compile lxc])])
273 AC_CHECK_LIB([gnutls], [gnutls_hash_fast],[],[AC_MSG_ERROR([You must install the GnuTLS development package in order to compile lxc])])
274 AC_SUBST([GNUTLS_LIBS], [-lgnutls])])
275
276 # SELinux
277 AC_ARG_ENABLE([selinux],
278 [AC_HELP_STRING([--enable-selinux], [enable SELinux support [default=auto]])],
279 [], [enable_selinux=auto])
280
281 if test "x$enable_selinux" = xauto; then
282 AC_CHECK_LIB([selinux],[setexeccon_raw],[enable_selinux=yes],[enable_selinux=no])
283 fi
284 AM_CONDITIONAL([ENABLE_SELINUX], [test "x$enable_selinux" = "xyes"])
285 AM_COND_IF([ENABLE_SELINUX],
286 [AC_CHECK_HEADER([selinux/selinux.h],[],[AC_MSG_ERROR([You must install the SELinux development package in order to compile lxc])])
287 AC_CHECK_LIB([selinux], [setexeccon_raw],[true],[AC_MSG_ERROR([You must install the SELinux development package in order to compile lxc])])
288 AC_SUBST([SELINUX_LIBS], [-lselinux])])
289
290 # Seccomp syscall filter
291 AC_ARG_ENABLE([seccomp],
292 [AC_HELP_STRING([--enable-seccomp], [enable seccomp support [default=auto]])],
293 [], [enable_seccomp=auto])
294
295 if test "x$enable_seccomp" = "xauto" ; then
296 AC_CHECK_LIB([seccomp],[seccomp_init],[enable_seccomp=yes],[enable_seccomp=no])
297 fi
298 AM_CONDITIONAL([ENABLE_SECCOMP], [test "x$enable_seccomp" = "xyes"])
299
300 AM_COND_IF([ENABLE_SECCOMP],
301 [PKG_CHECK_MODULES([SECCOMP],[libseccomp],[],[
302 AC_CHECK_HEADER([seccomp.h],[],[AC_MSG_ERROR([You must install the seccomp development package in order to compile lxc])])
303 AC_CHECK_LIB([seccomp], [seccomp_init],[],[AC_MSG_ERROR([You must install the seccomp development package in order to compile lxc])])
304 AC_SUBST([SECCOMP_LIBS], [-lseccomp])
305 ])
306 ])
307
308 # cgmanager
309 AC_ARG_ENABLE([cgmanager],
310 [AC_HELP_STRING([--enable-cgmanager], [enable cgmanager support [default=auto]])],
311 [], [enable_cgmanager=auto])
312
313 if test "x$enable_cgmanager" = "xauto" ; then
314 AC_CHECK_LIB([cgmanager],[cgmanager_create],[enable_cgmanager=yes],[enable_cgmanager=no],[-lnih -lnih-dbus -ldbus-1])
315 fi
316 AM_CONDITIONAL([ENABLE_CGMANAGER], [test "x$enable_cgmanager" = "xyes"])
317
318 AM_COND_IF([ENABLE_CGMANAGER],
319 [PKG_CHECK_MODULES([CGMANAGER], [libcgmanager])
320 PKG_CHECK_MODULES([NIH], [libnih >= 1.0.2])
321 PKG_CHECK_MODULES([NIH_DBUS], [libnih-dbus >= 1.0.0])
322 PKG_CHECK_MODULES([DBUS], [dbus-1 >= 1.2.16])
323 ])
324
325 AC_MSG_CHECKING(for get_pid_cgroup_abs_sync)
326 save_LIBS=$LIBS
327 AC_SEARCH_LIBS([cgmanager_get_pid_cgroup_abs_sync], [cgmanager], [have_abs_cgroups=yes], [have_abs_cgroups=no], [-lnih -lnih-dbus -ldbus-1])
328 LIBS=$save_LIBS
329 if test "x$have_abs_cgroups" = "xyes"; then
330 AC_DEFINE([HAVE_CGMANAGER_GET_PID_CGROUP_ABS_SYNC], 1, [Have cgmanager_get_pid_cgroup_abs_sync])
331 AC_MSG_RESULT([yes])
332 else
333 AC_MSG_RESULT([no])
334 fi
335
336 AC_MSG_CHECKING(for cgmanager_list_controllers)
337 save_LIBS=$LIBS
338 AC_SEARCH_LIBS([cgmanager_list_controllers_sync], [cgmanager], [have_list_controllers=yes], [have_list_controllers=no], [-lnih -lnih-dbus -ldbus-1])
339 LIBS=$save_LIBS
340 if test "x$have_list_controllers" = "xyes"; then
341 AC_DEFINE([HAVE_CGMANAGER_LIST_CONTROLLERS], 1, [Have cgmanager_list_controllers])
342 AC_MSG_RESULT([yes])
343 else
344 AC_MSG_RESULT([no])
345 fi
346
347 AC_MSG_CHECKING(for static libcap)
348 # Check for static libcap, make sure the function checked for differs from the
349 # the one checked below so the cache doesn't give a wrong answer
350 OLD_CFLAGS="$CFLAGS"
351 OLD_CPPFLAGS="$CPPFLAGS"
352 OLD_LDFLAGS="$LDFLAGS"
353 OLD_LIBS="$LIBS"
354 CFLAGS=""
355 CPPFLAGS=""
356 LDFLAGS="-static"
357 LIBS="-lcap"
358 AC_LINK_IFELSE([
359 AC_LANG_SOURCE(
360 [[int main() { return 0; }]]
361 )],[have_static_libcap=yes],[have_static_libcap=no])
362 AM_CONDITIONAL([HAVE_STATIC_LIBCAP], [test "x$have_static_libcap" = "xyes"])
363 if test "x$have_static_libcap" = "xyes"; then
364 AC_DEFINE([HAVE_STATIC_LIBCAP], 1, [Have static libcap])
365 AC_MSG_RESULT([yes])
366 else
367 AC_MSG_RESULT([no])
368 fi
369 CPPFLAGS="$OLD_CPPFLAGS"
370 CFLAGS="$OLD_CFLAGS"
371 LDFLAGS="$OLD_LDFLAGS"
372 LIBS="$OLD_LIBS"
373
374
375 # Linux capabilities
376 AC_ARG_ENABLE([capabilities],
377 [AC_HELP_STRING([--enable-capabilities], [enable kernel capabilities support [default=auto]])],
378 [], [enable_capabilities=auto])
379
380 if test "x$enable_capabilities" = "xauto"; then
381 AC_CHECK_LIB([cap],[cap_set_proc],[enable_capabilities=yes],[enable_capabilities=no])
382 fi
383 AM_CONDITIONAL([ENABLE_CAP], [test "x$enable_capabilities" = "xyes"])
384
385 AM_COND_IF([ENABLE_CAP],
386 [AC_CHECK_HEADER([sys/capability.h],[],[AC_MSG_ERROR([You must install the libcap development package in order to compile lxc])])
387 AC_CHECK_LIB(cap,cap_set_proc,[],[AC_MSG_ERROR([You must install the libcap development package in order to compile lxc])])
388 # Test whether we support getting file capabilities via cap_get_file().
389 AC_CHECK_LIB(cap,cap_get_file, AC_DEFINE(LIBCAP_SUPPORTS_FILE_CAPABILITIES,1,[Have cap_get_file]),[],[])
390 AC_SUBST([CAP_LIBS], [-lcap])])
391
392 # HAVE_SCMP_FILTER_CTX=1 will tell us we have libseccomp api >= 1.0.0
393 OLD_CFLAGS="$CFLAGS"
394 CFLAGS="$CFLAGS $SECCOMP_CFLAGS"
395 AC_CHECK_TYPES([scmp_filter_ctx], [], [], [[#include <seccomp.h>]])
396 AC_CHECK_DECLS([seccomp_syscall_resolve_name_arch], [], [], [[#include <seccomp.h>]])
397 CFLAGS="$OLD_CFLAGS"
398
399 # Configuration examples
400 AC_ARG_ENABLE([examples],
401 [AC_HELP_STRING([--enable-examples], [install examples [default=yes]])],
402 [], [enable_examples=yes])
403 AM_CONDITIONAL([ENABLE_EXAMPLES], [test "x$enable_examples" = "xyes"])
404
405 # Python3 module and scripts
406 AC_ARG_ENABLE([python],
407 [AC_HELP_STRING([--enable-python], [enable python binding [default=auto]])],
408 [], [enable_python=auto])
409
410 if test "x$enable_python" = "xauto"; then
411 PKG_CHECK_MODULES([PYTHONDEV], [python3 >= 3.2],[enable_python=yes],[enable_python=no])
412 if test "$CC" = "clang"; then
413 enable_python=no
414 fi
415 fi
416
417 if test "x$enable_python" = "xyes" && test "$CC" = "clang"; then
418 AC_MSG_ERROR([Python3 is incompatible with the clang compiler])
419 fi
420
421 AM_CONDITIONAL([ENABLE_PYTHON], [test "x$enable_python" = "xyes"])
422
423 AM_COND_IF([ENABLE_PYTHON],
424 [AM_PATH_PYTHON([3.2], [], [AC_MSG_ERROR([You must install python3])])
425 PKG_CHECK_MODULES([PYTHONDEV], [python3 >= 3.2],[],[AC_MSG_ERROR([You must install python3-dev])])
426 AC_DEFINE_UNQUOTED([ENABLE_PYTHON], 1, [Python3 is available])])
427
428 # Enable dumping stack traces
429 AC_ARG_ENABLE([mutex-debugging],
430 [AC_HELP_STRING([--enable-mutex-debugging], [Makes mutexes to report error and provide stack trace [default=no]])],
431 [], [enable_mutex_debugging=no])
432 AM_CONDITIONAL([MUTEX_DEBUGGING], [test "x$enable_mutex_debugging" = "xyes"])
433
434 AM_COND_IF([MUTEX_DEBUGGING],
435 AC_DEFINE_UNQUOTED([MUTEX_DEBUGGING], 1, [Enabling mutex debugging]))
436
437 # Not in older autoconf versions
438 # AS_VAR_COPY(DEST, SOURCE)
439 # -------------------------
440 # Set the polymorphic shell variable DEST to the contents of the polymorphic
441 # shell variable SOURCE.
442 m4_ifdef([AS_VAR_COPY], [],
443 [AC_DEFUN([AS_VAR_COPY],
444 [AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
445 ])
446
447 dnl PKG_CHECK_VAR was introduced with pkg-config 0.28
448 m4_ifdef([PKG_CHECK_VAR], [],
449 [AC_DEFUN([PKG_CHECK_VAR],
450 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
451 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
452 _PKG_CONFIG([$1], [variable="][$3]["], [$2])
453 AS_VAR_COPY([$1], [pkg_cv_][$1])
454 AS_VAR_IF([$1], [""], [$5], [$4])dnl
455 ])# PKG_CHECK_VAR
456 ])
457
458 # Lua module and scripts
459 AC_ARG_ENABLE([lua],
460 [AC_HELP_STRING([--enable-lua], [enable lua binding [default=auto]])],
461 [], [enable_lua=auto])
462
463 AC_ARG_WITH([lua-pc],
464 [AS_HELP_STRING(
465 [--with-lua-pc=PKG],
466 [Specify pkg-config package name for lua]
467 )], [], [with_lua_pc=no])
468
469 if test "x$enable_lua" = "xyes" -a "x$with_lua_pc" != "xno"; then
470 # exit with error if not found
471 PKG_CHECK_MODULES([LUA], [$with_lua_pc], [LUAPKGCONFIG=$with_lua_pc])
472 fi
473
474 if test "x$enable_lua" = "xauto" -a "x$with_lua_pc" != "xno"; then
475 PKG_CHECK_MODULES([LUA], [$with_lua_pc],
476 [LUAPKGCONFIG=$with_lua_pc
477 enable_lua=yes],
478 [enable_lua=no])
479 fi
480
481 if test "x$enable_lua" != "xno"; then
482 PKG_CHECK_MODULES([LUA], [lua], [LUAPKGCONFIG=lua],
483 [PKG_CHECK_MODULES([LUA], [lua5.2], [LUAPKGCONFIG=lua5.2],
484 [PKG_CHECK_MODULES([LUA], [lua5.1], [LUAPKGCONFIG=lua5.1],
485 [AS_IF([test "x$enable_lua" = "xyes"],
486 [AC_MSG_ERROR([Lua not found. Please use --with-lua-pc=PKG])],
487 [enable_lua=no])]
488 )]
489 )])
490 AS_IF([test "x$LUAPKGCONFIG" != "x"], [enable_lua=yes])
491 fi
492
493 AM_CONDITIONAL([ENABLE_LUA],
494 [test "x$enable_lua" = "xyes"])
495
496 AM_COND_IF([ENABLE_LUA],
497 [AC_MSG_CHECKING([Lua version])
498 PKG_CHECK_VAR([LUA_VERSION], [$LUAPKGCONFIG], [V],,
499 [PKG_CHECK_VAR([LUA_VERSION], [$LUAPKGCONFIG], [major_version])])
500 AC_MSG_RESULT([$LUA_VERSION])
501 AC_SUBST([LUA_LIBDIR], [$libdir/lua/$LUA_VERSION])
502 AC_SUBST([LUA_SHAREDIR], [$datadir/lua/$LUA_VERSION])
503 ])
504
505 # Optional bash integration
506 AC_ARG_ENABLE([bash],
507 [AC_HELP_STRING([--enable-bash], [build bash integration [default=yes]])],
508 [], [enable_bash=yes])
509 AM_CONDITIONAL([ENABLE_BASH], [test "x$enable_bash" = "xyes"])
510
511 AM_COND_IF([ENABLE_BASH],
512 [AC_MSG_CHECKING([bash completion directory])
513 PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir], ,
514 bashcompdir="${sysconfdir}/bash_completion.d")
515 AC_MSG_RESULT([$bashcompdir])
516 AC_SUBST(bashcompdir)
517 ])
518
519 # Optional test binaries
520 AC_ARG_ENABLE([tests],
521 [AC_HELP_STRING([--enable-tests], [build test/example binaries [default=no]])],
522 [], [enable_tests=no])
523 AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = "xyes"])
524
525 # Allow overriding the default runtime dir (/run)
526 AC_ARG_WITH([runtime-path],
527 [AC_HELP_STRING(
528 [--with-runtime-path=dir],
529 [runtime directory (default: /run)]
530 )], [], [with_runtime_path=['/run']])
531
532 # LXC container path, where the containers are actually stored
533 # This is overridden by an entry in the file called LXCCONF
534 # (i.e. /etc/lxc/lxc.conf)
535 AC_ARG_WITH([config-path],
536 [AC_HELP_STRING(
537 [--with-config-path=dir],
538 [lxc configuration repository path]
539 )], [], [with_config_path=['${localstatedir}/lib/lxc']])
540
541 # The path of the global lxc configuration file.
542 AC_ARG_WITH([global-conf],
543 [AC_HELP_STRING(
544 [--with-global-conf=dir],
545 [global lxc configuration file]
546 )], [], [with_global_conf=['${sysconfdir}/lxc/lxc.conf']])
547
548 # The path of the userns network configuration file
549 AC_ARG_WITH([usernic-conf],
550 [AC_HELP_STRING(
551 [--with-usernic-conf],
552 [user network interface configuration file]
553 )], [], [with_usernic_conf=['${sysconfdir}/lxc/lxc-usernet']])
554
555 # The path of the runtime usernic database
556 AC_ARG_WITH([usernic-db],
557 [AC_HELP_STRING(
558 [--with-usernic-db],
559 [lxc user nic database]
560 )], [], [with_usernic_db=['${with_runtime_path}/lxc/nics']])
561
562 # Rootfs path, where the container mount structure is assembled
563 AC_ARG_WITH([rootfs-path],
564 [AC_HELP_STRING(
565 [--with-rootfs-path=dir],
566 [lxc rootfs mount point]
567 )], [], [with_rootfs_path=['${libdir}/lxc/rootfs']])
568
569 # cgroup pattern specification
570 AC_ARG_WITH([cgroup-pattern],
571 [AC_HELP_STRING(
572 [--with-cgroup-pattern=pattern],
573 [pattern for container cgroups]
574 )], [], [with_cgroup_pattern=['lxc/%n']])
575
576 # Container log path. By default, use $lxcpath.
577 AC_MSG_CHECKING([Whether to place logfiles in container config path])
578 AC_ARG_ENABLE([configpath-log],
579 [AC_HELP_STRING([--enable-configpath-log], [use logfiles in config path [default=no]])],
580 [], [enable_configpath_log=no])
581 AC_MSG_RESULT([$enable_configpath_log])
582 AM_CONDITIONAL([USE_CONFIGPATH_LOGS], [test "$enable_configpath_log" = "yes"])
583
584 if test "$enable_configpath_log" = "yes"; then
585 default_log_path="${with_config_path}"
586 else
587 default_log_path="${localstatedir}/log/lxc"
588 fi
589
590 AC_ARG_WITH([log-path],
591 [AC_HELP_STRING(
592 [--with-log-path=dir],
593 [per container log path]
594 )], [], [with_log_path=['${default_log_path}']])
595
596 # Expand some useful variables
597 AS_AC_EXPAND(PREFIX, "$prefix")
598 AS_AC_EXPAND(LIBDIR, "$libdir")
599 AS_AC_EXPAND(BINDIR, "$bindir")
600 AS_AC_EXPAND(SBINDIR, "$sbindir")
601 AS_AC_EXPAND(LIBEXECDIR, "$libexecdir")
602 AS_AC_EXPAND(INCLUDEDIR, "$includedir")
603 AS_AC_EXPAND(SYSCONFDIR, "$sysconfdir")
604 AS_AC_EXPAND(LXC_DEFAULT_CONFIG, "$sysconfdir/lxc/default.conf")
605 AS_AC_EXPAND(DATADIR, "$datadir")
606 AS_AC_EXPAND(LOCALSTATEDIR, "$localstatedir")
607 AS_AC_EXPAND(DOCDIR, "$docdir")
608 AS_AC_EXPAND(LXC_GENERATE_DATE, "$(date --utc --date=@${SOURCE_DATE_EPOCH:-$(date +%s)} '+%Y-%m-%d')")
609 AS_AC_EXPAND(LXCPATH, "$with_config_path")
610 AS_AC_EXPAND(LXC_GLOBAL_CONF, "$with_global_conf")
611 AS_AC_EXPAND(LXC_USERNIC_CONF, "$with_usernic_conf")
612 AS_AC_EXPAND(LXC_USERNIC_DB, "$with_usernic_db")
613 AS_AC_EXPAND(LXC_DISTRO_SYSCONF, "$distrosysconf")
614 AS_AC_EXPAND(LXCROOTFSMOUNT, "$with_rootfs_path")
615 AS_AC_EXPAND(LXCTEMPLATEDIR, "$datadir/lxc/templates")
616 AS_AC_EXPAND(LXCTEMPLATECONFIG, "$datadir/lxc/config")
617 AS_AC_EXPAND(LXCHOOKDIR, "$datadir/lxc/hooks")
618 AS_AC_EXPAND(LXCBINHOOKDIR, "$libexecdir/lxc/hooks")
619 AS_AC_EXPAND(LXCINITDIR, "$libexecdir")
620 AS_AC_EXPAND(LOGPATH, "$with_log_path")
621 AS_AC_EXPAND(RUNTIME_PATH, "$with_runtime_path")
622 AC_SUBST(DEFAULT_CGROUP_PATTERN, ["$with_cgroup_pattern"])
623
624 # We need the install path so criu knows where to reference the hook scripts.
625 AC_DEFINE_UNQUOTED([DATADIR], "$DATADIR", ["Prefix for shared files."])
626
627 # Check for some standard kernel headers
628 AC_CHECK_HEADERS([linux/unistd.h linux/netlink.h linux/genetlink.h],
629 [],
630 AC_MSG_ERROR([Please install the Linux kernel headers.]),
631 [#include <sys/socket.h>])
632
633 # Check for alternate C libraries
634 AC_MSG_CHECKING(for bionic libc)
635 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
636 [[#ifndef __ANDROID__
637 error: Not bionic!
638 #endif]])],
639 [is_bionic=yes],
640 [is_bionic=no])
641 if test "x$is_bionic" = "xyes"; then
642 AC_DEFINE([IS_BIONIC], 1, [bionic libc])
643 AC_MSG_RESULT([yes])
644 else
645 AC_MSG_RESULT([no])
646 fi
647 AM_CONDITIONAL([IS_BIONIC], [test "x$is_bionic" = "xyes"])
648
649 # Some systems lack PR_CAPBSET_DROP definition => HAVE_DECL_PR_CAPBSET_DROP
650 AC_CHECK_DECLS([PR_CAPBSET_DROP], [], [], [#include <sys/prctl.h>])
651
652 # Some systems lack PR_{G,S}ET_NO_NEW_PRIVS definition => HAVE_DECL_PR_{G,S}ET_NO_NEW_PRIVS
653 AC_CHECK_DECLS([PR_SET_NO_NEW_PRIVS], [], [], [#include <sys/prctl.h>])
654 AC_CHECK_DECLS([PR_GET_NO_NEW_PRIVS], [], [], [#include <sys/prctl.h>])
655
656 # Check for some headers
657 AC_CHECK_HEADERS([sys/signalfd.h pty.h ifaddrs.h sys/memfd.h sys/personality.h utmpx.h sys/timerfd.h sys/resource.h])
658
659 # lookup major()/minor()/makedev()
660 AC_HEADER_MAJOR
661
662 # Check for some syscalls functions
663 AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r confstr faccessat gettid memfd_create])
664
665 # Check for some functions
666 AC_CHECK_LIB(pthread, main)
667 AC_CHECK_FUNCS(pthread_atfork)
668 AC_CHECK_FUNCS(statvfs)
669 AC_CHECK_LIB(util, openpty)
670 AC_CHECK_FUNCS([openpty hasmntopt setmntent endmntent utmpxname])
671 AC_CHECK_FUNCS([getline],
672 AM_CONDITIONAL(HAVE_GETLINE, true)
673 AC_DEFINE(HAVE_GETLINE,1,[Have getline]),
674 AM_CONDITIONAL(HAVE_GETLINE, false))
675 AC_CHECK_FUNCS([getsubopt],
676 AM_CONDITIONAL(HAVE_GETSUBOPT, true)
677 AC_DEFINE(HAVE_GETSUBOPT,1,[Have getsubopt]),
678 AM_CONDITIONAL(HAVE_GETSUBOPT, false))
679 AC_CHECK_FUNCS([fgetln],
680 AM_CONDITIONAL(HAVE_FGETLN, true)
681 AC_DEFINE(HAVE_FGETLN,1,[Have fgetln]),
682 AM_CONDITIONAL(HAVE_FGETLN, false))
683 AC_CHECK_FUNCS([prlimit],
684 AM_CONDITIONAL(HAVE_PRLIMIT, true)
685 AC_DEFINE(HAVE_PRLIMIT,1,[Have prlimit]),
686 AM_CONDITIONAL(HAVE_PRLIMIT, false))
687 AC_CHECK_FUNCS([prlimit64],
688 AM_CONDITIONAL(HAVE_PRLIMIT64, true)
689 AC_DEFINE(HAVE_PRLIMIT64,1,[Have prlimit64]),
690 AM_CONDITIONAL(HAVE_PRLIMIT64, false))
691
692 # Check for some libraries
693 AX_PTHREAD
694 AC_SEARCH_LIBS(clock_gettime, [rt])
695
696 # Check for some standard binaries
697 AC_PROG_GCC_TRADITIONAL
698 AC_PROG_SED
699
700 # See if we support thread-local storage.
701 LXC_CHECK_TLS
702
703 if test "x$GCC" = "xyes"; then
704 CFLAGS="$CFLAGS -Wall"
705 if test "x$enable_werror" = "xyes"; then
706 CFLAGS="$CFLAGS -Werror"
707 fi
708 fi
709
710 # Files requiring some variable expansion
711 AC_CONFIG_FILES([
712 Makefile
713 lxc.pc
714 lxc.spec
715
716 config/Makefile
717 config/apparmor/Makefile
718 config/selinux/Makefile
719 config/bash/Makefile
720 config/bash/lxc
721 config/init/Makefile
722 config/init/common/Makefile
723 config/init/common/lxc-containers
724 config/init/common/lxc-net
725 config/init/systemd/Makefile
726 config/init/systemd/lxc.service
727 config/init/systemd/lxc@.service
728 config/init/systemd/lxc-net.service
729 config/init/sysvinit/Makefile
730 config/init/sysvinit/lxc-containers
731 config/init/sysvinit/lxc-net
732 config/init/upstart/lxc.conf
733 config/init/upstart/lxc-net.conf
734 config/init/upstart/Makefile
735 config/etc/Makefile
736 config/templates/Makefile
737 config/templates/alpine.common.conf
738 config/templates/alpine.userns.conf
739 config/templates/archlinux.common.conf
740 config/templates/archlinux.userns.conf
741 config/templates/centos.common.conf
742 config/templates/centos.userns.conf
743 config/templates/common.conf
744 config/templates/common.conf.d/Makefile
745 config/templates/debian.common.conf
746 config/templates/debian.userns.conf
747 config/templates/fedora.common.conf
748 config/templates/fedora.userns.conf
749 config/templates/gentoo.common.conf
750 config/templates/gentoo.moresecure.conf
751 config/templates/gentoo.userns.conf
752 config/templates/nesting.conf
753 config/templates/oci.common.conf
754 config/templates/opensuse.common.conf
755 config/templates/opensuse.userns.conf
756 config/templates/oracle.common.conf
757 config/templates/oracle.userns.conf
758 config/templates/plamo.common.conf
759 config/templates/plamo.userns.conf
760 config/templates/slackware.common.conf
761 config/templates/slackware.userns.conf
762 config/templates/ubuntu-cloud.common.conf
763 config/templates/ubuntu-cloud.lucid.conf
764 config/templates/ubuntu-cloud.userns.conf
765 config/templates/ubuntu.common.conf
766 config/templates/ubuntu.lucid.conf
767 config/templates/ubuntu.userns.conf
768 config/templates/openwrt.common.conf
769 config/templates/sparclinux.common.conf
770 config/templates/sparclinux.userns.conf
771 config/templates/voidlinux.common.conf
772 config/templates/voidlinux.userns.conf
773 config/templates/sabayon.common.conf
774 config/templates/sabayon.userns.conf
775 config/templates/userns.conf
776 config/yum/Makefile
777 config/sysconfig/Makefile
778 config/sysconfig/lxc
779
780 doc/Makefile
781 doc/api/Makefile
782 doc/lxc-attach.sgml
783 doc/lxc-autostart.sgml
784 doc/lxc-cgroup.sgml
785 doc/lxc-checkconfig.sgml
786 doc/lxc-checkpoint.sgml
787 doc/lxc-clone.sgml
788 doc/lxc-config.sgml
789 doc/lxc-console.sgml
790 doc/lxc-copy.sgml
791 doc/lxc-create.sgml
792 doc/lxc-destroy.sgml
793 doc/lxc-device.sgml
794 doc/lxc-execute.sgml
795 doc/lxc-freeze.sgml
796 doc/lxc-info.sgml
797 doc/lxc-ls.sgml
798 doc/lxc-monitor.sgml
799 doc/lxc-snapshot.sgml
800 doc/lxc-start-ephemeral.sgml
801 doc/lxc-start.sgml
802 doc/lxc-stop.sgml
803 doc/lxc-top.sgml
804 doc/lxc-unfreeze.sgml
805 doc/lxc-unshare.sgml
806 doc/lxc-update-config.sgml
807 doc/lxc-user-nic.sgml
808 doc/lxc-usernsexec.sgml
809 doc/lxc-wait.sgml
810
811 doc/lxc.conf.sgml
812 doc/lxc.container.conf.sgml
813 doc/lxc.system.conf.sgml
814 doc/lxc-usernet.sgml
815 doc/lxc.sgml
816 doc/common_options.sgml
817 doc/see_also.sgml
818
819 doc/rootfs/Makefile
820
821 doc/examples/Makefile
822 doc/examples/lxc-macvlan.conf
823 doc/examples/lxc-vlan.conf
824 doc/examples/lxc-no-netns.conf
825 doc/examples/lxc-empty-netns.conf
826 doc/examples/lxc-phys.conf
827 doc/examples/lxc-veth.conf
828 doc/examples/lxc-complex.conf
829
830 doc/ja/Makefile
831 doc/ja/lxc-attach.sgml
832 doc/ja/lxc-autostart.sgml
833 doc/ja/lxc-cgroup.sgml
834 doc/ja/lxc-checkconfig.sgml
835 doc/ja/lxc-checkpoint.sgml
836 doc/ja/lxc-clone.sgml
837 doc/ja/lxc-config.sgml
838 doc/ja/lxc-console.sgml
839 doc/ja/lxc-copy.sgml
840 doc/ja/lxc-create.sgml
841 doc/ja/lxc-destroy.sgml
842 doc/ja/lxc-device.sgml
843 doc/ja/lxc-execute.sgml
844 doc/ja/lxc-freeze.sgml
845 doc/ja/lxc-info.sgml
846 doc/ja/lxc-ls.sgml
847 doc/ja/lxc-monitor.sgml
848 doc/ja/lxc-snapshot.sgml
849 doc/ja/lxc-start-ephemeral.sgml
850 doc/ja/lxc-start.sgml
851 doc/ja/lxc-stop.sgml
852 doc/ja/lxc-top.sgml
853 doc/ja/lxc-unfreeze.sgml
854 doc/ja/lxc-unshare.sgml
855 doc/ja/lxc-update-config.sgml
856 doc/ja/lxc-user-nic.sgml
857 doc/ja/lxc-usernsexec.sgml
858 doc/ja/lxc-wait.sgml
859
860 doc/ja/lxc.conf.sgml
861 doc/ja/lxc.container.conf.sgml
862 doc/ja/lxc.system.conf.sgml
863 doc/ja/lxc-usernet.sgml
864 doc/ja/lxc.sgml
865 doc/ja/common_options.sgml
866 doc/ja/see_also.sgml
867
868 doc/ko/Makefile
869 doc/ko/lxc-attach.sgml
870 doc/ko/lxc-autostart.sgml
871 doc/ko/lxc-cgroup.sgml
872 doc/ko/lxc-checkconfig.sgml
873 doc/ko/lxc-checkpoint.sgml
874 doc/ko/lxc-clone.sgml
875 doc/ko/lxc-config.sgml
876 doc/ko/lxc-console.sgml
877 doc/ko/lxc-copy.sgml
878 doc/ko/lxc-create.sgml
879 doc/ko/lxc-destroy.sgml
880 doc/ko/lxc-device.sgml
881 doc/ko/lxc-execute.sgml
882 doc/ko/lxc-freeze.sgml
883 doc/ko/lxc-info.sgml
884 doc/ko/lxc-ls.sgml
885 doc/ko/lxc-monitor.sgml
886 doc/ko/lxc-snapshot.sgml
887 doc/ko/lxc-start-ephemeral.sgml
888 doc/ko/lxc-start.sgml
889 doc/ko/lxc-stop.sgml
890 doc/ko/lxc-top.sgml
891 doc/ko/lxc-unfreeze.sgml
892 doc/ko/lxc-unshare.sgml
893 doc/ko/lxc-user-nic.sgml
894 doc/ko/lxc-usernsexec.sgml
895 doc/ko/lxc-wait.sgml
896
897 doc/ko/lxc.conf.sgml
898 doc/ko/lxc.container.conf.sgml
899 doc/ko/lxc.system.conf.sgml
900 doc/ko/lxc-usernet.sgml
901 doc/ko/lxc.sgml
902 doc/ko/common_options.sgml
903 doc/ko/see_also.sgml
904
905 hooks/Makefile
906 hooks/dhclient
907
908 templates/Makefile
909 templates/lxc-alpine
910 templates/lxc-altlinux
911 templates/lxc-archlinux
912 templates/lxc-busybox
913 templates/lxc-centos
914 templates/lxc-cirros
915 templates/lxc-debian
916 templates/lxc-download
917 templates/lxc-fedora
918 templates/lxc-fedora-legacy
919 templates/lxc-gentoo
920 templates/lxc-oci
921 templates/lxc-openmandriva
922 templates/lxc-opensuse
923 templates/lxc-oracle
924 templates/lxc-plamo
925 templates/lxc-pld
926 templates/lxc-slackware
927 templates/lxc-sshd
928 templates/lxc-ubuntu
929 templates/lxc-ubuntu-cloud
930 templates/lxc-sparclinux
931 templates/lxc-voidlinux
932 templates/lxc-sabayon
933
934 src/Makefile
935 src/lxc/Makefile
936 src/lxc/lxc.functions
937 src/lxc/tools/lxc-checkconfig
938 src/lxc/tools/lxc-start-ephemeral
939 src/lxc/tools/lxc-update-config
940 src/lxc/version.h
941 src/python-lxc/Makefile
942
943 src/lua-lxc/Makefile
944
945 src/tests/Makefile
946 src/tests/lxc-test-usernic
947 ])
948 AC_CONFIG_COMMANDS([default],[[]],[[]])
949 AC_OUTPUT
950
951 # Configuration overview
952 cat << EOF
953
954 ----------------------------
955 Environment:
956 - compiler: $CC
957 - distribution: $with_distro
958 - init script type(s): $init_script
959 - rpath: $enable_rpath
960 - GnuTLS: $enable_gnutls
961 - Bash integration: $enable_bash
962
963 Security features:
964 - Apparmor: $enable_apparmor
965 - Linux capabilities: $enable_capabilities
966 - seccomp: $enable_seccomp
967 - SELinux: $enable_selinux
968 - cgmanager: $enable_cgmanager
969
970 Bindings:
971 - lua: $enable_lua
972 - python3: $enable_python
973
974 Documentation:
975 - examples: $enable_examples
976 - API documentation: $enable_api_docs
977 - user documentation: $enable_doc
978
979 Debugging:
980 - tests: $enable_tests
981 - mutex debugging: $enable_mutex_debugging
982
983 Paths:
984 - Logs in configpath: $enable_configpath_log
985 EOF
986
987 if test "x$ac_cv_func_pthread_atfork" = "xno" ; then
988 cat << EOF
989
990 WARNING: Threading not supported on your platform
991
992 You are compiling LXC for bionic target which lacks certain threading related functionality used by LXC API (like pthread_atfork).
993 Please note that, because of the missing functionality, multithreaded usage of LXC API cause some problems.
994 EOF
995 fi