xref: /aosp_15_r20/external/erofs-utils/configure.ac (revision 33b1fccf6a0fada2c2875d400ed01119b7676ee5)
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], [[email protected]])
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 Check if the flag is supported by compiler
33dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
34AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [
35  AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]),
36    [ac_save_CFLAGS="$CFLAGS"
37     CFLAGS="$CFLAGS $1"
38     AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 0; }])],
39       [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"],
40       [eval "AS_TR_SH([cc_cv_cflags_$1])='no'"])
41     CFLAGS="$ac_save_CFLAGS"
42    ])
43
44  AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
45    [$2], [$3])
46])
47
48dnl Check if the flag is supported by compiler (cacheable)
49dnl CC_CHECK_CFLAG([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
50AC_DEFUN([CC_CHECK_CFLAG], [
51  AC_CACHE_CHECK([if $CC supports $1 flag],
52    AS_TR_SH([cc_cv_cflags_$1]),
53    CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
54  )
55
56  AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
57    [$2], [$3])
58])
59
60dnl CC_CHECK_CFLAGS([FLAG1 FLAG2], [action-if-found], [action-if-not])
61AC_DEFUN([CC_CHECK_CFLAGS], [
62  for flag in $1; do
63    CC_CHECK_CFLAG($flag, [$2], [$3])
64  done
65])
66
67dnl EROFS_UTILS_PARSE_DIRECTORY
68dnl Input:  $1 = a string to a relative or absolute directory
69dnl Output: $2 = the variable to set with the absolute directory
70AC_DEFUN([EROFS_UTILS_PARSE_DIRECTORY],
71[
72 dnl Check if argument is a directory
73 if test -d $1 ; then
74    dnl Get the absolute path of the directory
75    dnl in case of relative directory.
76    dnl If realpath is not a valid command,
77    dnl an error is produced and we keep the given path.
78    local_tmp=`realpath $1 2>/dev/null`
79    if test "$local_tmp" != "" ; then
80       if test -d "$local_tmp" ; then
81           $2="$local_tmp"
82       else
83           $2=$1
84       fi
85    else
86       $2=$1
87    fi
88    dnl Check for space in the directory
89    if test `echo $1|cut -d' ' -f1` != $1 ; then
90        AC_MSG_ERROR($1 directory shall not contain any space.)
91    fi
92 else
93    AC_MSG_ERROR($1 shall be a valid directory)
94 fi
95])
96
97AC_ARG_VAR([MAX_BLOCK_SIZE], [The maximum block size which erofs-utils supports])
98
99AC_MSG_CHECKING([whether to enable multi-threading support])
100AC_ARG_ENABLE([multithreading],
101    AS_HELP_STRING([--enable-multithreading],
102                   [enable multi-threading support (EXPERIMENTAL) @<:@default=no@:>@]),
103    [enable_multithreading="$enableval"],
104    [enable_multithreading="no"])
105AC_MSG_RESULT([$enable_multithreading])
106
107AC_ARG_ENABLE([debug],
108    [AS_HELP_STRING([--enable-debug],
109                    [enable debugging mode @<:@default=no@:>@])],
110    [enable_debug="$enableval"],
111    [enable_debug="no"])
112
113AC_ARG_ENABLE([werror],
114    [AS_HELP_STRING([--enable-werror],
115                    [enable -Werror @<:@default=no@:>@])],
116    [enable_werror="$enableval"],
117    [enable_werror="no"])
118
119AC_ARG_ENABLE([fuzzing],
120    [AS_HELP_STRING([--enable-fuzzing],
121                    [set up fuzzing mode @<:@default=no@:>@])],
122    [enable_fuzzing="$enableval"],
123    [enable_fuzzing="no"])
124
125AC_ARG_ENABLE(lz4,
126   [AS_HELP_STRING([--disable-lz4], [disable LZ4 compression support @<:@default=enabled@:>@])],
127   [enable_lz4="$enableval"], [enable_lz4="yes"])
128
129AC_ARG_ENABLE(lzma,
130   [AS_HELP_STRING([--disable-lzma], [disable LZMA compression support @<:@default=auto@:>@])],
131   [enable_lzma="$enableval"])
132
133AC_ARG_WITH(zlib,
134   [AS_HELP_STRING([--without-zlib],
135      [Ignore presence of zlib inflate support @<:@default=auto@:>@])])
136
137AC_ARG_WITH(libdeflate,
138   [AS_HELP_STRING([--with-libdeflate],
139      [Enable and build with libdeflate inflate support @<:@default=disabled@:>@])], [],
140      [with_libdeflate="no"])
141
142AC_ARG_WITH(libzstd,
143   [AS_HELP_STRING([--with-libzstd],
144      [Enable and build with of libzstd support @<:@default=auto@:>@])])
145
146AC_ARG_WITH(qpl,
147   [AS_HELP_STRING([--with-qpl],
148      [Enable and build with Intel QPL support @<:@default=disabled@:>@])], [],
149      [with_qpl="no"])
150
151AC_ARG_ENABLE(fuse,
152   [AS_HELP_STRING([--enable-fuse], [enable erofsfuse @<:@default=no@:>@])],
153   [enable_fuse="$enableval"], [enable_fuse="no"])
154
155AC_ARG_ENABLE([static-fuse],
156    [AS_HELP_STRING([--enable-static-fuse],
157                    [build erofsfuse as a static library @<:@default=no@:>@])],
158    [enable_static_fuse="$enableval"],
159    [enable_static_fuse="no"])
160
161AC_ARG_WITH(uuid,
162   [AS_HELP_STRING([--without-uuid],
163      [Ignore presence of libuuid and disable uuid support @<:@default=enabled@:>@])])
164
165AC_ARG_WITH(selinux,
166   [AS_HELP_STRING([--with-selinux],
167      [enable and build with selinux support @<:@default=no@:>@])],
168   [case "$with_selinux" in
169      yes|no) ;;
170      *) AC_MSG_ERROR([invalid argument to --with-selinux])
171      ;;
172    esac], [with_selinux=no])
173
174# Checks for libraries.
175# Use customized LZ4 library path when specified.
176AC_ARG_WITH(lz4-incdir,
177   [AS_HELP_STRING([--with-lz4-incdir=DIR], [LZ4 include directory])], [
178   EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])])
179
180AC_ARG_WITH(lz4-libdir,
181   [AS_HELP_STRING([--with-lz4-libdir=DIR], [LZ4 lib directory])], [
182   EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])])
183
184AC_ARG_VAR([LZ4_CFLAGS], [C compiler flags for lz4])
185AC_ARG_VAR([LZ4_LIBS], [linker flags for lz4])
186
187# Checks for header files.
188AC_CHECK_HEADERS(m4_flatten([
189	dirent.h
190	execinfo.h
191	fcntl.h
192	getopt.h
193	inttypes.h
194	linux/aufs_type.h
195	linux/falloc.h
196	linux/fs.h
197	linux/types.h
198	linux/xattr.h
199	limits.h
200	stddef.h
201	stdint.h
202	stdlib.h
203	string.h
204	sys/ioctl.h
205	sys/mman.h
206	sys/random.h
207	sys/sendfile.h
208	sys/stat.h
209	sys/statfs.h
210	sys/sysmacros.h
211	sys/time.h
212	unistd.h
213]))
214
215AC_HEADER_TIOCGWINSZ
216
217# Checks for typedefs, structures, and compiler characteristics.
218AC_C_INLINE
219AC_TYPE_INT64_T
220AC_TYPE_SIZE_T
221AC_TYPE_SSIZE_T
222AC_CHECK_MEMBERS([struct stat.st_rdev])
223AC_CHECK_MEMBERS([struct stat.st_atim])
224AC_CHECK_MEMBERS([struct stat.st_atimensec])
225AC_TYPE_UINT64_T
226
227#
228# Check to see if llseek() is declared in unistd.h.  On some libc's
229# it is, and on others it isn't..... Thank you glibc developers....
230#
231AC_CHECK_DECL(llseek,
232  [AC_DEFINE(HAVE_LLSEEK_PROTOTYPE, 1,
233    [Define to 1 if llseek declared in unistd.h])],,
234  [#include <unistd.h>])
235
236#
237# Check to see if lseek64() is declared in unistd.h.  Glibc's header files
238# are so convoluted that I can't tell whether it will always be defined,
239# and if it isn't defined while lseek64 is defined in the library,
240# disaster will strike.
241#
242# Warning!  Use of --enable-gcc-wall may throw off this test.
243#
244AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1,
245  [Define to 1 if lseek64 declared in unistd.h])],,
246  [#define _LARGEFILE_SOURCE
247   #define _LARGEFILE64_SOURCE
248   #include <unistd.h>])
249
250AC_CHECK_DECL(memrchr,[AC_DEFINE(HAVE_MEMRCHR, 1,
251  [Define to 1 if memrchr declared in string.h])],,
252  [#define _GNU_SOURCE
253   #include <string.h>])
254
255# Checks for library functions.
256AC_CHECK_FUNCS(m4_flatten([
257	backtrace
258	copy_file_range
259	fallocate
260	gettimeofday
261	lgetxattr
262	llistxattr
263	memset
264	realpath
265	lseek64
266	ftello64
267	pread64
268	pwrite64
269	posix_fadvise
270	fstatfs
271	sendfile
272	strdup
273	strerror
274	strrchr
275	strtoull
276	sysconf
277	tmpfile64
278	utimensat]))
279
280# Detect maximum block size if necessary
281AS_IF([test "x$MAX_BLOCK_SIZE" = "x"], [
282  AC_CACHE_CHECK([sysconf (_SC_PAGESIZE)], [erofs_cv_max_block_size],
283               AC_RUN_IFELSE([AC_LANG_PROGRAM(
284[[
285#include <unistd.h>
286#include <stdio.h>
287]],
288[[
289    int result;
290    FILE *f;
291
292    result = sysconf(_SC_PAGESIZE);
293    if (result < 0)
294	return 1;
295
296    f = fopen("conftest.out", "w");
297    if (!f)
298	return 1;
299
300    fprintf(f, "%d", result);
301    fclose(f);
302    return 0;
303]])],
304                             [erofs_cv_max_block_size=`cat conftest.out`],
305                             [erofs_cv_max_block_size=4096],
306                             [erofs_cv_max_block_size=4096]))
307], [erofs_cv_max_block_size=$MAX_BLOCK_SIZE])
308
309# Configure multi-threading support
310AS_IF([test "x$enable_multithreading" != "xno"], [
311  AC_CHECK_HEADERS([pthread.h])
312  AC_CHECK_LIB([pthread], [pthread_mutex_lock], [],
313    AC_MSG_ERROR([libpthread is required for multi-threaded build]))
314  AC_DEFINE(EROFS_MT_ENABLED, 1, [Enable multi-threading support])
315], [])
316
317# Configure debug mode
318AS_IF([test "x$enable_debug" != "xno"], [], [
319  dnl Turn off all assert checking.
320  CPPFLAGS="$CPPFLAGS -DNDEBUG"
321])
322
323# Configure -Werror
324AS_IF([test "x$enable_werror" != "xyes"], [], [
325  CPPFLAGS="$CPPFLAGS -Werror"
326])
327
328# Configure libuuid
329AS_IF([test "x$with_uuid" != "xno"], [
330  PKG_CHECK_MODULES([libuuid], [uuid])
331  # Paranoia: don't trust the result reported by pkgconfig before trying out
332  saved_LIBS="$LIBS"
333  saved_CPPFLAGS=${CPPFLAGS}
334  CPPFLAGS="${libuuid_CFLAGS} ${CPPFLAGS}"
335  LIBS="${libuuid_LIBS} $LIBS"
336  AC_MSG_CHECKING([libuuid usability])
337  AC_TRY_LINK([
338#include <uuid.h>
339], [
340uuid_t tmp;
341
342uuid_generate(tmp);
343return 0;
344], [have_uuid="yes"
345    AC_MSG_RESULT([yes])], [
346    have_uuid="no"
347    AC_MSG_RESULT([no])
348    AC_MSG_ERROR([libuuid doesn't work properly])])
349  LIBS="${saved_LIBS}"
350  CPPFLAGS="${saved_CPPFLAGS}"], [have_uuid="no"])
351
352# Configure selinux
353AS_IF([test "x$with_selinux" != "xno"], [
354  PKG_CHECK_MODULES([libselinux], [libselinux])
355  # Paranoia: don't trust the result reported by pkgconfig before trying out
356  saved_LIBS="$LIBS"
357  saved_CPPFLAGS=${CPPFLAGS}
358  CPPFLAGS="${libselinux_CFLAGS} ${CPPFLAGS}"
359  LIBS="${libselinux_LIBS} $LIBS"
360  AC_CHECK_LIB(selinux, selabel_lookup, [
361    have_selinux="yes" ], [
362    AC_MSG_ERROR([libselinux doesn't work properly])])
363  LIBS="${saved_LIBS}"
364  CPPFLAGS="${saved_CPPFLAGS}"], [have_selinux="no"])
365
366# Configure fuse
367AS_IF([test "x$enable_fuse" != "xno"], [
368  # Paranoia: don't trust the result reported by pkgconfig before trying out
369  saved_LIBS="$LIBS"
370  saved_CPPFLAGS=${CPPFLAGS}
371  PKG_CHECK_MODULES([libfuse3], [fuse3 >= 3.0], [
372    PKG_CHECK_MODULES([libfuse3_0], [fuse3 >= 3.0 fuse3 < 3.2], [
373      AC_DEFINE([FUSE_USE_VERSION], [30], [used FUSE API version])
374    ], [
375      PKG_CHECK_MODULES([libfuse3_2], [fuse3 >= 3.2], [
376        AC_DEFINE([FUSE_USE_VERSION], [32], [used FUSE API version])
377      ])
378    ])
379    CPPFLAGS="${libfuse3_CFLAGS} ${CPPFLAGS}"
380    LIBS="${libfuse3_LIBS} $LIBS"
381    AC_CHECK_LIB(fuse3, fuse_session_new, [], [
382    AC_MSG_ERROR([libfuse3 (>= 3.0) doesn't work properly for lowlevel api])])
383    have_fuse="yes"
384  ], [
385    PKG_CHECK_MODULES([libfuse2], [fuse >= 2.6], [
386      AC_DEFINE([FUSE_USE_VERSION], [26], [used FUSE API version])
387      CPPFLAGS="${libfuse2_CFLAGS} ${CPPFLAGS}"
388      LIBS="${libfuse2_LIBS} $LIBS"
389      AC_CHECK_LIB(fuse, fuse_lowlevel_new, [], [
390        AC_MSG_ERROR([libfuse (>= 2.6) doesn't work properly for lowlevel api])])
391      have_fuse="yes"
392    ], [have_fuse="no"])
393  ])
394  LIBS="${saved_LIBS}"
395  CPPFLAGS="${saved_CPPFLAGS}"], [have_fuse="no"])
396
397# Configure lz4
398test -z $LZ4_LIBS && LZ4_LIBS='-llz4'
399
400if test "x$enable_lz4" = "xyes"; then
401  test -z "${with_lz4_incdir}" || LZ4_CFLAGS="-I$with_lz4_incdir $LZ4_CFLAGS"
402
403  saved_CPPFLAGS=${CPPFLAGS}
404  CPPFLAGS="${LZ4_CFLAGS} ${CPPFLAGS}"
405
406  AC_CHECK_HEADERS([lz4.h],[have_lz4h="yes"], [])
407
408  if test "x${have_lz4h}" = "xyes" ; then
409    saved_LIBS="$LIBS"
410    saved_LDFLAGS=${LDFLAGS}
411    test -z "${with_lz4_libdir}" || LDFLAGS="-L$with_lz4_libdir ${LDFLAGS}"
412    AC_CHECK_LIB(lz4, LZ4_compress_destSize, [
413      have_lz4="yes"
414      have_lz4hc="yes"
415      AC_CHECK_LIB(lz4, LZ4_compress_HC_destSize, [], [
416        AC_CHECK_DECL(LZ4_compress_HC_destSize, [lz4_force_static="yes"],
417          [have_lz4hc="no"], [[
418#define LZ4_HC_STATIC_LINKING_ONLY (1)
419#include <lz4hc.h>
420        ]])
421      ])
422    ], [AC_MSG_ERROR([Cannot find proper lz4 version (>= 1.8.0)])])
423    LDFLAGS=${saved_LDFLAGS}
424    LIBS="${saved_LIBS}"
425  fi
426  CPPFLAGS=${saved_CPPFLAGS}
427fi
428
429# Configure liblzma
430have_liblzma="no"
431AS_IF([test "x$enable_lzma" != "xno"], [
432  saved_CPPFLAGS=${CPPFLAGS}
433  PKG_CHECK_MODULES([liblzma], [liblzma], [
434    # Paranoia: don't trust the result reported by pkgconfig before trying out
435    saved_LIBS="$LIBS"
436    saved_CPPFLAGS=${CPPFLAGS}
437    CPPFLAGS="${liblzma_CFLAGS} ${CPPFLAGS}"
438    LIBS="${liblzma_LIBS} $LIBS"
439    AC_CHECK_HEADERS([lzma.h],[
440      AC_CHECK_LIB(lzma, lzma_microlzma_encoder, [
441        AC_CHECK_DECL(lzma_microlzma_encoder, [have_liblzma="yes"],
442          [], [[
443#include <lzma.h>
444        ]])
445      ])
446    ])
447    LIBS="${saved_LIBS}"
448    CPPFLAGS="${saved_CPPFLAGS}"
449  ], [[]])
450  AS_IF([test "x$enable_lzma" = "xyes" -a "x$have_liblzma" != "xyes"], [
451    AC_MSG_ERROR([Cannot find a proper liblzma version])
452  ])
453])
454
455# Configure zlib
456have_zlib="no"
457AS_IF([test "x$with_zlib" != "xno"], [
458  PKG_CHECK_MODULES([zlib], [zlib], [
459    # Paranoia: don't trust the result reported by pkgconfig before trying out
460    saved_LIBS="$LIBS"
461    saved_CPPFLAGS=${CPPFLAGS}
462    CPPFLAGS="${zlib_CFLAGS} ${CPPFLAGS}"
463    LIBS="${zlib_LIBS} $LIBS"
464    AC_CHECK_HEADERS([zlib.h],[
465      AC_CHECK_LIB(z, inflate, [], [
466        AC_MSG_ERROR([zlib doesn't work properly])])
467      AC_CHECK_DECL(inflate, [have_zlib="yes"],
468        [AC_MSG_ERROR([zlib doesn't work properly])], [[
469#include <zlib.h>
470      ]])
471    ])
472    LIBS="${saved_LIBS}"
473    CPPFLAGS="${saved_CPPFLAGS}"], [
474    AS_IF([test "x$with_zlib" = "xyes"], [
475      AC_MSG_ERROR([Cannot find proper zlib])
476    ])
477  ])
478])
479
480# Configure libdeflate
481AS_IF([test "x$with_libdeflate" != "xno"], [
482  PKG_CHECK_MODULES([libdeflate], [libdeflate])
483  # Paranoia: don't trust the result reported by pkgconfig before trying out
484  saved_LIBS="$LIBS"
485  saved_CPPFLAGS=${CPPFLAGS}
486  CPPFLAGS="${libdeflate_CFLAGS} ${CPPFLAGS}"
487  LIBS="${libdeflate_LIBS} $LIBS"
488  AC_CHECK_LIB(deflate, libdeflate_deflate_decompress, [
489    have_libdeflate="yes" ], [
490    AC_MSG_ERROR([libdeflate doesn't work properly])])
491  LIBS="${saved_LIBS}"
492  CPPFLAGS="${saved_CPPFLAGS}"], [have_libdeflate="no"])
493
494# Configure libzstd
495have_libzstd="no"
496AS_IF([test "x$with_libzstd" != "xno"], [
497  PKG_CHECK_MODULES([libzstd], [libzstd >= 1.4.0], [
498    # Paranoia: don't trust the result reported by pkgconfig before trying out
499    saved_LIBS="$LIBS"
500    saved_CPPFLAGS=${CPPFLAGS}
501    CPPFLAGS="${libzstd_CFLAGS} ${CPPFLAGS}"
502    LIBS="${libzstd_LIBS} $LIBS"
503    AC_CHECK_HEADERS([zstd.h],[
504      AC_CHECK_LIB(zstd, ZSTD_compress2, [], [
505        AC_MSG_ERROR([libzstd doesn't work properly])])
506      AC_CHECK_DECL(ZSTD_compress2, [have_libzstd="yes"],
507        [AC_MSG_ERROR([libzstd doesn't work properly])], [[
508#include <zstd.h>
509      ]])
510      AC_CHECK_FUNCS([ZSTD_getFrameContentSize])
511    ])
512    LIBS="${saved_LIBS}"
513    CPPFLAGS="${saved_CPPFLAGS}"], [
514    AS_IF([test "x$with_libzstd" = "xyes"], [
515      AC_MSG_ERROR([Cannot find proper libzstd])
516    ])
517  ])
518])
519
520# Configure Intel QPL
521have_qpl="no"
522AS_IF([test "x$with_qpl" != "xno"], [
523  PKG_CHECK_MODULES([libqpl], [qpl >= 1.5.0], [
524    # Paranoia: don't trust the result reported by pkgconfig before trying out
525    saved_LIBS="$LIBS"
526    saved_CPPFLAGS=${CPPFLAGS}
527    CPPFLAGS="${libqpl_CFLAGS} ${CPPFLAGS}"
528    LIBS="${libqpl_LIBS} $LIBS"
529    AC_CHECK_HEADERS([qpl/qpl.h],[
530      AC_CHECK_LIB(qpl, qpl_execute_job, [], [
531        AC_MSG_ERROR([libqpl doesn't work properly])])
532      AC_CHECK_DECL(qpl_execute_job, [have_qpl="yes"],
533        [AC_MSG_ERROR([libqpl doesn't work properly])], [[
534#include <qpl/qpl.h>
535      ]])
536    ])
537    LIBS="${saved_LIBS}"
538    CPPFLAGS="${saved_CPPFLAGS}"], [
539    AS_IF([test "x$with_qpl" = "xyes"], [
540      AC_MSG_ERROR([Cannot find proper libqpl])
541    ])
542  ])
543])
544
545# Enable 64-bit off_t
546CFLAGS+=" -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
547
548# Configure fuzzing mode
549AS_IF([test "x$enable_fuzzing" != "xyes"], [], [
550  CC_CHECK_CFLAGS(["-fsanitize=address,fuzzer-no-link"], [
551    CFLAGS="$CFLAGS -g -O1 -fsanitize=address,fuzzer-no-link"
552  ], [
553    AC_MSG_ERROR([Compiler doesn't support `-fsanitize=address,fuzzer-no-link`])
554  ])
555])
556AM_CONDITIONAL([ENABLE_FUZZING], [test "x${enable_fuzzing}" = "xyes"])
557
558# Set up needed symbols, conditionals and compiler/linker flags
559AM_CONDITIONAL([ENABLE_EROFS_MT], [test "x${enable_multithreading}" != "xno"])
560AM_CONDITIONAL([ENABLE_LZ4], [test "x${have_lz4}" = "xyes"])
561AM_CONDITIONAL([ENABLE_LZ4HC], [test "x${have_lz4hc}" = "xyes"])
562AM_CONDITIONAL([ENABLE_FUSE], [test "x${have_fuse}" = "xyes"])
563AM_CONDITIONAL([ENABLE_LIBLZMA], [test "x${have_liblzma}" = "xyes"])
564AM_CONDITIONAL([ENABLE_LIBDEFLATE], [test "x${have_libdeflate}" = "xyes"])
565AM_CONDITIONAL([ENABLE_LIBZSTD], [test "x${have_libzstd}" = "xyes"])
566AM_CONDITIONAL([ENABLE_QPL], [test "x${have_qpl}" = "xyes"])
567AM_CONDITIONAL([ENABLE_STATIC_FUSE], [test "x${enable_static_fuse}" = "xyes"])
568
569if test "x$have_uuid" = "xyes"; then
570  AC_DEFINE([HAVE_LIBUUID], 1, [Define to 1 if libuuid is found])
571fi
572
573if test "x$have_selinux" = "xyes"; then
574  AC_DEFINE([HAVE_LIBSELINUX], 1, [Define to 1 if libselinux is found])
575fi
576
577if test "x${have_lz4}" = "xyes"; then
578  AC_DEFINE([LZ4_ENABLED], [1], [Define to 1 if lz4 is enabled.])
579
580  if test "x${have_lz4hc}" = "xyes"; then
581    AC_DEFINE([LZ4HC_ENABLED], [1], [Define to 1 if lz4hc is enabled.])
582  fi
583
584  if test "x${lz4_force_static}" = "xyes"; then
585    LZ4_LIBS="-Wl,-Bstatic -Wl,-whole-archive -Xlinker ${LZ4_LIBS} -Wl,-no-whole-archive -Wl,-Bdynamic"
586    test -z "${with_lz4_libdir}" || LZ4_LIBS="-L${with_lz4_libdir} $LZ4_LIBS"
587  else
588    test -z "${with_lz4_libdir}" || LZ4_LIBS="-L${with_lz4_libdir} -R${with_lz4_libdir} $LZ4_LIBS"
589  fi
590  liblz4_LIBS="${LZ4_LIBS}"
591fi
592AC_SUBST([liblz4_LIBS])
593
594if test "x${have_liblzma}" = "xyes"; then
595  AC_DEFINE([HAVE_LIBLZMA], [1], [Define to 1 if liblzma is enabled.])
596  liblzma_LIBS="-llzma"
597  test -z "${with_liblzma_libdir}" ||
598    liblzma_LIBS="-L${with_liblzma_libdir} $liblzma_LIBS"
599  test -z "${with_liblzma_incdir}" ||
600    liblzma_CFLAGS="-I${with_liblzma_incdir}"
601  AC_SUBST([liblzma_LIBS])
602  AC_SUBST([liblzma_CFLAGS])
603fi
604
605if test "x$have_zlib" = "xyes"; then
606  AC_DEFINE([HAVE_ZLIB], 1, [Define to 1 if zlib is found])
607fi
608
609if test "x$have_libdeflate" = "xyes"; then
610  AC_DEFINE([HAVE_LIBDEFLATE], 1, [Define to 1 if libdeflate is found])
611fi
612
613if test "x$have_libzstd" = "xyes"; then
614  AC_DEFINE([HAVE_LIBZSTD], 1, [Define to 1 if libzstd is found])
615fi
616
617if test "x$have_qpl" = "xyes"; then
618  AC_DEFINE([HAVE_QPL], 1, [Define to 1 if qpl is found])
619  AC_SUBST([libqpl_LIBS])
620  AC_SUBST([libqpl_CFLAGS])
621fi
622
623# Dump maximum block size
624AS_IF([test "x$erofs_cv_max_block_size" = "x"],
625      [$erofs_cv_max_block_size = 4096], [])
626
627AC_DEFINE_UNQUOTED([EROFS_MAX_BLOCK_SIZE], [$erofs_cv_max_block_size],
628		   [The maximum block size which erofs-utils supports])
629
630AC_CONFIG_FILES([Makefile
631		 man/Makefile
632		 lib/Makefile
633		 mkfs/Makefile
634		 dump/Makefile
635		 fuse/Makefile
636		 fsck/Makefile])
637AC_OUTPUT
638