Btrfs progs v4.17.1
[btrfs-progs-unstable/devel.git] / configure.ac
blobdf02f20655d94f6568c40d0ab291da5df45a0e6a
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([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
157         with_convert=auto
160 if test "$with_convert" = "no"; then
161         with_convert=
164 convertfs=
165 BTRFSCONVERT_EXT2=0
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"
172                 BTRFSCONVERT_EXT2=1
173         fi
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],[])
181         fi
182         if test "$BTRFSCONVERT_REISERFS" = 1; then
183                 convertfs="${convertfs:+$convertfs,}reiserfs"
184         fi
186 AC_SUBST([BTRFSCONVERT_EXT2])
187 AC_SUBST([BTRFSCONVERT_REISERFS])
189 # catch typos
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])
206 else
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)
249 AC_SUBST(PYTHON)
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.
254 UDEVDIR=
255 if ${PKG_CONFIG} udev --atleast-version 190; then
256         UDEVDIR="$(${PKG_CONFIG} udev --variable=udevdir)"
258 AC_SUBST(UDEVDIR)
260 dnl lzo library does not provide pkg-config, let use classic way
261 AC_CHECK_LIB([lzo2], [lzo_version], [
262         LZO2_LIBS="-llzo2"
263         LZO2_CFLAGS=""
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])
272 dnl library stuff
273 AC_SUBST([LIBBTRFS_MAJOR])
274 AC_SUBST([LIBBTRFS_MINOR])
275 AC_SUBST([LIBBTRFS_PATCHLEVEL])
277 AC_CONFIG_HEADERS([config.h])
279 AC_CONFIG_FILES([
280 Makefile.inc
281 Documentation/Makefile
282 version.h
285 AC_OUTPUT
287 AC_MSG_RESULT([
288         ${PACKAGE_NAME} ${PACKAGE_VERSION}
290         prefix:             ${prefix}
291         exec prefix:        ${exec_prefix}
293         bindir:             ${bindir}
294         libdir:             ${libdir}
295         includedir:         ${includedir}
297         compiler:           ${CC}
298         cflags:             ${CFLAGS}
299         ldflags:            ${LDFLAGS}
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.