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 [[email protected]]) 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/rw_hint.h 143 linux/fcntl.h 144 linux/falloc.h 145 linux/fiemap.h 146 linux/fs.h 147 linux/hdreg.h 148 linux/limits.h 149 linux/loop.h 150 linux/major.h 151 linux/posix_acl.h 152 linux/types.h 153 linux/xattr.h 154 mach/mach_time.h 155 mntent.h 156 pthread_time.h 157 scsi/sg.h 158 selinux/android.h 159 selinux/selinux.h 160 sparse/sparse.h 161 stdlib.h 162 string.h 163 sys/acl.h 164 sys/ioctl.h 165 sys/mount.h 166 sys/stat.h 167 sys/syscall.h 168 sys/sysmacros.h 169 sys/utsname.h 170 sys/xattr.h 171 unistd.h 172 uuid/uuid.h 173])) 174 175# Checks for typedefs, structures, and compiler characteristics. 176AC_C_INLINE 177AC_TYPE_INT32_T 178AC_TYPE_INT8_T 179AC_TYPE_SIZE_T 180 181# Checks for library functions. 182AC_FUNC_GETMNTENT 183AC_CHECK_FUNCS_ONCE([ 184 add_key 185 fallocate 186 fsetxattr 187 fstat 188 fstat64 189 fsync 190 getgid 191 getmntent 192 getuid 193 keyctl 194 memset 195 setmntent 196 clock_gettime 197]) 198 199AS_IF([test "$ac_cv_header_byteswap_h" = "yes"], 200 [AC_CHECK_DECLS([bswap_64],,,[#include <byteswap.h>])]) 201 202AC_MSG_CHECKING([for CLOCK_BOOTIME]) 203AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 204#include <time.h> 205#ifdef HAVE_PTHREAD_TIME_H 206#include <pthread_time.h> 207#endif 208],[return CLOCK_BOOTTIME])], 209 [AC_MSG_RESULT([yes]) 210 AC_DEFINE([HAVE_CLOCK_BOOTTIME], [1], 211 [Define if CLOCK_BOOTTIME is available])], 212 [AC_MSG_RESULT([no])]) 213 214# AC_CANONICAL_HOST is needed to access the 'host_os' variable 215AC_CANONICAL_HOST 216 217build_linux=no 218build_windows=no 219build_mac=no 220 221# Detect the target system 222case "${host_os}" in 223linux*|uclinux*) 224 build_linux=yes 225 ;; 226cygwin*|mingw*) 227 build_windows=yes 228 ;; 229darwin*) 230 build_mac=yes 231 ;; 232*) 233 AC_MSG_ERROR(["OS $host_os is not supported"]) 234 ;; 235esac 236 237# Pass the conditionals to automake 238AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"]) 239AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"]) 240AM_CONDITIONAL([OSX], [test "$build_mac" = "yes"]) 241 242# Install directories 243#AC_PREFIX_DEFAULT([/usr]) 244#AC_SUBST([sbindir], [/sbin]) 245#AC_SUBST([sysconfdir], [/etc]) 246#AC_SUBST([localstatedir], [/var]) 247 248AC_ARG_WITH([root-libdir], 249[ --with-root-libdir=DIR override location for /lib/libf2fs.so], 250root_libdir=$withval, 251root_libdir=NONE)dnl 252 253if test "$root_libdir" = NONE ; then 254 root_libdir="$libdir" 255fi 256AC_SUBST(root_libdir) 257 258AC_CONFIG_FILES([ 259 Makefile 260 man/Makefile 261 lib/Makefile 262 mkfs/Makefile 263 fsck/Makefile 264 tools/Makefile 265 tools/f2fs_io/Makefile 266]) 267 268AC_CHECK_MEMBER([struct blk_zone.capacity], 269 [AC_DEFINE(HAVE_BLK_ZONE_REP_V2, [1], [report zones includes zone capacity])], 270 [], [[ 271#ifdef HAVE_KERNEL_UAPI_LINUX_BLKZONED_H 272#include <kernel/uapi/linux/blkzoned.h> 273#elif defined(HAVE_LINUX_BLKZONED_H) 274#include <linux/blkzoned.h> 275#endif 276 ]]) 277 278# export library version info for mkfs/libf2fs_format_la 279AC_SUBST(FMT_CURRENT, 9) 280AC_SUBST(FMT_REVISION, 0) 281AC_SUBST(FMT_AGE, 0) 282 283# export library version info for lib/libf2fs_la 284AC_SUBST(LIBF2FS_CURRENT, 10) 285AC_SUBST(LIBF2FS_REVISION, 0) 286AC_SUBST(LIBF2FS_AGE, 0) 287 288AH_BOTTOM([ 289#ifndef _CONFIG_H_ 290#define _CONFIG_H_ 291 292#ifdef HAVE_SYS_STAT_H 293#include <sys/stat.h> 294#endif 295 296#ifndef HAVE_GETUID 297static inline unsigned int getuid(void) { return -1; } 298#endif 299#ifndef HAVE_GETGID 300static inline unsigned int getgid(void) { return -1; } 301#endif 302 303#ifndef S_ISLNK 304#define S_ISLNK(mode) false 305#endif 306#ifndef S_ISSOCK 307#define S_ISSOCK(mode) false 308#endif 309 310#endif 311]) 312 313AC_OUTPUT 314