]> git.proxmox.com Git - mirror_lxc.git/blame - configure.ac
configure: fix function detection
[mirror_lxc.git] / configure.ac
CommitLineData
f756a350 1AC_PREREQ([2.69])
5e97c3fc 2
c40aa8c8 3m4_define([lxc_devel], 1)
a8565bb4
SG
4m4_define([lxc_version_major], 4)
5m4_define([lxc_version_minor], 0)
6m4_define([lxc_version_micro], 0)
5b66b6ee 7m4_define([lxc_version_beta], [])
26419a7a
SG
8
9m4_define([lxc_abi_major], 1)
a8565bb4 10m4_define([lxc_abi_minor], 7)
26419a7a
SG
11m4_define([lxc_abi_micro], 0)
12m4_define([lxc_abi], [lxc_abi_major.lxc_abi_minor.lxc_abi_micro])
9588a6ce
SH
13
14m4_define([lxc_version_base], [lxc_version_major.lxc_version_minor.lxc_version_micro])
15m4_define([lxc_version],
8465a7f4 16 [ifelse(lxc_devel, 1,
5f98011c
SG
17 ifelse(lxc_version_beta, [], [lxc_version_base], [lxc_version_base.lxc_version_beta])-devel,
18 ifelse(lxc_version_beta, [], [lxc_version_base], [lxc_version_base.lxc_version_beta]))])
9588a6ce 19
d12860c0 20AC_INIT([lxc],[lxc_version])
ddb93593
SG
21
22# We need pkg-config
23PKG_PROG_PKG_CONFIG
24
9588a6ce
SH
25AC_SUBST(LXC_VERSION_BASE, lxc_version_base)
26AC_SUBST(LXC_VERSION_BETA, lxc_version_beta)
5e97c3fc 27
a22185dd
ÇO
28AC_SUBST([LXC_VERSION_MAJOR], [lxc_version_major])
29AC_SUBST([LXC_VERSION_MINOR], [lxc_version_minor])
30AC_SUBST([LXC_VERSION_MICRO], [lxc_version_micro])
31AC_SUBST([LXC_VERSION], [lxc_version])
d2d6b991 32AC_SUBST([LXC_DEVEL], [lxc_devel])
a22185dd 33
26419a7a
SG
34AC_SUBST([LXC_ABI_MAJOR], [lxc_abi_major])
35AC_SUBST([LXC_ABI_MINOR], [lxc_abi_minor])
36AC_SUBST([LXC_ABI_MICRO], [lxc_abi_micro])
37AC_SUBST([LXC_ABI], [lxc_abi])
38
f8dafdbb 39AC_CONFIG_SRCDIR([configure.ac])
5e97c3fc 40AC_CONFIG_AUX_DIR([config])
067cfaeb 41AC_CONFIG_HEADERS([src/config.h])
d007f8ab 42AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability subdir-objects])
5e97c3fc 43AC_CANONICAL_HOST
5e97c3fc 44AM_PROG_CC_C_O
d12860c0 45AC_USE_SYSTEM_EXTENSIONS
1aaf81c3 46AC_SYS_LARGEFILE
5c8f9bd8 47
9b5724cd
CB
48# Test if we have a new enough compiler.
49AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
50#define GCC_VERSION \
51 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
52
53#define CLANG_VERSION \
54 (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
55
218e8144 56#if GCC_VERSION < 40700 && CLANG_VERSION < 10000
9b5724cd
CB
57#error Sorry, your compiler is too old - please upgrade it
58#endif
59 ]])], [valid_compiler=yes], [valid_compiler=no])
60if test "x$valid_compiler" = "xno"; then
61 AC_MSG_ERROR([Sorry, your compiler is too old - please upgrade it])
62fi
63
6d6bfd4f
CB
64AC_PROG_GCC_TRADITIONAL
65AC_ENABLE_SHARED
66AC_ENABLE_STATIC
67# Check binaries
68AC_PROG_SED
69case $CC in clang*)
70 AC_CHECK_TOOL([AR], llvm-ar)
71 AC_CHECK_TOOL([NM], llvm-nm)
72 AC_CHECK_TOOL([OBJCOPY], llvm-objcopy)
73 AC_CHECK_TOOL([RANLIB], llvm-ranlib)
74esac
75
26419a7a
SG
76# libtool
77LT_INIT
78AC_SUBST([LIBTOOL_DEPS])
79
8aa4885c
SG
80# Detect the distribution. This is used for the default configuration and
81# for some distro-specific build options.
6f75ba0b 82AC_MSG_CHECKING([host distribution])
b195038d 83AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: One of redhat, redhatenterpriseserver, oracle, centos, fedora, suse, gentoo, debian, arch, slackware, plamo, paldo, openmandriva, pardus, sparclinux, altlinux.]))
5a15791e 84if type lsb_release >/dev/null 2>&1 && test "z$with_distro" = "z"; then
6f75ba0b 85 with_distro=`lsb_release -is`
be2e4e54 86fi
6f75ba0b
DE
87if test "z$with_distro" = "z"; then
88 AC_CHECK_FILE(/etc/redhat-release,with_distro="redhat")
89 AC_CHECK_FILE(/etc/oracle-release,with_distro="oracle")
beabd0a2 90 AC_CHECK_FILE(/etc/sparclinux-release,with_distro="sparclinux")
164105f6 91 AC_CHECK_FILE(/etc/centos-release,with_distro="centos")
6f75ba0b
DE
92 AC_CHECK_FILE(/etc/fedora-release,with_distro="fedora")
93 AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
94 AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
95 AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
96 AC_CHECK_FILE(/etc/arch-release,with_distro="arch")
97 AC_CHECK_FILE(/etc/slackware-version,with_distro="slackware")
af2d9fad 98 AC_CHECK_FILE(/etc/plamo-version,with_distro="plamo")
6f75ba0b 99 AC_CHECK_FILE(/etc/frugalware-release,with_distro="frugalware")
6e7e54d9
AK
100 AC_CHECK_FILE(/etc/mandrakelinux-release, with_distro="openmandriva")
101 AC_CHECK_FILE(/etc/mandriva-release,with_distro="openmandriva")
6f75ba0b 102 AC_CHECK_FILE(/etc/pardus-release,with_distro="pardus")
5c60f990 103 AC_CHECK_FILE(/etc/altlinux-release,with_distro="altlinux")
487ea5f6 104 AC_CHECK_FILE(/etc/pld-release,with_distro="pld")
6f75ba0b
DE
105fi
106with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]'`
107
beabd0a2
WC
108if test "z$with_distro" = "zforsparc"; then
109 with_distro="sparclinux"
110fi
111
6f75ba0b
DE
112if test "z$with_distro" = "z"; then
113 with_distro="unknown"
114fi
115case $with_distro in
1c1bb85a 116 ubuntu|raspbian)
0af99319
MW
117 distroconf=default.conf.lxcbr
118 distrosysconf="$sysconfdir/default"
6f75ba0b 119 ;;
b195038d 120 redhat|redhatenterpriseserver|centos|fedora|oracle|oracleserver|sparclinux|altlinux|suse|opensuse*|plamo|pld)
0af99319
MW
121 distroconf=default.conf.lxcbr
122 distrosysconf="$sysconfdir/sysconfig"
6f75ba0b
DE
123 ;;
124 *)
3a647d58 125 distroconf=default.conf.unknown
0af99319 126 distrosysconf="$sysconfdir/default"
6f75ba0b
DE
127 ;;
128esac
129AC_MSG_RESULT([$with_distro])
1c1bb85a 130AM_CONDITIONAL([HAVE_DEBIAN], [test x"$with_distro" = "xdebian" -o x"$with_distro" = "xubuntu" -o x"$with_distro" = "xraspbian"])
025f59ab 131AM_CONDITIONAL([DISTRO_UBUNTU], [test "x$with_distro" = "xubuntu"])
be2e4e54 132
d79067a7
DM
133AC_CONFIG_LINKS([config/etc/default.conf:config/etc/${distroconf}])
134
420dfb59
DE
135# Check for init system type
136AC_MSG_CHECKING([for init system type])
137AC_ARG_WITH([init-script],
f756a350 138 [AS_HELP_STRING([--with-init-script@<:@=TYPE@<:@,TYPE,...@:>@@:>@],
dc068290 139 [Type(s) of init script to install: sysvinit, systemd, upstart,
89f79f6b 140 distro @<:@default=distro@:>@])],[],[with_init_script=distro])
420dfb59 141case "$with_init_script" in
420dfb59
DE
142 distro)
143 case $with_distro in
5c60f990 144 fedora|altlinux|opensuse*)
420dfb59
DE
145 init_script=systemd
146 ;;
b195038d 147 redhat|redhatenterpriseserver|oracle|oracleserver|sparclinux|plamo)
dc068290 148 init_script=sysvinit
420dfb59 149 ;;
234f9815 150 centos)
151 init_script=sysvinit,systemd
152 ;;
82b47911 153 debian|raspbian|ubuntu)
882ab607 154 init_script=upstart,systemd
420dfb59 155 ;;
487ea5f6
ER
156 pld)
157 init_script=sysvinit,upstart,systemd
158 ;;
420dfb59 159 *)
dc068290
SG
160 echo -n "Linux distribution init system unknown."
161 init_script=
420dfb59
DE
162 ;;
163 esac
164 ;;
165 *)
89f79f6b 166 init_script=$with_init_script
420dfb59
DE
167 ;;
168esac
89f79f6b
DE
169
170# Check valid init systems were given, run in subshell so we don't mess up IFS
171(IFS="," ; for init_sys in $init_script;
172do
173 case "$init_sys" in
dc068290 174 none|sysvinit|systemd|upstart)
89f79f6b
DE
175 ;;
176 *)
177 exit 1
178 ;;
179 esac
180done) || AC_MSG_ERROR([Unknown init system type in $init_script])
181
dc068290 182AM_CONDITIONAL([INIT_SCRIPT_SYSV], [echo "$init_script" |grep -q "sysvinit"])
89f79f6b
DE
183AM_CONDITIONAL([INIT_SCRIPT_SYSTEMD], [echo "$init_script" |grep -q "systemd"])
184AM_CONDITIONAL([INIT_SCRIPT_UPSTART], [echo "$init_script" |grep -q "upstart"])
420dfb59
DE
185AC_MSG_RESULT($init_script)
186
213b0fe0
MP
187# systemd unit dir
188AC_ARG_WITH([systemdsystemunitdir],
b2963bf9
CS
189 AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
190 [with_systemdsystemunitdir=$withval],
191 [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
213b0fe0
MP
192if test -z "$with_systemdsystemunitdir"; then
193 with_systemdsystemunitdir=/lib/systemd/system
194fi
195if test "x$with_systemdsystemunitdir" != "xno"; then
196 AC_SUBST([SYSTEMD_UNIT_DIR], [$with_systemdsystemunitdir])
197fi
198
e9f34eb4 199AC_ARG_ENABLE([werror],
b2963bf9
CS
200 [AS_HELP_STRING([--disable-werror], [do not treat warnings as errors])],
201 [enable_werror=$enableval], [enable_werror=yes])
e9f34eb4 202
792a48b1
EV
203AC_ARG_ENABLE([no_undefined],
204 [AS_HELP_STRING([--disable-no-undefined], [do not pass -Wl,--no-undefined])],
205 [enable_no_undefined=$enableval], [enable_no_undefined=yes])
206AM_CONDITIONAL([ENABLE_NO_UNDEFINED], [test "x$enable_no_undefined" = "xyes"])
207
8aa4885c 208# Allow disabling rpath
1c41ddcb 209AC_ARG_ENABLE([rpath],
f756a350 210 [AS_HELP_STRING([--enable-rpath], [set rpath in executables [default=no]])],
b2963bf9 211 [enable_rpath=$enableval], [enable_rpath=no])
1c41ddcb
GK
212AM_CONDITIONAL([ENABLE_RPATH], [test "x$enable_rpath" = "xyes"])
213
8aa4885c 214# Documentation (manpages)
5c8f9bd8 215AC_ARG_ENABLE([doc],
f756a350 216 [AS_HELP_STRING([--enable-doc], [make man pages [default=auto]])],
b2963bf9 217 [enable_doc=$enableval], [enable_doc=auto])
5c8f9bd8
AN
218
219if test "x$enable_doc" = "xyes" -o "x$enable_doc" = "xauto"; then
7822022c 220 db2xman=""
487ea5f6 221 dbparsers="docbook2X2man docbook2x-man db2x_docbook2man docbook2man docbook-to-man"
69fe23ff 222
7822022c 223 AC_MSG_CHECKING(for docbook2x-man)
69fe23ff 224 for name in ${dbparsers}; do
7822022c
SG
225 if "$name" --help >/dev/null 2>&1; then
226 db2xman="$name"
227 break;
228 fi
229 done
230
231 if test -n "${db2xman}"; then
8aa4885c 232 AC_MSG_RESULT([${db2xman}])
f91d5e4e 233 enable_doc="yes"
7822022c 234 else
8aa4885c 235 AC_MSG_RESULT([no])
7822022c 236 if test "x$enable_doc" = "xyes"; then
f91d5e4e 237 AC_MSG_ERROR([docbook2x-man is required, but could not be found])
7822022c 238 fi
f91d5e4e 239 enable_doc="no"
7822022c
SG
240 fi
241
242 AC_SUBST(db2xman)
5c8f9bd8 243fi
8aa4885c 244AM_CONDITIONAL([ENABLE_DOCBOOK], [test "x$db2xman" != "x"])
7cb14f34 245AM_CONDITIONAL([USE_DOCBOOK2X], [test "x$db2xman" != "xdocbook2man"])
5c8f9bd8 246
7f951458
DE
247if test "x$db2xman" = "xdocbook2man"; then
248 docdtd="\"-//Davenport//DTD DocBook V3.0//EN\""
249else
250 docdtd="\"-//OASIS//DTD DocBook XML\" \"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd\""
251fi
252AC_SUBST(docdtd)
253
953e611c
JH
254# Documentation (API)
255AC_ARG_ENABLE([api-docs],
b2963bf9
CS
256 [AS_HELP_STRING([--enable-api-docs], [make API documentation [default=auto]])],
257 [enable_api_docs=$enableval], [enable_api_docs=auto])
953e611c
JH
258
259if test "x$enable_api_docs" = "xyes" -o "x$enable_api_docs" = "xauto"; then
f91d5e4e
SG
260 AC_CHECK_PROGS([HAVE_DOXYGEN],[doxygen])
261 AC_SUBST([HAVE_DOXYGEN])
262
263 if test "x$HAVE_DOXYGEN" != "x"; then
264 enable_api_docs="yes"
265 else
266 if test "x$enable_api_docs" = "xyes"; then
267 AC_MSG_ERROR([doxygen is required, but could not be found])
268 fi
269 enable_api_docs="no"
270 fi
953e611c
JH
271fi
272
f91d5e4e 273AM_CONDITIONAL([ENABLE_API_DOCS], [test "x$HAVE_DOXYGEN" != "x"])
953e611c 274
fa2bb6ba
SH
275AC_CONFIG_MACRO_DIRS([config])
276
8aa4885c 277# Apparmor
e767dd55 278AC_ARG_ENABLE([apparmor],
f756a350 279 [AS_HELP_STRING([--enable-apparmor], [enable apparmor support [default=auto]])],
b2963bf9 280 [enable_apparmor=$enableval], [enable_apparmor=auto])
e767dd55 281
f91d5e4e 282if test "$enable_apparmor" = "auto" ; then
e767dd55
SH
283 AC_CHECK_LIB([apparmor],[aa_change_profile],[enable_apparmor=yes], [enable_apparmor=no])
284fi
e767dd55
SH
285AM_CONDITIONAL([ENABLE_APPARMOR], [test "x$enable_apparmor" = "xyes"])
286
fa2bb6ba
SH
287# OpenSSL
288# libssl-dev
289AC_ARG_ENABLE([openssl],
f756a350 290 [AS_HELP_STRING([--enable-openssl], [enable OpenSSL support [default=auto]])],
b2963bf9 291 [enable_openssl=$enableval], [enable_openssl=auto])
fa2bb6ba
SH
292
293if test "$enable_openssl" = "auto" ; then
294 AC_CHECK_LIB([ssl], [OPENSSL_init_ssl], [enable_openssl=yes], [enable_openssl=no])
c8601571 295
c8601571 296fi
fa2bb6ba 297AM_CONDITIONAL([ENABLE_OPENSSL], [test "x$enable_openssl" = "xyes"])
c8601571 298
014a65ef
CB
299AC_ARG_ENABLE([static-binaries],
300 [AS_HELP_STRING([--enable-static-binaries], [build all binaries statically [default=no]])],
301 [enable_static_binaries=$enableval], [enable_static_binaries=no])
302AM_CONDITIONAL([ENABLE_STATIC_BINARIES], [test "x$enable_static_binaries" = "xyes"])
303
fa2bb6ba
SH
304AM_COND_IF([ENABLE_OPENSSL],
305 [AC_CHECK_HEADER([openssl/engine.h],[],[AC_MSG_ERROR([You must install the OpenSSL development package in order to compile lxc])])
014a65ef 306 AM_COND_IF([ENABLE_STATIC_BINARIES], [AC_SUBST([OPENSSL_LIBS], '-lssl -lcrypto -ldl')], [AC_SUBST([OPENSSL_LIBS], '-lssl -lcrypto')])])
c8601571 307
fe4de9a6
DE
308# SELinux
309AC_ARG_ENABLE([selinux],
f756a350 310 [AS_HELP_STRING([--enable-selinux], [enable SELinux support [default=auto]])],
b2963bf9 311 [enable_selinux=$enableval], [enable_selinux=auto])
fe4de9a6 312
f91d5e4e 313if test "x$enable_selinux" = xauto; then
fe4de9a6
DE
314 AC_CHECK_LIB([selinux],[setexeccon_raw],[enable_selinux=yes],[enable_selinux=no])
315fi
316AM_CONDITIONAL([ENABLE_SELINUX], [test "x$enable_selinux" = "xyes"])
317AM_COND_IF([ENABLE_SELINUX],
318 [AC_CHECK_HEADER([selinux/selinux.h],[],[AC_MSG_ERROR([You must install the SELinux development package in order to compile lxc])])
e9aeeade
DE
319 AC_CHECK_LIB([selinux], [setexeccon_raw],[true],[AC_MSG_ERROR([You must install the SELinux development package in order to compile lxc])])
320 AC_SUBST([SELINUX_LIBS], [-lselinux])])
fe4de9a6 321
8aa4885c 322# Seccomp syscall filter
e767dd55 323AC_ARG_ENABLE([seccomp],
f756a350 324 [AS_HELP_STRING([--enable-seccomp], [enable seccomp support [default=auto]])],
b2963bf9 325 [enable_seccomp=$enableval], [enable_seccomp=auto])
e767dd55 326
f91d5e4e 327if test "x$enable_seccomp" = "xauto" ; then
e767dd55
SH
328 AC_CHECK_LIB([seccomp],[seccomp_init],[enable_seccomp=yes],[enable_seccomp=no])
329fi
e767dd55
SH
330AM_CONDITIONAL([ENABLE_SECCOMP], [test "x$enable_seccomp" = "xyes"])
331
8f2c3a70 332AM_COND_IF([ENABLE_SECCOMP],
12dcc892
JS
333 [PKG_CHECK_MODULES([SECCOMP],[libseccomp],[],[
334 AC_CHECK_HEADER([seccomp.h],[],[AC_MSG_ERROR([You must install the seccomp development package in order to compile lxc])])
335 AC_CHECK_LIB([seccomp], [seccomp_init],[],[AC_MSG_ERROR([You must install the seccomp development package in order to compile lxc])])
336 AC_SUBST([SECCOMP_LIBS], [-lseccomp])
337 ])
67cd8bde
EQ
338 # HAVE_SCMP_FILTER_CTX=1 will tell us we have libseccomp api >= 1.0.0
339 OLD_CFLAGS="$CFLAGS"
340 CFLAGS="$CFLAGS $SECCOMP_CFLAGS"
341 AC_CHECK_TYPES([scmp_filter_ctx], [], [], [[#include <seccomp.h>]])
342 AC_CHECK_DECLS([seccomp_notify_fd], [], [], [[#include <seccomp.h>]])
343 AC_CHECK_TYPES([struct seccomp_notif_sizes], [], [], [[#include <seccomp.h>]])
344 AC_CHECK_DECLS([seccomp_syscall_resolve_name_arch], [], [], [[#include <seccomp.h>]])
345 CFLAGS="$OLD_CFLAGS"
12dcc892 346 ])
8f2c3a70 347
c06ed219 348AC_MSG_CHECKING(for static libcap)
e78884c9
DE
349# Check for static libcap, make sure the function checked for differs from the
350# the one checked below so the cache doesn't give a wrong answer
351OLD_CFLAGS="$CFLAGS"
c06ed219
SH
352OLD_CPPFLAGS="$CPPFLAGS"
353OLD_LDFLAGS="$LDFLAGS"
354OLD_LIBS="$LIBS"
355CFLAGS=""
356CPPFLAGS=""
357LDFLAGS="-static"
358LIBS="-lcap"
359AC_LINK_IFELSE([
360 AC_LANG_SOURCE(
361 [[int main() { return 0; }]]
362 )],[have_static_libcap=yes],[have_static_libcap=no])
e78884c9
DE
363AM_CONDITIONAL([HAVE_STATIC_LIBCAP], [test "x$have_static_libcap" = "xyes"])
364if test "x$have_static_libcap" = "xyes"; then
365 AC_DEFINE([HAVE_STATIC_LIBCAP], 1, [Have static libcap])
c06ed219
SH
366 AC_MSG_RESULT([yes])
367else
368 AC_MSG_RESULT([no])
e78884c9 369fi
c06ed219 370CPPFLAGS="$OLD_CPPFLAGS"
e78884c9 371CFLAGS="$OLD_CFLAGS"
c06ed219
SH
372LDFLAGS="$OLD_LDFLAGS"
373LIBS="$OLD_LIBS"
e78884c9
DE
374
375
f91d5e4e
SG
376# Linux capabilities
377AC_ARG_ENABLE([capabilities],
f756a350 378 [AS_HELP_STRING([--enable-capabilities], [enable kernel capabilities support [default=auto]])],
b2963bf9 379 [enable_capabilities=$enableval], [enable_capabilities=auto])
f91d5e4e
SG
380
381if test "x$enable_capabilities" = "xauto"; then
382 AC_CHECK_LIB([cap],[cap_set_proc],[enable_capabilities=yes],[enable_capabilities=no])
383fi
384AM_CONDITIONAL([ENABLE_CAP], [test "x$enable_capabilities" = "xyes"])
385
386AM_COND_IF([ENABLE_CAP],
e37dda71
FF
387 [AC_CHECK_HEADER([sys/capability.h],[],[AC_MSG_ERROR([You must install the libcap development package in order to compile lxc])])
388 AC_CHECK_LIB(cap,cap_set_proc,[],[AC_MSG_ERROR([You must install the libcap development package in order to compile lxc])])
69924fff
CB
389 # Test whether we support getting file capabilities via cap_get_file().
390 AC_CHECK_LIB(cap,cap_get_file, AC_DEFINE(LIBCAP_SUPPORTS_FILE_CAPABILITIES,1,[Have cap_get_file]),[],[])
391 AC_SUBST([CAP_LIBS], [-lcap])])
f91d5e4e 392
8aa4885c 393# Configuration examples
3fb0a9bb 394AC_ARG_ENABLE([examples],
f756a350 395 [AS_HELP_STRING([--enable-examples], [install examples [default=yes]])],
b2963bf9 396 [enable_examples=$enableval], [enable_examples=yes])
3fb0a9bb
AN
397AM_CONDITIONAL([ENABLE_EXAMPLES], [test "x$enable_examples" = "xyes"])
398
052616eb
ÇO
399# Enable dumping stack traces
400AC_ARG_ENABLE([mutex-debugging],
f756a350 401 [AS_HELP_STRING([--enable-mutex-debugging], [Makes mutexes to report error and provide stack trace [default=no]])],
b2963bf9 402 [enable_mutex_debugging=$enableval], [enable_mutex_debugging=no])
052616eb
ÇO
403AM_CONDITIONAL([MUTEX_DEBUGGING], [test "x$enable_mutex_debugging" = "xyes"])
404
405AM_COND_IF([MUTEX_DEBUGGING],
406 AC_DEFINE_UNQUOTED([MUTEX_DEBUGGING], 1, [Enabling mutex debugging]))
407
3a1675bf
DE
408# Not in older autoconf versions
409# AS_VAR_COPY(DEST, SOURCE)
410# -------------------------
411# Set the polymorphic shell variable DEST to the contents of the polymorphic
412# shell variable SOURCE.
413m4_ifdef([AS_VAR_COPY], [],
414[AC_DEFUN([AS_VAR_COPY],
415 [AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
416])
417
12e93188
NC
418dnl PKG_CHECK_VAR was introduced with pkg-config 0.28
419m4_ifdef([PKG_CHECK_VAR], [],
420[AC_DEFUN([PKG_CHECK_VAR],
421 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
422 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
423 _PKG_CONFIG([$1], [variable="][$3]["], [$2])
424 AS_VAR_COPY([$1], [pkg_cv_][$1])
425 AS_VAR_IF([$1], [""], [$5], [$4])dnl
426 ])# PKG_CHECK_VAR
427])
f080ffd7 428
0306de4f
SG
429# Optional bash integration
430AC_ARG_ENABLE([bash],
f756a350 431 [AS_HELP_STRING([--enable-bash], [build bash integration [default=yes]])],
b2963bf9 432 [enable_bash=$enableval], [enable_bash=yes])
0306de4f
SG
433AM_CONDITIONAL([ENABLE_BASH], [test "x$enable_bash" = "xyes"])
434
23f4c8a0
EG
435AM_COND_IF([ENABLE_BASH],
436 [AC_MSG_CHECKING([bash completion directory])
437 PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir], ,
438 bashcompdir="${sysconfdir}/bash_completion.d")
439 AC_MSG_RESULT([$bashcompdir])
440 AC_SUBST(bashcompdir)
441 ])
442
8d060937
CB
443# Build the command line tools
444AC_ARG_ENABLE([tools],
f756a350 445 [AS_HELP_STRING([--enable-tools], [build the command line tools [default=yes]])],
b2963bf9 446 [enable_tools=$enableval], [enable_tools=yes])
8d060937
CB
447AM_CONDITIONAL([ENABLE_TOOLS], [test "x$enable_tools" = "xyes"])
448
449# Build the liblxc commands
450AC_ARG_ENABLE([commands],
f756a350 451 [AS_HELP_STRING([--enable-commands], [build the liblxc commands [default=yes]])],
b2963bf9 452 [enable_commands=$enableval], [enable_commands=yes])
8d060937
CB
453AM_CONDITIONAL([ENABLE_COMMANDS], [test "x$enable_commands" = "xyes"])
454
014a65ef
CB
455AC_ARG_ENABLE([static-binaries],
456 [AS_HELP_STRING([--enable-static-binaries], [build all binaries statically [default=no]])],
457 [enable_static_binaries=$enableval], [enable_static_binaries=no])
458AM_CONDITIONAL([ENABLE_STATIC_BINARIES], [test "x$enable_static_binaries" = "xyes"])
459
5f404236
CB
460AC_ARG_ENABLE([sanitizers],
461 [AS_HELP_STRING([--enable-sanitizers], [build with sanitizers enabled [default=no]])],
462 [enable_sanitizers=$enableval], [enable_sanitizers=no])
463AM_CONDITIONAL([ENABLE_SANITIZERS], [test "x$enable_sanitizers" = "xyes"])
464if test "x$enable_sanitizers" = "xyes"; then
465 AC_DEFINE([ENABLE_SANITIZERS], 1, [build with sanitizers enabled])
466
467 CC_CHECK_FLAGS_APPEND([AM_CFLAGS],[CFLAGS],[ \
468 -fsanitize=address \
469 -fsanitize=undefined \
cdfa8f13 470 -fno-optimize-sibling-calls \
5f404236
CB
471 -fno-omit-frame-pointer])
472 AC_SUBST(AM_CFLAGS)
473
474 AC_MSG_RESULT([yes])
475else
476 AC_MSG_RESULT([no])
477fi
384db5d7 478
8aa4885c 479# Optional test binaries
525421c9 480AC_ARG_ENABLE([tests],
f756a350 481 [AS_HELP_STRING([--enable-tests], [build test/example binaries [default=no]])],
b2963bf9 482 [enable_tests=$enableval], [enable_tests=no])
525421c9
SG
483AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = "xyes"])
484
061ba5d0
SG
485# Allow overriding the default runtime dir (/run)
486AC_ARG_WITH([runtime-path],
b2963bf9
CS
487 [AS_HELP_STRING([--with-runtime-path=dir], [runtime directory (default: /run)])],
488 [with_runtime_path=$withval], [with_runtime_path=['/run']])
061ba5d0 489
8aa4885c 490# LXC container path, where the containers are actually stored
fbf5de31 491# This is overridden by an entry in the file called LXCCONF
2a59a681 492# (i.e. /etc/lxc/lxc.conf)
aef4ebcf 493AC_ARG_WITH([config-path],
b2963bf9
CS
494 [AS_HELP_STRING([--with-config-path=dir], [lxc configuration repository path])],
495 [with_config_path=$withval], [with_config_path=['${localstatedir}/lib/lxc']])
aef4ebcf 496
2a59a681
SH
497# The path of the global lxc configuration file.
498AC_ARG_WITH([global-conf],
b2963bf9
CS
499 [AS_HELP_STRING([--with-global-conf=dir], [global lxc configuration file])],
500 [with_global_conf=$withval], [with_global_conf=['${sysconfdir}/lxc/lxc.conf']])
2a59a681 501
c75c30ec 502# The path of the userns network configuration file
070a4b8e 503AC_ARG_WITH([usernic-conf],
b2963bf9
CS
504 [AS_HELP_STRING([--with-usernic-conf], [user network interface configuration file])],
505 [with_usernic_conf=$withval], [with_usernic_conf=['${sysconfdir}/lxc/lxc-usernet']])
070a4b8e 506
c75c30ec 507# The path of the runtime usernic database
070a4b8e 508AC_ARG_WITH([usernic-db],
b2963bf9
CS
509 [AS_HELP_STRING([--with-usernic-db], [lxc user nic database])],
510 [with_usernic_db=$withval], [with_usernic_db=['${with_runtime_path}/lxc/nics']])
070a4b8e 511
8aa4885c 512# Rootfs path, where the container mount structure is assembled
196db713 513AC_ARG_WITH([rootfs-path],
b2963bf9
CS
514 [AS_HELP_STRING([--with-rootfs-path=dir], [lxc rootfs mount point])],
515 [with_rootfs_path=$withval], [with_rootfs_path=['${libdir}/lxc/rootfs']])
c75c30ec 516
6e16552d
CS
517# cgroup pattern specification
518AC_ARG_WITH([cgroup-pattern],
b2963bf9 519 [AS_HELP_STRING([--with-cgroup-pattern=pattern], [pattern for container cgroups])],
b3ed2061 520 [with_cgroup_pattern=$withval], [with_cgroup_pattern=['']])
196db713 521
1800f924
WB
522# The path for the apparmor_parser's cache for generated apparmor profiles
523AC_ARG_WITH([apparmor-cache-dir],
b2963bf9
CS
524 [AS_HELP_STRING([--with-apparmor-cache-dir=dir],[path for apparmor_parser cache])],
525 [with_apparmor_cache_dir=$withval], [with_apparmor_cache_dir=['${localstatedir}/cache/lxc/apparmor']])
1800f924 526
5e1e7aaf
SH
527# Container log path. By default, use $lxcpath.
528AC_MSG_CHECKING([Whether to place logfiles in container config path])
529AC_ARG_ENABLE([configpath-log],
f756a350 530 [AS_HELP_STRING([--enable-configpath-log], [use logfiles in config path [default=no]])],
b2963bf9 531 [enable_configpath_log=$enableval], [enable_configpath_log=no])
f91d5e4e
SG
532AC_MSG_RESULT([$enable_configpath_log])
533AM_CONDITIONAL([USE_CONFIGPATH_LOGS], [test "$enable_configpath_log" = "yes"])
5e1e7aaf 534
f91d5e4e 535if test "$enable_configpath_log" = "yes"; then
5e1e7aaf
SH
536 default_log_path="${with_config_path}"
537else
89d556d8 538 default_log_path="${localstatedir}/log/lxc"
5e1e7aaf
SH
539fi
540
541AC_ARG_WITH([log-path],
b2963bf9
CS
542 [AS_HELP_STRING([--with-log-path=dir],[per container log path])],
543 [with_log_path=$withval], [with_log_path=['${default_log_path}']])
5e1e7aaf 544
8aa4885c
SG
545# Expand some useful variables
546AS_AC_EXPAND(PREFIX, "$prefix")
547AS_AC_EXPAND(LIBDIR, "$libdir")
548AS_AC_EXPAND(BINDIR, "$bindir")
718e4f48 549AS_AC_EXPAND(SBINDIR, "$sbindir")
8aa4885c
SG
550AS_AC_EXPAND(LIBEXECDIR, "$libexecdir")
551AS_AC_EXPAND(INCLUDEDIR, "$includedir")
552AS_AC_EXPAND(SYSCONFDIR, "$sysconfdir")
0a18b545 553AS_AC_EXPAND(LXC_DEFAULT_CONFIG, "$sysconfdir/lxc/default.conf")
8aa4885c
SG
554AS_AC_EXPAND(DATADIR, "$datadir")
555AS_AC_EXPAND(LOCALSTATEDIR, "$localstatedir")
556AS_AC_EXPAND(DOCDIR, "$docdir")
8d256e4d 557AS_AC_EXPAND(LXC_GENERATE_DATE, "$(date --utc --date=@${SOURCE_DATE_EPOCH:-$(date +%s)} '+%Y-%m-%d')")
8aa4885c 558AS_AC_EXPAND(LXCPATH, "$with_config_path")
2a59a681 559AS_AC_EXPAND(LXC_GLOBAL_CONF, "$with_global_conf")
070a4b8e
SH
560AS_AC_EXPAND(LXC_USERNIC_CONF, "$with_usernic_conf")
561AS_AC_EXPAND(LXC_USERNIC_DB, "$with_usernic_db")
0af99319 562AS_AC_EXPAND(LXC_DISTRO_SYSCONF, "$distrosysconf")
8aa4885c
SG
563AS_AC_EXPAND(LXCROOTFSMOUNT, "$with_rootfs_path")
564AS_AC_EXPAND(LXCTEMPLATEDIR, "$datadir/lxc/templates")
f2a95ee1 565AS_AC_EXPAND(LXCTEMPLATECONFIG, "$datadir/lxc/config")
906f8c4d 566AS_AC_EXPAND(LXCHOOKDIR, "$datadir/lxc/hooks")
16d08ae7 567AS_AC_EXPAND(LXCBINHOOKDIR, "$libexecdir/lxc/hooks")
8aa4885c 568AS_AC_EXPAND(LXCINITDIR, "$libexecdir")
5e1e7aaf 569AS_AC_EXPAND(LOGPATH, "$with_log_path")
061ba5d0 570AS_AC_EXPAND(RUNTIME_PATH, "$with_runtime_path")
1800f924 571AS_AC_EXPAND(APPARMOR_CACHE_DIR, "$with_apparmor_cache_dir")
6e16552d 572AC_SUBST(DEFAULT_CGROUP_PATTERN, ["$with_cgroup_pattern"])
881450bb 573
0080bebf
TA
574# We need the install path so criu knows where to reference the hook scripts.
575AC_DEFINE_UNQUOTED([DATADIR], "$DATADIR", ["Prefix for shared files."])
576
8aa4885c 577# Check for some standard kernel headers
910bb4fa 578AC_CHECK_HEADERS([linux/unistd.h linux/netlink.h linux/genetlink.h],
8aa4885c
SG
579 [],
580 AC_MSG_ERROR([Please install the Linux kernel headers.]),
581 [#include <sys/socket.h>])
35f549fe 582
a6168a17
SG
583# Check for alternate C libraries
584AC_MSG_CHECKING(for bionic libc)
585AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
8aa4885c 586 [[#ifndef __ANDROID__
a6168a17
SG
587error: Not bionic!
588#endif]])],
8aa4885c
SG
589 [is_bionic=yes],
590 [is_bionic=no])
a6168a17 591if test "x$is_bionic" = "xyes"; then
8aa4885c
SG
592 AC_DEFINE([IS_BIONIC], 1, [bionic libc])
593 AC_MSG_RESULT([yes])
a6168a17 594else
8aa4885c 595 AC_MSG_RESULT([no])
a6168a17
SG
596fi
597AM_CONDITIONAL([IS_BIONIC], [test "x$is_bionic" = "xyes"])
598
f7a8609f
CB
599# Configuration examples
600AC_ARG_ENABLE([pam],
f756a350 601 [AS_HELP_STRING([--enable-pam], [enable pam module [default=no]])],
b2963bf9 602 [enable_pam=$enableval], [enable_pam=no])
f7a8609f
CB
603AM_CONDITIONAL([ENABLE_PAM], [test "x$enable_pam" = "xyes"])
604
605AM_COND_IF([ENABLE_PAM],
606 [AC_ARG_WITH(
607 [pamdir],
608 [AS_HELP_STRING([--with-pamdir=PATH],[Specify the directory where PAM modules are stored,
609 or "none" if PAM modules are not to be built])],
b2963bf9 610 [pamdir=$withval],
f7a8609f
CB
611 [
612 if test "${prefix}" = "/usr"; then
613 pamdir="/lib${libdir##*/lib}/security"
614 else
615 pamdir="\$(libdir)/security"
616 fi
617 ]
618 )])
7ac43d3d
CB
619
620AM_CONDITIONAL([HAVE_PAM], [test x"$pamdir" != "xnone"])
f7a8609f
CB
621AM_COND_IF([ENABLE_PAM],
622 [if test "z$pamdir" != "znone"; then
623 AC_ARG_VAR([PAM_CFLAGS], [C compiler flags for pam])
624 AC_ARG_VAR([PAM_LIBS], [linker flags for pam])
625 AC_CHECK_LIB(
626 [pam],
627 [pam_authenticate],
628 [PAM_LIBS="-lpam"],
629 [AC_MSG_ERROR([*** libpam not found.])
630 ])
631
632 AC_SUBST(PAM_LIBS)
633 AC_SUBST([pamdir])
634 fi])
7ac43d3d 635
656994bb
MH
636# Some systems lack PR_CAPBSET_DROP definition => HAVE_DECL_PR_CAPBSET_DROP
637AC_CHECK_DECLS([PR_CAPBSET_DROP], [], [], [#include <sys/prctl.h>])
638
955e2a02
CB
639# Some systems lack PR_{G,S}ET_NO_NEW_PRIVS definition => HAVE_DECL_PR_{G,S}ET_NO_NEW_PRIVS
640AC_CHECK_DECLS([PR_SET_NO_NEW_PRIVS], [], [], [#include <sys/prctl.h>])
641AC_CHECK_DECLS([PR_GET_NO_NEW_PRIVS], [], [], [#include <sys/prctl.h>])
642
e827ff7e 643# Check for some headers
44843972 644AC_CHECK_HEADERS([pty.h sys/memfd.h sys/personality.h sys/resource.h sys/signalfd.h sys/timerfd.h utmpx.h])
d029e1de
CB
645
646AC_CHECK_HEADER([ifaddrs.h],
647 AM_CONDITIONAL(HAVE_IFADDRS_H, true)
648 AC_DEFINE(HAVE_IFADDRS_H, 1, [Have ifaddrs.h]),
649 AM_CONDITIONAL(HAVE_IFADDRS_H, false))
ff218c25 650
af6824fc
ST
651# lookup major()/minor()/makedev()
652AC_HEADER_MAJOR
653
2d76d1d7 654# Check for some syscalls functions
305b3b9c 655AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r confstr faccessat gettid memfd_create move_mount open_tree execveat clone3 fsopen fspick fsconfig fsmount openat2 close_range statvfs mount_setattr])
b1abf15d 656AC_CHECK_TYPES([__aligned_u64], [], [], [[#include <linux/types.h>]])
031e0285 657AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]])
2b0c8106 658AC_CHECK_TYPES([struct open_how], [], [], [[#include <linux/openat2.h>]])
96086a6b
CB
659AC_CHECK_TYPES([struct clone_args], [], [], [[#include <linux/sched.h>]])
660AC_CHECK_MEMBERS([struct clone_args.set_tid],[],[],[[#include <linux/sched.h>]])
661AC_CHECK_MEMBERS([struct clone_args.cgroup],[],[],[[#include <linux/sched.h>]])
2d76d1d7 662
607e3fca
CB
663# Check for strerror_r() support. Defines:
664# - HAVE_STRERROR_R if available
665# - HAVE_DECL_STRERROR_R if defined
666# - STRERROR_R_CHAR_P if it returns char *
667AC_FUNC_STRERROR_R
668
720bbb31
RK
669# Check if "%m" is supported by printf and Co
670AC_MSG_CHECKING([%m format])
d12860c0 671AC_RUN_IFELSE([AC_LANG_SOURCE([[
720bbb31
RK
672#include <stdio.h>
673int main(void)
674{
675 char msg[256];
676 int rc;
677
678 rc = snprintf(msg, sizeof(msg), "%m\n");
679 if ((rc > 1) && (msg[0] != '%'))
680 {
681 return 0;
682 }
683 else
684 {
685 return 1;
686 }
d12860c0 687}]])],[fmt_m=yes],[fmt_m=no],[fmt_m=no])
720bbb31
RK
688if test "x$fmt_m" = "xyes"; then
689 AC_DEFINE([HAVE_M_FORMAT], 1, [Have %m format])
690 AC_MSG_RESULT([yes])
691else
692 AC_MSG_RESULT([no])
693fi
694
e827ff7e 695# Check for some functions
babbea4b 696AC_CHECK_LIB(pthread, main)
740ee8c7 697AC_CHECK_LIB(util, openpty)
35eb5cdc 698AC_CHECK_FUNCS([hasmntopt setmntent endmntent utmpxname])
477e62b6
CB
699AC_CHECK_FUNCS([getgrgid_r],
700 AM_CONDITIONAL(HAVE_GETGRGID_R, true)
701 AC_DEFINE(HAVE_GETGRGID_R,1,[Have getgrgid_r]),
702 AM_CONDITIONAL(HAVE_GETGRGID_R, false))
1ba0013f
SG
703AC_CHECK_FUNCS([getline],
704 AM_CONDITIONAL(HAVE_GETLINE, true)
705 AC_DEFINE(HAVE_GETLINE,1,[Have getline]),
706 AM_CONDITIONAL(HAVE_GETLINE, false))
9dbcd668
SG
707AC_CHECK_FUNCS([getsubopt],
708 AM_CONDITIONAL(HAVE_GETSUBOPT, true)
709 AC_DEFINE(HAVE_GETSUBOPT,1,[Have getsubopt]),
710 AM_CONDITIONAL(HAVE_GETSUBOPT, false))
1ba0013f
SG
711AC_CHECK_FUNCS([fgetln],
712 AM_CONDITIONAL(HAVE_FGETLN, true)
713 AC_DEFINE(HAVE_FGETLN,1,[Have fgetln]),
714 AM_CONDITIONAL(HAVE_FGETLN, false))
b25291da
CB
715AC_CHECK_FUNCS([keyctl],
716 AM_CONDITIONAL(HAVE_KEYCTL, true)
717 AC_DEFINE(HAVE_KEYCTL,1,[Have keyctl]),
718 AM_CONDITIONAL(HAVE_KEYCTL, false))
35eb5cdc
CB
719AC_CHECK_FUNCS([openpty],
720 AM_CONDITIONAL(HAVE_OPENPTY, true)
721 AC_DEFINE(HAVE_OPENPTY,1,[Have openpty]),
722 AM_CONDITIONAL(HAVE_OPENPTY, false))
a04f5407
CB
723AC_CHECK_FUNCS([prlimit],
724 AM_CONDITIONAL(HAVE_PRLIMIT, true)
725 AC_DEFINE(HAVE_PRLIMIT,1,[Have prlimit]),
726 AM_CONDITIONAL(HAVE_PRLIMIT, false))
f48b5fd8
FF
727AC_CHECK_FUNCS([prlimit64],
728 AM_CONDITIONAL(HAVE_PRLIMIT64, true)
729 AC_DEFINE(HAVE_PRLIMIT64,1,[Have prlimit64]),
730 AM_CONDITIONAL(HAVE_PRLIMIT64, false))
477e62b6
CB
731AC_CHECK_FUNCS([pthread_setcancelstate],
732 AM_CONDITIONAL(HAVE_PTHREAD_SETCANCELSTATE, true)
733 AC_DEFINE(HAVE_PTHREAD_SETCANCELSTATE,1,[Have pthread_setcancelstate]),
734 AM_CONDITIONAL(HAVE_PTHREAD_SETCANCELSTATE, false))
91c272a5
CB
735AC_CHECK_FUNCS([strlcpy],
736 AM_CONDITIONAL(HAVE_STRLCPY, true)
737 AC_DEFINE(HAVE_STRLCPY,1,[Have strlcpy]),
738 AM_CONDITIONAL(HAVE_STRLCPY, false))
9a5e7ac4
CB
739AC_CHECK_FUNCS([strlcat],
740 AM_CONDITIONAL(HAVE_STRLCAT, true)
741 AC_DEFINE(HAVE_STRLCAT,1,[Have strlcat]),
742 AM_CONDITIONAL(HAVE_STRLCAT, false))
7e4ea7bf
CB
743AC_CHECK_FUNCS([strchrnul],
744 AM_CONDITIONAL(HAVE_STRCHRNUL, true)
745 AC_DEFINE(HAVE_STRCHRNUL,1,[Have strchnul]),
746 AM_CONDITIONAL(HAVE_STRCHRNUL, false))
7fa90630
CB
747AC_CHECK_FUNCS([fmemopen],
748 AM_CONDITIONAL(HAVE_FMEMOPEN, true)
749 AC_DEFINE(HAVE_FMEMOPEN,1,[Have fmemopen]),
750 AM_CONDITIONAL(HAVE_FMEMOPEN, false))
1ba0013f 751
da5efb6f
CB
752# HAVE_STRUCT_RTNL_LINK_STATS64={0,1}
753AC_CHECK_TYPES([struct rtnl_link_stats64], [], [], [[#include <linux/if_link.h>]])
754
c9a84173 755# Check for some libraries
a81c46e9 756AX_PTHREAD
336d5469 757AC_SEARCH_LIBS(clock_gettime, [rt])
c9a84173 758
babbea4b
ÇO
759# See if we support thread-local storage.
760LXC_CHECK_TLS
761
fb3b3ef4 762# Hardening flags
b59bc011
CB
763CC_CHECK_FLAGS_APPEND([AM_CFLAGS],[CFLAGS],[ \
764 -fPIE \
765 -Wvla \
766 -std=gnu11 \
767 -fms-extensions \
768 -fdiagnostics-color \
769 -Wimplicit-fallthrough=5 \
770 -Wcast-align \
771 -Wstrict-prototypes \
772 -fno-strict-aliasing \
773 -fstack-clash-protection \
774 -fstack-protector-strong \
775 --param=ssp-buffer-size=4 \
776 -g \
777 --mcet -fcf-protection \
778 -Werror=implicit-function-declaration \
779 -Wlogical-op \
780 -Wmissing-include-dirs \
781 -Wold-style-definition \
782 -Winit-self \
783 -Wunused-but-set-variable \
784 -Wfloat-equal \
785 -Wsuggest-attribute=noreturn \
786 -Werror=return-type \
787 -Werror=incompatible-pointer-types \
788 -Wformat=2 \
789 -Wshadow \
790 -Wendif-labels \
791 -Werror=overflow \
792 -fdiagnostics-show-option \
793 -Werror=shift-count-overflow \
794 -Werror=shift-overflow=2 \
795 -Wdate-time \
796 -Wnested-externs \
797 -fasynchronous-unwind-tables \
798 -pipe \
799 -fexceptions \
800 -Warray-bounds \
801 -Wrestrict \
802 -Wreturn-local-addr \
803 -flto=thin \
804 -fsanitize=cfi \
805 -Wstringop-overflow])
806AC_SUBST(AM_CFLAGS)
807
808CC_CHECK_FLAGS_APPEND([AM_LDFLAGS],[LDFLAGS],[ \
809 -Wl,--as-needed \
b59bc011
CB
810 -Wl,--gc-sections \
811 -Wl,-z,relro \
812 -Wl,-z,now \
813 -pie \
814 -Wl,-fuse-ld=gold])
792a48b1
EV
815
816AM_COND_IF([ENABLE_NO_UNDEFINED],
817 [CC_CHECK_FLAGS_APPEND([AM_LDFLAGS],[LDFLAGS],[-Wl,--no-undefined])])
818
b59bc011 819AC_SUBST(AM_LDFLAGS)
e6fe24e1 820
96086a6b 821CFLAGS="$CFLAGS -Wvla -std=gnu11 -fms-extensions"
81a56e80 822if test "x$enable_werror" = "xyes"; then
218e8144 823 CFLAGS="$CFLAGS -Werror"
5e97c3fc 824fi
825
81c76cff 826AC_ARG_ENABLE([thread-safety],
f756a350 827 [AS_HELP_STRING([--enable-thread-safety], [enforce thread-safety otherwise fail the build [default=yes]])],
b2963bf9 828 [enable_thread_safety=$enableval], [enable_thread_safety=yes])
81c76cff 829AM_CONDITIONAL([ENFORCE_THREAD_SAFETY], [test "x$enable_thread_safety" = "xyes"])
538337ee
CB
830if test "x$enable_thread_safety" = "xyes"; then
831 AC_DEFINE([ENFORCE_THREAD_SAFETY], 1, [enforce thread-safety otherwise fail the build])
832 AC_MSG_RESULT([yes])
833else
834 AC_MSG_RESULT([no])
835fi
81c76cff 836
64a2547c 837AC_ARG_ENABLE([coverity-build],
538337ee
CB
838 [AS_HELP_STRING([--enable-coverity-build], [build for use with Coverity [default=no]])],
839 [enable_coverity_build=$enableval], [enable_coverity_build=no])
64a2547c 840AM_CONDITIONAL([ENABLE_COVERITY_BUILD], [test "x$enable_coverity_build" = "xyes"])
538337ee
CB
841if test "x$enable_coverity_build" = "xyes"; then
842 AC_DEFINE([ENABLE_COVERITY_BUILD], 1, [build for use with Coverity])
843 AC_MSG_RESULT([yes])
844else
845 AC_MSG_RESULT([no])
846fi
64a2547c 847
5c7bfc02 848AC_ARG_ENABLE([dlog],
f756a350 849 [AS_HELP_STRING([--enable-dlog], [enable dlog support [default=no]])],
b2963bf9 850 [enable_dlog=$enableval], [enable_dlog=no])
5c7bfc02 851AM_CONDITIONAL([ENABLE_DLOG], [test "x$enable_dlog" = "xyes"])
852
853AM_COND_IF([ENABLE_DLOG],
854 [PKG_CHECK_MODULES([DLOG],[dlog],[],[
855 AC_CHECK_HEADER([dlog.h],[],[AC_MSG_ERROR([You must install the dlog development package in order to compile lxc])])
856 AC_CHECK_LIB([dlog], [dlog_print],[],[AC_MSG_ERROR([You must install the dlog development package in order to compile lxc])])
857 AC_SUBST([DLOG_LIBS], [-ldlog])
858 ])
859 ])
860
6400238d 861AC_ARG_ENABLE([memfd-rexec],
f756a350 862 [AS_HELP_STRING([--enable-memfd-rexec], [enforce liblxc as a memfd to protect against certain symlink attacks [default=yes]])],
b2963bf9 863 [enable_memfd_rexec=$enableval], [enable_memfd_rexec=yes])
6400238d
CB
864AM_CONDITIONAL([ENFORCE_MEMFD_REXEC], [test "x$enable_memfd_rexec" = "xyes"])
865if test "x$enable_memfd_rexec" = "xyes"; then
866 AC_DEFINE([ENFORCE_MEMFD_REXEC], 1, [Rexec liblxc as memfd])
867 AC_MSG_RESULT([yes])
868else
869 AC_MSG_RESULT([no])
870fi
871
8aa4885c 872# Files requiring some variable expansion
5e97c3fc 873AC_CONFIG_FILES([
288063bd 874 Makefile
b6345ba1 875 lxc.pc
5e97c3fc 876 lxc.spec
f2a95ee1 877
fef909cf
CB
878 coccinelle/Makefile
879
288063bd 880 config/Makefile
8da250da 881 config/apparmor/Makefile
b19c5d12 882 config/apparmor/abstractions/start-container
719fae07 883 config/selinux/Makefile
0306de4f
SG
884 config/bash/Makefile
885 config/bash/lxc
dc068290 886 config/init/Makefile
0af99319
MW
887 config/init/common/Makefile
888 config/init/common/lxc-containers
889 config/init/common/lxc-net
dc068290 890 config/init/systemd/Makefile
015f0dd7 891 config/init/systemd/lxc.service
de2b7e65 892 config/init/systemd/lxc@.service
65b27d84 893 config/init/systemd/lxc-net.service
b6278254 894 config/init/systemd/lxc-monitord.service
0af99319
MW
895 config/init/sysvinit/Makefile
896 config/init/sysvinit/lxc-containers
897 config/init/sysvinit/lxc-net
a8c71063 898 config/init/upstart/lxc.conf
0af99319 899 config/init/upstart/lxc-net.conf
dc068290 900 config/init/upstart/Makefile
f2a95ee1
SG
901 config/etc/Makefile
902 config/templates/Makefile
5b99af00 903 config/templates/common.conf
4662c6de 904 config/templates/common.conf.d/Makefile
108b88ce 905 config/templates/nesting.conf
1689c7cf 906 config/templates/oci.common.conf
5b99af00 907 config/templates/userns.conf
7ceebfd1 908 config/yum/Makefile
0af99319
MW
909 config/sysconfig/Makefile
910 config/sysconfig/lxc
d823d5b9 911
288063bd 912 doc/Makefile
953e611c 913 doc/api/Makefile
4019712d 914 doc/lxc-attach.sgml
a6adab20 915 doc/lxc-autostart.sgml
4019712d
SG
916 doc/lxc-cgroup.sgml
917 doc/lxc-checkconfig.sgml
735f2c6e 918 doc/lxc-checkpoint.sgml
ff5e2751 919 doc/lxc-config.sgml
4019712d 920 doc/lxc-console.sgml
2b47bac3 921 doc/lxc-copy.sgml
d823d5b9 922 doc/lxc-create.sgml
923 doc/lxc-destroy.sgml
4019712d 924 doc/lxc-device.sgml
d823d5b9 925 doc/lxc-execute.sgml
d823d5b9 926 doc/lxc-freeze.sgml
4019712d 927 doc/lxc-info.sgml
d823d5b9 928 doc/lxc-ls.sgml
4019712d 929 doc/lxc-monitor.sgml
813a4837 930 doc/lxc-snapshot.sgml
4019712d
SG
931 doc/lxc-start.sgml
932 doc/lxc-stop.sgml
f080ffd7 933 doc/lxc-top.sgml
4019712d
SG
934 doc/lxc-unfreeze.sgml
935 doc/lxc-unshare.sgml
0a29a3ef 936 doc/lxc-update-config.sgml
df3415e0 937 doc/lxc-user-nic.sgml
adade80c 938 doc/lxc-usernsexec.sgml
4019712d
SG
939 doc/lxc-wait.sgml
940
a98ad25d
VHRA
941 doc/pam_cgfs.sgml
942
8a67a2b2 943 doc/lxc.conf.sgml
55fc19a1
SG
944 doc/lxc.container.conf.sgml
945 doc/lxc.system.conf.sgml
df3415e0 946 doc/lxc-usernet.sgml
8b8b04f8 947 doc/lxc.sgml
10fba81b 948 doc/common_options.sgml
99e4008c 949 doc/see_also.sgml
d823d5b9 950
baf6671f
DL
951 doc/rootfs/Makefile
952
0f71d073
DL
953 doc/examples/Makefile
954 doc/examples/lxc-macvlan.conf
26c39028 955 doc/examples/lxc-vlan.conf
0f71d073
DL
956 doc/examples/lxc-no-netns.conf
957 doc/examples/lxc-empty-netns.conf
958 doc/examples/lxc-phys.conf
959 doc/examples/lxc-veth.conf
c553a9c2 960 doc/examples/lxc-complex.conf
0f71d073 961
57da8c32 962 doc/ja/Makefile
57da8c32 963 doc/ja/lxc-attach.sgml
28f2ab26 964 doc/ja/lxc-autostart.sgml
57da8c32
KY
965 doc/ja/lxc-cgroup.sgml
966 doc/ja/lxc-checkconfig.sgml
b0e26ca7 967 doc/ja/lxc-checkpoint.sgml
3220eceb 968 doc/ja/lxc-config.sgml
57da8c32 969 doc/ja/lxc-console.sgml
842948e4 970 doc/ja/lxc-copy.sgml
57da8c32
KY
971 doc/ja/lxc-create.sgml
972 doc/ja/lxc-destroy.sgml
973 doc/ja/lxc-device.sgml
974 doc/ja/lxc-execute.sgml
975 doc/ja/lxc-freeze.sgml
976 doc/ja/lxc-info.sgml
57da8c32
KY
977 doc/ja/lxc-ls.sgml
978 doc/ja/lxc-monitor.sgml
ebe0aeb1 979 doc/ja/lxc-snapshot.sgml
57da8c32
KY
980 doc/ja/lxc-start.sgml
981 doc/ja/lxc-stop.sgml
982 doc/ja/lxc-top.sgml
983 doc/ja/lxc-unfreeze.sgml
984 doc/ja/lxc-unshare.sgml
607a8de5 985 doc/ja/lxc-update-config.sgml
07ece600 986 doc/ja/lxc-user-nic.sgml
755d8d03 987 doc/ja/lxc-usernsexec.sgml
57da8c32
KY
988 doc/ja/lxc-wait.sgml
989
6da6d73e
KY
990 doc/ja/pam_cgfs.sgml
991
57da8c32 992 doc/ja/lxc.conf.sgml
fb261f53
KY
993 doc/ja/lxc.container.conf.sgml
994 doc/ja/lxc.system.conf.sgml
07ece600 995 doc/ja/lxc-usernet.sgml
57da8c32
KY
996 doc/ja/lxc.sgml
997 doc/ja/common_options.sgml
998 doc/ja/see_also.sgml
999
2b371b26 1000 doc/ko/Makefile
2b371b26
SY
1001 doc/ko/lxc-attach.sgml
1002 doc/ko/lxc-autostart.sgml
1003 doc/ko/lxc-cgroup.sgml
1004 doc/ko/lxc-checkconfig.sgml
1005 doc/ko/lxc-checkpoint.sgml
2b371b26
SY
1006 doc/ko/lxc-config.sgml
1007 doc/ko/lxc-console.sgml
b035f792 1008 doc/ko/lxc-copy.sgml
2b371b26
SY
1009 doc/ko/lxc-create.sgml
1010 doc/ko/lxc-destroy.sgml
1011 doc/ko/lxc-device.sgml
1012 doc/ko/lxc-execute.sgml
1013 doc/ko/lxc-freeze.sgml
1014 doc/ko/lxc-info.sgml
1015 doc/ko/lxc-ls.sgml
1016 doc/ko/lxc-monitor.sgml
1017 doc/ko/lxc-snapshot.sgml
2b371b26
SY
1018 doc/ko/lxc-start.sgml
1019 doc/ko/lxc-stop.sgml
1020 doc/ko/lxc-top.sgml
1021 doc/ko/lxc-unfreeze.sgml
1022 doc/ko/lxc-unshare.sgml
1023 doc/ko/lxc-user-nic.sgml
1024 doc/ko/lxc-usernsexec.sgml
1025 doc/ko/lxc-wait.sgml
1026
1027 doc/ko/lxc.conf.sgml
1028 doc/ko/lxc.container.conf.sgml
1029 doc/ko/lxc.system.conf.sgml
1030 doc/ko/lxc-usernet.sgml
1031 doc/ko/lxc.sgml
1032 doc/ko/common_options.sgml
1033 doc/ko/see_also.sgml
1034
906f8c4d 1035 hooks/Makefile
84bf5645 1036 hooks/dhclient
906f8c4d 1037
c01d62f2 1038 templates/Makefile
f8d0243a 1039 templates/lxc-busybox
71d3a659 1040 templates/lxc-download
35444f38 1041 templates/lxc-local
0ef43a5c 1042 templates/lxc-oci
c9844b87 1043
288063bd 1044 src/Makefile
5e97c3fc 1045 src/lxc/Makefile
2a59a681 1046 src/lxc/lxc.functions
48b1dc4c 1047 src/lxc/cmd/lxc-checkconfig
6a342cab 1048 src/lxc/cmd/lxc-update-config
a22185dd 1049 src/lxc/version.h
be2e4e54 1050
72d0e1cb 1051 src/tests/Makefile
8cb8e496 1052 src/tests/lxc-test-usernic
5e97c3fc 1053])
1054AC_CONFIG_COMMANDS([default],[[]],[[]])
1055AC_OUTPUT
f91d5e4e
SG
1056
1057# Configuration overview
1058cat << EOF
1059
1060----------------------------
8d060937
CB
1061Binaries
1062 - Command Line Tools:
1063 - lxc-attach: $enable_tools
1064 - lxc-autostart: $enable_tools
1065 - lxc-cgroup: $enable_tools
1066 - lxc-checkpoint: $enable_tools
1067 - lxc-config: $enable_tools
1068 - lxc-console: $enable_tools
1069 - lxc-copy: $enable_tools
1070 - lxc-create: $enable_tools
1071 - lxc-destroy: $enable_tools
1072 - lxc-device: $enable_tools
1073 - lxc-execute: $enable_tools
1074 - lxc-freeze: $enable_tools
1075 - lxc-info: $enable_tools
1076 - lxc-ls: $enable_tools
1077 - lxc-monitor: $enable_tools
1078 - lxc-snapshot: $enable_tools
1079 - lxc-start: $enable_tools
1080 - lxc-stop: $enable_tools
1081 - lxc-top: $enable_tools
1082 - lxc-unfreeze: $enable_tools
1083 - lxc-unshare: $enable_tools
1084 - lxc-wait: $enable_tools
1085
1086 - liblxc Commands:
1087 - lxc-checkconfig: $enable_commands
1088 - lxc-update-config: $enable_commands
1089 - lxc-init: $enable_commands
1090 - lxc-monitord: $enable_commands
1091 - lxc-user-nic: $enable_commands
1092 - lxc-usernsexec: $enable_commands
1093
014a65ef
CB
1094 - static binaries: $enable_static_binaries
1095
f91d5e4e
SG
1096Environment:
1097 - compiler: $CC
b59bc011
CB
1098 - cflags: ${AM_CFLAGS} ${PTHREAD_CFLAGS}
1099 - ldflags: ${AM_LDFLAGS} ${PTHREAD_LIBS}
f91d5e4e 1100 - distribution: $with_distro
89f79f6b 1101 - init script type(s): $init_script
f91d5e4e 1102 - rpath: $enable_rpath
fa2bb6ba 1103 - OpenSSL: $enable_openssl
0306de4f 1104 - Bash integration: $enable_bash
f91d5e4e
SG
1105
1106Security features:
1107 - Apparmor: $enable_apparmor
1108 - Linux capabilities: $enable_capabilities
1109 - seccomp: $enable_seccomp
1110 - SELinux: $enable_selinux
6400238d 1111 - memfd rexec: $enable_memfd_rexec
f91d5e4e 1112
7ac43d3d 1113PAM:
f7a8609f 1114 - PAM module: $enable_pam
7ac43d3d
CB
1115 - cgroup PAM module: $pamdir
1116
f91d5e4e
SG
1117Documentation:
1118 - examples: $enable_examples
1119 - API documentation: $enable_api_docs
1120 - user documentation: $enable_doc
1121
1122Debugging:
5f404236 1123 - Sanitizers: $enable_sanitizers
538337ee 1124 - Coverity: $enable_coverity_build
f91d5e4e 1125 - mutex debugging: $enable_mutex_debugging
538337ee 1126 - tests: $enable_tests
f91d5e4e
SG
1127
1128Paths:
1129 - Logs in configpath: $enable_configpath_log
81c76cff
CB
1130
1131Thread-safety:
1132 - enforce: $enable_thread_safety
5c7bfc02 1133
1134Dlog:
1135 - enable: $enable_dlog
f91d5e4e 1136EOF