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 45AC_ARG_WITH([blkid], 46 AS_HELP_STRING([--without-blkid], 47 [Ignore presence of libblkid and disable blkid support])) 48 49# Checks for programs. 50AC_PROG_CC 51AM_PROG_AR 52LT_INIT 53AC_PATH_PROG([LDCONFIG], [ldconfig], 54 [AC_MSG_ERROR([ldconfig not found])], 55 [$PATH:/sbin]) 56 57# Checks for libraries. 58AC_CHECK_LIB([blkid], [blkid_probe_all], 59 [AC_SUBST([libblkid_LIBS], ["-lblkid"]) 60 AC_DEFINE([HAVE_LIBBLKID], [1], 61 [Define if you have libblkid]) 62 ], [], []) 63 64AC_CHECK_LIB([lzo2], [main], 65 [AC_SUBST([liblzo2_LIBS], ["-llzo2"]) 66 AC_DEFINE([HAVE_LIBLZO2], [1], 67 [Define if you have liblzo2]) 68 ], [], []) 69 70AC_CHECK_LIB([lz4], [main], 71 [AC_SUBST([liblz4_LIBS], ["-llz4"]) 72 AC_DEFINE([HAVE_LIBLZ4], [1], 73 [Define if you have liblz4]) 74 ], [], []) 75 76AC_CHECK_LIB([selinux], [getcon], 77 [AC_SUBST([libselinux_LIBS], ["-lselinux"]) 78 AC_DEFINE([HAVE_LIBSELINUX], [1], 79 [Define if you have libselinux]) 80 ], [], []) 81 82AC_CHECK_LIB([uuid], [uuid_clear], 83 [AC_SUBST([libuuid_LIBS], ["-luuid"]) 84 AC_DEFINE([HAVE_LIBUUID], [1], 85 [Define if you have libuuid]) 86 ], [], []) 87 88AC_CHECK_LIB([winpthread], [clock_gettime], 89 [AC_SUBST([libwinpthread_LIBS], ["-lwinpthread"]) 90 AC_DEFINE([HAVE_LIBWINPTHREAD], [1], 91 [Define if you have libwinpthread]) 92 ], [], []) 93 94# Checks for header files. 95AC_CHECK_HEADERS(m4_flatten([ 96 attr/xattr.h 97 blkid/blkid.h 98 byteswap.h 99 fcntl.h 100 kernel/uapi/linux/blkzoned.h 101 linux/blkzoned.h 102 linux/falloc.h 103 linux/fiemap.h 104 linux/fs.h 105 linux/hdreg.h 106 linux/limits.h 107 linux/posix_acl.h 108 linux/types.h 109 linux/xattr.h 110 mach/mach_time.h 111 mntent.h 112 pthread_time.h 113 scsi/sg.h 114 selinux/android.h 115 selinux/selinux.h 116 sparse/sparse.h 117 stdlib.h 118 string.h 119 sys/acl.h 120 sys/ioctl.h 121 sys/mount.h 122 sys/stat.h 123 sys/syscall.h 124 sys/sysmacros.h 125 sys/utsname.h 126 sys/xattr.h 127 unistd.h 128 uuid/uuid.h 129])) 130 131# Checks for typedefs, structures, and compiler characteristics. 132AC_C_INLINE 133AC_TYPE_INT32_T 134AC_TYPE_INT8_T 135AC_TYPE_SIZE_T 136 137# Checks for library functions. 138AC_FUNC_GETMNTENT 139AC_CHECK_FUNCS_ONCE([ 140 add_key 141 fallocate 142 fsetxattr 143 fstat 144 fstat64 145 fsync 146 getgid 147 getmntent 148 getuid 149 keyctl 150 llseek 151 lseek64 152 memset 153 setmntent 154]) 155 156AS_IF([test "$ac_cv_header_byteswap_h" = "yes"], 157 [AC_CHECK_DECLS([bswap_64],,,[#include <byteswap.h>])]) 158 159AC_MSG_CHECKING([for CLOCK_BOOTIME]) 160AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 161#include <time.h> 162#ifdef HAVE_PTHREAD_TIME_H 163#include <pthread_time.h> 164#endif 165],[return CLOCK_BOOTTIME])], 166 [AC_MSG_RESULT([yes]) 167 AC_DEFINE([HAVE_CLOCK_BOOTTIME], [1], 168 [Define if CLOCK_BOOTTIME is available])], 169 [AC_MSG_RESULT([no])]) 170 171# AC_CANONICAL_HOST is needed to access the 'host_os' variable 172AC_CANONICAL_HOST 173 174build_linux=no 175build_windows=no 176build_mac=no 177 178# Detect the target system 179case "${host_os}" in 180linux*|uclinux*) 181 build_linux=yes 182 ;; 183cygwin*|mingw*) 184 build_windows=yes 185 ;; 186darwin*) 187 build_mac=yes 188 ;; 189*) 190 AC_MSG_ERROR(["OS $host_os is not supported"]) 191 ;; 192esac 193 194# Pass the conditionals to automake 195AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"]) 196AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"]) 197AM_CONDITIONAL([OSX], [test "$build_mac" = "yes"]) 198 199# Install directories 200#AC_PREFIX_DEFAULT([/usr]) 201#AC_SUBST([sbindir], [/sbin]) 202#AC_SUBST([sysconfdir], [/etc]) 203#AC_SUBST([localstatedir], [/var]) 204 205AC_ARG_WITH([root-libdir], 206[ --with-root-libdir=DIR override location for /lib/libf2fs.so], 207root_libdir=$withval, 208root_libdir=NONE)dnl 209 210if test "$root_libdir" = NONE ; then 211 root_libdir="$libdir" 212fi 213AC_SUBST(root_libdir) 214 215AC_CONFIG_FILES([ 216 Makefile 217 man/Makefile 218 lib/Makefile 219 mkfs/Makefile 220 fsck/Makefile 221 tools/Makefile 222 tools/sg_write_buffer/Makefile 223 tools/f2fs_io/Makefile 224]) 225 226AC_CHECK_MEMBER([struct blk_zone.capacity], 227 [AC_DEFINE(HAVE_BLK_ZONE_REP_V2, [1], [report zones includes zone capacity])], 228 [], [[ 229#ifdef HAVE_KERNEL_UAPI_LINUX_BLKZONED_H 230#include <kernel/uapi/linux/blkzoned.h> 231#elif defined(HAVE_LINUX_BLKZONED_H) 232#include <linux/blkzoned.h> 233#endif 234 ]]) 235 236# export library version info for mkfs/libf2fs_format_la 237AC_SUBST(FMT_CURRENT, 8) 238AC_SUBST(FMT_REVISION, 0) 239AC_SUBST(FMT_AGE, 0) 240 241# export library version info for lib/libf2fs_la 242AC_SUBST(LIBF2FS_CURRENT, 9) 243AC_SUBST(LIBF2FS_REVISION, 0) 244AC_SUBST(LIBF2FS_AGE, 0) 245 246AH_BOTTOM([ 247#ifndef _CONFIG_H_ 248#define _CONFIG_H_ 249 250#ifdef HAVE_SYS_STAT_H 251#include <sys/stat.h> 252#endif 253 254#ifndef HAVE_GETUID 255static inline unsigned int getuid(void) { return -1; } 256#endif 257#ifndef HAVE_GETGID 258static inline unsigned int getgid(void) { return -1; } 259#endif 260 261#ifndef S_ISLNK 262#define S_ISLNK(mode) false 263#endif 264#ifndef S_ISSOCK 265#define S_ISSOCK(mode) false 266#endif 267 268#endif 269]) 270 271AC_OUTPUT 272