btrfs-progs: build: modify cscope/ctags rules to include directories such as check
[btrfs-progs-unstable/devel.git] / configure.ac
blobaf13a959e9dc12a1a9c00381195e58f377f41649
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])
43 AC_CHECK_FUNCS([openat], [],
44         [AC_MSG_ERROR([cannot find openat() function])])
46 AC_CHECK_FUNCS([reallocarray])
48 m4_ifndef([PKG_PROG_PKG_CONFIG],
49   [m4_fatal([Could not locate the pkg-config autoconf
50     macros. These are usually located in /usr/share/aclocal/pkg.m4.
51     If your macros are in a different location, try setting the
52     environment variable AL_OPTS="-I/other/macro/dir" before running
53     ./autogen.sh or autoreconf again.])])
54 PKG_PROG_PKG_CONFIG
57 dnl
58 dnl Calls pkg-config --static
59 dnl
60 AC_DEFUN([PKG_STATIC], [
61   if AC_RUN_LOG([${PKG_CONFIG} --exists --print-errors "$2"]); then
62     $1=`${PKG_CONFIG} --libs --static "$2"`
63     AC_SUBST([$1])
64   else
65     AC_MSG_ERROR([pkg-config description of $2, needed for static build, is not available])
66   fi
70 AC_ARG_ENABLE([backtrace],
71   AS_HELP_STRING([--disable-backtrace], [disable btrfs backtrace]),
72   [], [enable_backtrace=yes]
75 AS_IF([test "x$enable_backtrace" = xno], [
76   AC_DEFINE([BTRFS_DISABLE_BACKTRACE], [1], [disable backtrace stuff in kerncompat.h ])
79 if test "x$enable_backtrace" = xyes; then
80         AC_CHECK_HEADERS([execinfo.h])
81         AC_CHECK_FUNCS([backtrace backtrace_symbols_fd], [],
82               AC_MSG_ERROR([standard library does not have backtrace support]))
86 AC_ARG_ENABLE([documentation],
87               AS_HELP_STRING([--disable-documentation], [do not build domumentation]),
88   [], [enable_documentation=yes]
90 AS_IF([test "x$enable_documentation" = xyes], [DISABLE_DOCUMENTATION=0], [DISABLE_DOCUMENTATION=1])
91 AC_SUBST([DISABLE_DOCUMENTATION])
93 dnl detect tools to build documentation
94 ASCIIDOC_TOOL="none"
95 if test "x$enable_documentation" = xyes; then
96         AC_PATH_PROG([XMLTO], [xmlto], [xmlto])
97         AC_PATH_PROG([GZIP], [gzip], [gzip])
98         AC_PATH_PROG([MV], [mv], [mv])
99         AC_PROG_SED
100         AC_PATH_PROG([ASCIIDOC], [asciidoc])
101         AC_PATH_PROG([ASCIIDOCTOR], [asciidoctor])
103         dnl asciidoc is preferred
104         if test -n "$ASCIIDOC"; then
105                 ASCIIDOC_TOOL="asciidoc"
106         else
107                 if test -n "$ASCIIDOCTOR"; then
108                         ASCIIDOC_TOOL="asciidoctor"
109                 else
110                         AC_MSG_ERROR([cannot find asciidoc or asciidoctor, cannot build documentation])
111                 fi
112         fi
114 AC_SUBST([ASCIIDOC_TOOL])
116 AC_ARG_ENABLE([convert],
117               AS_HELP_STRING([--disable-convert], [do not build btrfs-convert]),
118   [], [enable_convert=yes]
121 AS_IF([test "x$enable_convert" = xyes], [DISABLE_BTRFSCONVERT=0], [DISABLE_BTRFSCONVERT=1])
122 AC_SUBST([DISABLE_BTRFSCONVERT])
124 AC_ARG_WITH([convert],
125             AS_HELP_STRING([[[]--with-convert[[=auto]]]], [built-in filesystems for convert (default: auto)
126 supported (comma separated list): ext2,reiserfs]),
127   [], [with_convert=auto]
130 if test "$with_convert" = "yes"; then
131         with_convert=auto
134 if test "$with_convert" = "no"; then
135         with_convert=
138 convertfs=
139 BTRFSCONVERT_EXT2=0
140 BTRFSCONVERT_REISERFS=0
141 if test "x$enable_convert" = xyes; then
142         if test "x$with_convert" = "xauto" || echo "$with_convert" | grep -q "ext2"; then
143                 PKG_CHECK_MODULES(EXT2FS, [ext2fs >= 1.42],,
144                         [PKG_CHECK_MODULES(EXT2FS, [ext2fs],
145                                 [AC_DEFINE([HAVE_OLD_E2FSPROGS], [1],
146                                           [E2fsprogs does not support BIGALLOC])]
147                                 )])
148                 PKG_CHECK_MODULES(COM_ERR, [com_err])
149                 convertfs="${convertfs:+$convertfs,}ext2"
150                 BTRFSCONVERT_EXT2=1
151         fi
152         if test "x$with_convert" = "xauto"; then
153                 PKG_CHECK_MODULES(REISERFS, [reiserfscore >= 3.6.27],
154                                   [BTRFSCONVERT_REISERFS=1],
155                                   [BTRFSCONVERT_REISERFS=0])
156         elif echo "$with_convert" | grep -q "reiserfs"; then
157                 PKG_CHECK_MODULES(REISERFS, [reiserfscore >= 3.6.27],
158                                   [BTRFSCONVERT_REISERFS=1],[])
159         fi
160         if test "$BTRFSCONVERT_REISERFS" = 1; then
161                 convertfs="${convertfs:+$convertfs,}reiserfs"
162         fi
164 AC_SUBST([BTRFSCONVERT_EXT2])
165 AC_SUBST([BTRFSCONVERT_REISERFS])
167 # catch typos
168 tmp=$(echo "$with_convert" | sed -e 's/auto//' | sed -e 's/ext2//' | sed -e 's/reiserfs//' | sed -e 's/,\+//')
169 if ! test "x$tmp" = "x"; then
170         AC_MSG_ERROR([unknown tokens for --with-convert: $tmp])
173 if test "$DISABLE_BTRFSCONVERT" = 0 && test "x$convertfs" = "x"; then
174         AC_MSG_ERROR([no filesystems for convert, use --disable-convert instead])
177 HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE=0
178 AX_CHECK_DEFINE([linux/fiemap.h], [FIEMAP_EXTENT_SHARED], [],
179                 [HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE=1
180                  AC_MSG_WARN([no definition of FIEMAP_EXTENT_SHARED found, probably old kernel, will use own defintion, 'btrfs fi du' might report wrong numbers])])
182 if test "x$HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE" == "x1"; then
183 AC_DEFINE([HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE], [1], [We defined FIEMAP_EXTENT_SHARED])
184 else
185 AC_DEFINE([HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE], [0], [We did not define FIEMAP_EXTENT_SHARED])
188 dnl Define <NAME>_LIBS= and <NAME>_CFLAGS= by pkg-config
190 dnl The default PKG_CHECK_MODULES() action-if-not-found is end the
191 dnl execution with error. The static libs are optional.
193 PKG_CHECK_MODULES(BLKID, [blkid])
194 PKG_STATIC(BLKID_LIBS_STATIC, [blkid])
196 PKG_CHECK_MODULES(UUID, [uuid])
197 PKG_STATIC(UUID_LIBS_STATIC, [uuid])
199 PKG_CHECK_MODULES(ZLIB, [zlib])
200 PKG_STATIC(ZLIB_LIBS_STATIC, [zlib])
202 AC_ARG_ENABLE([zstd],
203         AS_HELP_STRING([--disable-zstd], [build without zstd support]),
204         [], [enable_zstd=yes]
207 if test "x$enable_zstd" = xyes; then
208         PKG_CHECK_MODULES(ZSTD, [libzstd >= 1.0.0])
209         PKG_STATIC(ZSTD_LIBS_STATIC, [libzstd])
212 AS_IF([test "x$enable_zstd" = xyes], [BTRFSRESTORE_ZSTD=1], [BTRFSRESTORE_ZSTD=0])
213 AC_SUBST(BTRFSRESTORE_ZSTD)
215 AC_ARG_ENABLE([python],
216         AS_HELP_STRING([--disable-python], [do not build libbtrfsutil Python bindings]),
217         [], [enable_python=yes]
220 if test "x$enable_python" = xyes; then
221         AM_PATH_PYTHON([3.4])
222         PKG_CHECK_MODULES(PYTHON, [python-${PYTHON_VERSION}])
225 AS_IF([test "x$enable_python" = xyes], [PYTHON_BINDINGS=1], [PYTHON_BINDINGS=0])
226 AC_SUBST(PYTHON_BINDINGS)
227 AC_SUBST(PYTHON)
229 # udev v190 introduced the btrfs builtin and a udev rule to use it.
230 # Our udev rule gives us the friendly dm names but isn't required (or valid)
231 # on earlier releases.
232 UDEVDIR=
233 if ${PKG_CONFIG} udev --atleast-version 190; then
234         UDEVDIR="$(${PKG_CONFIG} udev --variable=udevdir)"
236 AC_SUBST(UDEVDIR)
238 dnl lzo library does not provide pkg-config, let use classic way
239 AC_CHECK_LIB([lzo2], [lzo_version], [
240         LZO2_LIBS="-llzo2"
241         LZO2_CFLAGS=""
242         LZO2_LIBS_STATIC="-llzo2"],[
243         AC_MSG_ERROR([cannot find lzo2 library])
245 AC_SUBST([LZO2_LIBS])
246 AC_SUBST([LZO2_LIBS_STATIC])
247 AC_SUBST([LZO2_CFLAGS])
250 dnl library stuff
251 AC_SUBST([LIBBTRFS_MAJOR])
252 AC_SUBST([LIBBTRFS_MINOR])
253 AC_SUBST([LIBBTRFS_PATCHLEVEL])
255 AC_CONFIG_HEADERS([config.h])
257 AC_CONFIG_FILES([
258 Makefile.inc
259 Documentation/Makefile
260 version.h
263 AC_OUTPUT
265 AC_MSG_RESULT([
266         ${PACKAGE_NAME} ${PACKAGE_VERSION}
268         prefix:             ${prefix}
269         exec prefix:        ${exec_prefix}
271         bindir:             ${bindir}
272         libdir:             ${libdir}
273         includedir:         ${includedir}
275         compiler:           ${CC}
276         cflags:             ${CFLAGS}
277         ldflags:            ${LDFLAGS}
279         documentation:      ${enable_documentation}
280         doc generator:      ${ASCIIDOC_TOOL}
281         backtrace support:  ${enable_backtrace}
282         btrfs-convert:      ${enable_convert} ${convertfs:+($convertfs)}
283         btrfs-restore zstd: ${enable_zstd}
284         Python bindings:    ${enable_python}
285         Python interpreter: ${PYTHON}
287         Type 'make' to compile.