f2fs_io: change fibmap to fiemap
[platform/upstream/f2fs-tools.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.68])
5
6 # Get version from file VERSION
7 m4_define([f2fs_tools_version], m4_esyscmd([sed -n '1p' VERSION | tr -d '\n']))
8 m4_define([f2fs_tools_date], m4_esyscmd([sed -n '2p' VERSION | tr -d '\n']))
9 m4_define([f2fs_tools_gitdate],
10                 m4_esyscmd([git log -1 --pretty=format:%ci 2> /dev/null]))
11
12 AC_INIT([F2FS tools], [f2fs_tools_version],
13                         [linux-f2fs-devel@lists.sourceforge.net])
14
15 AC_DEFINE([F2FS_TOOLS_VERSION], "f2fs_tools_version", [f2fs-tools version])
16 AC_DEFINE([F2FS_MAJOR_VERSION], m4_bpatsubst(f2fs_tools_version,
17                                 [\([0-9]*\)\(\w\|\W\)*], [\1]),
18                                 [Major version for f2fs-tools])
19 AC_DEFINE([F2FS_MINOR_VERSION], m4_bpatsubst(f2fs_tools_version,
20                                 [\([0-9]*\).\([0-9]*\)\(\w\|\W\)*], [\2]),
21                                 [Minor version for f2fs-tools])
22
23 AS_IF([test -d .git],[
24         AC_DEFINE([F2FS_TOOLS_DATE],
25                 "m4_bpatsubst(f2fs_tools_gitdate,
26                 [\([0-9-]*\)\(\w\|\W\)*], [\1])",
27                 [f2fs-tools date based on Git commits])],[
28         AC_DEFINE([F2FS_TOOLS_DATE],
29                 "f2fs_tools_date",
30                 [f2fs-tools date based on Source releases])])
31
32 AC_CONFIG_SRCDIR([config.h.in])
33 AC_CONFIG_HEADER([config.h])
34 AC_CONFIG_MACRO_DIR([m4])
35 AC_CONFIG_AUX_DIR([build-aux])
36 AM_INIT_AUTOMAKE([foreign tar-pax dist-xz])
37
38 # Test configure options.
39 AC_ARG_WITH([selinux],
40         AS_HELP_STRING([--without-selinux],
41           [Ignore presence of libselinux and disable selinux support]))
42
43 AC_ARG_WITH([blkid],
44         AS_HELP_STRING([--without-blkid],
45           [Ignore presence of libblkid and disable blkid support]))
46
47 # Checks for programs.
48 AC_PROG_CC
49 AC_PROG_LIBTOOL
50 AC_PATH_PROG([LDCONFIG], [ldconfig],
51        [AC_MSG_ERROR([ldconfig not found])],
52        [$PATH:/sbin])
53
54 # Checks for libraries.
55 PKG_CHECK_MODULES([libuuid], [uuid])
56
57 AS_IF([test "x$with_selinux" != "xno"],
58         [PKG_CHECK_MODULES([libselinux], [libselinux],
59                            [have_selinux=yes], [have_selinux=no])],
60         [have_selinux=no]
61 )
62
63 AS_IF([test "x$have_selinux" = "xyes"],
64         [AC_DEFINE([HAVE_LIBSELINUX], [1], [Use libselinux])],
65         [AS_IF([test "x$with_selinux" = "xyes"],
66                 [AC_MSG_ERROR([selinux support requested but libselinux not found])]
67         )]
68 )
69
70 AS_IF([test "x$with_blkid" != "xno"],
71         [PKG_CHECK_MODULES([libblkid], [blkid],
72                            [have_blkid=yes], [have_blkid=no])],
73         [have_blkid=no]
74 )
75
76 AS_IF([test "x$have_blkid" = "xyes"],
77         [AC_DEFINE([HAVE_LIBBLKID], [1], [Use blkid])],
78         [AS_IF([test "x$with_blkid" = "xyes"],
79                 [AC_MSG_ERROR([blkid support requested but libblkid not found])]
80         )]
81 )
82
83 # Checks for header files.
84 AC_CHECK_HEADERS(m4_flatten([
85         attr/xattr.h
86         byteswap.h
87         fcntl.h
88         linux/blkzoned.h
89         linux/falloc.h
90         linux/fs.h
91         linux/hdreg.h
92         linux/limits.h
93         linux/posix_acl.h
94         linux/types.h
95         linux/xattr.h
96         linux/fiemap.h
97         mach/mach_time.h
98         mntent.h
99         scsi/sg.h
100         stdlib.h
101         string.h
102         sys/acl.h
103         sys/ioctl.h
104         sys/syscall.h
105         sys/mount.h
106         sys/sysmacros.h
107         sys/utsname.h
108         sys/xattr.h
109         unistd.h
110 ]))
111
112 # Checks for typedefs, structures, and compiler characteristics.
113 AC_C_INLINE
114 AC_TYPE_INT32_T
115 AC_TYPE_INT8_T
116 AC_TYPE_SIZE_T
117
118 # Checks for library functions.
119 AC_FUNC_GETMNTENT
120 AC_CHECK_FUNCS_ONCE([
121         add_key
122         fallocate
123         fsetxattr
124         fstat
125         fstat64
126         getmntent
127         keyctl
128         llseek
129         lseek64
130         memset
131         setmntent
132 ])
133
134 AS_IF([test "$ac_cv_header_byteswap_h" = "yes"],
135       [AC_CHECK_DECLS([bswap_64],,,[#include <byteswap.h>])])
136
137 dnl
138 dnl Check to see if llseek() is declared in unistd.h.  On some libc's
139 dnl it is, and on others it isn't..... Thank you glibc developers....
140 dnl
141 AC_CHECK_DECL(llseek,[AC_DEFINE(HAVE_LLSEEK_PROTOTYPE, 1,
142                         [Define to 1 if llseek declared in unistd.h])],,
143                         [#include <unistd.h>])
144 dnl
145 dnl Check to see if lseek64() is declared in unistd.h.  Glibc's header files
146 dnl are so convoluted that I can't tell whether it will always be defined,
147 dnl and if it isn't defined while lseek64 is defined in the library,
148 dnl disaster will strike.
149 dnl
150 dnl Warning!  Use of --enable-gcc-wall may throw off this test.
151 dnl
152 dnl
153 AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1,
154                 [Define to 1 if lseek64 declared in unistd.h])],,
155                 [#define _LARGEFILE_SOURCE
156                 #define _LARGEFILE64_SOURCE
157                 #include <unistd.h>])
158 dnl
159 dnl Word sizes...
160 dnl
161
162 # AC_CANONICAL_HOST is needed to access the 'host_os' variable
163 AC_CANONICAL_HOST
164
165 build_linux=no
166 build_windows=no
167 build_mac=no
168
169 # Detect the target system
170 case "${host_os}" in
171 linux*|uclinux*)
172         build_linux=yes
173         ;;
174 cygwin*|mingw*)
175         build_windows=yes
176         ;;
177 darwin*)
178         build_mac=yes
179         ;;
180 *)
181         AC_MSG_ERROR(["OS $host_os is not supported"])
182         ;;
183 esac
184
185 # Pass the conditionals to automake
186 AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"])
187 AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"])
188 AM_CONDITIONAL([OSX], [test "$build_mac" = "yes"])
189
190 # Install directories
191 #AC_PREFIX_DEFAULT([/usr])
192 #AC_SUBST([sbindir], [/sbin])
193 #AC_SUBST([sysconfdir], [/etc])
194 #AC_SUBST([localstatedir], [/var])
195
196 AC_ARG_WITH([root-libdir],
197 [  --with-root-libdir=DIR override location for /lib/libf2fs.so],
198 root_libdir=$withval,
199 root_libdir=NONE)dnl
200
201 if test "$root_libdir" = NONE ; then
202    root_libdir="$libdir"
203 fi
204 AC_SUBST(root_libdir)
205
206 AC_CONFIG_FILES([
207         Makefile
208         man/Makefile
209         lib/Makefile
210         mkfs/Makefile
211         fsck/Makefile
212         tools/Makefile
213         tools/sg_write_buffer/Makefile
214         tools/f2fs_io/Makefile
215 ])
216
217 AC_CHECK_MEMBER([struct blk_zone.capacity],
218                 [AC_DEFINE(HAVE_BLK_ZONE_REP_V2, [1], [report zones includes zone capacity])],
219                 [], [[#include <linux/blkzoned.h>]])
220
221 # export library version info for mkfs/libf2fs_format_la
222 AC_SUBST(FMT_CURRENT, 7)
223 AC_SUBST(FMT_REVISION, 0)
224 AC_SUBST(FMT_AGE, 0)
225
226 # export library version info for lib/libf2fs_la
227 AC_SUBST(LIBF2FS_CURRENT, 8)
228 AC_SUBST(LIBF2FS_REVISION, 0)
229 AC_SUBST(LIBF2FS_AGE, 0)
230
231 AC_OUTPUT