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