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