]> git.proxmox.com Git - mirror_zfs.git/blame - config/zfs-build.m4
OpenZFS 8965 - zfs_acl_ls_001_pos fails due to no longer supported grep regex
[mirror_zfs.git] / config / zfs-build.m4
CommitLineData
c9c0d073
BB
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
6f174823 9AC_DEFUN([ZFS_AC_DEBUG_ENABLE], [
fed90353
BB
10 DEBUG_CFLAGS="-Werror"
11 DEBUG_CPPFLAGS="-DDEBUG -UNDEBUG"
12 DEBUG_LDFLAGS=""
6f174823
RY
13 DEBUG_ZFS="_with_debug"
14 AC_DEFINE(ZFS_DEBUG, 1, [zfs debugging enabled])
fed90353
BB
15
16 KERNEL_DEBUG_CFLAGS="-Werror"
17 KERNEL_DEBUG_CPPFLAGS="-DDEBUG -UNDEBUG"
6f174823
RY
18])
19
20AC_DEFUN([ZFS_AC_DEBUG_DISABLE], [
fed90353
BB
21 DEBUG_CFLAGS=""
22 DEBUG_CPPFLAGS="-UDEBUG -DNDEBUG"
23 DEBUG_LDFLAGS=""
6f174823 24 DEBUG_ZFS="_without_debug"
fed90353
BB
25
26 KERNEL_DEBUG_CFLAGS=""
27 KERNEL_DEBUG_CPPFLAGS="-UDEBUG -DNDEBUG"
6f174823
RY
28])
29
fed90353
BB
30dnl #
31dnl # When debugging is enabled:
32dnl # - Enable all ASSERTs (-DDEBUG)
33dnl # - Promote all compiler warnings to errors (-Werror)
34dnl #
c9c0d073 35AC_DEFUN([ZFS_AC_DEBUG], [
6f174823 36 AC_MSG_CHECKING([whether assertion support will be enabled])
c9c0d073
BB
37 AC_ARG_ENABLE([debug],
38 [AS_HELP_STRING([--enable-debug],
fed90353 39 [Enable compiler and code assertions @<:@default=no@:>@])],
c9c0d073
BB
40 [],
41 [enable_debug=no])
42
6f174823
RY
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])])
c9c0d073 49
fed90353
BB
50 AC_SUBST(DEBUG_CFLAGS)
51 AC_SUBST(DEBUG_CPPFLAGS)
52 AC_SUBST(DEBUG_LDFLAGS)
4b787d75 53 AC_SUBST(DEBUG_ZFS)
fed90353
BB
54
55 AC_SUBST(KERNEL_DEBUG_CFLAGS)
56 AC_SUBST(KERNEL_DEBUG_CPPFLAGS)
57
c9c0d073
BB
58 AC_MSG_RESULT([$enable_debug])
59])
60
fed90353
BB
61AC_DEFUN([ZFS_AC_DEBUGINFO_ENABLE], [
62 DEBUG_CFLAGS="$DEBUG_CFLAGS -g -fno-inline"
63
64 KERNEL_DEBUG_CFLAGS="$KERNEL_DEBUG_CFLAGS -fno-inline"
65 KERNEL_MAKE="$KERNEL_MAKE CONFIG_DEBUG_INFO=y"
66
67 DEBUGINFO_ZFS="_with_debuginfo"
0d3980ac
RY
68])
69
fed90353
BB
70AC_DEFUN([ZFS_AC_DEBUGINFO_DISABLE], [
71 DEBUGINFO_ZFS="_without_debuginfo"
0d3980ac
RY
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"],
fed90353 84 [ZFS_AC_DEBUGINFO_ENABLE],
0d3980ac 85 ["xno"],
fed90353
BB
86 [ZFS_AC_DEBUGINFO_DISABLE],
87 [AC_MSG_ERROR([Unknown option $enable_debuginfo])])
0d3980ac
RY
88
89 AC_SUBST(DEBUG_CFLAGS)
fed90353
BB
90 AC_SUBST(DEBUGINFO_ZFS)
91
92 AC_SUBST(KERNEL_DEBUG_CFLAGS)
93 AC_SUBST(KERNEL_MAKE)
94
0d3980ac
RY
95 AC_MSG_RESULT([$enable_debuginfo])
96])
97
2e08aedb 98AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
fed90353
BB
99 ZFS_AC_CONFIG_ALWAYS_CC_NO_UNUSED_BUT_SET_VARIABLE
100 ZFS_AC_CONFIG_ALWAYS_CC_NO_BOOL_COMPARE
101 ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN
102 ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION
103 ZFS_AC_CONFIG_ALWAYS_CC_ASAN
fc0c72b1 104 ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD
0b04990a 105 ZFS_AC_CONFIG_ALWAYS_ARCH
2e08aedb
BB
106])
107
c9c0d073 108AC_DEFUN([ZFS_AC_CONFIG], [
c9c0d073
BB
109 ZFS_CONFIG=all
110 AC_ARG_WITH([config],
111 AS_HELP_STRING([--with-config=CONFIG],
112 [Config file 'kernel|user|all|srpm']),
113 [ZFS_CONFIG="$withval"])
319a99a3
ED
114 AC_ARG_ENABLE([linux-builtin],
115 [AC_HELP_STRING([--enable-linux-builtin],
116 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
117 [],
118 [enable_linux_builtin=no])
c9c0d073
BB
119
120 AC_MSG_CHECKING([zfs config])
121 AC_MSG_RESULT([$ZFS_CONFIG]);
122 AC_SUBST(ZFS_CONFIG)
123
2e08aedb
BB
124 ZFS_AC_CONFIG_ALWAYS
125
c9c0d073
BB
126 case "$ZFS_CONFIG" in
127 kernel) ZFS_AC_CONFIG_KERNEL ;;
128 user) ZFS_AC_CONFIG_USER ;;
6bb24f4d
BB
129 all) ZFS_AC_CONFIG_USER
130 ZFS_AC_CONFIG_KERNEL ;;
c9c0d073
BB
131 srpm) ;;
132 *)
133 AC_MSG_RESULT([Error!])
134 AC_MSG_ERROR([Bad value "$ZFS_CONFIG" for --with-config,
135 user kernel|user|all|srpm]) ;;
136 esac
137
138 AM_CONDITIONAL([CONFIG_USER],
63e0828c 139 [test "$ZFS_CONFIG" = user -o "$ZFS_CONFIG" = all])
c9c0d073 140 AM_CONDITIONAL([CONFIG_KERNEL],
63e0828c
BB
141 [test "$ZFS_CONFIG" = kernel -o "$ZFS_CONFIG" = all] &&
142 [test "x$enable_linux_builtin" != xyes ])
143 AM_CONDITIONAL([WANT_DEVNAME2DEVID],
144 [test "x$user_libudev" = xyes ])
6a9d6359 145 AM_CONDITIONAL([CONFIG_QAT],
146 [test "$ZFS_CONFIG" = kernel -o "$ZFS_CONFIG" = all] &&
147 [test "x$qatsrc" != x ])
c9c0d073
BB
148])
149
150dnl #
151dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
152dnl # are missing it is non-fatal but you will not be able to build
153dnl # RPM packages and will be warned if you try too.
154dnl #
f3757573
BB
155dnl # By default the generic spec file will be used because it requires
156dnl # minimal dependencies. Distribution specific spec files can be
157dnl # placed under the 'rpm/<distribution>' directory and enabled using
158dnl # the --with-spec=<distribution> configure option.
159dnl #
c9c0d073
BB
160AC_DEFUN([ZFS_AC_RPM], [
161 RPM=rpm
162 RPMBUILD=rpmbuild
163
164 AC_MSG_CHECKING([whether $RPM is available])
165 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
166 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
167 HAVE_RPM=yes
168 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
169 ],[
170 HAVE_RPM=no
171 AC_MSG_RESULT([$HAVE_RPM])
172 ])
173
174 AC_MSG_CHECKING([whether $RPMBUILD is available])
175 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
176 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
177 HAVE_RPMBUILD=yes
178 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
179 ],[
180 HAVE_RPMBUILD=no
181 AC_MSG_RESULT([$HAVE_RPMBUILD])
182 ])
183
3ec3bc21 184 RPM_DEFINE_COMMON='--define "$(DEBUG_ZFS) 1"'
fed90353
BB
185 RPM_DEFINE_COMMON+=' --define "$(DEBUGINFO_ZFS) 1"'
186 RPM_DEFINE_COMMON+=' --define "$(ASAN_ZFS) 1"'
187
188 RPM_DEFINE_UTIL='--define "_dracutdir $(dracutdir)"'
189 RPM_DEFINE_UTIL+=' --define "_udevdir $(udevdir)"'
190 RPM_DEFINE_UTIL+=' --define "_udevruledir $(udevruledir)"'
191 RPM_DEFINE_UTIL+=' --define "_initconfdir $(DEFAULT_INITCONF_DIR)"'
192 RPM_DEFINE_UTIL+=' $(DEFINE_INITRAMFS)'
193 RPM_DEFINE_UTIL+=' $(DEFINE_SYSTEMD)'
194
3d25488a
BB
195 dnl # Override default lib directory on Debian/Ubuntu systems. The provided
196 dnl # /usr/lib/rpm/platform/<arch>/macros files do not specify the correct
197 dnl # path for multiarch systems as described by the packaging guidelines.
198 dnl #
199 dnl # https://wiki.ubuntu.com/MultiarchSpec
200 dnl # https://wiki.debian.org/Multiarch/Implementation
201 dnl #
202 AS_IF([test "$DEFAULT_PACKAGE" = "deb"], [
203 MULTIARCH_LIBDIR="lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
204 RPM_DEFINE_UTIL+=' --define "_lib $(MULTIARCH_LIBDIR)"'
205 AC_SUBST(MULTIARCH_LIBDIR)
206 ])
207
fed90353
BB
208 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
209 RPM_DEFINE_KMOD+=' --define "require_spldir $(SPL)"'
210 RPM_DEFINE_KMOD+=' --define "require_splobj $(SPL_OBJ)"'
211 RPM_DEFINE_KMOD+=' --define "ksrc $(LINUX)"'
212 RPM_DEFINE_KMOD+=' --define "kobj $(LINUX_OBJ)"'
213
214 RPM_DEFINE_DKMS=''
f3757573
BB
215
216 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
217 SRPM_DEFINE_UTIL=
218 SRPM_DEFINE_KMOD=
219 SRPM_DEFINE_DKMS=
220
221 RPM_SPEC_DIR="rpm/generic"
222 AC_ARG_WITH([spec],
223 AS_HELP_STRING([--with-spec=SPEC],
ee2ca1db 224 [Spec files 'generic|redhat']),
f3757573
BB
225 [RPM_SPEC_DIR="rpm/$withval"])
226
227 AC_MSG_CHECKING([whether spec files are available])
228 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
229
c9c0d073
BB
230 AC_SUBST(HAVE_RPM)
231 AC_SUBST(RPM)
232 AC_SUBST(RPM_VERSION)
233
234 AC_SUBST(HAVE_RPMBUILD)
235 AC_SUBST(RPMBUILD)
236 AC_SUBST(RPMBUILD_VERSION)
f3757573
BB
237
238 AC_SUBST(RPM_SPEC_DIR)
239 AC_SUBST(RPM_DEFINE_UTIL)
240 AC_SUBST(RPM_DEFINE_KMOD)
241 AC_SUBST(RPM_DEFINE_DKMS)
242 AC_SUBST(RPM_DEFINE_COMMON)
243 AC_SUBST(SRPM_DEFINE_UTIL)
244 AC_SUBST(SRPM_DEFINE_KMOD)
245 AC_SUBST(SRPM_DEFINE_DKMS)
246 AC_SUBST(SRPM_DEFINE_COMMON)
c9c0d073
BB
247])
248
249dnl #
250dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
251dnl # tools are missing it is non-fatal but you will not be able to build
252dnl # DEB packages and will be warned if you try too.
253dnl #
254AC_DEFUN([ZFS_AC_DPKG], [
255 DPKG=dpkg
256 DPKGBUILD=dpkg-buildpackage
257
258 AC_MSG_CHECKING([whether $DPKG is available])
259 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
260 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
261 HAVE_DPKG=yes
262 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
263 ],[
264 HAVE_DPKG=no
265 AC_MSG_RESULT([$HAVE_DPKG])
266 ])
267
268 AC_MSG_CHECKING([whether $DPKGBUILD is available])
269 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
270 DPKGBUILD_VERSION=$(echo $tmp | \
271 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
272 HAVE_DPKGBUILD=yes
273 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
274 ],[
275 HAVE_DPKGBUILD=no
276 AC_MSG_RESULT([$HAVE_DPKGBUILD])
277 ])
278
279 AC_SUBST(HAVE_DPKG)
280 AC_SUBST(DPKG)
281 AC_SUBST(DPKG_VERSION)
282
283 AC_SUBST(HAVE_DPKGBUILD)
284 AC_SUBST(DPKGBUILD)
285 AC_SUBST(DPKGBUILD_VERSION)
286])
287
288dnl #
289dnl # Until native packaging for various different packing systems
290dnl # can be added the least we can do is attempt to use alien to
291dnl # convert the RPM packages to the needed package type. This is
292dnl # a hack but so far it has worked reasonable well.
293dnl #
294AC_DEFUN([ZFS_AC_ALIEN], [
295 ALIEN=alien
296
297 AC_MSG_CHECKING([whether $ALIEN is available])
298 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
299 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
300 HAVE_ALIEN=yes
301 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
302 ],[
303 HAVE_ALIEN=no
304 AC_MSG_RESULT([$HAVE_ALIEN])
305 ])
306
307 AC_SUBST(HAVE_ALIEN)
308 AC_SUBST(ALIEN)
309 AC_SUBST(ALIEN_VERSION)
310])
311
312dnl #
313dnl # Using the VENDOR tag from config.guess set the default
314dnl # package type for 'make pkg': (rpm | deb | tgz)
315dnl #
316AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
317 AC_MSG_CHECKING([linux distribution])
76c2b24c
RY
318 if test -f /etc/toss-release ; then
319 VENDOR=toss ;
c9c0d073
BB
320 elif test -f /etc/fedora-release ; then
321 VENDOR=fedora ;
76c2b24c
RY
322 elif test -f /etc/redhat-release ; then
323 VENDOR=redhat ;
d9bfe0f5
AS
324 elif test -f /etc/gentoo-release ; then
325 VENDOR=gentoo ;
76c2b24c
RY
326 elif test -f /etc/arch-release ; then
327 VENDOR=arch ;
c9c0d073
BB
328 elif test -f /etc/SuSE-release ; then
329 VENDOR=sles ;
330 elif test -f /etc/slackware-version ; then
331 VENDOR=slackware ;
712f8bd8
BB
332 elif test -f /etc/lunar.release ; then
333 VENDOR=lunar ;
76c2b24c
RY
334 elif test -f /etc/lsb-release ; then
335 VENDOR=ubuntu ;
336 elif test -f /etc/debian_version ; then
337 VENDOR=debian ;
c53fb011
CL
338 elif test -f /etc/alpine-release ; then
339 VENDOR=alpine ;
c9c0d073
BB
340 else
341 VENDOR= ;
342 fi
343 AC_MSG_RESULT([$VENDOR])
344 AC_SUBST(VENDOR)
345
346 AC_MSG_CHECKING([default package type])
347 case "$VENDOR" in
76c2b24c
RY
348 toss) DEFAULT_PACKAGE=rpm ;;
349 redhat) DEFAULT_PACKAGE=rpm ;;
350 fedora) DEFAULT_PACKAGE=rpm ;;
351 gentoo) DEFAULT_PACKAGE=tgz ;;
c53fb011 352 alpine) DEFAULT_PACKAGE=tgz ;;
0da31cd6 353 arch) DEFAULT_PACKAGE=tgz ;;
76c2b24c
RY
354 sles) DEFAULT_PACKAGE=rpm ;;
355 slackware) DEFAULT_PACKAGE=tgz ;;
356 lunar) DEFAULT_PACKAGE=tgz ;;
357 ubuntu) DEFAULT_PACKAGE=deb ;;
358 debian) DEFAULT_PACKAGE=deb ;;
359 *) DEFAULT_PACKAGE=rpm ;;
c9c0d073 360 esac
c9c0d073
BB
361 AC_MSG_RESULT([$DEFAULT_PACKAGE])
362 AC_SUBST(DEFAULT_PACKAGE)
01c0e61d 363
0da31cd6 364 DEFAULT_INIT_DIR=$sysconfdir/init.d
615ab66d 365 AC_MSG_CHECKING([default init directory])
615ab66d
KF
366 AC_MSG_RESULT([$DEFAULT_INIT_DIR])
367 AC_SUBST(DEFAULT_INIT_DIR)
368
01c0e61d
BB
369 AC_MSG_CHECKING([default init script type])
370 case "$VENDOR" in
76c2b24c 371 toss) DEFAULT_INIT_SCRIPT=redhat ;;
712f8bd8 372 redhat) DEFAULT_INIT_SCRIPT=redhat ;;
01c0e61d 373 fedora) DEFAULT_INIT_SCRIPT=fedora ;;
c53fb011
CL
374 gentoo) DEFAULT_INIT_SCRIPT=openrc ;;
375 alpine) DEFAULT_INIT_SCRIPT=openrc ;;
0da31cd6 376 arch) DEFAULT_INIT_SCRIPT=lsb ;;
76c2b24c
RY
377 sles) DEFAULT_INIT_SCRIPT=lsb ;;
378 slackware) DEFAULT_INIT_SCRIPT=lsb ;;
379 lunar) DEFAULT_INIT_SCRIPT=lunar ;;
380 ubuntu) DEFAULT_INIT_SCRIPT=lsb ;;
381 debian) DEFAULT_INIT_SCRIPT=lsb ;;
382 *) DEFAULT_INIT_SCRIPT=lsb ;;
01c0e61d 383 esac
01c0e61d
BB
384 AC_MSG_RESULT([$DEFAULT_INIT_SCRIPT])
385 AC_SUBST(DEFAULT_INIT_SCRIPT)
2a34db1b
TF
386
387 AC_MSG_CHECKING([default init config direectory])
388 case "$VENDOR" in
c53fb011 389 alpine) DEFAULT_INITCONF_DIR=/etc/conf.d ;;
2a34db1b
TF
390 gentoo) DEFAULT_INITCONF_DIR=/etc/conf.d ;;
391 toss) DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
392 redhat) DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
393 fedora) DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
394 sles) DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
395 ubuntu) DEFAULT_INITCONF_DIR=/etc/default ;;
396 debian) DEFAULT_INITCONF_DIR=/etc/default ;;
397 *) DEFAULT_INITCONF_DIR=/etc/default ;;
398 esac
2a34db1b
TF
399 AC_MSG_RESULT([$DEFAULT_INITCONF_DIR])
400 AC_SUBST(DEFAULT_INITCONF_DIR)
2cac7f5f
TF
401
402 AC_MSG_CHECKING([whether initramfs-tools is available])
403 if test -d /usr/share/initramfs-tools ; then
404 DEFINE_INITRAMFS='--define "_initramfs 1"'
405 AC_MSG_RESULT([yes])
406 else
407 DEFINE_INITRAMFS=''
408 AC_MSG_RESULT([no])
409 fi
410 AC_SUBST(DEFINE_INITRAMFS)
c9c0d073
BB
411])
412
413dnl #
414dnl # Default ZFS package configuration
415dnl #
416AC_DEFUN([ZFS_AC_PACKAGE], [
58d956b0 417 ZFS_AC_DEFAULT_PACKAGE
c9c0d073
BB
418 ZFS_AC_RPM
419 ZFS_AC_DPKG
420 ZFS_AC_ALIEN
c9c0d073 421])