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