1 AC_DEFUN([ZFS_AC_LICENSE], [
2 AC_MSG_CHECKING([zfs author])
3 AC_MSG_RESULT([$ZFS_META_AUTHOR])
5 AC_MSG_CHECKING([zfs license])
6 AC_MSG_RESULT([$ZFS_META_LICENSE])
9 AC_DEFUN([ZFS_AC_DEBUG_ENABLE], [
10 DEBUG_CFLAGS="-Werror"
11 DEBUG_CPPFLAGS="-DDEBUG -UNDEBUG"
13 DEBUG_ZFS="_with_debug"
14 AC_DEFINE(ZFS_DEBUG, 1, [zfs debugging enabled])
16 KERNEL_DEBUG_CFLAGS="-Werror"
17 KERNEL_DEBUG_CPPFLAGS="-DDEBUG -UNDEBUG"
20 AC_DEFUN([ZFS_AC_DEBUG_DISABLE], [
22 DEBUG_CPPFLAGS="-UDEBUG -DNDEBUG"
24 DEBUG_ZFS="_without_debug"
26 KERNEL_DEBUG_CFLAGS=""
27 KERNEL_DEBUG_CPPFLAGS="-UDEBUG -DNDEBUG"
31 dnl # When debugging is enabled:
32 dnl # - Enable all ASSERTs (-DDEBUG)
33 dnl # - Promote all compiler warnings to errors (-Werror)
35 AC_DEFUN([ZFS_AC_DEBUG], [
36 AC_MSG_CHECKING([whether assertion support will be enabled])
37 AC_ARG_ENABLE([debug],
38 [AS_HELP_STRING([--enable-debug],
39 [Enable compiler and code assertions @<:@default=no@:>@])],
43 AS_CASE(["x$enable_debug"],
45 [ZFS_AC_DEBUG_ENABLE],
47 [ZFS_AC_DEBUG_DISABLE],
48 [AC_MSG_ERROR([Unknown option $enable_debug])])
50 AC_SUBST(DEBUG_CFLAGS)
51 AC_SUBST(DEBUG_CPPFLAGS)
52 AC_SUBST(DEBUG_LDFLAGS)
55 AC_SUBST(KERNEL_DEBUG_CFLAGS)
56 AC_SUBST(KERNEL_DEBUG_CPPFLAGS)
58 AC_MSG_RESULT([$enable_debug])
61 AC_DEFUN([ZFS_AC_DEBUGINFO_ENABLE], [
62 DEBUG_CFLAGS="$DEBUG_CFLAGS -g -fno-inline"
64 KERNEL_DEBUG_CFLAGS="$KERNEL_DEBUG_CFLAGS -fno-inline"
65 KERNEL_MAKE="$KERNEL_MAKE CONFIG_DEBUG_INFO=y"
67 DEBUGINFO_ZFS="_with_debuginfo"
70 AC_DEFUN([ZFS_AC_DEBUGINFO_DISABLE], [
71 DEBUGINFO_ZFS="_without_debuginfo"
74 AC_DEFUN([ZFS_AC_DEBUGINFO], [
75 AC_MSG_CHECKING([whether debuginfo support will be forced])
76 AC_ARG_ENABLE([debuginfo],
77 [AS_HELP_STRING([--enable-debuginfo],
78 [Force generation of debuginfo @<:@default=no@:>@])],
80 [enable_debuginfo=no])
82 AS_CASE(["x$enable_debuginfo"],
84 [ZFS_AC_DEBUGINFO_ENABLE],
86 [ZFS_AC_DEBUGINFO_DISABLE],
87 [AC_MSG_ERROR([Unknown option $enable_debuginfo])])
89 AC_SUBST(DEBUG_CFLAGS)
90 AC_SUBST(DEBUGINFO_ZFS)
92 AC_SUBST(KERNEL_DEBUG_CFLAGS)
95 AC_MSG_RESULT([$enable_debuginfo])
99 dnl # Disabled by default, provides basic memory tracking. Track the total
100 dnl # number of bytes allocated with kmem_alloc() and freed with kmem_free().
101 dnl # Then at module unload time if any bytes were leaked it will be reported
102 dnl # on the console.
104 AC_DEFUN([ZFS_AC_DEBUG_KMEM], [
105 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
106 AC_ARG_ENABLE([debug-kmem],
107 [AS_HELP_STRING([--enable-debug-kmem],
108 [Enable basic kmem accounting @<:@default=no@:>@])],
110 [enable_debug_kmem=no])
112 AS_IF([test "x$enable_debug_kmem" = xyes], [
113 KERNEL_DEBUG_CPPFLAGS+=" -DDEBUG_KMEM"
114 DEBUG_KMEM_ZFS="_with_debug_kmem"
116 DEBUG_KMEM_ZFS="_without_debug_kmem"
119 AC_SUBST(KERNEL_DEBUG_CPPFLAGS)
120 AC_SUBST(DEBUG_KMEM_ZFS)
122 AC_MSG_RESULT([$enable_debug_kmem])
126 dnl # Disabled by default, provides detailed memory tracking. This feature
127 dnl # also requires --enable-debug-kmem to be set. When enabled not only will
128 dnl # total bytes be tracked but also the location of every kmem_alloc() and
129 dnl # kmem_free(). When the module is unloaded a list of all leaked addresses
130 dnl # and where they were allocated will be dumped to the console. Enabling
131 dnl # this feature has a significant impact on performance but it makes finding
132 dnl # memory leaks straight forward.
134 AC_DEFUN([ZFS_AC_DEBUG_KMEM_TRACKING], [
135 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
136 AC_ARG_ENABLE([debug-kmem-tracking],
137 [AS_HELP_STRING([--enable-debug-kmem-tracking],
138 [Enable detailed kmem tracking @<:@default=no@:>@])],
140 [enable_debug_kmem_tracking=no])
142 AS_IF([test "x$enable_debug_kmem_tracking" = xyes], [
143 KERNEL_DEBUG_CPPFLAGS+=" -DDEBUG_KMEM_TRACKING"
144 DEBUG_KMEM_TRACKING_ZFS="_with_debug_kmem_tracking"
146 DEBUG_KMEM_TRACKING_ZFS="_without_debug_kmem_tracking"
149 AC_SUBST(KERNEL_DEBUG_CPPFLAGS)
150 AC_SUBST(DEBUG_KMEM_TRACKING_ZFS)
152 AC_MSG_RESULT([$enable_debug_kmem_tracking])
155 AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
156 ZFS_AC_CONFIG_ALWAYS_CC_NO_UNUSED_BUT_SET_VARIABLE
157 ZFS_AC_CONFIG_ALWAYS_CC_NO_BOOL_COMPARE
158 ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN
159 ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION
160 ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER
161 ZFS_AC_CONFIG_ALWAYS_CC_ASAN
162 ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD
163 ZFS_AC_CONFIG_ALWAYS_ARCH
164 ZFS_AC_CONFIG_ALWAYS_PYTHON
165 ZFS_AC_CONFIG_ALWAYS_PYZFS
168 AC_DEFUN([ZFS_AC_CONFIG], [
170 AC_ARG_WITH([config],
171 AS_HELP_STRING([--with-config=CONFIG],
172 [Config file 'kernel|user|all|srpm']),
173 [ZFS_CONFIG="$withval"])
174 AC_ARG_ENABLE([linux-builtin],
175 [AC_HELP_STRING([--enable-linux-builtin],
176 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
178 [enable_linux_builtin=no])
180 AC_MSG_CHECKING([zfs config])
181 AC_MSG_RESULT([$ZFS_CONFIG]);
186 case "$ZFS_CONFIG" in
187 kernel) ZFS_AC_CONFIG_KERNEL ;;
188 user) ZFS_AC_CONFIG_USER ;;
189 all) ZFS_AC_CONFIG_USER
190 ZFS_AC_CONFIG_KERNEL ;;
193 AC_MSG_RESULT([Error!])
194 AC_MSG_ERROR([Bad value "$ZFS_CONFIG" for --with-config,
195 user kernel|user|all|srpm]) ;;
198 AM_CONDITIONAL([CONFIG_USER],
199 [test "$ZFS_CONFIG" = user -o "$ZFS_CONFIG" = all])
200 AM_CONDITIONAL([CONFIG_KERNEL],
201 [test "$ZFS_CONFIG" = kernel -o "$ZFS_CONFIG" = all] &&
202 [test "x$enable_linux_builtin" != xyes ])
203 AM_CONDITIONAL([CONFIG_QAT],
204 [test "$ZFS_CONFIG" = kernel -o "$ZFS_CONFIG" = all] &&
205 [test "x$qatsrc" != x ])
206 AM_CONDITIONAL([WANT_DEVNAME2DEVID], [test "x$user_libudev" = xyes ])
207 AM_CONDITIONAL([WANT_MMAP_LIBAIO], [test "x$user_libaio" = xyes ])
211 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
212 dnl # are missing it is non-fatal but you will not be able to build
213 dnl # RPM packages and will be warned if you try too.
215 dnl # By default the generic spec file will be used because it requires
216 dnl # minimal dependencies. Distribution specific spec files can be
217 dnl # placed under the 'rpm/<distribution>' directory and enabled using
218 dnl # the --with-spec=<distribution> configure option.
220 AC_DEFUN([ZFS_AC_RPM], [
224 AC_MSG_CHECKING([whether $RPM is available])
225 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
226 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
228 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
231 AC_MSG_RESULT([$HAVE_RPM])
234 AC_MSG_CHECKING([whether $RPMBUILD is available])
235 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
236 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
238 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
241 AC_MSG_RESULT([$HAVE_RPMBUILD])
244 RPM_DEFINE_COMMON='--define "$(DEBUG_ZFS) 1"'
245 RPM_DEFINE_COMMON+=' --define "$(DEBUG_KMEM_ZFS) 1"'
246 RPM_DEFINE_COMMON+=' --define "$(DEBUG_KMEM_TRACKING_ZFS) 1"'
247 RPM_DEFINE_COMMON+=' --define "$(DEBUGINFO_ZFS) 1"'
248 RPM_DEFINE_COMMON+=' --define "$(ASAN_ZFS) 1"'
250 RPM_DEFINE_UTIL=' --define "_initconfdir $(DEFAULT_INITCONF_DIR)"'
252 dnl # Make the next three RPM_DEFINE_UTIL additions conditional, since
253 dnl # their values may not be set when running:
255 dnl # ./configure --with-config=srpm
257 AS_IF([test -n "$dracutdir" ], [
258 RPM_DEFINE_UTIL='--define "_dracutdir $(dracutdir)"'
260 AS_IF([test -n "$udevdir" ], [
261 RPM_DEFINE_UTIL+=' --define "_udevdir $(udevdir)"'
263 AS_IF([test -n "$udevruledir" ], [
264 RPM_DEFINE_UTIL+=' --define "_udevdir $(udevruledir)"'
266 RPM_DEFINE_UTIL+=' $(DEFINE_INITRAMFS)'
267 RPM_DEFINE_UTIL+=' $(DEFINE_SYSTEMD)'
268 RPM_DEFINE_UTIL+=' $(DEFINE_PYZFS)'
269 RPM_DEFINE_UTIL+=' $(DEFINE_PYTHON_VERSION)'
270 RPM_DEFINE_UTIL+=' $(DEFINE_PYTHON_PKG_VERSION)'
272 dnl # Override default lib directory on Debian/Ubuntu systems. The
273 dnl # provided /usr/lib/rpm/platform/<arch>/macros files do not
274 dnl # specify the correct path for multiarch systems as described
275 dnl # by the packaging guidelines.
277 dnl # https://wiki.ubuntu.com/MultiarchSpec
278 dnl # https://wiki.debian.org/Multiarch/Implementation
280 AS_IF([test "$DEFAULT_PACKAGE" = "deb"], [
281 MULTIARCH_LIBDIR="lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
282 RPM_DEFINE_UTIL+=' --define "_lib $(MULTIARCH_LIBDIR)"'
283 AC_SUBST(MULTIARCH_LIBDIR)
286 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
287 RPM_DEFINE_KMOD+=' --define "ksrc $(LINUX)"'
288 RPM_DEFINE_KMOD+=' --define "kobj $(LINUX_OBJ)"'
289 RPM_DEFINE_KMOD+=' --define "_wrong_version_format_terminate_build 0"'
293 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
298 RPM_SPEC_DIR="rpm/generic"
300 AS_HELP_STRING([--with-spec=SPEC],
301 [Spec files 'generic|redhat']),
302 [RPM_SPEC_DIR="rpm/$withval"])
304 AC_MSG_CHECKING([whether spec files are available])
305 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
309 AC_SUBST(RPM_VERSION)
311 AC_SUBST(HAVE_RPMBUILD)
313 AC_SUBST(RPMBUILD_VERSION)
315 AC_SUBST(RPM_SPEC_DIR)
316 AC_SUBST(RPM_DEFINE_UTIL)
317 AC_SUBST(RPM_DEFINE_KMOD)
318 AC_SUBST(RPM_DEFINE_DKMS)
319 AC_SUBST(RPM_DEFINE_COMMON)
320 AC_SUBST(SRPM_DEFINE_UTIL)
321 AC_SUBST(SRPM_DEFINE_KMOD)
322 AC_SUBST(SRPM_DEFINE_DKMS)
323 AC_SUBST(SRPM_DEFINE_COMMON)
327 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
328 dnl # tools are missing it is non-fatal but you will not be able to build
329 dnl # DEB packages and will be warned if you try too.
331 AC_DEFUN([ZFS_AC_DPKG], [
333 DPKGBUILD=dpkg-buildpackage
335 AC_MSG_CHECKING([whether $DPKG is available])
336 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
337 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
339 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
342 AC_MSG_RESULT([$HAVE_DPKG])
345 AC_MSG_CHECKING([whether $DPKGBUILD is available])
346 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
347 DPKGBUILD_VERSION=$(echo $tmp | \
348 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
350 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
353 AC_MSG_RESULT([$HAVE_DPKGBUILD])
358 AC_SUBST(DPKG_VERSION)
360 AC_SUBST(HAVE_DPKGBUILD)
362 AC_SUBST(DPKGBUILD_VERSION)
366 dnl # Until native packaging for various different packing systems
367 dnl # can be added the least we can do is attempt to use alien to
368 dnl # convert the RPM packages to the needed package type. This is
369 dnl # a hack but so far it has worked reasonable well.
371 AC_DEFUN([ZFS_AC_ALIEN], [
374 AC_MSG_CHECKING([whether $ALIEN is available])
375 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
376 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
378 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
381 AC_MSG_RESULT([$HAVE_ALIEN])
386 AC_SUBST(ALIEN_VERSION)
390 dnl # Using the VENDOR tag from config.guess set the default
391 dnl # package type for 'make pkg': (rpm | deb | tgz)
393 AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
394 AC_MSG_CHECKING([linux distribution])
395 if test -f /etc/toss-release ; then
397 elif test -f /etc/fedora-release ; then
399 elif test -f /etc/redhat-release ; then
401 elif test -f /etc/gentoo-release ; then
403 elif test -f /etc/arch-release ; then
405 elif test -f /etc/SuSE-release ; then
407 elif test -f /etc/slackware-version ; then
409 elif test -f /etc/lunar.release ; then
411 elif test -f /etc/lsb-release ; then
413 elif test -f /etc/debian_version ; then
415 elif test -f /etc/alpine-release ; then
420 AC_MSG_RESULT([$VENDOR])
423 AC_MSG_CHECKING([default package type])
425 toss) DEFAULT_PACKAGE=rpm ;;
426 redhat) DEFAULT_PACKAGE=rpm ;;
427 fedora) DEFAULT_PACKAGE=rpm ;;
428 gentoo) DEFAULT_PACKAGE=tgz ;;
429 alpine) DEFAULT_PACKAGE=tgz ;;
430 arch) DEFAULT_PACKAGE=tgz ;;
431 sles) DEFAULT_PACKAGE=rpm ;;
432 slackware) DEFAULT_PACKAGE=tgz ;;
433 lunar) DEFAULT_PACKAGE=tgz ;;
434 ubuntu) DEFAULT_PACKAGE=deb ;;
435 debian) DEFAULT_PACKAGE=deb ;;
436 *) DEFAULT_PACKAGE=rpm ;;
438 AC_MSG_RESULT([$DEFAULT_PACKAGE])
439 AC_SUBST(DEFAULT_PACKAGE)
441 DEFAULT_INIT_DIR=$sysconfdir/init.d
442 AC_MSG_CHECKING([default init directory])
443 AC_MSG_RESULT([$DEFAULT_INIT_DIR])
444 AC_SUBST(DEFAULT_INIT_DIR)
446 AC_MSG_CHECKING([default init script type])
448 toss) DEFAULT_INIT_SCRIPT=redhat ;;
449 redhat) DEFAULT_INIT_SCRIPT=redhat ;;
450 fedora) DEFAULT_INIT_SCRIPT=fedora ;;
451 gentoo) DEFAULT_INIT_SCRIPT=openrc ;;
452 alpine) DEFAULT_INIT_SCRIPT=openrc ;;
453 arch) DEFAULT_INIT_SCRIPT=lsb ;;
454 sles) DEFAULT_INIT_SCRIPT=lsb ;;
455 slackware) DEFAULT_INIT_SCRIPT=lsb ;;
456 lunar) DEFAULT_INIT_SCRIPT=lunar ;;
457 ubuntu) DEFAULT_INIT_SCRIPT=lsb ;;
458 debian) DEFAULT_INIT_SCRIPT=lsb ;;
459 *) DEFAULT_INIT_SCRIPT=lsb ;;
461 AC_MSG_RESULT([$DEFAULT_INIT_SCRIPT])
462 AC_SUBST(DEFAULT_INIT_SCRIPT)
464 AC_MSG_CHECKING([default init config directory])
466 alpine) DEFAULT_INITCONF_DIR=/etc/conf.d ;;
467 gentoo) DEFAULT_INITCONF_DIR=/etc/conf.d ;;
468 toss) DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
469 redhat) DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
470 fedora) DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
471 sles) DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
472 ubuntu) DEFAULT_INITCONF_DIR=/etc/default ;;
473 debian) DEFAULT_INITCONF_DIR=/etc/default ;;
474 *) DEFAULT_INITCONF_DIR=/etc/default ;;
476 AC_MSG_RESULT([$DEFAULT_INITCONF_DIR])
477 AC_SUBST(DEFAULT_INITCONF_DIR)
479 AC_MSG_CHECKING([whether initramfs-tools is available])
480 if test -d /usr/share/initramfs-tools ; then
481 DEFINE_INITRAMFS='--define "_initramfs 1"'
487 AC_SUBST(DEFINE_INITRAMFS)
491 dnl # Default ZFS package configuration
493 AC_DEFUN([ZFS_AC_PACKAGE], [
494 ZFS_AC_DEFAULT_PACKAGE