resize.f2fs: fix wrong ovp calculation
[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 AC_CHECK_LIB([lzo2], [main],
56         [AC_SUBST([liblzo2_LIBS], ["-llzo2"])
57                 AC_DEFINE([HAVE_LIBLZO2], [1],
58                 [Define if you have liblzo2])
59         ], [], [])
60
61 AC_CHECK_LIB([lz4], [main],
62         [AC_SUBST([liblz4_LIBS], ["-llz4"])
63                 AC_DEFINE([HAVE_LIBLZ4], [1],
64                 [Define if you have liblz4])
65         ], [], [])
66
67 PKG_CHECK_MODULES([libuuid], [uuid])
68
69 AS_IF([test "x$with_selinux" != "xno"],
70         [PKG_CHECK_MODULES([libselinux], [libselinux],
71                            [have_selinux=yes], [have_selinux=no])],
72         [have_selinux=no]
73 )
74
75 AS_IF([test "x$have_selinux" = "xyes"],
76         [AC_DEFINE([HAVE_LIBSELINUX], [1], [Use libselinux])],
77         [AS_IF([test "x$with_selinux" = "xyes"],
78                 [AC_MSG_ERROR([selinux support requested but libselinux not found])]
79         )]
80 )
81
82 AS_IF([test "x$with_blkid" != "xno"],
83         [PKG_CHECK_MODULES([libblkid], [blkid],
84                            [have_blkid=yes], [have_blkid=no])],
85         [have_blkid=no]
86 )
87
88 AS_IF([test "x$have_blkid" = "xyes"],
89         [AC_DEFINE([HAVE_LIBBLKID], [1], [Use blkid])],
90         [AS_IF([test "x$with_blkid" = "xyes"],
91                 [AC_MSG_ERROR([blkid support requested but libblkid not found])]
92         )]
93 )
94
95 # Checks for header files.
96 AC_CHECK_HEADERS(m4_flatten([
97         attr/xattr.h
98         byteswap.h
99         fcntl.h
100         linux/blkzoned.h
101         linux/falloc.h
102         linux/fs.h
103         linux/hdreg.h
104         linux/limits.h
105         linux/posix_acl.h
106         linux/types.h
107         linux/xattr.h
108         linux/fiemap.h
109         mach/mach_time.h
110         mntent.h
111         scsi/sg.h
112         stdlib.h
113         string.h
114         sys/acl.h
115         sys/ioctl.h
116         sys/syscall.h
117         sys/mount.h
118         sys/sysmacros.h
119         sys/utsname.h
120         sys/xattr.h
121         unistd.h
122 ]))
123
124 # Checks for typedefs, structures, and compiler characteristics.
125 AC_C_INLINE
126 AC_TYPE_INT32_T
127 AC_TYPE_INT8_T
128 AC_TYPE_SIZE_T
129
130 # Checks for library functions.
131 AC_FUNC_GETMNTENT
132 AC_CHECK_FUNCS_ONCE([
133         add_key
134         fallocate
135         fsetxattr
136         fstat
137         fstat64
138         getmntent
139         keyctl
140         llseek
141         lseek64
142         memset
143         setmntent
144 ])
145
146 AS_IF([test "$ac_cv_header_byteswap_h" = "yes"],
147       [AC_CHECK_DECLS([bswap_64],,,[#include <byteswap.h>])])
148
149 dnl
150 dnl Check to see if llseek() is declared in unistd.h.  On some libc's
151 dnl it is, and on others it isn't..... Thank you glibc developers....
152 dnl
153 AC_CHECK_DECL(llseek,[AC_DEFINE(HAVE_LLSEEK_PROTOTYPE, 1,
154                         [Define to 1 if llseek declared in unistd.h])],,
155                         [#include <unistd.h>])
156 dnl
157 dnl Check to see if lseek64() is declared in unistd.h.  Glibc's header files
158 dnl are so convoluted that I can't tell whether it will always be defined,
159 dnl and if it isn't defined while lseek64 is defined in the library,
160 dnl disaster will strike.
161 dnl
162 dnl Warning!  Use of --enable-gcc-wall may throw off this test.
163 dnl
164 dnl
165 AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1,
166                 [Define to 1 if lseek64 declared in unistd.h])],,
167                 [#define _LARGEFILE_SOURCE
168                 #define _LARGEFILE64_SOURCE
169                 #include <unistd.h>])
170 dnl
171 dnl Word sizes...
172 dnl
173
174 # AC_CANONICAL_HOST is needed to access the 'host_os' variable
175 AC_CANONICAL_HOST
176
177 build_linux=no
178 build_windows=no
179 build_mac=no
180
181 # Detect the target system
182 case "${host_os}" in
183 linux*|uclinux*)
184         build_linux=yes
185         ;;
186 cygwin*|mingw*)
187         build_windows=yes
188         ;;
189 darwin*)
190         build_mac=yes
191         ;;
192 *)
193         AC_MSG_ERROR(["OS $host_os is not supported"])
194         ;;
195 esac
196
197 # Pass the conditionals to automake
198 AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"])
199 AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"])
200 AM_CONDITIONAL([OSX], [test "$build_mac" = "yes"])
201
202 # Install directories
203 #AC_PREFIX_DEFAULT([/usr])
204 #AC_SUBST([sbindir], [/sbin])
205 #AC_SUBST([sysconfdir], [/etc])
206 #AC_SUBST([localstatedir], [/var])
207
208 AC_ARG_WITH([root-libdir],
209 [  --with-root-libdir=DIR override location for /lib/libf2fs.so],
210 root_libdir=$withval,
211 root_libdir=NONE)dnl
212
213 if test "$root_libdir" = NONE ; then
214    root_libdir="$libdir"
215 fi
216 AC_SUBST(root_libdir)
217
218 AC_CONFIG_FILES([
219         Makefile
220         man/Makefile
221         lib/Makefile
222         mkfs/Makefile
223         fsck/Makefile
224         tools/Makefile
225         tools/sg_write_buffer/Makefile
226         tools/f2fs_io/Makefile
227 ])
228
229 AC_CHECK_MEMBER([struct blk_zone.capacity],
230                 [AC_DEFINE(HAVE_BLK_ZONE_REP_V2, [1], [report zones includes zone capacity])],
231                 [], [[#include <linux/blkzoned.h>]])
232
233 # export library version info for mkfs/libf2fs_format_la
234 AC_SUBST(FMT_CURRENT, 7)
235 AC_SUBST(FMT_REVISION, 0)
236 AC_SUBST(FMT_AGE, 0)
237
238 # export library version info for lib/libf2fs_la
239 AC_SUBST(LIBF2FS_CURRENT, 8)
240 AC_SUBST(LIBF2FS_REVISION, 0)
241 AC_SUBST(LIBF2FS_AGE, 0)
242
243 AC_OUTPUT