]> git.proxmox.com Git - mirror_lxcfs.git/blame - configure.ac
rename fuse_compat.h to avoid conflict with system header
[mirror_lxcfs.git] / configure.ac
CommitLineData
9ce186dc 1AC_PREREQ([2.69])
38ea5f47 2
f2f9f3a8 3AC_INIT([lxcfs], [4.0.5], [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
f4591664
SP
63PKG_CHECK_MODULES(FUSE, fuse, [], [
64 PKG_CHECK_MODULES(FUSE, fuse3, [AC_DEFINE([HAVE_FUSE3], [1], [Use fuse3])])
65])
2183082c
SH
66
67AC_PATH_PROG(HELP2MAN, help2man, false // No help2man //)
d85bd3de 68AM_CONDITIONAL([HAVE_HELP2MAN], [test "x$HELP2MAN" != "xfalse // No help2man //" ])
2183082c 69
35482f91
SH
70AC_ARG_WITH([runtime-path],
71 [AC_HELP_STRING(
72 [--with-runtime-path=dir],
73 [runtime directory (default: /run)]
74 )], [], [with_runtime_path=['/run']])
75
76AS_AC_EXPAND(RUNTIME_PATH, "$with_runtime_path")
7456f3b5 77AS_AC_EXPAND(LXCFSSHAREDIR, "$datarootdir/lxcfs")
b4851b56 78AS_AC_EXPAND(LXCCONFDIR, "$datarootdir/lxc/config/common.conf.d")
7456f3b5
SG
79AS_AC_EXPAND(LXCFSTARGETDIR, "$localstatedir/lib/lxcfs")
80
6cb7f996
SH
81# Detect the distribution. This is used for the default configuration and
82# for some distro-specific build options.
83AC_MSG_CHECKING([host distribution])
84AC_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.]))
85if type lsb_release >/dev/null 2>&1 && test "z$with_distro" = "z"; then
86 with_distro=`lsb_release -is`
87fi
38ea5f47 88
6cb7f996
SH
89if test "z$with_distro" = "z"; then
90 AC_CHECK_FILE(/etc/redhat-release,with_distro="redhat")
91 AC_CHECK_FILE(/etc/oracle-release,with_distro="oracle")
92 AC_CHECK_FILE(/etc/centos-release,with_distro="centos")
93 AC_CHECK_FILE(/etc/fedora-release,with_distro="fedora")
94 AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
95 AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
96 AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
97 AC_CHECK_FILE(/etc/arch-release,with_distro="arch")
98 AC_CHECK_FILE(/etc/slackware-version,with_distro="slackware")
99 AC_CHECK_FILE(/etc/frugalware-release,with_distro="frugalware")
100 AC_CHECK_FILE(/etc/mandrakelinux-release, with_distro="openmandriva")
101 AC_CHECK_FILE(/etc/mandriva-release,with_distro="openmandriva")
102 AC_CHECK_FILE(/etc/pardus-release,with_distro="pardus")
00d7fdd8 103 AC_CHECK_FILE(/etc/pld-release,with_distro="pld")
6cb7f996 104fi
38ea5f47 105
6cb7f996
SH
106with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]'`
107
108if test "z$with_distro" = "z"; then
109 with_distro="unknown"
110fi
38ea5f47 111
6cb7f996
SH
112case $with_distro in
113 ubuntu)
114 distroconf=default.conf.ubuntu
115 ;;
00d7fdd8 116 redhat|centos|fedora|oracle|oracleserver|pld)
6cb7f996
SH
117 distroconf=default.conf.libvirt
118 ;;
119 *)
120 distroconf=default.conf.unknown
121 ;;
122esac
38ea5f47 123
6cb7f996
SH
124AC_MSG_RESULT([$with_distro])
125AM_CONDITIONAL([HAVE_DEBIAN], [test x"$with_distro" = "xdebian" -o x"$with_distro" = "xubuntu"])
126AM_CONDITIONAL([DISTRO_UBUNTU], [test "x$with_distro" = "xubuntu"])
127
128# Check for init system type
129AC_MSG_CHECKING([for init system type])
130AC_ARG_WITH([init-script],
131 [AC_HELP_STRING([--with-init-script@<:@=TYPE@<:@,TYPE,...@:>@@:>@],
132 [Type(s) of init script to install: bsd, openrc, sysvinit, systemd, upstart,
133 distro @<:@default=distro@:>@])],[],[with_init_script=distro])
134case "$with_init_script" in
135 distro)
136 case $with_distro in
137 fedora)
138 init_script=systemd
139 ;;
140 redhat|centos|oracle|oracleserver)
141 init_script=sysvinit
142 ;;
143 debian)
ef2256ce 144 init_script=upstart,systemd,sysvinit
6cb7f996
SH
145 ;;
146 ubuntu)
ef2256ce 147 init_script=upstart,systemd,sysvinit
6cb7f996 148 ;;
00d7fdd8
ER
149 pld)
150 init_script=systemd,sysvinit
151 ;;
6cb7f996
SH
152 slackware)
153 echo -n "Warning: bsd init job not yet implemented"
154 init_script=
155 ;;
156 gentoo)
157 echo -n "Warning: openrc init job not yet implemented"
158 init_script=
159 ;;
160 *)
161 echo -n "Linux distribution init system unknown."
162 init_script=
163 ;;
164 esac
165 ;;
166 *)
167 init_script=$with_init_script
168 ;;
169esac
170
171# Check valid init systems were given, run in subshell so we don't mess up IFS
172(IFS="," ; for init_sys in $init_script;
173do
174 case "$init_sys" in
175 none|bsd|openrc|sysvinit|systemd|upstart)
176 ;;
177 *)
178 exit 1
179 ;;
180 esac
181done) || AC_MSG_ERROR([Unknown init system type in $init_script])
182
183AM_CONDITIONAL([INIT_SCRIPT_BSD], [echo "$init_script" |grep -q "bsd"])
184AM_CONDITIONAL([INIT_SCRIPT_OPENRC], [echo "$init_script" |grep -q "openrc"])
185AM_CONDITIONAL([INIT_SCRIPT_SYSV], [echo "$init_script" |grep -q "sysvinit"])
186AM_CONDITIONAL([INIT_SCRIPT_SYSTEMD], [echo "$init_script" |grep -q "systemd"])
187AM_CONDITIONAL([INIT_SCRIPT_UPSTART], [echo "$init_script" |grep -q "upstart"])
188AC_MSG_RESULT($init_script)
189
369154d6 190AC_SUBST([lxcfsdir], "${libdir}/lxcfs")
df54106a 191
237e200e
SH
192# Rootfs path, where the container mount structure is assembled
193AC_ARG_WITH([rootfs-path],
194 [AC_HELP_STRING(
195 [--with-rootfs-path=dir],
196 [lxc rootfs mount point]
197 )], [], [with_rootfs_path=['${libdir}/lxc/rootfs']])
198
199AS_AC_EXPAND(LIBDIR, "$libdir")
200
5fbea8a6
CB
201AC_CHECK_FUNCS([strlcpy],
202 AM_CONDITIONAL(HAVE_STRLCPY, true)
203 AC_DEFINE(HAVE_STRLCPY,1,[Have strlcpy]),
204 AM_CONDITIONAL(HAVE_STRLCPY, false))
38ea5f47 205
5fbea8a6
CB
206AC_CHECK_FUNCS([strlcat],
207 AM_CONDITIONAL(HAVE_STRLCAT, true)
208 AC_DEFINE(HAVE_STRLCAT,1,[Have strlcat]),
209 AM_CONDITIONAL(HAVE_STRLCAT, false))
210
2aa59b2e
CB
211AC_CHECK_FUNCS([pidfd_open],
212 AM_CONDITIONAL(HAVE_PIDFD_OPEN, true)
213 AC_DEFINE(HAVE_PIDFD_OPEN,1,[Supports pidfd_open]),
214 AM_CONDITIONAL(HAVE_PIDFD_OPEN, false))
215
216AC_CHECK_FUNCS([pidfd_send_signal],
217 AM_CONDITIONAL(HAVE_PIDFD_SEND_SIGNAL, true)
218 AC_DEFINE(HAVE_PIDFD_SEND_SIGNAL,1,[Supports pidfd_send_signal]),
219 AM_CONDITIONAL(HAVE_PIDFD_SEND_SIGNAL, false))
220
9ce186dc
CB
221AX_CHECK_COMPILE_FLAG([-fdiagnostics-color], [CFLAGS="$CFLAGS -fdiagnostics-color"],,[-Werror])
222AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough=5], [CFLAGS="$CFLAGS -Wimplicit-fallthrough=5"],,[-Werror])
223AX_CHECK_COMPILE_FLAG([-Wcast-align], [CFLAGS="$CFLAGS -Wcast-align"],,[-Werror])
224AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes], [CFLAGS="$CFLAGS -Wstrict-prototypes"],,[-Werror])
225AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"],,[-Werror])
226AX_CHECK_COMPILE_FLAG([-fstack-clash-protection], [CFLAGS="$CFLAGS -fstack-clash-protection"],,[-Werror])
227AX_CHECK_LINK_FLAG([-fstack-protector-strong], [CFLAGS="$CFLAGS -fstack-protector-strong"],,[-Werror])
228AX_CHECK_LINK_FLAG([--param=ssp-buffer-size=4], [CFLAGS="$CFLAGS --param=ssp-buffer-size=4"],,[-Werror])
229AX_CHECK_COMPILE_FLAG([-g], [CFLAGS="$CFLAGS -g"],,[-Werror])
230AX_CHECK_COMPILE_FLAG([--mcet -fcf-protection], [CFLAGS="$CFLAGS --mcet -fcf-protection"],,[-Werror])
231AX_CHECK_COMPILE_FLAG([-Werror=implicit-function-declaration], [CFLAGS="$CFLAGS -Werror=implicit-function-declaration"],,[-Werror])
232AX_CHECK_COMPILE_FLAG([-Wlogical-op], [CFLAGS="$CFLAGS -Wlogical-op"],,[-Werror])
233AX_CHECK_COMPILE_FLAG([-Wmissing-include-dirs], [CFLAGS="$CFLAGS -Wmissing-include-dirs"],,[-Werror])
234AX_CHECK_COMPILE_FLAG([-Wold-style-definition], [CFLAGS="$CFLAGS -Wold-style-definition"],,[-Werror])
235AX_CHECK_COMPILE_FLAG([-Winit-self], [CFLAGS="$CFLAGS -Winit-self"],,[-Werror])
236AX_CHECK_COMPILE_FLAG([-Wunused-but-set-variable], [CFLAGS="$CFLAGS -Wunused-but-set-variable"],,[-Werror])
237AX_CHECK_COMPILE_FLAG([-Wfloat-equal], [CFLAGS="$CFLAGS -Wfloat-equal"],,[-Werror])
238AX_CHECK_COMPILE_FLAG([-Wsuggest-attribute=noreturn], [CFLAGS="$CFLAGS -Wsuggest-attribute=noreturn"],,[-Werror])
239AX_CHECK_COMPILE_FLAG([-Werror=return-type], [CFLAGS="$CFLAGS -Werror=return-type"],,[-Werror])
240AX_CHECK_COMPILE_FLAG([-Werror=incompatible-pointer-types], [CFLAGS="$CFLAGS -Werror=incompatible-pointer-types"],,[-Werror])
241AX_CHECK_COMPILE_FLAG([-Wformat=2], [CFLAGS="$CFLAGS -Wformat=2"],,[-Werror])
242AX_CHECK_COMPILE_FLAG([-Wshadow], [CFLAGS="$CFLAGS -Wshadow"],,[-Werror])
243AX_CHECK_COMPILE_FLAG([-Wendif-labels], [CFLAGS="$CFLAGS -Wendif-labels"],,[-Werror])
244AX_CHECK_COMPILE_FLAG([-Werror=overflow], [CFLAGS="$CFLAGS -Werror=overflow"],,[-Werror])
245AX_CHECK_COMPILE_FLAG([-fdiagnostics-show-option], [CFLAGS="$CFLAGS -fdiagnostics-show-option"],,[-Werror])
246AX_CHECK_COMPILE_FLAG([-Werror=shift-count-overflow], [CFLAGS="$CFLAGS -Werror=shift-count-overflow"],,[-Werror])
247AX_CHECK_COMPILE_FLAG([-Werror=shift-overflow=2], [CFLAGS="$CFLAGS -Werror=shift-overflow=2"],,[-Werror])
248AX_CHECK_COMPILE_FLAG([-Wdate-time], [CFLAGS="$CFLAGS -Wdate-time"],,[-Werror])
249AX_CHECK_COMPILE_FLAG([-Wnested-externs], [CFLAGS="$CFLAGS -Wnested-externs"],,[-Werror])
250AX_CHECK_COMPILE_FLAG([-fasynchronous-unwind-tables], [CFLAGS="$CFLAGS -fasynchronous-unwind-tables"],,[-Werror])
251AX_CHECK_COMPILE_FLAG([-pipe], [CFLAGS="$CFLAGS -pipe"],,[-Werror])
252AX_CHECK_COMPILE_FLAG([-fexceptions], [CFLAGS="$CFLAGS -fexceptions"],,[-Werror])
253
515f1ddf 254CFLAGS="$CFLAGS -fvisibility=hidden -Wvla -std=gnu11"
9ce186dc
CB
255AX_CHECK_LINK_FLAG([-z relro], [LDFLAGS="$LDFLAGS -z relro"],,[])
256AX_CHECK_LINK_FLAG([-z now], [LDFLAGS="$LDFLAGS -z now"],,[])
257
7eac3825
CB
258# Build with ASAN commands
259AC_ARG_ENABLE([asan],
260 [AS_HELP_STRING([--enable-asan], [build with address sanitizer enabled [default=no]])],
261 [enable_asan=$enableval], [enable_asan=no])
262AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = "xyes"])
263
264# Build with UBSAN commands
265AC_ARG_ENABLE([ubsan],
266 [AS_HELP_STRING([--enable-ubsan], [build with ubsan sanitizer enabled [default=no]])],
267 [enable_asan=$enableval], [enable_ubsan=no])
268AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = "xyes"])
269
2183082c 270AC_OUTPUT
7eac3825
CB
271
272# Configuration overview
273cat << EOF
274
275----------------------------
276Environment:
277 - compiler: $CC
278
279Debugging:
280 - tests: $enable_tests
281 - ASAN: $enable_asan
282 - mutex debugging: $enable_mutex_debugging
283EOF