]> granicus.if.org Git - zfs/blob - config/zfs-build.m4
Implement --enable-debuginfo to force debuginfo
[zfs] / config / zfs-build.m4
1 AC_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
9 AC_DEFUN([ZFS_AC_DEBUG_ENABLE], [
10         KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
11         HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG -Werror"
12         DEBUG_CFLAGS="-DDEBUG -Werror"
13         DEBUG_STACKFLAGS="-fstack-check"
14         DEBUG_ZFS="_with_debug"
15         AC_DEFINE(ZFS_DEBUG, 1, [zfs debugging enabled])
16 ])
17
18 AC_DEFUN([ZFS_AC_DEBUG_DISABLE], [
19         KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG "
20         HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG "
21         DEBUG_CFLAGS="-DNDEBUG"
22         DEBUG_STACKFLAGS=""
23         DEBUG_ZFS="_without_debug"
24 ])
25
26 AC_DEFUN([ZFS_AC_DEBUG], [
27         AC_MSG_CHECKING([whether assertion support will be enabled])
28         AC_ARG_ENABLE([debug],
29                 [AS_HELP_STRING([--enable-debug],
30                 [Enable assertion support @<:@default=no@:>@])],
31                 [],
32                 [enable_debug=no])
33
34         AS_CASE(["x$enable_debug"],
35                 ["xyes"],
36                 [ZFS_AC_DEBUG_ENABLE],
37                 ["xno"],
38                 [ZFS_AC_DEBUG_DISABLE],
39                 [AC_MSG_ERROR([Unknown option $enable_debug])])
40
41         AC_SUBST(DEBUG_STACKFLAGS)
42         AC_SUBST(DEBUG_ZFS)
43         AC_MSG_RESULT([$enable_debug])
44 ])
45
46 AC_DEFUN([ZFS_AC_DEBUGINFO_KERNEL], [
47         KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS CONFIG_DEBUG_INFO=y"
48 ])
49
50 AC_DEFUN([ZFS_AC_DEBUGINFO_USER], [
51         DEBUG_CFLAGS="$DEBUG_CFLAGS -g"
52 ])
53
54 AC_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
78 AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
79         ZFS_AC_CONFIG_ALWAYS_NO_UNUSED_BUT_SET_VARIABLE
80         ZFS_AC_CONFIG_ALWAYS_NO_BOOL_COMPARE
81         ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD
82         ZFS_AC_CONFIG_ALWAYS_ARCH
83 ])
84
85 AC_DEFUN([ZFS_AC_CONFIG], [
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"])
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])
96
97         AC_MSG_CHECKING([zfs config])
98         AC_MSG_RESULT([$ZFS_CONFIG]);
99         AC_SUBST(ZFS_CONFIG)
100
101         ZFS_AC_CONFIG_ALWAYS
102
103         case "$ZFS_CONFIG" in
104                 kernel) ZFS_AC_CONFIG_KERNEL ;;
105                 user)   ZFS_AC_CONFIG_USER   ;;
106                 all)    ZFS_AC_CONFIG_USER
107                         ZFS_AC_CONFIG_KERNEL ;;
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],
116             [test "$ZFS_CONFIG" = user -o "$ZFS_CONFIG" = all])
117         AM_CONDITIONAL([CONFIG_KERNEL],
118             [test "$ZFS_CONFIG" = kernel -o "$ZFS_CONFIG" = all] &&
119             [test "x$enable_linux_builtin" != xyes ])
120         AM_CONDITIONAL([WANT_DEVNAME2DEVID],
121             [test "x$user_libudev" = xyes ])
122         AM_CONDITIONAL([CONFIG_QAT],
123             [test "$ZFS_CONFIG" = kernel -o "$ZFS_CONFIG" = all] &&
124             [test "x$qatsrc" != x ])
125 ])
126
127 dnl #
128 dnl # Check for rpm+rpmbuild to build RPM packages.  If these tools
129 dnl # are missing it is non-fatal but you will not be able to build
130 dnl # RPM packages and will be warned if you try too.
131 dnl #
132 dnl # By default the generic spec file will be used because it requires
133 dnl # minimal dependencies.  Distribution specific spec files can be
134 dnl # placed under the 'rpm/<distribution>' directory and enabled using
135 dnl # the --with-spec=<distribution> configure option.
136 dnl #
137 AC_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
161         RPM_DEFINE_COMMON='--define "$(DEBUG_ZFS) 1"'
162         RPM_DEFINE_UTIL='--define "_dracutdir $(dracutdir)" --define "_udevdir $(udevdir)" --define "_udevruledir $(udevruledir)" --define "_initconfdir $(DEFAULT_INITCONF_DIR)" $(DEFINE_INITRAMFS)'
163         RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)" --define "require_spldir $(SPL)" --define "require_splobj $(SPL_OBJ)" --define "ksrc $(LINUX)" --define "kobj $(LINUX_OBJ)"'
164         RPM_DEFINE_DKMS=
165
166         SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
167         SRPM_DEFINE_UTIL=
168         SRPM_DEFINE_KMOD=
169         SRPM_DEFINE_DKMS=
170
171         RPM_SPEC_DIR="rpm/generic"
172         AC_ARG_WITH([spec],
173                 AS_HELP_STRING([--with-spec=SPEC],
174                 [Spec files 'generic|redhat']),
175                 [RPM_SPEC_DIR="rpm/$withval"])
176
177         AC_MSG_CHECKING([whether spec files are available])
178         AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
179
180         AC_SUBST(HAVE_RPM)
181         AC_SUBST(RPM)
182         AC_SUBST(RPM_VERSION)
183
184         AC_SUBST(HAVE_RPMBUILD)
185         AC_SUBST(RPMBUILD)
186         AC_SUBST(RPMBUILD_VERSION)
187
188         AC_SUBST(RPM_SPEC_DIR)
189         AC_SUBST(RPM_DEFINE_UTIL)
190         AC_SUBST(RPM_DEFINE_KMOD)
191         AC_SUBST(RPM_DEFINE_DKMS)
192         AC_SUBST(RPM_DEFINE_COMMON)
193         AC_SUBST(SRPM_DEFINE_UTIL)
194         AC_SUBST(SRPM_DEFINE_KMOD)
195         AC_SUBST(SRPM_DEFINE_DKMS)
196         AC_SUBST(SRPM_DEFINE_COMMON)
197 ])
198
199 dnl #
200 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages.  If these
201 dnl # tools are missing it is non-fatal but you will not be able to build
202 dnl # DEB packages and will be warned if you try too.
203 dnl #
204 AC_DEFUN([ZFS_AC_DPKG], [
205         DPKG=dpkg
206         DPKGBUILD=dpkg-buildpackage
207
208         AC_MSG_CHECKING([whether $DPKG is available])
209         AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
210                 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
211                 HAVE_DPKG=yes
212                 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
213         ],[
214                 HAVE_DPKG=no
215                 AC_MSG_RESULT([$HAVE_DPKG])
216         ])
217
218         AC_MSG_CHECKING([whether $DPKGBUILD is available])
219         AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
220                 DPKGBUILD_VERSION=$(echo $tmp | \
221                     $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
222                 HAVE_DPKGBUILD=yes
223                 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
224         ],[
225                 HAVE_DPKGBUILD=no
226                 AC_MSG_RESULT([$HAVE_DPKGBUILD])
227         ])
228
229         AC_SUBST(HAVE_DPKG)
230         AC_SUBST(DPKG)
231         AC_SUBST(DPKG_VERSION)
232
233         AC_SUBST(HAVE_DPKGBUILD)
234         AC_SUBST(DPKGBUILD)
235         AC_SUBST(DPKGBUILD_VERSION)
236 ])
237
238 dnl #
239 dnl # Until native packaging for various different packing systems
240 dnl # can be added the least we can do is attempt to use alien to
241 dnl # convert the RPM packages to the needed package type.  This is
242 dnl # a hack but so far it has worked reasonable well.
243 dnl #
244 AC_DEFUN([ZFS_AC_ALIEN], [
245         ALIEN=alien
246
247         AC_MSG_CHECKING([whether $ALIEN is available])
248         AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
249                 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
250                 HAVE_ALIEN=yes
251                 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
252         ],[
253                 HAVE_ALIEN=no
254                 AC_MSG_RESULT([$HAVE_ALIEN])
255         ])
256
257         AC_SUBST(HAVE_ALIEN)
258         AC_SUBST(ALIEN)
259         AC_SUBST(ALIEN_VERSION)
260 ])
261
262 dnl #
263 dnl # Using the VENDOR tag from config.guess set the default
264 dnl # package type for 'make pkg': (rpm | deb | tgz)
265 dnl #
266 AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
267         AC_MSG_CHECKING([linux distribution])
268         if test -f /etc/toss-release ; then
269                 VENDOR=toss ;
270         elif test -f /etc/fedora-release ; then
271                 VENDOR=fedora ;
272         elif test -f /etc/redhat-release ; then
273                 VENDOR=redhat ;
274         elif test -f /etc/gentoo-release ; then
275                 VENDOR=gentoo ;
276         elif test -f /etc/arch-release ; then
277                 VENDOR=arch ;
278         elif test -f /etc/SuSE-release ; then
279                 VENDOR=sles ;
280         elif test -f /etc/slackware-version ; then
281                 VENDOR=slackware ;
282         elif test -f /etc/lunar.release ; then
283                 VENDOR=lunar ;
284         elif test -f /etc/lsb-release ; then
285                 VENDOR=ubuntu ;
286         elif test -f /etc/debian_version ; then
287                 VENDOR=debian ;
288         elif test -f /etc/alpine-release ; then
289                 VENDOR=alpine ;
290         else
291                 VENDOR= ;
292         fi
293         AC_MSG_RESULT([$VENDOR])
294         AC_SUBST(VENDOR)
295
296         AC_MSG_CHECKING([default package type])
297         case "$VENDOR" in
298                 toss)       DEFAULT_PACKAGE=rpm  ;;
299                 redhat)     DEFAULT_PACKAGE=rpm  ;;
300                 fedora)     DEFAULT_PACKAGE=rpm  ;;
301                 gentoo)     DEFAULT_PACKAGE=tgz  ;;
302                 alpine)     DEFAULT_PACKAGE=tgz  ;;
303                 arch)       DEFAULT_PACKAGE=tgz  ;;
304                 sles)       DEFAULT_PACKAGE=rpm  ;;
305                 slackware)  DEFAULT_PACKAGE=tgz  ;;
306                 lunar)      DEFAULT_PACKAGE=tgz  ;;
307                 ubuntu)     DEFAULT_PACKAGE=deb  ;;
308                 debian)     DEFAULT_PACKAGE=deb  ;;
309                 *)          DEFAULT_PACKAGE=rpm  ;;
310         esac
311         AC_MSG_RESULT([$DEFAULT_PACKAGE])
312         AC_SUBST(DEFAULT_PACKAGE)
313
314         DEFAULT_INIT_DIR=$sysconfdir/init.d
315         AC_MSG_CHECKING([default init directory])
316         AC_MSG_RESULT([$DEFAULT_INIT_DIR])
317         AC_SUBST(DEFAULT_INIT_DIR)
318
319         AC_MSG_CHECKING([default init script type])
320         case "$VENDOR" in
321                 toss)       DEFAULT_INIT_SCRIPT=redhat ;;
322                 redhat)     DEFAULT_INIT_SCRIPT=redhat ;;
323                 fedora)     DEFAULT_INIT_SCRIPT=fedora ;;
324                 gentoo)     DEFAULT_INIT_SCRIPT=openrc ;;
325                 alpine)     DEFAULT_INIT_SCRIPT=openrc ;;
326                 arch)       DEFAULT_INIT_SCRIPT=lsb    ;;
327                 sles)       DEFAULT_INIT_SCRIPT=lsb    ;;
328                 slackware)  DEFAULT_INIT_SCRIPT=lsb    ;;
329                 lunar)      DEFAULT_INIT_SCRIPT=lunar  ;;
330                 ubuntu)     DEFAULT_INIT_SCRIPT=lsb    ;;
331                 debian)     DEFAULT_INIT_SCRIPT=lsb    ;;
332                 *)          DEFAULT_INIT_SCRIPT=lsb    ;;
333         esac
334         AC_MSG_RESULT([$DEFAULT_INIT_SCRIPT])
335         AC_SUBST(DEFAULT_INIT_SCRIPT)
336
337         AC_MSG_CHECKING([default init config direectory])
338         case "$VENDOR" in
339                 alpine)     DEFAULT_INITCONF_DIR=/etc/conf.d    ;;
340                 gentoo)     DEFAULT_INITCONF_DIR=/etc/conf.d    ;;
341                 toss)       DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
342                 redhat)     DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
343                 fedora)     DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
344                 sles)       DEFAULT_INITCONF_DIR=/etc/sysconfig ;;
345                 ubuntu)     DEFAULT_INITCONF_DIR=/etc/default   ;;
346                 debian)     DEFAULT_INITCONF_DIR=/etc/default   ;;
347                 *)          DEFAULT_INITCONF_DIR=/etc/default   ;;
348         esac
349         AC_MSG_RESULT([$DEFAULT_INITCONF_DIR])
350         AC_SUBST(DEFAULT_INITCONF_DIR)
351
352         AC_MSG_CHECKING([whether initramfs-tools is available])
353         if test -d /usr/share/initramfs-tools ; then
354                 DEFINE_INITRAMFS='--define "_initramfs 1"'
355                 AC_MSG_RESULT([yes])
356         else
357                 DEFINE_INITRAMFS=''
358                 AC_MSG_RESULT([no])
359         fi
360         AC_SUBST(DEFINE_INITRAMFS)
361 ])
362
363 dnl #
364 dnl # Default ZFS package configuration
365 dnl #
366 AC_DEFUN([ZFS_AC_PACKAGE], [
367         ZFS_AC_DEFAULT_PACKAGE
368         ZFS_AC_RPM
369         ZFS_AC_DPKG
370         ZFS_AC_ALIEN
371 ])