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 15AM_SILENT_RULES([yes]) 16 17AC_DEFINE([F2FS_TOOLS_VERSION], "f2fs_tools_version", [f2fs-tools version]) 18AC_DEFINE([F2FS_MAJOR_VERSION], m4_bpatsubst(f2fs_tools_version, 19 [\([0-9]*\)\(\w\|\W\)*], [\1]), 20 [Major version for f2fs-tools]) 21AC_DEFINE([F2FS_MINOR_VERSION], m4_bpatsubst(f2fs_tools_version, 22 [\([0-9]*\).\([0-9]*\)\(\w\|\W\)*], [\2]), 23 [Minor version for f2fs-tools]) 24 25AS_IF([test -d .git],[ 26 AC_DEFINE([F2FS_TOOLS_DATE], 27 "m4_bpatsubst(f2fs_tools_gitdate, 28 [\([0-9-]*\)\(\w\|\W\)*], [\1])", 29 [f2fs-tools date based on Git commits])],[ 30 AC_DEFINE([F2FS_TOOLS_DATE], 31 "f2fs_tools_date", 32 [f2fs-tools date based on Source releases])]) 33 34AC_CONFIG_SRCDIR([config.h.in]) 35AC_CONFIG_HEADERS([config.h]) 36AC_CONFIG_MACRO_DIR([m4]) 37AC_CONFIG_AUX_DIR([build-aux]) 38AM_INIT_AUTOMAKE([-Wall -Werror foreign tar-pax dist-xz]) 39 40# Test configure options. 41AC_ARG_WITH([selinux], 42 [AS_HELP_STRING([--without-selinux], 43 [Ignore presence of libselinux and disable selinux support])], 44 [], 45 [with_selinux=check]) 46 47AC_ARG_WITH([blkid], 48 [AS_HELP_STRING([--without-blkid], 49 [Ignore presence of libblkid and disable blkid support])], 50 [], 51 [with_blkid=check]) 52 53AC_ARG_WITH([lzo2], 54 [AS_HELP_STRING([--without-lzo2], 55 [Ignore presence of liblzo2 and disable lzo2 support])], 56 [], 57 [with_lzo2=check]) 58 59AC_ARG_WITH([lz4], 60 [AS_HELP_STRING([--without-lz4], 61 [Ignore presence of liblz4 and disable lz4 support])], 62 [], 63 [with_lz4=check]) 64 65# Checks for programs. 66AC_PROG_CC 67AM_PROG_AR 68LT_INIT 69AC_PATH_PROG([LDCONFIG], [ldconfig], 70 [AC_MSG_ERROR([ldconfig not found])], 71 [$PATH:/sbin]) 72 73# Checks for libraries. 74AS_IF([test "x$with_blkid" != xno], 75 [AC_CHECK_LIB([blkid], [blkid_probe_all], 76 [AC_SUBST([libblkid_LIBS], ["-lblkid"]) 77 AC_DEFINE([HAVE_LIBBLKID], [1], 78 [Define if you have libblkid]) 79 ], 80 [if test "x$with_blkid" != xcheck; then 81 AC_MSG_FAILURE( 82 [--with-blkid was given, but test for blkid failed]) 83 fi 84 ], -lblkid)]) 85 86AS_IF([test "x$with_lzo2" != xno], 87 [AC_CHECK_LIB([lzo2], [main], 88 [AC_SUBST([liblzo2_LIBS], ["-llzo2"]) 89 AC_DEFINE([HAVE_LIBLZO2], [1], 90 [Define if you have liblzo2]) 91 ], 92 [if test "x$with_lzo2" != xcheck; then 93 AC_MSG_FAILURE( 94 [--with-lzo2 was given, but test for lzo2 failed]) 95 fi 96 ], -llzo2)]) 97 98AS_IF([test "x$with_lz4" != xno], 99 [AC_CHECK_LIB([lz4], [main], 100 [AC_SUBST([liblz4_LIBS], ["-llz4"]) 101 AC_DEFINE([HAVE_LIBLZ4], [1], 102 [Define if you have liblz4]) 103 ], 104 [if test "x$with_lz4" != xcheck; then 105 AC_MSG_FAILURE( 106 [--with-lz4 was given, but test for lz4 failed]) 107 fi 108 ], -llz4)]) 109 110AS_IF([test "x$with_selinux" != xno], 111 [AC_CHECK_LIB([selinux], [getcon], 112 [AC_SUBST([libselinux_LIBS], ["-lselinux"]) 113 AC_DEFINE([HAVE_LIBSELINUX], [1], 114 [Define if you have libselinux]) 115 ], 116 [if test "x$with_selinux" != xcheck; then 117 AC_MSG_FAILURE( 118 [--with-selinux was given, but test for selinux failed]) 119 fi 120 ], -lselinux)]) 121 122AC_CHECK_LIB([uuid], [uuid_clear], 123 [AC_SUBST([libuuid_LIBS], ["-luuid"]) 124 AC_DEFINE([HAVE_LIBUUID], [1], 125 [Define if you have libuuid]) 126 ], [], []) 127 128AC_CHECK_LIB([winpthread], [clock_gettime], 129 [AC_SUBST([libwinpthread_LIBS], ["-lwinpthread"]) 130 AC_DEFINE([HAVE_LIBWINPTHREAD], [1], 131 [Define if you have libwinpthread]) 132 ], [], []) 133 134# Checks for header files. 135AC_CHECK_HEADERS(m4_flatten([ 136 attr/xattr.h 137 blkid/blkid.h 138 byteswap.h 139 fcntl.h 140 kernel/uapi/linux/blkzoned.h 141 linux/blkzoned.h 142 linux/falloc.h 143 linux/fiemap.h 144 linux/fs.h 145 linux/hdreg.h 146 linux/limits.h 147 linux/posix_acl.h 148 linux/types.h 149 linux/xattr.h 150 mach/mach_time.h 151 mntent.h 152 pthread_time.h 153 scsi/sg.h 154 selinux/android.h 155 selinux/selinux.h 156 sparse/sparse.h 157 stdlib.h 158 string.h 159 sys/acl.h 160 sys/ioctl.h 161 sys/mount.h 162 sys/stat.h 163 sys/syscall.h 164 sys/sysmacros.h 165 sys/utsname.h 166 sys/xattr.h 167 unistd.h 168 uuid/uuid.h 169])) 170 171# Checks for typedefs, structures, and compiler characteristics. 172AC_C_INLINE 173AC_TYPE_INT32_T 174AC_TYPE_INT8_T 175AC_TYPE_SIZE_T 176 177# Checks for library functions. 178AC_FUNC_GETMNTENT 179AC_CHECK_FUNCS_ONCE([ 180 add_key 181 fallocate 182 fsetxattr 183 fstat 184 fstat64 185 fsync 186 getgid 187 getmntent 188 getuid 189 keyctl 190 llseek 191 lseek64 192 memset 193 setmntent 194 clock_gettime 195]) 196 197AS_IF([test "$ac_cv_header_byteswap_h" = "yes"], 198 [AC_CHECK_DECLS([bswap_64],,,[#include <byteswap.h>])]) 199 200AC_MSG_CHECKING([for CLOCK_BOOTIME]) 201AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 202#include <time.h> 203#ifdef HAVE_PTHREAD_TIME_H 204#include <pthread_time.h> 205#endif 206],[return CLOCK_BOOTTIME])], 207 [AC_MSG_RESULT([yes]) 208 AC_DEFINE([HAVE_CLOCK_BOOTTIME], [1], 209 [Define if CLOCK_BOOTTIME is available])], 210 [AC_MSG_RESULT([no])]) 211 212# AC_CANONICAL_HOST is needed to access the 'host_os' variable 213AC_CANONICAL_HOST 214 215build_linux=no 216build_windows=no 217build_mac=no 218 219# Detect the target system 220case "${host_os}" in 221linux*|uclinux*) 222 build_linux=yes 223 ;; 224cygwin*|mingw*) 225 build_windows=yes 226 ;; 227darwin*) 228 build_mac=yes 229 ;; 230*) 231 AC_MSG_ERROR(["OS $host_os is not supported"]) 232 ;; 233esac 234 235# Pass the conditionals to automake 236AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"]) 237AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"]) 238AM_CONDITIONAL([OSX], [test "$build_mac" = "yes"]) 239 240# Install directories 241#AC_PREFIX_DEFAULT([/usr]) 242#AC_SUBST([sbindir], [/sbin]) 243#AC_SUBST([sysconfdir], [/etc]) 244#AC_SUBST([localstatedir], [/var]) 245 246AC_ARG_WITH([root-libdir], 247[ --with-root-libdir=DIR override location for /lib/libf2fs.so], 248root_libdir=$withval, 249root_libdir=NONE)dnl 250 251if test "$root_libdir" = NONE ; then 252 root_libdir="$libdir" 253fi 254AC_SUBST(root_libdir) 255 256AC_CONFIG_FILES([ 257 Makefile 258 man/Makefile 259 lib/Makefile 260 mkfs/Makefile 261 fsck/Makefile 262 tools/Makefile 263 tools/f2fs_io/Makefile 264]) 265 266AC_CHECK_MEMBER([struct blk_zone.capacity], 267 [AC_DEFINE(HAVE_BLK_ZONE_REP_V2, [1], [report zones includes zone capacity])], 268 [], [[ 269#ifdef HAVE_KERNEL_UAPI_LINUX_BLKZONED_H 270#include <kernel/uapi/linux/blkzoned.h> 271#elif defined(HAVE_LINUX_BLKZONED_H) 272#include <linux/blkzoned.h> 273#endif 274 ]]) 275 276# export library version info for mkfs/libf2fs_format_la 277AC_SUBST(FMT_CURRENT, 9) 278AC_SUBST(FMT_REVISION, 0) 279AC_SUBST(FMT_AGE, 0) 280 281# export library version info for lib/libf2fs_la 282AC_SUBST(LIBF2FS_CURRENT, 10) 283AC_SUBST(LIBF2FS_REVISION, 0) 284AC_SUBST(LIBF2FS_AGE, 0) 285 286AH_BOTTOM([ 287#ifndef _CONFIG_H_ 288#define _CONFIG_H_ 289 290#ifdef HAVE_SYS_STAT_H 291#include <sys/stat.h> 292#endif 293 294#ifndef HAVE_GETUID 295static inline unsigned int getuid(void) { return -1; } 296#endif 297#ifndef HAVE_GETGID 298static inline unsigned int getgid(void) { return -1; } 299#endif 300 301#ifndef S_ISLNK 302#define S_ISLNK(mode) false 303#endif 304#ifndef S_ISSOCK 305#define S_ISSOCK(mode) false 306#endif 307 308#endif 309]) 310 311AC_OUTPUT 312