]> git.proxmox.com Git - mirror_zfs.git/blame - config/zfs-build.m4
Import pyzfs source code from ClusterHQ
[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 ])
6a9d6359 143 AM_CONDITIONAL([CONFIG_QAT],
144 [test "$ZFS_CONFIG" = kernel -o "$ZFS_CONFIG" = all] &&
145 [test "x$qatsrc" != x ])
b2ab468d
BB
146 AM_CONDITIONAL([WANT_DEVNAME2DEVID], [test "x$user_libudev" = xyes ])
147 AM_CONDITIONAL([WANT_MMAP_LIBAIO], [test "x$user_libaio" = xyes ])
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
9ea6c3d3
TH
188
189 RPM_DEFINE_UTIL=' --define "_initconfdir $(DEFAULT_INITCONF_DIR)"'
190
191 dnl # Make the next three RPM_DEFINE_UTIL additions conditional, since
192 dnl # their values may not be set when running:
193 dnl #
194 dnl # ./configure --with-config=srpm
195 dnl #
196 AS_IF([test -n "$dracutdir" ], [
197 RPM_DEFINE_UTIL='--define "_dracutdir $(dracutdir)"'
198 ])
199 AS_IF([test -n "$udevdir" ], [
200 RPM_DEFINE_UTIL+=' --define "_udevdir $(udevdir)"'
201 ])
202 AS_IF([test -n "$udevruledir" ], [
203 RPM_DEFINE_UTIL+=' --define "_udevdir $(udevruledir)"'
204 ])
fed90353
BB
205 RPM_DEFINE_UTIL+=' $(DEFINE_INITRAMFS)'
206 RPM_DEFINE_UTIL+=' $(DEFINE_SYSTEMD)'
207
3d25488a
BB
208 dnl # Override default lib directory on Debian/Ubuntu systems. The provided
209 dnl # /usr/lib/rpm/platform/<arch>/macros files do not specify the correct
210 dnl # path for multiarch systems as described by the packaging guidelines.
211 dnl #
212 dnl # https://wiki.ubuntu.com/MultiarchSpec
213 dnl # https://wiki.debian.org/Multiarch/Implementation
214 dnl #
215 AS_IF([test "$DEFAULT_PACKAGE" = "deb"], [
216 MULTIARCH_LIBDIR="lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
217 RPM_DEFINE_UTIL+=' --define "_lib $(MULTIARCH_LIBDIR)"'
218 AC_SUBST(MULTIARCH_LIBDIR)
219 ])
220
fed90353
BB
221 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
222 RPM_DEFINE_KMOD+=' --define "require_spldir $(SPL)"'
223 RPM_DEFINE_KMOD+=' --define "require_splobj $(SPL_OBJ)"'
224 RPM_DEFINE_KMOD+=' --define "ksrc $(LINUX)"'
225 RPM_DEFINE_KMOD+=' --define "kobj $(LINUX_OBJ)"'
c45c6d92 226 RPM_DEFINE_KMOD+=' --define "_wrong_version_format_terminate_build 0"'
fed90353
BB
227
228 RPM_DEFINE_DKMS=''
f3757573
BB
229
230 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
231 SRPM_DEFINE_UTIL=
232 SRPM_DEFINE_KMOD=
233 SRPM_DEFINE_DKMS=
234
235 RPM_SPEC_DIR="rpm/generic"
236 AC_ARG_WITH([spec],
237 AS_HELP_STRING([--with-spec=SPEC],
ee2ca1db 238 [Spec files 'generic|redhat']),
f3757573
BB
239 [RPM_SPEC_DIR="rpm/$withval"])
240
241 AC_MSG_CHECKING([whether spec files are available])
242 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
243
c9c0d073
BB
244 AC_SUBST(HAVE_RPM)
245 AC_SUBST(RPM)
246 AC_SUBST(RPM_VERSION)
247
248 AC_SUBST(HAVE_RPMBUILD)
249 AC_SUBST(RPMBUILD)
250 AC_SUBST(RPMBUILD_VERSION)
f3757573
BB
251
252 AC_SUBST(RPM_SPEC_DIR)
253 AC_SUBST(RPM_DEFINE_UTIL)
254 AC_SUBST(RPM_DEFINE_KMOD)
255 AC_SUBST(RPM_DEFINE_DKMS)
256 AC_SUBST(RPM_DEFINE_COMMON)
257 AC_SUBST(SRPM_DEFINE_UTIL)
258 AC_SUBST(SRPM_DEFINE_KMOD)
259 AC_SUBST(SRPM_DEFINE_DKMS)
260 AC_SUBST(SRPM_DEFINE_COMMON)
c9c0d073
BB
261])
262
263dnl #
264dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
265dnl # tools are missing it is non-fatal but you will not be able to build
266dnl # DEB packages and will be warned if you try too.
267dnl #
268AC_DEFUN([ZFS_AC_DPKG], [
269 DPKG=dpkg
270 DPKGBUILD=dpkg-buildpackage
271
272 AC_MSG_CHECKING([whether $DPKG is available])
273 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
274 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
275 HAVE_DPKG=yes
276 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
277 ],[
278 HAVE_DPKG=no
279 AC_MSG_RESULT([$HAVE_DPKG])
280 ])
281
282 AC_MSG_CHECKING([whether $DPKGBUILD is available])
283 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
284 DPKGBUILD_VERSION=$(echo $tmp | \
285 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
286 HAVE_DPKGBUILD=yes
287 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
288 ],[
289 HAVE_DPKGBUILD=no
290 AC_MSG_RESULT([$HAVE_DPKGBUILD])
291 ])
292
293 AC_SUBST(HAVE_DPKG)
294 AC_SUBST(DPKG)
295 AC_SUBST(DPKG_VERSION)
296
297 AC_SUBST(HAVE_DPKGBUILD)
298 AC_SUBST(DPKGBUILD)
299 AC_SUBST(DPKGBUILD_VERSION)
300])
301
302dnl #
303dnl # Until native packaging for various different packing systems
304dnl # can be added the least we can do is attempt to use alien to
305dnl # convert the RPM packages to the needed package type. This is
306dnl # a hack but so far it has worked reasonable well.
307dnl #
308AC_DEFUN([ZFS_AC_ALIEN], [
309 ALIEN=alien
310
311 AC_MSG_CHECKING([whether $ALIEN is available])
312 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
313 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
314 HAVE_ALIEN=yes
315 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
316 ],[
317 HAVE_ALIEN=no
318 AC_MSG_RESULT([$HAVE_ALIEN])
319 ])
320
321 AC_SUBST(HAVE_ALIEN)
322 AC_SUBST(ALIEN)
323 AC_SUBST(ALIEN_VERSION)
324])
325
326dnl #
327dnl # Using the VENDOR tag from config.guess set the default
328dnl # package type for 'make pkg': (rpm | deb | tgz)
329dnl #
330AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
331 AC_MSG_CHECKING([linux distribution])
76c2b24c
RY
332 if test -f /etc/toss-release ; then
333 VENDOR=toss ;
c9c0d073
BB
334 elif test -f /etc/fedora-release ; then
335 VENDOR=fedora ;
76c2b24c
RY
336 elif test -f /etc/redhat-release ; then
337 VENDOR=redhat ;
d9bfe0f5
AS
338 elif test -f /etc/gentoo-release ; then
339 VENDOR=gentoo ;
76c2b24c
RY
340 elif test -f /etc/arch-release ; then
341 VENDOR=arch ;
c9c0d073
BB
342 elif test -f /etc/SuSE-release ; then
343 VENDOR=sles ;
344 elif test -f /etc/slackware-version ; then
345 VENDOR=slackware ;
712f8bd8
BB
346 elif test -f /etc/lunar.release ; then
347 VENDOR=lunar ;
76c2b24c
RY
348 elif test -f /etc/lsb-release ; then
349 VENDOR=ubuntu ;
350 elif test -f /etc/debian_version ; then
351 VENDOR=debian ;
c53fb011
CL
352 elif test -f /etc/alpine-release ; then
353 VENDOR=alpine ;
c9c0d073
BB
354 else
355 VENDOR= ;
356 fi
357 AC_MSG_RESULT([$VENDOR])
358 AC_SUBST(VENDOR)
359
360 AC_MSG_CHECKING([default package type])
361 case "$VENDOR" in
76c2b24c
RY
362 toss) DEFAULT_PACKAGE=rpm ;;
363 redhat) DEFAULT_PACKAGE=rpm ;;
364 fedora) DEFAULT_PACKAGE=rpm ;;
365 gentoo) DEFAULT_PACKAGE=tgz ;;
c53fb011 366 alpine) DEFAULT_PACKAGE=tgz ;;
0da31cd6 367 arch) DEFAULT_PACKAGE=tgz ;;
76c2b24c
RY
368 sles) DEFAULT_PACKAGE=rpm ;;
369 slackware) DEFAULT_PACKAGE=tgz ;;
370 lunar) DEFAULT_PACKAGE=tgz ;;
371 ubuntu) DEFAULT_PACKAGE=deb ;;
372 debian) DEFAULT_PACKAGE=deb ;;
373 *) DEFAULT_PACKAGE=rpm ;;
c9c0d073 374 esac
c9c0d073
BB
375 AC_MSG_RESULT([$DEFAULT_PACKAGE])
376 AC_SUBST(DEFAULT_PACKAGE)
01c0e61d 377
0da31cd6 378 DEFAULT_INIT_DIR=$sysconfdir/init.d
615ab66d 379 AC_MSG_CHECKING([default init directory])
615ab66d
KF
380 AC_MSG_RESULT([$DEFAULT_INIT_DIR])
381 AC_SUBST(DEFAULT_INIT_DIR)
382
01c0e61d
BB
383 AC_MSG_CHECKING([default init script type])
384 case "$VENDOR" in
76c2b24c 385 toss) DEFAULT_INIT_SCRIPT=redhat ;;
712f8bd8 386 redhat) DEFAULT_INIT_SCRIPT=redhat ;;
01c0e61d 387 fedora) DEFAULT_INIT_SCRIPT=fedora ;;
c53fb011
CL
388 gentoo) DEFAULT_INIT_SCRIPT=openrc ;;
389 alpine) DEFAULT_INIT_SCRIPT=openrc ;;
0da31cd6 390 arch) DEFAULT_INIT_SCRIPT=lsb ;;
76c2b24c
RY
391 sles) DEFAULT_INIT_SCRIPT=lsb ;;
392 slackware) DEFAULT_INIT_SCRIPT=lsb ;;
393 lunar) DEFAULT_INIT_SCRIPT=lunar ;;
394 ubuntu) DEFAULT_INIT_SCRIPT=lsb ;;
395 debian) DEFAULT_INIT_SCRIPT=lsb ;;
396 *) DEFAULT_INIT_SCRIPT=lsb ;;
01c0e61d 397 esac
01c0e61d
BB
398 AC_MSG_RESULT([$DEFAULT_INIT_SCRIPT])
399 AC_SUBST(DEFAULT_INIT_SCRIPT)
2a34db1b
TF
400
401 AC_MSG_CHECKING([default init config direectory])
402 case "$VENDOR" in
c53fb011 403 alpine) DEFAULT_INITCONF_DIR=/etc/conf.d ;;
2a34db1b
TF
404 gentoo) DEFAULT_INITCONF_DIR=/etc/conf.d ;;
405 toss) DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
406 redhat) DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
407 fedora) DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
408 sles) DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
409 ubuntu) DEFAULT_INITCONF_DIR=/etc/default ;;
410 debian) DEFAULT_INITCONF_DIR=/etc/default ;;
411 *) DEFAULT_INITCONF_DIR=/etc/default ;;
412 esac
2a34db1b
TF
413 AC_MSG_RESULT([$DEFAULT_INITCONF_DIR])
414 AC_SUBST(DEFAULT_INITCONF_DIR)
2cac7f5f
TF
415
416 AC_MSG_CHECKING([whether initramfs-tools is available])
417 if test -d /usr/share/initramfs-tools ; then
418 DEFINE_INITRAMFS='--define "_initramfs 1"'
419 AC_MSG_RESULT([yes])
420 else
421 DEFINE_INITRAMFS=''
422 AC_MSG_RESULT([no])
423 fi
424 AC_SUBST(DEFINE_INITRAMFS)
c9c0d073
BB
425])
426
427dnl #
428dnl # Default ZFS package configuration
429dnl #
430AC_DEFUN([ZFS_AC_PACKAGE], [
58d956b0 431 ZFS_AC_DEFAULT_PACKAGE
c9c0d073
BB
432 ZFS_AC_RPM
433 ZFS_AC_DPKG
434 ZFS_AC_ALIEN
c9c0d073 435])