]> git.proxmox.com Git - mirror_lxcfs.git/blame - configure.ac
doc: guide for reload share libary file
[mirror_lxcfs.git] / configure.ac
CommitLineData
9ce186dc 1AC_PREREQ([2.69])
38ea5f47 2
cfbad91c 3AC_INIT([lxcfs], [4.0.9], [lxc-devel@lists.linuxcontainers.org])
38ea5f47
CB
4
5# We need pkg-config
6PKG_PROG_PKG_CONFIG
7
8AC_CONFIG_SRCDIR([configure.ac])
9ce186dc
CB
9AC_CONFIG_AUX_DIR([config])
10AC_CONFIG_HEADERS([config.h])
2183082c 11
38ea5f47
CB
12AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
13AC_CONFIG_MACRO_DIR([m4])
14AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability subdir-objects])
15AC_CANONICAL_HOST
16AM_PROG_CC_C_O
17AC_USE_SYSTEM_EXTENSIONS
18
19# Test if we have a new enough compiler.
20AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
21#define GCC_VERSION \
22 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
23
24#define CLANG_VERSION \
25 (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
26
27#if GCC_VERSION < 40700 && CLANG_VERSION < 10000
28#error Sorry, your compiler is too old - please upgrade it
29#endif
30 ]])], [valid_compiler=yes], [valid_compiler=no])
31if test "x$valid_compiler" = "xno"; then
32 AC_MSG_ERROR([Sorry, your compiler is too old - please upgrade it])
33fi
34
35# libtool
36LT_INIT
37AC_SUBST([LIBTOOL_DEPS])
df54106a 38
2183082c 39AC_CONFIG_FILES([
c1f9bbee 40 Makefile
3cd4195e 41 lxcfs.spec
38ea5f47 42
6cb7f996
SH
43 config/Makefile
44 config/init/Makefile
45 config/init/systemd/Makefile
89113f7e 46 config/init/systemd/lxcfs.service
6cb7f996
SH
47 config/init/sysvinit/Makefile
48 config/init/upstart/Makefile
38ea5f47
CB
49
50 doc/Makefile
51
7456f3b5
SG
52 share/Makefile
53 share/00-lxcfs.conf
54 share/lxc.mount.hook
5d6df2dd 55 share/lxc.reboot.hook
38ea5f47 56
0efe589c 57 src/Makefile
2183082c 58
38ea5f47 59 tests/Makefile ])
2183082c 60
2c51f8dd
SH
61AC_CHECK_LIB(pthread, main)
62
7182b4ce
CB
63PKG_CHECK_MODULES(FUSE, fuse3, [have_fuse3=yes], [have_fuse3=no])
64if test "x$have_fuse3" = "xyes"; then
65 AC_DEFINE([HAVE_FUSE3], [1], [Use fuse3])
66 AC_DEFINE_UNQUOTED([FUSE_USE_VERSION], [30], [Use fuse version 30])
67else
68 PKG_CHECK_MODULES(FUSE, fuse, [AC_DEFINE_UNQUOTED([FUSE_USE_VERSION], [26], [Use fuse])])
69fi
2183082c
SH
70
71AC_PATH_PROG(HELP2MAN, help2man, false // No help2man //)
d85bd3de 72AM_CONDITIONAL([HAVE_HELP2MAN], [test "x$HELP2MAN" != "xfalse // No help2man //" ])
2183082c 73
35482f91
SH
74AC_ARG_WITH([runtime-path],
75 [AC_HELP_STRING(
76 [--with-runtime-path=dir],
77 [runtime directory (default: /run)]
78 )], [], [with_runtime_path=['/run']])
79
80AS_AC_EXPAND(RUNTIME_PATH, "$with_runtime_path")
7456f3b5 81AS_AC_EXPAND(LXCFSSHAREDIR, "$datarootdir/lxcfs")
b4851b56 82AS_AC_EXPAND(LXCCONFDIR, "$datarootdir/lxc/config/common.conf.d")
7456f3b5
SG
83AS_AC_EXPAND(LXCFSTARGETDIR, "$localstatedir/lib/lxcfs")
84
6cb7f996
SH
85# Detect the distribution. This is used for the default configuration and
86# for some distro-specific build options.
87AC_MSG_CHECKING([host distribution])
88AC_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, paldo, openmandriva or pardus.]))
89if type lsb_release >/dev/null 2>&1 && test "z$with_distro" = "z"; then
90 with_distro=`lsb_release -is`
91fi
38ea5f47 92
6cb7f996
SH
93if test "z$with_distro" = "z"; then
94 AC_CHECK_FILE(/etc/redhat-release,with_distro="redhat")
95 AC_CHECK_FILE(/etc/oracle-release,with_distro="oracle")
96 AC_CHECK_FILE(/etc/centos-release,with_distro="centos")
97 AC_CHECK_FILE(/etc/fedora-release,with_distro="fedora")
98 AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
99 AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
100 AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
101 AC_CHECK_FILE(/etc/arch-release,with_distro="arch")
102 AC_CHECK_FILE(/etc/slackware-version,with_distro="slackware")
103 AC_CHECK_FILE(/etc/frugalware-release,with_distro="frugalware")
104 AC_CHECK_FILE(/etc/mandrakelinux-release, with_distro="openmandriva")
105 AC_CHECK_FILE(/etc/mandriva-release,with_distro="openmandriva")
106 AC_CHECK_FILE(/etc/pardus-release,with_distro="pardus")
00d7fdd8 107 AC_CHECK_FILE(/etc/pld-release,with_distro="pld")
6cb7f996 108fi
38ea5f47 109
6cb7f996
SH
110with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]'`
111
112if test "z$with_distro" = "z"; then
113 with_distro="unknown"
114fi
38ea5f47 115
6cb7f996
SH
116case $with_distro in
117 ubuntu)
118 distroconf=default.conf.ubuntu
119 ;;
00d7fdd8 120 redhat|centos|fedora|oracle|oracleserver|pld)
6cb7f996
SH
121 distroconf=default.conf.libvirt
122 ;;
123 *)
124 distroconf=default.conf.unknown
125 ;;
126esac
38ea5f47 127
6cb7f996
SH
128AC_MSG_RESULT([$with_distro])
129AM_CONDITIONAL([HAVE_DEBIAN], [test x"$with_distro" = "xdebian" -o x"$with_distro" = "xubuntu"])
130AM_CONDITIONAL([DISTRO_UBUNTU], [test "x$with_distro" = "xubuntu"])
131
132# Check for init system type
133AC_MSG_CHECKING([for init system type])
134AC_ARG_WITH([init-script],
135 [AC_HELP_STRING([--with-init-script@<:@=TYPE@<:@,TYPE,...@:>@@:>@],
136 [Type(s) of init script to install: bsd, openrc, sysvinit, systemd, upstart,
137 distro @<:@default=distro@:>@])],[],[with_init_script=distro])
138case "$with_init_script" in
139 distro)
140 case $with_distro in
141 fedora)
142 init_script=systemd
143 ;;
144 redhat|centos|oracle|oracleserver)
145 init_script=sysvinit
146 ;;
147 debian)
ef2256ce 148 init_script=upstart,systemd,sysvinit
6cb7f996
SH
149 ;;
150 ubuntu)
ef2256ce 151 init_script=upstart,systemd,sysvinit
6cb7f996 152 ;;
00d7fdd8
ER
153 pld)
154 init_script=systemd,sysvinit
155 ;;
6cb7f996
SH
156 slackware)
157 echo -n "Warning: bsd init job not yet implemented"
158 init_script=
159 ;;
160 gentoo)
161 echo -n "Warning: openrc init job not yet implemented"
162 init_script=
163 ;;
164 *)
165 echo -n "Linux distribution init system unknown."
166 init_script=
167 ;;
168 esac
169 ;;
170 *)
171 init_script=$with_init_script
172 ;;
173esac
174
175# Check valid init systems were given, run in subshell so we don't mess up IFS
176(IFS="," ; for init_sys in $init_script;
177do
178 case "$init_sys" in
179 none|bsd|openrc|sysvinit|systemd|upstart)
180 ;;
181 *)
182 exit 1
183 ;;
184 esac
185done) || AC_MSG_ERROR([Unknown init system type in $init_script])
186
187AM_CONDITIONAL([INIT_SCRIPT_BSD], [echo "$init_script" |grep -q "bsd"])
188AM_CONDITIONAL([INIT_SCRIPT_OPENRC], [echo "$init_script" |grep -q "openrc"])
189AM_CONDITIONAL([INIT_SCRIPT_SYSV], [echo "$init_script" |grep -q "sysvinit"])
190AM_CONDITIONAL([INIT_SCRIPT_SYSTEMD], [echo "$init_script" |grep -q "systemd"])
191AM_CONDITIONAL([INIT_SCRIPT_UPSTART], [echo "$init_script" |grep -q "upstart"])
192AC_MSG_RESULT($init_script)
193
369154d6 194AC_SUBST([lxcfsdir], "${libdir}/lxcfs")
df54106a 195
237e200e
SH
196# Rootfs path, where the container mount structure is assembled
197AC_ARG_WITH([rootfs-path],
198 [AC_HELP_STRING(
199 [--with-rootfs-path=dir],
200 [lxc rootfs mount point]
201 )], [], [with_rootfs_path=['${libdir}/lxc/rootfs']])
202
203AS_AC_EXPAND(LIBDIR, "$libdir")
204
5fbea8a6
CB
205AC_CHECK_FUNCS([strlcpy],
206 AM_CONDITIONAL(HAVE_STRLCPY, true)
207 AC_DEFINE(HAVE_STRLCPY,1,[Have strlcpy]),
208 AM_CONDITIONAL(HAVE_STRLCPY, false))
38ea5f47 209
5fbea8a6
CB
210AC_CHECK_FUNCS([strlcat],
211 AM_CONDITIONAL(HAVE_STRLCAT, true)
212 AC_DEFINE(HAVE_STRLCAT,1,[Have strlcat]),
213 AM_CONDITIONAL(HAVE_STRLCAT, false))
214
2aa59b2e
CB
215AC_CHECK_FUNCS([pidfd_open],
216 AM_CONDITIONAL(HAVE_PIDFD_OPEN, true)
217 AC_DEFINE(HAVE_PIDFD_OPEN,1,[Supports pidfd_open]),
218 AM_CONDITIONAL(HAVE_PIDFD_OPEN, false))
219
220AC_CHECK_FUNCS([pidfd_send_signal],
221 AM_CONDITIONAL(HAVE_PIDFD_SEND_SIGNAL, true)
222 AC_DEFINE(HAVE_PIDFD_SEND_SIGNAL,1,[Supports pidfd_send_signal]),
223 AM_CONDITIONAL(HAVE_PIDFD_SEND_SIGNAL, false))
224
9ce186dc
CB
225AX_CHECK_COMPILE_FLAG([-fdiagnostics-color], [CFLAGS="$CFLAGS -fdiagnostics-color"],,[-Werror])
226AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough=5], [CFLAGS="$CFLAGS -Wimplicit-fallthrough=5"],,[-Werror])
227AX_CHECK_COMPILE_FLAG([-Wcast-align], [CFLAGS="$CFLAGS -Wcast-align"],,[-Werror])
228AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes], [CFLAGS="$CFLAGS -Wstrict-prototypes"],,[-Werror])
229AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"],,[-Werror])
230AX_CHECK_COMPILE_FLAG([-fstack-clash-protection], [CFLAGS="$CFLAGS -fstack-clash-protection"],,[-Werror])
231AX_CHECK_LINK_FLAG([-fstack-protector-strong], [CFLAGS="$CFLAGS -fstack-protector-strong"],,[-Werror])
232AX_CHECK_LINK_FLAG([--param=ssp-buffer-size=4], [CFLAGS="$CFLAGS --param=ssp-buffer-size=4"],,[-Werror])
233AX_CHECK_COMPILE_FLAG([-g], [CFLAGS="$CFLAGS -g"],,[-Werror])
234AX_CHECK_COMPILE_FLAG([--mcet -fcf-protection], [CFLAGS="$CFLAGS --mcet -fcf-protection"],,[-Werror])
235AX_CHECK_COMPILE_FLAG([-Werror=implicit-function-declaration], [CFLAGS="$CFLAGS -Werror=implicit-function-declaration"],,[-Werror])
236AX_CHECK_COMPILE_FLAG([-Wlogical-op], [CFLAGS="$CFLAGS -Wlogical-op"],,[-Werror])
237AX_CHECK_COMPILE_FLAG([-Wmissing-include-dirs], [CFLAGS="$CFLAGS -Wmissing-include-dirs"],,[-Werror])
238AX_CHECK_COMPILE_FLAG([-Wold-style-definition], [CFLAGS="$CFLAGS -Wold-style-definition"],,[-Werror])
239AX_CHECK_COMPILE_FLAG([-Winit-self], [CFLAGS="$CFLAGS -Winit-self"],,[-Werror])
240AX_CHECK_COMPILE_FLAG([-Wunused-but-set-variable], [CFLAGS="$CFLAGS -Wunused-but-set-variable"],,[-Werror])
241AX_CHECK_COMPILE_FLAG([-Wfloat-equal], [CFLAGS="$CFLAGS -Wfloat-equal"],,[-Werror])
242AX_CHECK_COMPILE_FLAG([-Wsuggest-attribute=noreturn], [CFLAGS="$CFLAGS -Wsuggest-attribute=noreturn"],,[-Werror])
243AX_CHECK_COMPILE_FLAG([-Werror=return-type], [CFLAGS="$CFLAGS -Werror=return-type"],,[-Werror])
244AX_CHECK_COMPILE_FLAG([-Werror=incompatible-pointer-types], [CFLAGS="$CFLAGS -Werror=incompatible-pointer-types"],,[-Werror])
245AX_CHECK_COMPILE_FLAG([-Wformat=2], [CFLAGS="$CFLAGS -Wformat=2"],,[-Werror])
246AX_CHECK_COMPILE_FLAG([-Wshadow], [CFLAGS="$CFLAGS -Wshadow"],,[-Werror])
247AX_CHECK_COMPILE_FLAG([-Wendif-labels], [CFLAGS="$CFLAGS -Wendif-labels"],,[-Werror])
248AX_CHECK_COMPILE_FLAG([-Werror=overflow], [CFLAGS="$CFLAGS -Werror=overflow"],,[-Werror])
249AX_CHECK_COMPILE_FLAG([-fdiagnostics-show-option], [CFLAGS="$CFLAGS -fdiagnostics-show-option"],,[-Werror])
250AX_CHECK_COMPILE_FLAG([-Werror=shift-count-overflow], [CFLAGS="$CFLAGS -Werror=shift-count-overflow"],,[-Werror])
251AX_CHECK_COMPILE_FLAG([-Werror=shift-overflow=2], [CFLAGS="$CFLAGS -Werror=shift-overflow=2"],,[-Werror])
252AX_CHECK_COMPILE_FLAG([-Wdate-time], [CFLAGS="$CFLAGS -Wdate-time"],,[-Werror])
253AX_CHECK_COMPILE_FLAG([-Wnested-externs], [CFLAGS="$CFLAGS -Wnested-externs"],,[-Werror])
254AX_CHECK_COMPILE_FLAG([-fasynchronous-unwind-tables], [CFLAGS="$CFLAGS -fasynchronous-unwind-tables"],,[-Werror])
255AX_CHECK_COMPILE_FLAG([-pipe], [CFLAGS="$CFLAGS -pipe"],,[-Werror])
256AX_CHECK_COMPILE_FLAG([-fexceptions], [CFLAGS="$CFLAGS -fexceptions"],,[-Werror])
257
515f1ddf 258CFLAGS="$CFLAGS -fvisibility=hidden -Wvla -std=gnu11"
9ce186dc
CB
259AX_CHECK_LINK_FLAG([-z relro], [LDFLAGS="$LDFLAGS -z relro"],,[])
260AX_CHECK_LINK_FLAG([-z now], [LDFLAGS="$LDFLAGS -z now"],,[])
261
7eac3825
CB
262# Build with ASAN commands
263AC_ARG_ENABLE([asan],
264 [AS_HELP_STRING([--enable-asan], [build with address sanitizer enabled [default=no]])],
265 [enable_asan=$enableval], [enable_asan=no])
266AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = "xyes"])
267
268# Build with UBSAN commands
269AC_ARG_ENABLE([ubsan],
270 [AS_HELP_STRING([--enable-ubsan], [build with ubsan sanitizer enabled [default=no]])],
271 [enable_asan=$enableval], [enable_ubsan=no])
272AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = "xyes"])
273
2183082c 274AC_OUTPUT
7eac3825
CB
275
276# Configuration overview
277cat << EOF
278
279----------------------------
280Environment:
281 - compiler: $CC
282
283Debugging:
284 - tests: $enable_tests
285 - ASAN: $enable_asan
286 - mutex debugging: $enable_mutex_debugging
287EOF