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])
15 CFLAGS=${CFLAGS:-"-g -O1 -Wall -D_FORTIFY_SOURCE=2"}
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])
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.])])
59 dnl Calls pkg-config --static
61 AC_DEFUN([PKG_STATIC], [
62 if AC_RUN_LOG([${PKG_CONFIG} --exists --print-errors "$2"]); then
63 $1=`${PKG_CONFIG} --libs --static "$2"`
66 AC_MSG_ERROR([pkg-config description of $2, needed for static build, is not available])
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
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])
102 AC_PATH_PROG([GZIP], [gzip], [gzip])
103 AC_PATH_PROG([MV], [mv], [mv])
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"
112 if test -n "$ASCIIDOCTOR"; then
113 ASCIIDOC_TOOL="asciidoctor"
115 AC_MSG_ERROR([cannot find asciidoc or asciidoctor, cannot build documentation])
119 AC_SUBST([ASCIIDOC_TOOL])
121 AC_ARG_ENABLE([programs],
122 AS_HELP_STRING([--disable-programs], [do not build utility programs]),
123 [], [enable_programs=yes]
125 AS_IF([test "x$enable_programs" = xyes], [BUILD_PROGRAMS=1], [BUILD_PROGRAMS=0])
126 AC_SUBST([BUILD_PROGRAMS])
128 AC_ARG_ENABLE([shared],
129 AS_HELP_STRING([--disable-shared], [do not build shared libraries]),
130 [], [enable_shared=yes]
132 AS_IF([test "x$enable_shared" = xyes], [BUILD_SHARED_LIBRARIES=1], [BUILD_SHARED_LIBRARIES=0])
133 AC_SUBST([BUILD_SHARED_LIBRARIES])
135 AC_ARG_ENABLE([static],
136 AS_HELP_STRING([--disable-static], [do not build static libraries]),
137 [], [enable_static=yes]
139 AS_IF([test "x$enable_static" = xyes], [BUILD_STATIC_LIBRARIES=1], [BUILD_STATIC_LIBRARIES=0])
140 AC_SUBST([BUILD_STATIC_LIBRARIES])
142 AC_ARG_ENABLE([convert],
143 AS_HELP_STRING([--disable-convert], [do not build btrfs-convert]),
144 [], [enable_convert=$enable_programs]
147 AS_IF([test "x$enable_convert" = xyes], [DISABLE_BTRFSCONVERT=0], [DISABLE_BTRFSCONVERT=1])
148 AC_SUBST([DISABLE_BTRFSCONVERT])
150 AC_ARG_WITH([convert],
151 AS_HELP_STRING([[[]--with-convert[[=auto]]]], [built-in filesystems for convert (default: auto)
152 supported (comma separated list): ext2,reiserfs]),
153 [], [with_convert=auto]
156 if test "$with_convert" = "yes"; then
160 if test "$with_convert" = "no"; then
166 BTRFSCONVERT_REISERFS=0
167 if test "x$enable_convert" = xyes; then
168 if test "x$with_convert" = "xauto" || echo "$with_convert" | grep -q "ext2"; then
169 PKG_CHECK_MODULES(EXT2FS, [ext2fs])
170 PKG_CHECK_MODULES(COM_ERR, [com_err])
171 convertfs="${convertfs:+$convertfs,}ext2"
174 if test "x$with_convert" = "xauto"; then
175 PKG_CHECK_MODULES(REISERFS, [reiserfscore >= 3.6.27],
176 [BTRFSCONVERT_REISERFS=1],
177 [BTRFSCONVERT_REISERFS=0])
178 elif echo "$with_convert" | grep -q "reiserfs"; then
179 PKG_CHECK_MODULES(REISERFS, [reiserfscore >= 3.6.27],
180 [BTRFSCONVERT_REISERFS=1],[])
182 if test "$BTRFSCONVERT_REISERFS" = 1; then
183 convertfs="${convertfs:+$convertfs,}reiserfs"
186 AC_SUBST([BTRFSCONVERT_EXT2])
187 AC_SUBST([BTRFSCONVERT_REISERFS])
190 tmp=$(echo "$with_convert" | sed -e 's/auto//' | sed -e 's/ext2//' | sed -e 's/reiserfs//' | sed -e 's/,\+//')
191 if ! test "x$tmp" = "x"; then
192 AC_MSG_ERROR([unknown tokens for --with-convert: $tmp])
195 if test "$DISABLE_BTRFSCONVERT" = 0 && test "x$convertfs" = "x"; then
196 AC_MSG_ERROR([no filesystems for convert, use --disable-convert instead])
199 HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE=0
200 AX_CHECK_DEFINE([linux/fiemap.h], [FIEMAP_EXTENT_SHARED], [],
201 [HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE=1
202 AC_MSG_WARN([no definition of FIEMAP_EXTENT_SHARED found, probably old kernel, will use own defintion, 'btrfs fi du' might report wrong numbers])])
204 if test "x$HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE" == "x1"; then
205 AC_DEFINE([HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE], [1], [We defined FIEMAP_EXTENT_SHARED])
207 AC_DEFINE([HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE], [0], [We did not define FIEMAP_EXTENT_SHARED])
210 dnl Define <NAME>_LIBS= and <NAME>_CFLAGS= by pkg-config
212 dnl The default PKG_CHECK_MODULES() action-if-not-found is end the
213 dnl execution with error. The static libs are optional.
215 PKG_CHECK_MODULES(BLKID, [blkid])
216 PKG_STATIC(BLKID_LIBS_STATIC, [blkid])
218 PKG_CHECK_MODULES(UUID, [uuid])
219 PKG_STATIC(UUID_LIBS_STATIC, [uuid])
221 PKG_CHECK_MODULES(ZLIB, [zlib])
222 PKG_STATIC(ZLIB_LIBS_STATIC, [zlib])
224 AC_ARG_ENABLE([zstd],
225 AS_HELP_STRING([--disable-zstd], [build without zstd support]),
226 [], [enable_zstd=yes]
229 if test "x$enable_zstd" = xyes; then
230 PKG_CHECK_MODULES(ZSTD, [libzstd >= 1.0.0])
231 PKG_STATIC(ZSTD_LIBS_STATIC, [libzstd])
234 AS_IF([test "x$enable_zstd" = xyes], [BTRFSRESTORE_ZSTD=1], [BTRFSRESTORE_ZSTD=0])
235 AC_SUBST(BTRFSRESTORE_ZSTD)
237 AC_ARG_ENABLE([python],
238 AS_HELP_STRING([--disable-python], [do not build libbtrfsutil Python bindings]),
239 [], [enable_python=$enable_shared]
242 if test "x$enable_python" = xyes; then
243 AM_PATH_PYTHON([3.4])
244 PKG_CHECK_MODULES(PYTHON, [python-${PYTHON_VERSION}])
247 AS_IF([test "x$enable_python" = xyes], [PYTHON_BINDINGS=1], [PYTHON_BINDINGS=0])
248 AC_SUBST(PYTHON_BINDINGS)
251 # udev v190 introduced the btrfs builtin and a udev rule to use it.
252 # Our udev rule gives us the friendly dm names but isn't required (or valid)
253 # on earlier releases.
255 if ${PKG_CONFIG} udev --atleast-version 190; then
256 UDEVDIR="$(${PKG_CONFIG} udev --variable=udevdir)"
260 dnl lzo library does not provide pkg-config, let use classic way
261 AC_CHECK_LIB([lzo2], [lzo_version], [
264 LZO2_LIBS_STATIC="-llzo2"],[
265 AC_MSG_ERROR([cannot find lzo2 library])
267 AC_SUBST([LZO2_LIBS])
268 AC_SUBST([LZO2_LIBS_STATIC])
269 AC_SUBST([LZO2_CFLAGS])
273 AC_SUBST([LIBBTRFS_MAJOR])
274 AC_SUBST([LIBBTRFS_MINOR])
275 AC_SUBST([LIBBTRFS_PATCHLEVEL])
277 AC_CONFIG_HEADERS([config.h])
281 Documentation/Makefile
288 ${PACKAGE_NAME} ${PACKAGE_VERSION}
291 exec prefix: ${exec_prefix}
295 includedir: ${includedir}
301 programs: ${enable_programs}
302 shared libraries: ${enable_shared}
303 static libraries: ${enable_static}
304 documentation: ${enable_documentation}
305 doc generator: ${ASCIIDOC_TOOL}
306 backtrace support: ${enable_backtrace}
307 btrfs-convert: ${enable_convert} ${convertfs:+($convertfs)}
308 btrfs-restore zstd: ${enable_zstd}
309 Python bindings: ${enable_python}
310 Python interpreter: ${PYTHON}
312 Type 'make' to compile.