1# -*- Autoconf -*- 2# Process this file with autoconf to produce a configure script. 3 4AC_PREREQ([2.69]) 5 6m4_define([erofs_utils_version], m4_esyscmd_s([scripts/get-version-number])) 7m4_define([erofs_utils_date], m4_esyscmd([sed -n '2p' VERSION | tr -d '\n'])) 8 9AC_INIT([erofs-utils], [erofs_utils_version], [linux-erofs@lists.ozlabs.org]) 10AC_CONFIG_SRCDIR([config.h.in]) 11AC_CONFIG_HEADERS([config.h]) 12AC_CONFIG_MACRO_DIR([m4]) 13AC_CONFIG_AUX_DIR(config) 14AM_INIT_AUTOMAKE([foreign -Wall]) 15 16# Checks for programs. 17AM_PROG_AR 18AC_PROG_CC 19AC_PROG_INSTALL 20 21LT_INIT 22 23# Test presence of pkg-config 24AC_MSG_CHECKING([pkg-config m4 macros]) 25if test m4_ifdef([PKG_CHECK_MODULES], [yes], [no]) = "yes"; then 26 AC_MSG_RESULT([yes]); 27else 28 AC_MSG_RESULT([no]); 29 AC_MSG_ERROR([pkg-config is required. See pkg-config.freedesktop.org]) 30fi 31 32dnl EROFS_UTILS_PARSE_DIRECTORY 33dnl Input: $1 = a string to a relative or absolute directory 34dnl Output: $2 = the variable to set with the absolute directory 35AC_DEFUN([EROFS_UTILS_PARSE_DIRECTORY], 36[ 37 dnl Check if argument is a directory 38 if test -d $1 ; then 39 dnl Get the absolute path of the directory 40 dnl in case of relative directory. 41 dnl If realpath is not a valid command, 42 dnl an error is produced and we keep the given path. 43 local_tmp=`realpath $1 2>/dev/null` 44 if test "$local_tmp" != "" ; then 45 if test -d "$local_tmp" ; then 46 $2="$local_tmp" 47 else 48 $2=$1 49 fi 50 else 51 $2=$1 52 fi 53 dnl Check for space in the directory 54 if test `echo $1|cut -d' ' -f1` != $1 ; then 55 AC_MSG_ERROR($1 directory shall not contain any space.) 56 fi 57 else 58 AC_MSG_ERROR($1 shall be a valid directory) 59 fi 60]) 61 62AC_ARG_ENABLE([debug], 63 [AS_HELP_STRING([--enable-debug], 64 [enable debugging mode @<:@default=no@:>@])], 65 [enable_debug="$enableval"], 66 [enable_debug="no"]) 67 68AC_ARG_ENABLE([werror], 69 [AS_HELP_STRING([--enable-werror], 70 [enable -Werror @<:@default=no@:>@])], 71 [enable_werror="$enableval"], 72 [enable_werror="no"]) 73 74AC_ARG_ENABLE(lz4, 75 [AS_HELP_STRING([--disable-lz4], [disable LZ4 compression support @<:@default=enabled@:>@])], 76 [enable_lz4="$enableval"], [enable_lz4="yes"]) 77 78AC_ARG_ENABLE(lzma, 79 [AS_HELP_STRING([--enable-lzma], [enable LZMA compression support @<:@default=no@:>@])], 80 [enable_lzma="$enableval"], [enable_lzma="no"]) 81 82AC_ARG_ENABLE(fuse, 83 [AS_HELP_STRING([--enable-fuse], [enable erofsfuse @<:@default=no@:>@])], 84 [enable_fuse="$enableval"], [enable_fuse="no"]) 85 86AC_ARG_WITH(uuid, 87 [AS_HELP_STRING([--without-uuid], 88 [Ignore presence of libuuid and disable uuid support @<:@default=enabled@:>@])]) 89 90AC_ARG_WITH(selinux, 91 [AS_HELP_STRING([--with-selinux], 92 [enable and build with selinux support @<:@default=no@:>@])], 93 [case "$with_selinux" in 94 yes|no) ;; 95 *) AC_MSG_ERROR([invalid argument to --with-selinux]) 96 ;; 97 esac], [with_selinux=no]) 98 99# Checks for libraries. 100# Use customized LZ4 library path when specified. 101AC_ARG_WITH(lz4-incdir, 102 [AS_HELP_STRING([--with-lz4-incdir=DIR], [LZ4 include directory])], [ 103 EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])]) 104 105AC_ARG_WITH(lz4-libdir, 106 [AS_HELP_STRING([--with-lz4-libdir=DIR], [LZ4 lib directory])], [ 107 EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])]) 108 109AC_ARG_VAR([LZ4_CFLAGS], [C compiler flags for lz4]) 110AC_ARG_VAR([LZ4_LIBS], [linker flags for lz4]) 111 112AC_ARG_WITH(liblzma-incdir, 113 [AS_HELP_STRING([--with-liblzma-incdir=DIR], [liblzma include directory])], [ 114 EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])]) 115 116AC_ARG_WITH(liblzma-libdir, 117 [AS_HELP_STRING([--with-liblzma-libdir=DIR], [liblzma lib directory])], [ 118 EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])]) 119 120# Checks for header files. 121AC_CHECK_HEADERS(m4_flatten([ 122 dirent.h 123 execinfo.h 124 fcntl.h 125 getopt.h 126 inttypes.h 127 linux/falloc.h 128 linux/fs.h 129 linux/types.h 130 linux/xattr.h 131 limits.h 132 stddef.h 133 stdint.h 134 stdlib.h 135 string.h 136 sys/ioctl.h 137 sys/stat.h 138 sys/sysmacros.h 139 sys/time.h 140 unistd.h 141])) 142 143AC_HEADER_TIOCGWINSZ 144 145# Checks for typedefs, structures, and compiler characteristics. 146AC_C_INLINE 147AC_TYPE_INT64_T 148AC_TYPE_SIZE_T 149AC_TYPE_SSIZE_T 150AC_CHECK_MEMBERS([struct stat.st_rdev]) 151AC_CHECK_MEMBERS([struct stat.st_atim]) 152AC_CHECK_MEMBERS([struct stat.st_atimensec]) 153AC_TYPE_UINT64_T 154 155# 156# Check to see if llseek() is declared in unistd.h. On some libc's 157# it is, and on others it isn't..... Thank you glibc developers.... 158# 159AC_CHECK_DECL(llseek, 160 [AC_DEFINE(HAVE_LLSEEK_PROTOTYPE, 1, 161 [Define to 1 if llseek declared in unistd.h])],, 162 [#include <unistd.h>]) 163 164# 165# Check to see if lseek64() is declared in unistd.h. Glibc's header files 166# are so convoluted that I can't tell whether it will always be defined, 167# and if it isn't defined while lseek64 is defined in the library, 168# disaster will strike. 169# 170# Warning! Use of --enable-gcc-wall may throw off this test. 171# 172AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1, 173 [Define to 1 if lseek64 declared in unistd.h])],, 174 [#define _LARGEFILE_SOURCE 175 #define _LARGEFILE64_SOURCE 176 #include <unistd.h>]) 177 178AC_CHECK_DECL(memrchr,[AC_DEFINE(HAVE_MEMRCHR, 1, 179 [Define to 1 if memrchr declared in string.h])],, 180 [#define _GNU_SOURCE 181 #include <string.h>]) 182 183# Checks for library functions. 184AC_CHECK_FUNCS(m4_flatten([ 185 backtrace 186 copy_file_range 187 fallocate 188 gettimeofday 189 lgetxattr 190 llistxattr 191 memset 192 realpath 193 pread64 194 pwrite64 195 strdup 196 strerror 197 strrchr 198 strtoull 199 tmpfile64 200 utimensat])) 201 202# Configure debug mode 203AS_IF([test "x$enable_debug" != "xno"], [], [ 204 dnl Turn off all assert checking. 205 CPPFLAGS="$CPPFLAGS -DNDEBUG" 206]) 207 208# Configure -Werror 209AS_IF([test "x$enable_werror" != "xyes"], [], [ 210 CPPFLAGS="$CPPFLAGS -Werror" 211]) 212 213# Configure libuuid 214AS_IF([test "x$with_uuid" != "xno"], [ 215 PKG_CHECK_MODULES([libuuid], [uuid]) 216 # Paranoia: don't trust the result reported by pkgconfig before trying out 217 saved_LIBS="$LIBS" 218 saved_CPPFLAGS=${CPPFLAGS} 219 CPPFLAGS="${libuuid_CFLAGS} ${CPPFLAGS}" 220 LIBS="${libuuid_LIBS} $LIBS" 221 AC_MSG_CHECKING([libuuid usability]) 222 AC_TRY_LINK([ 223#include <uuid.h> 224], [ 225uuid_t tmp; 226 227uuid_generate(tmp); 228return 0; 229], [have_uuid="yes" 230 AC_MSG_RESULT([yes])], [ 231 have_uuid="no" 232 AC_MSG_RESULT([no]) 233 AC_MSG_ERROR([libuuid doesn't work properly])]) 234 LIBS="${saved_LIBS}" 235 CPPFLAGS="${saved_CPPFLAGS}"], [have_uuid="no"]) 236 237# Configure selinux 238AS_IF([test "x$with_selinux" != "xno"], [ 239 PKG_CHECK_MODULES([libselinux], [libselinux]) 240 # Paranoia: don't trust the result reported by pkgconfig before trying out 241 saved_LIBS="$LIBS" 242 saved_CPPFLAGS=${CPPFLAGS} 243 CPPFLAGS="${libselinux_CFLAGS} ${CPPFLAGS}" 244 LIBS="${libselinux_LIBS} $LIBS" 245 AC_CHECK_LIB(selinux, selabel_lookup, [ 246 have_selinux="yes" ], [ 247 AC_MSG_ERROR([libselinux doesn't work properly])]) 248 LIBS="${saved_LIBS}" 249 CPPFLAGS="${saved_CPPFLAGS}"], [have_selinux="no"]) 250 251# Configure fuse 252AS_IF([test "x$enable_fuse" != "xno"], [ 253 PKG_CHECK_MODULES([libfuse], [fuse >= 2.6]) 254 # Paranoia: don't trust the result reported by pkgconfig before trying out 255 saved_LIBS="$LIBS" 256 saved_CPPFLAGS=${CPPFLAGS} 257 CPPFLAGS="${libfuse_CFLAGS} ${CPPFLAGS}" 258 LIBS="${libfuse_LIBS} $LIBS" 259 AC_CHECK_LIB(fuse, fuse_main, [ 260 have_fuse="yes" ], [ 261 AC_MSG_ERROR([libfuse (>= 2.6) doesn't work properly])]) 262 LIBS="${saved_LIBS}" 263 CPPFLAGS="${saved_CPPFLAGS}"], [have_fuse="no"]) 264 265# Configure lz4 266test -z $LZ4_LIBS && LZ4_LIBS='-llz4' 267 268if test "x$enable_lz4" = "xyes"; then 269 test -z "${with_lz4_incdir}" || LZ4_CFLAGS="-I$with_lz4_incdir $LZ4_CFLAGS" 270 271 saved_CPPFLAGS=${CPPFLAGS} 272 CPPFLAGS="${LZ4_CFLAGS} ${CPPFLAGS}" 273 274 AC_CHECK_HEADERS([lz4.h],[have_lz4h="yes"], []) 275 276 if test "x${have_lz4h}" = "xyes" ; then 277 saved_LIBS="$LIBS" 278 saved_LDFLAGS=${LDFLAGS} 279 test -z "${with_lz4_libdir}" || LDFLAGS="-L$with_lz4_libdir ${LDFLAGS}" 280 AC_CHECK_LIB(lz4, LZ4_compress_destSize, [ 281 have_lz4="yes" 282 have_lz4hc="yes" 283 AC_CHECK_LIB(lz4, LZ4_compress_HC_destSize, [], [ 284 AC_CHECK_DECL(LZ4_compress_HC_destSize, [lz4_force_static="yes"], 285 [have_lz4hc="no"], [[ 286#define LZ4_HC_STATIC_LINKING_ONLY (1) 287#include <lz4hc.h> 288 ]]) 289 ]) 290 ], [AC_MSG_ERROR([Cannot find proper lz4 version (>= 1.8.0)])]) 291 LDFLAGS=${saved_LDFLAGS} 292 LIBS="${saved_LIBS}" 293 fi 294 CPPFLAGS=${saved_CPPFLAGS} 295fi 296 297if test "x$enable_lzma" = "xyes"; then 298 saved_CPPFLAGS=${CPPFLAGS} 299 test -z "${with_liblzma_incdir}" || 300 CPPFLAGS="-I$with_liblzma_incdir $CPPFLAGS" 301 AC_CHECK_HEADERS([lzma.h],[have_lzmah="yes"], []) 302 303 if test "x${have_lzmah}" = "xyes" ; then 304 saved_LIBS="$LIBS" 305 saved_LDFLAGS="$LDFLAGS" 306 307 test -z "${with_liblzma_libdir}" || 308 LDFLAGS="-L$with_liblzma_libdir ${LDFLAGS}" 309 AC_CHECK_LIB(lzma, lzma_microlzma_encoder, [], 310 [AC_MSG_ERROR([Cannot find proper liblzma])]) 311 312 AC_CHECK_DECL(lzma_microlzma_encoder, [have_liblzma="yes"], 313 [AC_MSG_ERROR([Cannot find proper liblzma])], [[ 314#include <lzma.h> 315 ]]) 316 LDFLAGS="${saved_LDFLAGS}" 317 LIBS="${saved_LIBS}" 318 fi 319 CPPFLAGS="${saved_CPPFLAGS}" 320fi 321 322# Set up needed symbols, conditionals and compiler/linker flags 323AM_CONDITIONAL([ENABLE_LZ4], [test "x${have_lz4}" = "xyes"]) 324AM_CONDITIONAL([ENABLE_LZ4HC], [test "x${have_lz4hc}" = "xyes"]) 325AM_CONDITIONAL([ENABLE_FUSE], [test "x${have_fuse}" = "xyes"]) 326AM_CONDITIONAL([ENABLE_LIBLZMA], [test "x${have_liblzma}" = "xyes"]) 327 328if test "x$have_uuid" = "xyes"; then 329 AC_DEFINE([HAVE_LIBUUID], 1, [Define to 1 if libuuid is found]) 330fi 331 332if test "x$have_selinux" = "xyes"; then 333 AC_DEFINE([HAVE_LIBSELINUX], 1, [Define to 1 if libselinux is found]) 334fi 335 336if test "x${have_lz4}" = "xyes"; then 337 AC_DEFINE([LZ4_ENABLED], [1], [Define to 1 if lz4 is enabled.]) 338 339 if test "x${have_lz4hc}" = "xyes"; then 340 AC_DEFINE([LZ4HC_ENABLED], [1], [Define to 1 if lz4hc is enabled.]) 341 fi 342 343 if test "x${lz4_force_static}" = "xyes"; then 344 LZ4_LIBS="-Wl,-Bstatic -Wl,-whole-archive -Xlinker ${LZ4_LIBS} -Wl,-no-whole-archive -Wl,-Bdynamic" 345 test -z "${with_lz4_libdir}" || LZ4_LIBS="-L${with_lz4_libdir} $LZ4_LIBS" 346 else 347 test -z "${with_lz4_libdir}" || LZ4_LIBS="-L${with_lz4_libdir} -R${with_lz4_libdir} $LZ4_LIBS" 348 fi 349 liblz4_LIBS="${LZ4_LIBS}" 350fi 351AC_SUBST([liblz4_LIBS]) 352 353if test "x${have_liblzma}" = "xyes"; then 354 AC_DEFINE([HAVE_LIBLZMA], [1], [Define to 1 if liblzma is enabled.]) 355 liblzma_LIBS="-llzma" 356 test -z "${with_liblzma_libdir}" || 357 liblzma_LIBS="-L${with_liblzma_libdir} $liblzma_LIBS" 358 test -z "${with_liblzma_incdir}" || 359 liblzma_CFLAGS="-I${with_liblzma_incdir}" 360 AC_SUBST([liblzma_LIBS]) 361 AC_SUBST([liblzma_CFLAGS]) 362fi 363 364AC_CONFIG_FILES([Makefile 365 man/Makefile 366 lib/Makefile 367 mkfs/Makefile 368 dump/Makefile 369 fuse/Makefile 370 fsck/Makefile]) 371AC_OUTPUT 372