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