xref: /freebsd/sys/contrib/openzfs/config/zfs-build.m4 (revision eac7052fdebb90caf2f653e06187bdbca837b9c7)
1AC_DEFUN([ZFS_AC_LICENSE], [
2	AC_MSG_CHECKING([zfs author])
3	AC_MSG_RESULT([$ZFS_META_AUTHOR])
4
5	AC_MSG_CHECKING([zfs license])
6	AC_MSG_RESULT([$ZFS_META_LICENSE])
7])
8
9AC_DEFUN([ZFS_AC_DEBUG_ENABLE], [
10	DEBUG_CFLAGS="-Werror"
11	DEBUG_CPPFLAGS="-DDEBUG -UNDEBUG"
12	DEBUG_LDFLAGS=""
13	DEBUG_ZFS="_with_debug"
14	AC_DEFINE(ZFS_DEBUG, 1, [zfs debugging enabled])
15
16	KERNEL_DEBUG_CFLAGS="-Werror"
17	KERNEL_DEBUG_CPPFLAGS="-DDEBUG -UNDEBUG"
18])
19
20AC_DEFUN([ZFS_AC_DEBUG_DISABLE], [
21	DEBUG_CFLAGS=""
22	DEBUG_CPPFLAGS="-UDEBUG -DNDEBUG"
23	DEBUG_LDFLAGS=""
24	DEBUG_ZFS="_without_debug"
25
26	KERNEL_DEBUG_CFLAGS=""
27	KERNEL_DEBUG_CPPFLAGS="-UDEBUG -DNDEBUG"
28])
29
30dnl #
31dnl # When debugging is enabled:
32dnl # - Enable all ASSERTs (-DDEBUG)
33dnl # - Promote all compiler warnings to errors (-Werror)
34dnl #
35AC_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@:>@])],
40		[],
41		[enable_debug=no])
42
43	AS_CASE(["x$enable_debug"],
44		["xyes"],
45		[ZFS_AC_DEBUG_ENABLE],
46		["xno"],
47		[ZFS_AC_DEBUG_DISABLE],
48		[AC_MSG_ERROR([Unknown option $enable_debug])])
49
50	AC_SUBST(DEBUG_CFLAGS)
51	AC_SUBST(DEBUG_CPPFLAGS)
52	AC_SUBST(DEBUG_LDFLAGS)
53	AC_SUBST(DEBUG_ZFS)
54
55	AC_SUBST(KERNEL_DEBUG_CFLAGS)
56	AC_SUBST(KERNEL_DEBUG_CPPFLAGS)
57
58	AC_MSG_RESULT([$enable_debug])
59])
60
61AC_DEFUN([ZFS_AC_DEBUGINFO_ENABLE], [
62	DEBUG_CFLAGS="$DEBUG_CFLAGS -g -fno-inline $NO_IPA_SRA"
63
64	KERNEL_DEBUG_CFLAGS="$KERNEL_DEBUG_CFLAGS -fno-inline $NO_IPA_SRA"
65	KERNEL_MAKE="$KERNEL_MAKE CONFIG_DEBUG_INFO=y"
66
67	DEBUGINFO_ZFS="_with_debuginfo"
68])
69
70AC_DEFUN([ZFS_AC_DEBUGINFO_DISABLE], [
71	DEBUGINFO_ZFS="_without_debuginfo"
72])
73
74AC_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@:>@])],
79		[],
80		[enable_debuginfo=no])
81
82	AS_CASE(["x$enable_debuginfo"],
83		["xyes"],
84		[ZFS_AC_DEBUGINFO_ENABLE],
85		["xno"],
86		[ZFS_AC_DEBUGINFO_DISABLE],
87		[AC_MSG_ERROR([Unknown option $enable_debuginfo])])
88
89	AC_SUBST(DEBUG_CFLAGS)
90	AC_SUBST(DEBUGINFO_ZFS)
91
92	AC_SUBST(KERNEL_DEBUG_CFLAGS)
93	AC_SUBST(KERNEL_MAKE)
94
95	AC_MSG_RESULT([$enable_debuginfo])
96])
97
98dnl #
99dnl # Disabled by default, provides basic memory tracking.  Track the total
100dnl # number of bytes allocated with kmem_alloc() and freed with kmem_free().
101dnl # Then at module unload time if any bytes were leaked it will be reported
102dnl # on the console.
103dnl #
104AC_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@:>@])],
109		[],
110		[enable_debug_kmem=no])
111
112	AS_IF([test "x$enable_debug_kmem" = xyes], [
113		KERNEL_DEBUG_CPPFLAGS="${KERNEL_DEBUG_CPPFLAGS} -DDEBUG_KMEM"
114		DEBUG_KMEM_ZFS="_with_debug_kmem"
115	], [
116		DEBUG_KMEM_ZFS="_without_debug_kmem"
117	])
118
119	AC_SUBST(KERNEL_DEBUG_CPPFLAGS)
120	AC_SUBST(DEBUG_KMEM_ZFS)
121
122	AC_MSG_RESULT([$enable_debug_kmem])
123])
124
125dnl #
126dnl # Disabled by default, provides detailed memory tracking.  This feature
127dnl # also requires --enable-debug-kmem to be set.  When enabled not only will
128dnl # total bytes be tracked but also the location of every kmem_alloc() and
129dnl # kmem_free().  When the module is unloaded a list of all leaked addresses
130dnl # and where they were allocated will be dumped to the console.  Enabling
131dnl # this feature has a significant impact on performance but it makes finding
132dnl # memory leaks straight forward.
133dnl #
134AC_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@:>@])],
139		[],
140		[enable_debug_kmem_tracking=no])
141
142	AS_IF([test "x$enable_debug_kmem_tracking" = xyes], [
143		KERNEL_DEBUG_CPPFLAGS="${KERNEL_DEBUG_CPPFLAGS} -DDEBUG_KMEM_TRACKING"
144		DEBUG_KMEM_TRACKING_ZFS="_with_debug_kmem_tracking"
145	], [
146		DEBUG_KMEM_TRACKING_ZFS="_without_debug_kmem_tracking"
147	])
148
149	AC_SUBST(KERNEL_DEBUG_CPPFLAGS)
150	AC_SUBST(DEBUG_KMEM_TRACKING_ZFS)
151
152	AC_MSG_RESULT([$enable_debug_kmem_tracking])
153])
154
155AC_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_FORMAT_ZERO_LENGTH
161	ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER
162	ZFS_AC_CONFIG_ALWAYS_CC_NO_IPA_SRA
163	ZFS_AC_CONFIG_ALWAYS_CC_ASAN
164	ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD
165	ZFS_AC_CONFIG_ALWAYS_SYSTEM
166	ZFS_AC_CONFIG_ALWAYS_ARCH
167	ZFS_AC_CONFIG_ALWAYS_PYTHON
168	ZFS_AC_CONFIG_ALWAYS_PYZFS
169	ZFS_AC_CONFIG_ALWAYS_SED
170])
171
172AC_DEFUN([ZFS_AC_CONFIG], [
173
174        dnl # Remove the previous build test directory.
175        rm -Rf build
176
177	ZFS_CONFIG=all
178	AC_ARG_WITH([config],
179		AS_HELP_STRING([--with-config=CONFIG],
180		[Config file 'kernel|user|all|srpm']),
181		[ZFS_CONFIG="$withval"])
182	AC_ARG_ENABLE([linux-builtin],
183		[AC_HELP_STRING([--enable-linux-builtin],
184		[Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
185		[],
186		[enable_linux_builtin=no])
187
188	AC_MSG_CHECKING([zfs config])
189	AC_MSG_RESULT([$ZFS_CONFIG]);
190	AC_SUBST(ZFS_CONFIG)
191
192	ZFS_AC_CONFIG_ALWAYS
193
194
195	AM_COND_IF([BUILD_LINUX], [
196		AC_ARG_VAR([TEST_JOBS],
197		    [simultaneous jobs during configure (defaults to $(nproc))])
198		if test "x$ac_cv_env_TEST_JOBS_set" != "xset"; then
199			TEST_JOBS=$(nproc)
200		fi
201		AC_SUBST(TEST_JOBS)
202	])
203
204	case "$ZFS_CONFIG" in
205		kernel) ZFS_AC_CONFIG_KERNEL ;;
206		user)	ZFS_AC_CONFIG_USER   ;;
207		all)    ZFS_AC_CONFIG_USER
208			ZFS_AC_CONFIG_KERNEL ;;
209		srpm)                        ;;
210		*)
211		AC_MSG_RESULT([Error!])
212		AC_MSG_ERROR([Bad value "$ZFS_CONFIG" for --with-config,
213		              user kernel|user|all|srpm]) ;;
214	esac
215
216	AM_CONDITIONAL([CONFIG_USER],
217	    [test "$ZFS_CONFIG" = user -o "$ZFS_CONFIG" = all])
218	AM_CONDITIONAL([CONFIG_KERNEL],
219	    [test "$ZFS_CONFIG" = kernel -o "$ZFS_CONFIG" = all] &&
220	    [test "x$enable_linux_builtin" != xyes ])
221	AM_CONDITIONAL([CONFIG_QAT],
222	    [test "$ZFS_CONFIG" = kernel -o "$ZFS_CONFIG" = all] &&
223	    [test "x$qatsrc" != x ])
224	AM_CONDITIONAL([WANT_DEVNAME2DEVID], [test "x$user_libudev" = xyes ])
225	AM_CONDITIONAL([WANT_MMAP_LIBAIO], [test "x$user_libaio" = xyes ])
226	AM_CONDITIONAL([PAM_ZFS_ENABLED], [test "x$enable_pam" = xyes])
227])
228
229dnl #
230dnl # Check for rpm+rpmbuild to build RPM packages.  If these tools
231dnl # are missing it is non-fatal but you will not be able to build
232dnl # RPM packages and will be warned if you try too.
233dnl #
234dnl # By default the generic spec file will be used because it requires
235dnl # minimal dependencies.  Distribution specific spec files can be
236dnl # placed under the 'rpm/<distribution>' directory and enabled using
237dnl # the --with-spec=<distribution> configure option.
238dnl #
239AC_DEFUN([ZFS_AC_RPM], [
240	RPM=rpm
241	RPMBUILD=rpmbuild
242
243	AC_MSG_CHECKING([whether $RPM is available])
244	AS_IF([tmp=$($RPM --version 2>/dev/null)], [
245		RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
246		HAVE_RPM=yes
247		AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
248	],[
249		HAVE_RPM=no
250		AC_MSG_RESULT([$HAVE_RPM])
251	])
252
253	AC_MSG_CHECKING([whether $RPMBUILD is available])
254	AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
255		RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
256		HAVE_RPMBUILD=yes
257		AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
258	],[
259		HAVE_RPMBUILD=no
260		AC_MSG_RESULT([$HAVE_RPMBUILD])
261	])
262
263	RPM_DEFINE_COMMON='--define "$(DEBUG_ZFS) 1"'
264	RPM_DEFINE_COMMON=${RPM_DEFINE_COMMON}' --define "$(DEBUGINFO_ZFS) 1"'
265	RPM_DEFINE_COMMON=${RPM_DEFINE_COMMON}' --define "$(DEBUG_KMEM_ZFS) 1"'
266	RPM_DEFINE_COMMON=${RPM_DEFINE_COMMON}' --define "$(DEBUG_KMEM_TRACKING_ZFS) 1"'
267	RPM_DEFINE_COMMON=${RPM_DEFINE_COMMON}' --define "$(ASAN_ZFS) 1"'
268
269	RPM_DEFINE_UTIL=' --define "_initconfdir $(initconfdir)"'
270
271	dnl # Make the next three RPM_DEFINE_UTIL additions conditional, since
272	dnl # their values may not be set when running:
273	dnl #
274	dnl #	./configure --with-config=srpm
275	dnl #
276	AS_IF([test -n "$dracutdir" ], [
277		RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' --define "_dracutdir $(dracutdir)"'
278	])
279	AS_IF([test -n "$udevdir" ], [
280		RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' --define "_udevdir $(udevdir)"'
281	])
282	AS_IF([test -n "$udevruledir" ], [
283		RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' --define "_udevruledir $(udevruledir)"'
284	])
285	RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' $(DEFINE_INITRAMFS)'
286	RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' $(DEFINE_SYSTEMD)'
287	RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' $(DEFINE_PYZFS)'
288	RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' $(DEFINE_PAM)'
289	RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' $(DEFINE_PYTHON_VERSION)'
290	RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' $(DEFINE_PYTHON_PKG_VERSION)'
291
292	dnl # Override default lib directory on Debian/Ubuntu systems.  The
293	dnl # provided /usr/lib/rpm/platform/<arch>/macros files do not
294	dnl # specify the correct path for multiarch systems as described
295	dnl # by the packaging guidelines.
296	dnl #
297	dnl # https://wiki.ubuntu.com/MultiarchSpec
298	dnl # https://wiki.debian.org/Multiarch/Implementation
299	dnl #
300	AS_IF([test "$DEFAULT_PACKAGE" = "deb"], [
301		MULTIARCH_LIBDIR="lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
302		RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' --define "_lib $(MULTIARCH_LIBDIR)"'
303		AC_SUBST(MULTIARCH_LIBDIR)
304	])
305
306	dnl # Make RPM_DEFINE_KMOD additions conditional on CONFIG_KERNEL,
307	dnl # since the values will not be set otherwise. The spec files
308	dnl # provide defaults for them.
309	dnl #
310	RPM_DEFINE_KMOD='--define "_wrong_version_format_terminate_build 0"'
311	AM_COND_IF([CONFIG_KERNEL], [
312		RPM_DEFINE_KMOD=${RPM_DEFINE_KMOD}' --define "kernels $(LINUX_VERSION)"'
313		RPM_DEFINE_KMOD=${RPM_DEFINE_KMOD}' --define "ksrc $(LINUX)"'
314		RPM_DEFINE_KMOD=${RPM_DEFINE_KMOD}' --define "kobj $(LINUX_OBJ)"'
315	])
316
317	RPM_DEFINE_DKMS=''
318
319	SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
320	SRPM_DEFINE_UTIL=
321	SRPM_DEFINE_KMOD=
322	SRPM_DEFINE_DKMS=
323
324	RPM_SPEC_DIR="rpm/generic"
325	AC_ARG_WITH([spec],
326		AS_HELP_STRING([--with-spec=SPEC],
327		[Spec files 'generic|redhat']),
328		[RPM_SPEC_DIR="rpm/$withval"])
329
330	AC_MSG_CHECKING([whether spec files are available])
331	AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
332
333	AC_SUBST(HAVE_RPM)
334	AC_SUBST(RPM)
335	AC_SUBST(RPM_VERSION)
336
337	AC_SUBST(HAVE_RPMBUILD)
338	AC_SUBST(RPMBUILD)
339	AC_SUBST(RPMBUILD_VERSION)
340
341	AC_SUBST(RPM_SPEC_DIR)
342	AC_SUBST(RPM_DEFINE_UTIL)
343	AC_SUBST(RPM_DEFINE_KMOD)
344	AC_SUBST(RPM_DEFINE_DKMS)
345	AC_SUBST(RPM_DEFINE_COMMON)
346	AC_SUBST(SRPM_DEFINE_UTIL)
347	AC_SUBST(SRPM_DEFINE_KMOD)
348	AC_SUBST(SRPM_DEFINE_DKMS)
349	AC_SUBST(SRPM_DEFINE_COMMON)
350])
351
352dnl #
353dnl # Check for dpkg+dpkg-buildpackage to build DEB packages.  If these
354dnl # tools are missing it is non-fatal but you will not be able to build
355dnl # DEB packages and will be warned if you try too.
356dnl #
357AC_DEFUN([ZFS_AC_DPKG], [
358	DPKG=dpkg
359	DPKGBUILD=dpkg-buildpackage
360
361	AC_MSG_CHECKING([whether $DPKG is available])
362	AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
363		DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
364		HAVE_DPKG=yes
365		AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
366	],[
367		HAVE_DPKG=no
368		AC_MSG_RESULT([$HAVE_DPKG])
369	])
370
371	AC_MSG_CHECKING([whether $DPKGBUILD is available])
372	AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
373		DPKGBUILD_VERSION=$(echo $tmp | \
374		    $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
375		HAVE_DPKGBUILD=yes
376		AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
377	],[
378		HAVE_DPKGBUILD=no
379		AC_MSG_RESULT([$HAVE_DPKGBUILD])
380	])
381
382	AC_SUBST(HAVE_DPKG)
383	AC_SUBST(DPKG)
384	AC_SUBST(DPKG_VERSION)
385
386	AC_SUBST(HAVE_DPKGBUILD)
387	AC_SUBST(DPKGBUILD)
388	AC_SUBST(DPKGBUILD_VERSION)
389])
390
391dnl #
392dnl # Until native packaging for various different packing systems
393dnl # can be added the least we can do is attempt to use alien to
394dnl # convert the RPM packages to the needed package type.  This is
395dnl # a hack but so far it has worked reasonable well.
396dnl #
397AC_DEFUN([ZFS_AC_ALIEN], [
398	ALIEN=alien
399
400	AC_MSG_CHECKING([whether $ALIEN is available])
401	AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
402		ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
403		HAVE_ALIEN=yes
404		AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
405	],[
406		HAVE_ALIEN=no
407		AC_MSG_RESULT([$HAVE_ALIEN])
408	])
409
410	AC_SUBST(HAVE_ALIEN)
411	AC_SUBST(ALIEN)
412	AC_SUBST(ALIEN_VERSION)
413])
414
415dnl #
416dnl # Using the VENDOR tag from config.guess set the default
417dnl # package type for 'make pkg': (rpm | deb | tgz)
418dnl #
419AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
420	AC_MSG_CHECKING([os distribution])
421	AC_ARG_WITH([vendor],
422		[AS_HELP_STRING([--with-vendor],
423			[Distribution vendor @<:@default=check@:>@])],
424		[with_vendor=$withval],
425		[with_vendor=check])
426	AS_IF([test "x$with_vendor" = "xcheck"],[
427		if test -f /etc/toss-release ; then
428			VENDOR=toss ;
429		elif test -f /etc/fedora-release ; then
430			VENDOR=fedora ;
431		elif test -f /etc/redhat-release ; then
432			VENDOR=redhat ;
433		elif test -f /etc/gentoo-release ; then
434			VENDOR=gentoo ;
435		elif test -f /etc/arch-release ; then
436			VENDOR=arch ;
437		elif test -f /etc/SuSE-release ; then
438			VENDOR=sles ;
439		elif test -f /etc/slackware-version ; then
440			VENDOR=slackware ;
441		elif test -f /etc/lunar.release ; then
442			VENDOR=lunar ;
443		elif test -f /etc/lsb-release ; then
444			VENDOR=ubuntu ;
445		elif test -f /etc/debian_version ; then
446			VENDOR=debian ;
447		elif test -f /etc/alpine-release ; then
448			VENDOR=alpine ;
449		elif test -f /bin/freebsd-version ; then
450			VENDOR=freebsd ;
451		else
452			VENDOR= ;
453		fi],
454		[ test "x${with_vendor}" != x],[
455			VENDOR="$with_vendor" ],
456		[ VENDOR= ; ]
457	)
458	AC_MSG_RESULT([$VENDOR])
459	AC_SUBST(VENDOR)
460
461	AC_MSG_CHECKING([default package type])
462	case "$VENDOR" in
463		toss)       DEFAULT_PACKAGE=rpm  ;;
464		redhat)     DEFAULT_PACKAGE=rpm  ;;
465		fedora)     DEFAULT_PACKAGE=rpm  ;;
466		gentoo)     DEFAULT_PACKAGE=tgz  ;;
467		alpine)     DEFAULT_PACKAGE=tgz  ;;
468		arch)       DEFAULT_PACKAGE=tgz  ;;
469		sles)       DEFAULT_PACKAGE=rpm  ;;
470		slackware)  DEFAULT_PACKAGE=tgz  ;;
471		lunar)      DEFAULT_PACKAGE=tgz  ;;
472		ubuntu)     DEFAULT_PACKAGE=deb  ;;
473		debian)     DEFAULT_PACKAGE=deb  ;;
474		freebsd)    DEFAULT_PACKAGE=pkg  ;;
475		*)          DEFAULT_PACKAGE=rpm  ;;
476	esac
477	AC_MSG_RESULT([$DEFAULT_PACKAGE])
478	AC_SUBST(DEFAULT_PACKAGE)
479
480	AC_MSG_CHECKING([default init directory])
481	case "$VENDOR" in
482		freebsd)    initdir=$sysconfdir/rc.d  ;;
483		*)          initdir=$sysconfdir/init.d;;
484	esac
485	AC_MSG_RESULT([$initdir])
486	AC_SUBST(initdir)
487
488	AC_MSG_CHECKING([default init script type and shell])
489	case "$VENDOR" in
490		toss)       DEFAULT_INIT_SCRIPT=redhat ;;
491		redhat)     DEFAULT_INIT_SCRIPT=redhat ;;
492		fedora)     DEFAULT_INIT_SCRIPT=fedora ;;
493		gentoo)     DEFAULT_INIT_SCRIPT=openrc ;;
494		alpine)     DEFAULT_INIT_SCRIPT=openrc ;;
495		arch)       DEFAULT_INIT_SCRIPT=lsb    ;;
496		sles)       DEFAULT_INIT_SCRIPT=lsb    ;;
497		slackware)  DEFAULT_INIT_SCRIPT=lsb    ;;
498		lunar)      DEFAULT_INIT_SCRIPT=lunar  ;;
499		ubuntu)     DEFAULT_INIT_SCRIPT=lsb    ;;
500		debian)     DEFAULT_INIT_SCRIPT=lsb    ;;
501		freebsd)    DEFAULT_INIT_SCRIPT=freebsd;;
502		*)          DEFAULT_INIT_SCRIPT=lsb    ;;
503	esac
504
505	# On gentoo, it's possible that OpenRC isn't installed.  Check if
506	# /sbin/openrc-run exists, and if not, fall back to generic defaults.
507
508	DEFAULT_INIT_SHELL="/bin/sh"
509	AS_IF([test "$DEFAULT_INIT_SCRIPT" = "openrc"], [
510		AS_IF([test -x "/sbin/openrc-run"],
511			[DEFAULT_INIT_SHELL="/sbin/openrc-run"],
512			[DEFAULT_INIT_SCRIPT=lsb])
513	])
514
515	AC_MSG_RESULT([$DEFAULT_INIT_SCRIPT:$DEFAULT_INIT_SHELL])
516	AC_SUBST(DEFAULT_INIT_SCRIPT)
517	AC_SUBST(DEFAULT_INIT_SHELL)
518
519	AC_MSG_CHECKING([default nfs server init script])
520	AS_IF([test "$VENDOR" = "debian"],
521		[DEFAULT_INIT_NFS_SERVER="nfs-kernel-server"],
522		[DEFAULT_INIT_NFS_SERVER="nfs"]
523	)
524	AC_MSG_RESULT([$DEFAULT_INIT_NFS_SERVER])
525	AC_SUBST(DEFAULT_INIT_NFS_SERVER)
526
527	AC_MSG_CHECKING([default init config directory])
528	case "$VENDOR" in
529		alpine)     initconfdir=/etc/conf.d    ;;
530		gentoo)     initconfdir=/etc/conf.d    ;;
531		toss)       initconfdir=/etc/sysconfig ;;
532		redhat)     initconfdir=/etc/sysconfig ;;
533		fedora)     initconfdir=/etc/sysconfig ;;
534		sles)       initconfdir=/etc/sysconfig ;;
535		ubuntu)     initconfdir=/etc/default   ;;
536		debian)     initconfdir=/etc/default   ;;
537		freebsd)    initconfdir=$sysconfdir/rc.conf.d;;
538		*)          initconfdir=/etc/default   ;;
539	esac
540	AC_MSG_RESULT([$initconfdir])
541	AC_SUBST(initconfdir)
542
543	AC_MSG_CHECKING([whether initramfs-tools is available])
544	if test -d /usr/share/initramfs-tools ; then
545		DEFINE_INITRAMFS='--define "_initramfs 1"'
546		AC_MSG_RESULT([yes])
547	else
548		DEFINE_INITRAMFS=''
549		AC_MSG_RESULT([no])
550	fi
551	AC_SUBST(DEFINE_INITRAMFS)
552])
553
554dnl #
555dnl # Default ZFS package configuration
556dnl #
557AC_DEFUN([ZFS_AC_PACKAGE], [
558	ZFS_AC_DEFAULT_PACKAGE
559	AS_IF([test x$VENDOR != xfreebsd], [
560		ZFS_AC_RPM
561		ZFS_AC_DPKG
562		ZFS_AC_ALIEN
563	])
564])
565