btrfs-progs: mkfs: Prevent temporary system chunk to use space in reserved 1M range
[btrfs-progs-unstable/devel.git] / configure.ac
blob55242b0dd788de97a81e3fde89c1a732a135d212
1 AC_INIT([btrfs-progs],
2         m4_chomp(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 AC_CANONICAL_HOST
30 AC_C_CONST
31 AC_C_VOLATILE
32 AC_C_BIGENDIAN
34 AC_SYS_LARGEFILE
36 AC_PROG_INSTALL
37 AC_PROG_LN_S
38 AC_CHECK_TOOL([AR], [ar])
39 AC_PATH_PROG([RM], [rm], [rm])
40 AC_PATH_PROG([RMDIR], [rmdir], [rmdir])
42 AC_CHECK_FUNCS([openat], [],
43         [AC_MSG_ERROR([cannot find openat() function])])
45 m4_ifndef([PKG_PROG_PKG_CONFIG],
46   [m4_fatal([Could not locate the pkg-config autoconf
47     macros. These are usually located in /usr/share/aclocal/pkg.m4.
48     If your macros are in a different location, try setting the
49     environment variable AL_OPTS="-I/other/macro/dir" before running
50     ./autogen.sh or autoreconf again.])])
51 PKG_PROG_PKG_CONFIG
54 dnl
55 dnl Calls pkg-config --static
56 dnl
57 AC_DEFUN([PKG_STATIC], [
58   if AC_RUN_LOG([pkg-config --exists --print-errors "$2"]); then
59     $1=`pkg-config --libs --static "$2"`
60     AC_SUBST([$1])
61   else
62     AC_MSG_ERROR([pkg-config description of $2, needed for static build, is not available])
63   fi
67 AC_ARG_ENABLE([backtrace],
68   AS_HELP_STRING([--disable-backtrace], [disable btrfs backtrace]),
69   [], [enable_backtrace=yes]
72 AS_IF([test "x$enable_backtrace" = xno], [
73   AC_DEFINE([BTRFS_DISABLE_BACKTRACE], [1], [disable backtrace stuff in kerncompat.h ])
76 if test "x$enable_backtrace" = xyes; then
77         AC_CHECK_HEADERS([execinfo.h])
78         AC_CHECK_FUNCS([backtrace backtrace_symbols_fd], [],
79               AC_MSG_ERROR([standard library does not have backtrace support]))
83 AC_ARG_ENABLE([documentation],
84               AS_HELP_STRING([--disable-documentation], [do not build domumentation]),
85   [], [enable_documentation=yes]
87 AS_IF([test "x$enable_documentation" = xyes], [DISABLE_DOCUMENTATION=0], [DISABLE_DOCUMENTATION=1])
88 AC_SUBST([DISABLE_DOCUMENTATION])
90 dnl detect tools to build documentation
91 if test "x$enable_documentation" = xyes; then
92         AC_PATH_PROG([ASCIIDOC], [asciidoc], [asciidoc])
93         AC_PATH_PROG([XMLTO], [xmlto], [xmlto])
94         AC_PATH_PROG([GZIP], [gzip], [gzip])
95         AC_PATH_PROG([MV], [mv], [mv])
96         AC_PROG_SED
99 AC_ARG_ENABLE([convert],
100               AS_HELP_STRING([--disable-convert], [do not build btrfs-convert]),
101   [], [enable_convert=yes]
104 AS_IF([test "x$enable_convert" = xyes], [DISABLE_BTRFSCONVERT=0], [DISABLE_BTRFSCONVERT=1])
105 AC_SUBST([DISABLE_BTRFSCONVERT])
107 AC_ARG_WITH([convert],
108             AS_HELP_STRING([[[]--with-convert[[=auto]]]], [built-in filesystems for convert (default: auto)
109 supported (comma separated list): ext2,reiserfs]),
110   [], [with_convert=auto]
113 if test "$with_convert" = "yes"; then
114         with_convert=auto
117 if test "$with_convert" = "no"; then
118         with_convert=
121 convertfs=
122 BTRFSCONVERT_EXT2=0
123 BTRFSCONVERT_REISERFS=0
124 if test "x$enable_convert" = xyes; then
125         if test "x$with_convert" = "xauto" || echo "$with_convert" | grep -q "ext2"; then
126                 PKG_CHECK_MODULES(EXT2FS, [ext2fs >= 1.42],,
127                         [PKG_CHECK_MODULES(EXT2FS, [ext2fs],
128                                 [AC_DEFINE([HAVE_OLD_E2FSPROGS], [1],
129                                           [E2fsprogs does not support BIGALLOC])]
130                                 )])
131                 PKG_CHECK_MODULES(COM_ERR, [com_err])
132                 convertfs="${convertfs:+$convertfs,}ext2"
133                 BTRFSCONVERT_EXT2=1
134         fi
135         if test "x$with_convert" = "xauto"; then
136                 PKG_CHECK_MODULES(REISERFS, [reiserfscore >= 3.6.27],
137                                   [BTRFSCONVERT_REISERFS=1],
138                                   [BTRFSCONVERT_REISERFS=0])
139         elif echo "$with_convert" | grep -q "reiserfs"; then
140                 PKG_CHECK_MODULES(REISERFS, [reiserfscore >= 3.6.27],
141                                   [BTRFSCONVERT_REISERFS=1],[])
142         fi
143         if test "$BTRFSCONVERT_REISERFS" = 1; then
144                 convertfs="${convertfs:+$convertfs,}reiserfs"
145         fi
147 AC_SUBST([BTRFSCONVERT_EXT2])
148 AC_SUBST([BTRFSCONVERT_REISERFS])
150 # catch typos
151 tmp=$(echo "$with_convert" | sed -e 's/auto//' | sed -e 's/ext2//' | sed -e 's/reiserfs//' | sed -e 's/,\+//')
152 if ! test "x$tmp" = "x"; then
153         AC_MSG_ERROR([unknown tokens for --with-convert: $tmp])
156 if test "$DISABLE_BTRFSCONVERT" = 0 && test "x$convertfs" = "x"; then
157         AC_MSG_ERROR([no filesystems for convert, use --disable-convert instead])
160 HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE=0
161 AX_CHECK_DEFINE([linux/fiemap.h], [FIEMAP_EXTENT_SHARED], [],
162                 [HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE=1
163                  AC_MSG_WARN([no definition of FIEMAP_EXTENT_SHARED found, probably old kernel, will use own defintion, 'btrfs fi du' might report wrong numbers])])
165 if test "x$HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE" == "x1"; then
166 AC_DEFINE([HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE], [1], [We defined FIEMAP_EXTENT_SHARED])
167 else
168 AC_DEFINE([HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE], [0], [We did not define FIEMAP_EXTENT_SHARED])
171 dnl Define <NAME>_LIBS= and <NAME>_CFLAGS= by pkg-config
173 dnl The default PKG_CHECK_MODULES() action-if-not-found is end the
174 dnl execution with error. The static libs are optional.
176 PKG_CHECK_MODULES(BLKID, [blkid])
177 PKG_STATIC(BLKID_LIBS_STATIC, [blkid])
179 PKG_CHECK_MODULES(UUID, [uuid])
180 PKG_STATIC(UUID_LIBS_STATIC, [uuid])
182 PKG_CHECK_MODULES(ZLIB, [zlib])
183 PKG_STATIC(ZLIB_LIBS_STATIC, [zlib])
185 AC_ARG_ENABLE([zstd],
186         AS_HELP_STRING([--disable-zstd@<:@=yes@:>@], [build with zstd support (default: yes)]),
187         [], [enable_zstd=yes]
190 if test "x$enable_zstd" = xauto; then
191         PKG_CHECK_EXISTS([libzstd >= 1.0.0], [enable_zstd=yes], [enable_zstd=no])
194 if test "x$enable_zstd" = xyes; then
195         PKG_CHECK_MODULES(ZSTD, [libzstd >= 1.0.0])
196         PKG_STATIC(ZSTD_LIBS_STATIC, [libzstd])
199 AS_IF([test "x$enable_zstd" = xyes], [BTRFSRESTORE_ZSTD=1], [BTRFSRESTORE_ZSTD=0])
200 AC_SUBST(BTRFSRESTORE_ZSTD)
202 # udev v190 introduced the btrfs builtin and a udev rule to use it.
203 # Our udev rule gives us the friendly dm names but isn't required (or valid)
204 # on earlier releases.
205 UDEVDIR=
206 if pkg-config udev --atleast-version 190; then
207         UDEVDIR="$(pkg-config udev --variable=udevdir)"
209 AC_SUBST(UDEVDIR)
211 dnl lzo library does not provide pkg-config, let use classic way
212 AC_CHECK_LIB([lzo2], [lzo_version], [
213         LZO2_LIBS="-llzo2"
214         LZO2_CFLAGS=""
215         LZO2_LIBS_STATIC="-llzo2"],[
216         AC_MSG_ERROR([cannot find lzo2 library])
218 AC_SUBST([LZO2_LIBS])
219 AC_SUBST([LZO2_LIBS_STATIC])
220 AC_SUBST([LZO2_CFLAGS])
223 dnl library stuff
224 AC_SUBST([LIBBTRFS_MAJOR])
225 AC_SUBST([LIBBTRFS_MINOR])
226 AC_SUBST([LIBBTRFS_PATCHLEVEL])
228 AC_CONFIG_HEADERS([config.h])
230 AC_CONFIG_FILES([
231 Makefile.inc
232 Documentation/Makefile
233 version.h
236 AC_OUTPUT
238 AC_MSG_RESULT([
239         ${PACKAGE_NAME} ${PACKAGE_VERSION}
241         prefix:             ${prefix}
242         exec prefix:        ${exec_prefix}
244         bindir:             ${bindir}
245         libdir:             ${libdir}
246         includedir:         ${includedir}
248         compiler:           ${CC}
249         cflags:             ${CFLAGS}
250         ldflags:            ${LDFLAGS}
252         documentation:      ${enable_documentation}
253         backtrace support:  ${enable_backtrace}
254         btrfs-convert:      ${enable_convert} ${convertfs:+($convertfs)}
255         btrfs-restore zstd: ${enable_zstd}
257         Type 'make' to compile.