btrfs-progs: check: Initialize all filed of btrfs_inode_item in insert_inode_item()
[btrfs-progs-unstable/devel.git] / configure.ac
blob2567de12899379f20c0b368d5984b05e171c58a1
1 AC_INIT([btrfs-progs],
2         m4_flatten(m4_include([VERSION])),
3         [linux-btrfs@vger.kernel.org],,
4         [http://btrfs.wiki.kernel.org])
6 if test "x$PACKAGE_URL" = "x"; then
7         AC_DEFINE([PACKAGE_URL], ["http://btrfs.wiki.kernel.org"], [URL])
8 fi
10 dnl library version
11 LIBBTRFS_MAJOR=0
12 LIBBTRFS_MINOR=1
13 LIBBTRFS_PATCHLEVEL=2
15 CFLAGS=${CFLAGS:-"-g -O1 -Wall -D_FORTIFY_SOURCE=2"}
16 AC_SUBST([CFLAGS])
18 AC_PREREQ([2.60])
20 AC_CONFIG_AUX_DIR([config])
21 dnl AC_USE_SYSTEM_EXTENSIONS must be called before any macros that run
22 dnl the compiler (like AC_PROG_LIBTOOL) to avoid autoconf errors.
23 AC_USE_SYSTEM_EXTENSIONS
25 AC_CONFIG_SRCDIR([btrfs.c])
26 AC_PREFIX_DEFAULT([/usr/local])
28 AC_PROG_CC
29 BTRFS_DETECT_CSTD
30 AC_CANONICAL_HOST
31 AC_C_CONST
32 AC_C_VOLATILE
33 AC_C_BIGENDIAN
35 AC_SYS_LARGEFILE
37 AC_PROG_INSTALL
38 AC_PROG_LN_S
39 AC_CHECK_TOOL([AR], [ar])
40 AC_PATH_PROG([RM], [rm], [rm])
41 AC_PATH_PROG([RMDIR], [rmdir], [rmdir])
44 AC_CHECK_FUNCS([openat], [],
45         [AC_MSG_ERROR([cannot find openat() function])])
47 AC_CHECK_FUNCS([reallocarray])
49 m4_ifndef([PKG_PROG_PKG_CONFIG],
50   [m4_fatal([Could not locate the pkg-config autoconf
51     macros. These are usually located in /usr/share/aclocal/pkg.m4.
52     If your macros are in a different location, try setting the
53     environment variable AL_OPTS="-I/other/macro/dir" before running
54     ./autogen.sh or autoreconf again.])])
55 PKG_PROG_PKG_CONFIG
58 dnl
59 dnl Calls pkg-config --static
60 dnl
61 AC_DEFUN([PKG_STATIC], [
62   if AC_RUN_LOG([${PKG_CONFIG} --exists --print-errors "$2"]); then
63     $1=`${PKG_CONFIG} --libs --static "$2"`
64     AC_SUBST([$1])
65   else
66     AC_MSG_ERROR([pkg-config description of $2, needed for static build, is not available])
67   fi
71 AC_ARG_ENABLE([backtrace],
72   AS_HELP_STRING([--disable-backtrace], [disable btrfs backtrace]),
73   [], [enable_backtrace=yes]
76 AS_IF([test "x$enable_backtrace" = xno], [
77   AC_DEFINE([BTRFS_DISABLE_BACKTRACE], [1], [disable backtrace stuff in kerncompat.h ])
80 if test "x$enable_backtrace" = xyes; then
81         AC_CHECK_HEADERS([execinfo.h])
82         AC_CHECK_FUNCS([backtrace backtrace_symbols_fd], [],
83               AC_MSG_ERROR([standard library does not have backtrace support]))
87 AC_ARG_ENABLE([documentation],
88               AS_HELP_STRING([--disable-documentation], [do not build domumentation]),
89   [], [enable_documentation=yes]
91 AS_IF([test "x$enable_documentation" = xyes], [DISABLE_DOCUMENTATION=0], [DISABLE_DOCUMENTATION=1])
92 AC_SUBST([DISABLE_DOCUMENTATION])
94 dnl detect tools to build documentation
95 ASCIIDOC_TOOL="none"
96 if test "x$enable_documentation" = xyes; then
97         AC_PATH_PROG([XMLTO], [xmlto])
98         if test -z "$XMLTO"; then
99                 AC_MSG_ERROR([cannot find xmlto, cannot build documentation])
100         fi
102         AC_PATH_PROG([GZIP], [gzip], [gzip])
103         AC_PATH_PROG([MV], [mv], [mv])
104         AC_PROG_SED
105         AC_PATH_PROG([ASCIIDOC], [asciidoc])
106         AC_PATH_PROG([ASCIIDOCTOR], [asciidoctor])
108         dnl asciidoc is preferred
109         if test -n "$ASCIIDOC"; then
110                 ASCIIDOC_TOOL="asciidoc"
111         else
112                 if test -n "$ASCIIDOCTOR"; then
113                         ASCIIDOC_TOOL="asciidoctor"
114                 else
115                         AC_MSG_ERROR([cannot find asciidoc or asciidoctor, cannot build documentation])
116                 fi
117         fi
119 AC_SUBST([ASCIIDOC_TOOL])
121 AC_ARG_ENABLE([convert],
122               AS_HELP_STRING([--disable-convert], [do not build btrfs-convert]),
123   [], [enable_convert=yes]
126 AS_IF([test "x$enable_convert" = xyes], [DISABLE_BTRFSCONVERT=0], [DISABLE_BTRFSCONVERT=1])
127 AC_SUBST([DISABLE_BTRFSCONVERT])
129 AC_ARG_WITH([convert],
130             AS_HELP_STRING([[[]--with-convert[[=auto]]]], [built-in filesystems for convert (default: auto)
131 supported (comma separated list): ext2,reiserfs]),
132   [], [with_convert=auto]
135 if test "$with_convert" = "yes"; then
136         with_convert=auto
139 if test "$with_convert" = "no"; then
140         with_convert=
143 convertfs=
144 BTRFSCONVERT_EXT2=0
145 BTRFSCONVERT_REISERFS=0
146 if test "x$enable_convert" = xyes; then
147         if test "x$with_convert" = "xauto" || echo "$with_convert" | grep -q "ext2"; then
148                 PKG_CHECK_MODULES(EXT2FS, [ext2fs])
149                 PKG_CHECK_MODULES(COM_ERR, [com_err])
150                 convertfs="${convertfs:+$convertfs,}ext2"
151                 BTRFSCONVERT_EXT2=1
152         fi
153         if test "x$with_convert" = "xauto"; then
154                 PKG_CHECK_MODULES(REISERFS, [reiserfscore >= 3.6.27],
155                                   [BTRFSCONVERT_REISERFS=1],
156                                   [BTRFSCONVERT_REISERFS=0])
157         elif echo "$with_convert" | grep -q "reiserfs"; then
158                 PKG_CHECK_MODULES(REISERFS, [reiserfscore >= 3.6.27],
159                                   [BTRFSCONVERT_REISERFS=1],[])
160         fi
161         if test "$BTRFSCONVERT_REISERFS" = 1; then
162                 convertfs="${convertfs:+$convertfs,}reiserfs"
163         fi
165 AC_SUBST([BTRFSCONVERT_EXT2])
166 AC_SUBST([BTRFSCONVERT_REISERFS])
168 # catch typos
169 tmp=$(echo "$with_convert" | sed -e 's/auto//' | sed -e 's/ext2//' | sed -e 's/reiserfs//' | sed -e 's/,\+//')
170 if ! test "x$tmp" = "x"; then
171         AC_MSG_ERROR([unknown tokens for --with-convert: $tmp])
174 if test "$DISABLE_BTRFSCONVERT" = 0 && test "x$convertfs" = "x"; then
175         AC_MSG_ERROR([no filesystems for convert, use --disable-convert instead])
178 HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE=0
179 AX_CHECK_DEFINE([linux/fiemap.h], [FIEMAP_EXTENT_SHARED], [],
180                 [HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE=1
181                  AC_MSG_WARN([no definition of FIEMAP_EXTENT_SHARED found, probably old kernel, will use own defintion, 'btrfs fi du' might report wrong numbers])])
183 if test "x$HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE" == "x1"; then
184 AC_DEFINE([HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE], [1], [We defined FIEMAP_EXTENT_SHARED])
185 else
186 AC_DEFINE([HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE], [0], [We did not define FIEMAP_EXTENT_SHARED])
189 dnl Define <NAME>_LIBS= and <NAME>_CFLAGS= by pkg-config
191 dnl The default PKG_CHECK_MODULES() action-if-not-found is end the
192 dnl execution with error. The static libs are optional.
194 PKG_CHECK_MODULES(BLKID, [blkid])
195 PKG_STATIC(BLKID_LIBS_STATIC, [blkid])
197 PKG_CHECK_MODULES(UUID, [uuid])
198 PKG_STATIC(UUID_LIBS_STATIC, [uuid])
200 PKG_CHECK_MODULES(ZLIB, [zlib])
201 PKG_STATIC(ZLIB_LIBS_STATIC, [zlib])
203 AC_ARG_ENABLE([zstd],
204         AS_HELP_STRING([--disable-zstd], [build without zstd support]),
205         [], [enable_zstd=yes]
208 if test "x$enable_zstd" = xyes; then
209         PKG_CHECK_MODULES(ZSTD, [libzstd >= 1.0.0])
210         PKG_STATIC(ZSTD_LIBS_STATIC, [libzstd])
213 AS_IF([test "x$enable_zstd" = xyes], [BTRFSRESTORE_ZSTD=1], [BTRFSRESTORE_ZSTD=0])
214 AC_SUBST(BTRFSRESTORE_ZSTD)
216 AC_ARG_ENABLE([python],
217         AS_HELP_STRING([--disable-python], [do not build libbtrfsutil Python bindings]),
218         [], [enable_python=yes]
221 if test "x$enable_python" = xyes; then
222         AM_PATH_PYTHON([3.4])
223         PKG_CHECK_MODULES(PYTHON, [python-${PYTHON_VERSION}])
226 AS_IF([test "x$enable_python" = xyes], [PYTHON_BINDINGS=1], [PYTHON_BINDINGS=0])
227 AC_SUBST(PYTHON_BINDINGS)
228 AC_SUBST(PYTHON)
230 # udev v190 introduced the btrfs builtin and a udev rule to use it.
231 # Our udev rule gives us the friendly dm names but isn't required (or valid)
232 # on earlier releases.
233 UDEVDIR=
234 if ${PKG_CONFIG} udev --atleast-version 190; then
235         UDEVDIR="$(${PKG_CONFIG} udev --variable=udevdir)"
237 AC_SUBST(UDEVDIR)
239 dnl lzo library does not provide pkg-config, let use classic way
240 AC_CHECK_LIB([lzo2], [lzo_version], [
241         LZO2_LIBS="-llzo2"
242         LZO2_CFLAGS=""
243         LZO2_LIBS_STATIC="-llzo2"],[
244         AC_MSG_ERROR([cannot find lzo2 library])
246 AC_SUBST([LZO2_LIBS])
247 AC_SUBST([LZO2_LIBS_STATIC])
248 AC_SUBST([LZO2_CFLAGS])
251 dnl library stuff
252 AC_SUBST([LIBBTRFS_MAJOR])
253 AC_SUBST([LIBBTRFS_MINOR])
254 AC_SUBST([LIBBTRFS_PATCHLEVEL])
256 AC_CONFIG_HEADERS([config.h])
258 AC_CONFIG_FILES([
259 Makefile.inc
260 Documentation/Makefile
261 version.h
264 AC_OUTPUT
266 AC_MSG_RESULT([
267         ${PACKAGE_NAME} ${PACKAGE_VERSION}
269         prefix:             ${prefix}
270         exec prefix:        ${exec_prefix}
272         bindir:             ${bindir}
273         libdir:             ${libdir}
274         includedir:         ${includedir}
276         compiler:           ${CC}
277         cflags:             ${CFLAGS}
278         ldflags:            ${LDFLAGS}
280         documentation:      ${enable_documentation}
281         doc generator:      ${ASCIIDOC_TOOL}
282         backtrace support:  ${enable_backtrace}
283         btrfs-convert:      ${enable_convert} ${convertfs:+($convertfs)}
284         btrfs-restore zstd: ${enable_zstd}
285         Python bindings:    ${enable_python}
286         Python interpreter: ${PYTHON}
288         Type 'make' to compile.