btrfs-progs: autoconf: make btrfs-convert build optional
[platform/upstream/btrfs-progs.git] / configure.ac
1 AC_INIT([btrfs-progs],
2         m4_esyscmd([./version.sh --configure]),
3         [linux-btrfs@vger.kernel.org],,
4         [http://btrfs.wiki.kernel.org])
5
6 dnl library version
7 LIBBTRFS_MAJOR=0
8 LIBBTRFS_MINOR=1
9 LIBBTRFS_PATCHLEVEL=1
10
11 CFLAGS="-g -O1"
12
13 AC_PREREQ([2.60])
14
15 AC_CONFIG_AUX_DIR([config])
16 dnl AC_USE_SYSTEM_EXTENSIONS must be called before any macros that run
17 dnl the compiler (like AC_PROG_LIBTOOL) to avoid autoconf errors.
18 AC_USE_SYSTEM_EXTENSIONS
19
20 AC_CONFIG_SRCDIR([btrfs.c])
21 AC_PREFIX_DEFAULT([/usr])
22
23 AC_PROG_CC
24 AC_CANONICAL_HOST
25 AC_C_CONST
26 AC_C_VOLATILE
27 AC_C_BIGENDIAN
28
29 AC_SYS_LARGEFILE
30
31 AC_PROG_INSTALL
32 AC_PROG_LN_S
33 AC_PATH_PROG([AR], [ar])
34 AC_PATH_PROG([RM], [rm], [rm])
35 AC_PATH_PROG([RMDIR], [rmdir], [rmdir])
36
37 AC_CHECK_FUNCS([openat], [],
38         [AC_MSG_ERROR([cannot find openat() function])])
39
40 m4_ifndef([PKG_PROG_PKG_CONFIG],
41   [m4_fatal([Could not locate the pkg-config autoconf
42     macros. These are usually located in /usr/share/aclocal/pkg.m4.
43     If your macros are in a different location, try setting the
44     environment variable AL_OPTS="-I/other/macro/dir" before running
45     ./autogen.sh or autoreconf again.])])
46 PKG_PROG_PKG_CONFIG
47
48
49 dnl
50 dnl Calls pkg-config --static
51 dnl
52 AC_DEFUN([PKG_STATIC], [
53   if AC_RUN_LOG([pkg-config --exists --print-errors "$2"]); then
54     $1=`pkg-config --libs --static "$2"`
55     AC_SUBST([$1])
56   else
57     AC_MSG_ERROR([pkg-config description of $2, needed for static build, is not available])
58   fi
59 ])
60
61
62 AC_ARG_ENABLE([backtrace],
63   AS_HELP_STRING([--disable-backtrace], [disable btrfs backtrace]),
64   [], [enable_backtrace=yes]
65 )
66
67 AS_IF([test "x$enable_backtrace" = xno], [
68   AC_DEFINE([BTRFS_DISABLE_BACKTRACE], [1], [disable backtrace stuff in kerncompat.h ])
69 ])
70
71
72 AC_ARG_ENABLE([documentation],
73               AS_HELP_STRING([--disable-documentation], [do not build domumentation]),
74   [], [enable_documentation=yes]
75 )
76 AS_IF([test "x$enable_documentation" = xyes], [DISABLE_DOCUMENTATION=0], [DISABLE_DOCUMENTATION=1])
77 AC_SUBST([DISABLE_DOCUMENTATION])
78
79 dnl detect tools to build documentation
80 if test "x$enable_documentation" = xyes; then
81         AC_PATH_PROG([ASCIIDOC], [asciidoc], [asciidoc])
82         AC_PATH_PROG([XMLTO], [xmlto], [xmlto])
83         AC_PATH_PROG([GZIP], [gzip], [gzip])
84         AC_PATH_PROG([MV], [mv], [mv])
85         AC_PROG_SED
86 fi
87
88 AC_ARG_ENABLE([convert],
89               AS_HELP_STRING([--disable-convert], [do not build btrfs-convert]),
90   [], [enable_btrfsconvert=yes]
91 )
92
93 AS_IF([test "x$enable_btrfsconvert" = xyes], [DISABLE_BTRFSCONVERT=0], [DISABLE_BTRFSCONVERT=1])
94 AC_SUBST([DISABLE_BTRFSCONVERT])
95
96
97 dnl Define <NAME>_LIBS= and <NAME>_CFLAGS= by pkg-config
98 dnl
99 dnl The default PKG_CHECK_MODULES() action-if-not-found is end the
100 dnl execution with error. The static libs are optional.
101
102 PKG_CHECK_MODULES(BLKID, [blkid])
103 PKG_STATIC(BLKID_LIBS_STATIC, [blkid])
104
105 PKG_CHECK_MODULES(UUID, [uuid])
106 PKG_STATIC(UUID_LIBS_STATIC, [uuid])
107
108 PKG_CHECK_MODULES(ZLIB, [zlib])
109 PKG_STATIC(ZLIB_LIBS_STATIC, [zlib])
110
111 dnl lzo library does not provide pkg-config, let use classic way
112 AC_CHECK_LIB([lzo2], [lzo_version], [
113         LZO2_LIBS="-llzo2"
114         LZO2_CFLAGS=""
115         LZO2_LIBS_STATIC="-llzo2"],[
116         AC_MSG_ERROR([cannot find lzo2 library])
117 ])
118 AC_SUBST([LZO2_LIBS])
119 AC_SUBST([LZO2_LIBS_STATIC])
120 AC_SUBST([LZO2_CFLAGS])
121
122
123 dnl library stuff
124 AC_SUBST([LIBBTRFS_MAJOR])
125 AC_SUBST([LIBBTRFS_MINOR])
126 AC_SUBST([LIBBTRFS_PATCHLEVEL])
127
128 AC_CONFIG_HEADERS([config.h])
129
130 AC_CONFIG_FILES([
131 Makefile
132 Documentation/Makefile
133 version.h
134 ])
135
136 AC_OUTPUT
137
138 AC_MSG_RESULT([
139         ${PACKAGE_NAME} ${PACKAGE_VERSION}
140
141         prefix:            ${prefix}
142         exec prefix:       ${exec_prefix}
143
144         bindir:            ${bindir}
145         libdir:            ${libdir}
146         includedir:        ${includedir}
147
148         compiler:          ${CC}
149         cflags:            ${CFLAGS}
150         ldflags:           ${LDFLAGS}
151
152         Type 'make' to compile.
153 ])
154