liblzma: Add RISC-V BCJ filter.
[xz.git] / configure.ac
blobbb2697f6d2e3b7ac51883a6f5e8fb20fdb3f3464
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 ###############################################################################
6 # Author: Lasse Collin
8 # This file has been put into the public domain.
9 # You can do whatever you want with this file.
11 ###############################################################################
13 # NOTE: Don't add useless checks. autoscan detects this and that, but don't
14 # let it confuse you. For example, we don't care about checking for behavior
15 # of malloc(), stat(), or lstat(), since we don't use those functions in
16 # a way that would cause the problems the autoconf macros check.
18 AC_PREREQ([2.69])
20 AC_INIT([XZ Utils], m4_esyscmd([/bin/sh build-aux/version.sh]),
21         [xz@tukaani.org], [xz], [https://xz.tukaani.org/xz-utils/])
22 AC_CONFIG_SRCDIR([src/liblzma/common/common.h])
23 AC_CONFIG_AUX_DIR([build-aux])
24 AC_CONFIG_MACRO_DIR([m4])
25 AC_CONFIG_HEADERS([config.h])
27 echo
28 echo "$PACKAGE_STRING"
30 echo
31 echo "System type:"
32 # This is needed to know if assembler optimizations can be used.
33 AC_CANONICAL_HOST
35 # We do some special things on Windows (32-bit or 64-bit) builds.
36 case $host_os in
37         mingw* | cygwin | msys) is_w32=yes ;;
38         *)                      is_w32=no ;;
39 esac
40 AM_CONDITIONAL([COND_W32], [test "$is_w32" = yes])
42 # We need to use $EXEEXT with $(LN_S) when creating symlinks to
43 # executables. Cygwin is an exception to this, since it is recommended
44 # that symlinks don't have the .exe suffix. To make this work, we
45 # define LN_EXEEXT.
47 # MSYS2 is treated the same way as Cygwin. It uses plain "msys" like
48 # the original MSYS when building MSYS/MSYS2-binaries. Hopefully this
49 # doesn't break things for the original MSYS developers. Note that this
50 # doesn't affect normal MSYS/MSYS2 users building non-MSYS/MSYS2 binaries
51 # since in that case the $host_os is usually mingw32.
52 case $host_os in
53         cygwin | msys)  LN_EXEEXT= ;;
54         *)              LN_EXEEXT='$(EXEEXT)' ;;
55 esac
56 AC_SUBST([LN_EXEEXT])
58 echo
59 echo "Configure options:"
60 AM_CFLAGS=
63 #############
64 # Debugging #
65 #############
67 AC_MSG_CHECKING([if debugging code should be compiled])
68 AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Enable debugging code.]),
69         [], enable_debug=no)
70 if test "x$enable_debug" = xyes; then
71         AC_MSG_RESULT([yes])
72 else
73         AC_DEFINE([NDEBUG], [1], [Define to 1 to disable debugging code.])
74         AC_MSG_RESULT([no])
78 ###########
79 # Filters #
80 ###########
82 m4_define([SUPPORTED_FILTERS], [lzma1,lzma2,delta,x86,powerpc,ia64,arm,armthumb,arm64,sparc,riscv])dnl
83 m4_define([SIMPLE_FILTERS], [x86,powerpc,ia64,arm,armthumb,arm64,sparc,riscv])
84 m4_define([LZ_FILTERS], [lzma1,lzma2])
86 m4_foreach([NAME], [SUPPORTED_FILTERS],
87 [enable_filter_[]NAME=no
88 enable_encoder_[]NAME=no
89 enable_decoder_[]NAME=no
90 ])dnl
92 AC_MSG_CHECKING([which encoders to build])
93 AC_ARG_ENABLE([encoders], AS_HELP_STRING([--enable-encoders=LIST],
94                 [Comma-separated list of encoders to build. Default=all.
95                 Available encoders:]
96                         m4_translit(m4_defn([SUPPORTED_FILTERS]), [,], [ ])),
97         [], [enable_encoders=SUPPORTED_FILTERS])
98 enable_encoders=`echo "$enable_encoders" | sed 's/,/ /g'`
99 if test "x$enable_encoders" = xno || test "x$enable_encoders" = x; then
100         enable_encoders=no
101         AC_MSG_RESULT([(none)])
102 else
103         for arg in $enable_encoders
104         do
105                 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
106                         NAME)
107                                 enable_filter_[]NAME=yes
108                                 enable_encoder_[]NAME=yes
109                                 AC_DEFINE(HAVE_ENCODER_[]m4_toupper(NAME), [1],
110                                 [Define to 1 if] NAME [encoder is enabled.])
111                                 ;;])
112                         *)
113                                 AC_MSG_RESULT([])
114                                 AC_MSG_ERROR([unknown filter: $arg])
115                                 ;;
116                 esac
117         done
118         AC_DEFINE([HAVE_ENCODERS], [1],
119                 [Define to 1 if any of HAVE_ENCODER_foo have been defined.])
120         AC_MSG_RESULT([$enable_encoders])
123 AC_MSG_CHECKING([which decoders to build])
124 AC_ARG_ENABLE([decoders], AS_HELP_STRING([--enable-decoders=LIST],
125                 [Comma-separated list of decoders to build. Default=all.
126                 Available decoders are the same as available encoders.]),
127         [], [enable_decoders=SUPPORTED_FILTERS])
128 enable_decoders=`echo "$enable_decoders" | sed 's/,/ /g'`
129 if test "x$enable_decoders" = xno || test "x$enable_decoders" = x; then
130         enable_decoders=no
131         AC_MSG_RESULT([(none)])
132 else
133         for arg in $enable_decoders
134         do
135                 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
136                         NAME)
137                                 enable_filter_[]NAME=yes
138                                 enable_decoder_[]NAME=yes
139                                 AC_DEFINE(HAVE_DECODER_[]m4_toupper(NAME), [1],
140                                 [Define to 1 if] NAME [decoder is enabled.])
141                                 ;;])
142                         *)
143                                 AC_MSG_RESULT([])
144                                 AC_MSG_ERROR([unknown filter: $arg])
145                                 ;;
146                 esac
147         done
148         AC_DEFINE([HAVE_DECODERS], [1],
149                 [Define to 1 if any of HAVE_DECODER_foo have been defined.])
150         AC_MSG_RESULT([$enable_decoders])
153 if test "x$enable_encoder_lzma2$enable_encoder_lzma1" = xyesno \
154                 || test "x$enable_decoder_lzma2$enable_decoder_lzma1" = xyesno; then
155         AC_MSG_ERROR([LZMA2 requires that LZMA1 is also enabled.])
158 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoders" != xno)
159 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoders" != xno)
161 m4_foreach([NAME], [SUPPORTED_FILTERS],
162 [AM_CONDITIONAL(COND_FILTER_[]m4_toupper(NAME), test "x$enable_filter_[]NAME" = xyes)
163 AM_CONDITIONAL(COND_ENCODER_[]m4_toupper(NAME), test "x$enable_encoder_[]NAME" = xyes)
164 AM_CONDITIONAL(COND_DECODER_[]m4_toupper(NAME), test "x$enable_decoder_[]NAME" = xyes)
165 ])dnl
167 # The so called "simple filters" share common code.
168 enable_filter_simple=no
169 enable_encoder_simple=no
170 enable_decoder_simple=no
171 m4_foreach([NAME], [SIMPLE_FILTERS],
172 [test "x$enable_filter_[]NAME" = xyes && enable_filter_simple=yes
173 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_simple=yes
174 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_simple=yes
175 ])dnl
176 AM_CONDITIONAL(COND_FILTER_SIMPLE, test "x$enable_filter_simple" = xyes)
177 AM_CONDITIONAL(COND_ENCODER_SIMPLE, test "x$enable_encoder_simple" = xyes)
178 AM_CONDITIONAL(COND_DECODER_SIMPLE, test "x$enable_decoder_simple" = xyes)
180 # LZ-based filters share common code.
181 enable_filter_lz=no
182 enable_encoder_lz=no
183 enable_decoder_lz=no
184 m4_foreach([NAME], [LZ_FILTERS],
185 [test "x$enable_filter_[]NAME" = xyes && enable_filter_lz=yes
186 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_lz=yes
187 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_lz=yes
188 ])dnl
189 AM_CONDITIONAL(COND_FILTER_LZ, test "x$enable_filter_lz" = xyes)
190 AM_CONDITIONAL(COND_ENCODER_LZ, test "x$enable_encoder_lz" = xyes)
191 AM_CONDITIONAL(COND_DECODER_LZ, test "x$enable_decoder_lz" = xyes)
194 #################
195 # Match finders #
196 #################
198 m4_define([SUPPORTED_MATCH_FINDERS], [hc3,hc4,bt2,bt3,bt4])
200 m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS],
201 [enable_match_finder_[]NAME=no
204 AC_MSG_CHECKING([which match finders to build])
205 AC_ARG_ENABLE([match-finders], AS_HELP_STRING([--enable-match-finders=LIST],
206                 [Comma-separated list of match finders to build. Default=all.
207                 At least one match finder is required for encoding with
208                 the LZMA1 and LZMA2 filters. Available match finders:]
209                 m4_translit(m4_defn([SUPPORTED_MATCH_FINDERS]), [,], [ ])), [],
210         [enable_match_finders=SUPPORTED_MATCH_FINDERS])
211 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
212 if test "x$enable_encoder_lz" = xyes ; then
213         if test -z "$enable_match_finders"; then
214                 AC_MSG_ERROR([At least one match finder is required for an LZ-based encoder.])
215         fi
217         for arg in $enable_match_finders
218                 do
219                 case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
220                         NAME)
221                                 enable_match_finder_[]NAME=yes
222                                 AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
223                                 [Define to 1 to enable] NAME [match finder.])
224                                 ;;])
225                         *)
226                                 AC_MSG_RESULT([])
227                                 AC_MSG_ERROR([unknown match finder: $arg])
228                                 ;;
229                 esac
230         done
231         AC_MSG_RESULT([$enable_match_finders])
232 else
233         AC_MSG_RESULT([(none because not building any LZ-based encoder)])
237 ####################
238 # Integrity checks #
239 ####################
241 m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
243 m4_foreach([NAME], [SUPPORTED_CHECKS],
244 [enable_check_[]NAME=no
245 ])dnl
247 AC_MSG_CHECKING([which integrity checks to build])
248 AC_ARG_ENABLE([checks], AS_HELP_STRING([--enable-checks=LIST],
249                 [Comma-separated list of integrity checks to build.
250                 Default=all. Available integrity checks:]
251                 m4_translit(m4_defn([SUPPORTED_CHECKS]), [,], [ ])),
252         [], [enable_checks=SUPPORTED_CHECKS])
253 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
254 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
255         AC_MSG_RESULT([(none)])
256 else
257         for arg in $enable_checks
258         do
259                 case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
260                         NAME)
261                                 enable_check_[]NAME=yes
262                                 AC_DEFINE(HAVE_CHECK_[]m4_toupper(NAME), [1],
263                                 [Define to 1 if] NAME
264                                 [integrity check is enabled.])
265                                 ;;])
266                         *)
267                                 AC_MSG_RESULT([])
268                                 AC_MSG_ERROR([unknown integrity check: $arg])
269                                 ;;
270                 esac
271         done
272         AC_MSG_RESULT([$enable_checks])
274 if test "x$enable_check_crc32" = xno ; then
275         AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
278 m4_foreach([NAME], [SUPPORTED_CHECKS],
279 [AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
280 ])dnl
282 AC_MSG_CHECKING([if external SHA-256 should be used])
283 AC_ARG_ENABLE([external-sha256], AS_HELP_STRING([--enable-external-sha256],
284                 [Use SHA-256 code from the operating system.
285                 See INSTALL for possible subtle problems.]),
286                 [], [enable_external_sha256=no])
287 if test "x$enable_check_sha256" != "xyes"; then
288         enable_external_sha256=no
290 if test "x$enable_external_sha256" = xyes; then
291         AC_MSG_RESULT([yes])
292 else
293         AC_MSG_RESULT([no])
297 #############
298 # MicroLZMA #
299 #############
301 AC_MSG_CHECKING([if MicroLZMA support should be built])
302 AC_ARG_ENABLE([microlzma], AS_HELP_STRING([--disable-microlzma],
303                 [Do not build MicroLZMA encoder and decoder.
304                 It is needed by specific applications only,
305                 for example, erofs-utils.]),
306         [], [enable_microlzma=yes])
307 case $enable_microlzma in
308         yes | no)
309                 AC_MSG_RESULT([$enable_microlzma])
310                 ;;
311         *)
312                 AC_MSG_RESULT([])
313                 AC_MSG_ERROR([--enable-microlzma accepts only 'yes' or 'no'.])
314                 ;;
315 esac
316 AM_CONDITIONAL(COND_MICROLZMA, test "x$enable_microlzma" = xyes)
319 #############################
320 # .lz (lzip) format support #
321 #############################
323 AC_MSG_CHECKING([if .lz (lzip) decompression support should be built])
324 AC_ARG_ENABLE([lzip-decoder], AS_HELP_STRING([--disable-lzip-decoder],
325                 [Disable decompression support for .lz (lzip) files.]),
326         [], [enable_lzip_decoder=yes])
327 if test "x$enable_decoder_lzma1" != xyes; then
328         enable_lzip_decoder=no
329         AC_MSG_RESULT([no because LZMA1 decoder is disabled])
330 elif test "x$enable_lzip_decoder" = xyes; then
331         AC_DEFINE([HAVE_LZIP_DECODER], [1],
332                 [Define to 1 if .lz (lzip) decompression support is enabled.])
333         AC_MSG_RESULT([yes])
334 else
335         AC_MSG_RESULT([no])
337 AM_CONDITIONAL(COND_LZIP_DECODER, test "x$enable_lzip_decoder" = xyes)
340 ###########################
341 # Assembler optimizations #
342 ###########################
344 AC_MSG_CHECKING([if assembler optimizations should be used])
345 AC_ARG_ENABLE([assembler], AS_HELP_STRING([--disable-assembler],
346                 [Do not use assembler optimizations even if such exist
347                 for the architecture.]),
348         [], [enable_assembler=yes])
349 if test "x$enable_assembler" = xyes; then
350         enable_assembler=no
351         case $host_os in
352                 # Darwin should work too but only if not creating universal
353                 # binaries. Solaris x86 could work too but I cannot test.
354                 linux* | *bsd* | mingw* | cygwin | msys | *djgpp*)
355                         case $host_cpu in
356                                 i?86)   enable_assembler=x86 ;;
357                         esac
358                         ;;
359         esac
361 case $enable_assembler in
362         x86 | no)
363                 AC_MSG_RESULT([$enable_assembler])
364                 ;;
365         *)
366                 AC_MSG_RESULT([])
367                 AC_MSG_ERROR([--enable-assembler accepts only 'yes', 'no', or 'x86' (32-bit).])
368                 ;;
369 esac
370 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
373 #############
374 # CLMUL CRC #
375 #############
377 AC_ARG_ENABLE([clmul-crc], AS_HELP_STRING([--disable-clmul-crc],
378                 [Do not use carryless multiplication for CRC calculation
379                 even if support for it is detected.]),
380         [], [enable_clmul_crc=yes])
383 #####################
384 # Size optimization #
385 #####################
387 AC_MSG_CHECKING([if small size is preferred over speed])
388 AC_ARG_ENABLE([small], AS_HELP_STRING([--enable-small],
389                 [Make liblzma smaller and a little slower.
390                 This is disabled by default to optimize for speed.]),
391         [], [enable_small=no])
392 if test "x$enable_small" = xyes; then
393         AC_DEFINE([HAVE_SMALL], [1], [Define to 1 if optimizing for size.])
394 elif test "x$enable_small" != xno; then
395         AC_MSG_RESULT([])
396         AC_MSG_ERROR([--enable-small accepts only 'yes' or 'no'])
398 AC_MSG_RESULT([$enable_small])
399 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
402 #############
403 # Threading #
404 #############
406 AC_MSG_CHECKING([if threading support is wanted])
407 AC_ARG_ENABLE([threads], AS_HELP_STRING([--enable-threads=METHOD],
408                 [Supported METHODS are 'yes', 'no', 'posix', 'win95', and
409                 'vista'. The default is 'yes'. Using 'no' together with
410                 --enable-small makes liblzma thread unsafe.]),
411         [], [enable_threads=yes])
413 if test "x$enable_threads" = xyes; then
414         case $host_os in
415                 mingw*)
416                         case $host_cpu in
417                                 i?86)   enable_threads=win95 ;;
418                                 *)      enable_threads=vista ;;
419                         esac
420                         ;;
421                 *)
422                         enable_threads=posix
423                         ;;
424         esac
427 case $enable_threads in
428         posix | win95 | vista)
429                 AC_MSG_RESULT([yes, $enable_threads])
430                 ;;
431         no)
432                 AC_MSG_RESULT([no])
433                 ;;
434         *)
435                 AC_MSG_RESULT([])
436                 AC_MSG_ERROR([--enable-threads only accepts 'yes', 'no', 'posix', 'win95', or 'vista'])
437                 ;;
438 esac
440 # We use the actual result a little later.
443 #########################
444 # Assumed amount of RAM #
445 #########################
447 # We use 128 MiB as default, because it will allow decompressing files
448 # created with "xz -9". It would be slightly safer to guess a lower value,
449 # but most systems, on which we don't have any way to determine the amount
450 # of RAM, will probably have at least 128 MiB of RAM.
451 AC_MSG_CHECKING([how much RAM to assume if the real amount is unknown])
452 AC_ARG_ENABLE([assume-ram], AS_HELP_STRING([--enable-assume-ram=SIZE],
453                 [If and only if the real amount of RAM cannot be determined,
454                 assume SIZE MiB. The default is 128 MiB. This affects the
455                 default memory usage limit.]),
456         [], [enable_assume_ram=128])
457 assume_ram_check=`echo "$enable_assume_ram" | tr -d 0123456789`
458 if test -z "$enable_assume_ram" || test -n "$assume_ram_check"; then
459         AC_MSG_RESULT([])
460         AC_MSG_ERROR([--enable-assume-ram accepts only an integer argument])
462 AC_MSG_RESULT([$enable_assume_ram MiB])
463 AC_DEFINE_UNQUOTED([ASSUME_RAM], [$enable_assume_ram],
464                 [How many MiB of RAM to assume if the real amount cannot
465                 be determined.])
468 #########################
469 # Components to install #
470 #########################
472 AC_ARG_ENABLE([xz], [AS_HELP_STRING([--disable-xz],
473                 [do not build the xz tool])],
474         [], [enable_xz=yes])
475 AM_CONDITIONAL([COND_XZ], [test x$enable_xz != xno])
477 AC_ARG_ENABLE([xzdec], [AS_HELP_STRING([--disable-xzdec],
478                 [do not build xzdec])],
479         [], [enable_xzdec=yes])
480 test "x$enable_decoders" = xno && enable_xzdec=no
481 AM_CONDITIONAL([COND_XZDEC], [test x$enable_xzdec != xno])
483 AC_ARG_ENABLE([lzmadec], [AS_HELP_STRING([--disable-lzmadec],
484                 [do not build lzmadec
485                 (it exists primarily for LZMA Utils compatibility)])],
486         [], [enable_lzmadec=yes])
487 test "x$enable_decoder_lzma1" = xno && enable_lzmadec=no
488 AM_CONDITIONAL([COND_LZMADEC], [test x$enable_lzmadec != xno])
490 AC_ARG_ENABLE([lzmainfo], [AS_HELP_STRING([--disable-lzmainfo],
491                 [do not build lzmainfo
492                 (it exists primarily for LZMA Utils compatibility)])],
493         [], [enable_lzmainfo=yes])
494 test "x$enable_decoder_lzma1" = xno && enable_lzmainfo=no
495 AM_CONDITIONAL([COND_LZMAINFO], [test x$enable_lzmainfo != xno])
497 AC_ARG_ENABLE([lzma-links], [AS_HELP_STRING([--disable-lzma-links],
498                 [do not create symlinks for LZMA Utils compatibility])],
499         [], [enable_lzma_links=yes])
500 AM_CONDITIONAL([COND_LZMALINKS], [test x$enable_lzma_links != xno])
502 AC_ARG_ENABLE([scripts], [AS_HELP_STRING([--disable-scripts],
503                 [do not install the scripts xzdiff, xzgrep, xzless, xzmore,
504                 and their symlinks])],
505         [], [enable_scripts=yes])
506 AM_CONDITIONAL([COND_SCRIPTS], [test x$enable_scripts != xno])
508 AC_ARG_ENABLE([doc], [AS_HELP_STRING([--disable-doc],
509                 [do not install documentation files to docdir
510                 (man pages will still be installed)])],
511         [], [enable_doc=yes])
512 AM_CONDITIONAL([COND_DOC], [test x$enable_doc != xno])
515 ##############
516 # Sandboxing #
517 ##############
519 AC_MSG_CHECKING([if sandboxing should be used])
520 AC_ARG_ENABLE([sandbox], [AS_HELP_STRING([--enable-sandbox=METHOD],
521                 [Sandboxing METHOD can be
522                 'auto', 'no', 'capsicum', 'pledge', or 'landlock'.
523                 The default is 'auto' which enables sandboxing if
524                 a supported sandboxing method is found.])],
525         [], [enable_sandbox=auto])
526 case $enable_xzdec-$enable_xz-$enable_sandbox in
527         no-no-*)
528                 enable_sandbox=no
529                 AC_MSG_RESULT([no, --disable-xz and --disable-xzdec was used])
530                 ;;
531         *-*-auto)
532                 AC_MSG_RESULT([maybe (autodetect)])
533                 ;;
534         *-*-no | *-*-capsicum | *-*-pledge | *-*-landlock)
535                 AC_MSG_RESULT([$enable_sandbox])
536                 ;;
537         *)
538                 AC_MSG_RESULT([])
539                 AC_MSG_ERROR([--enable-sandbox only accepts 'auto', 'no', 'capsicum', 'pledge', or 'landlock'.])
540                 ;;
541 esac
544 ###########################
545 # PATH prefix for scripts #
546 ###########################
548 # The scripts can add a prefix to the search PATH so that POSIX tools
549 # or the xz binary is always in the PATH.
550 AC_ARG_ENABLE([path-for-scripts],
551         [AS_HELP_STRING([--enable-path-for-scripts=PREFIX],
552                 [If PREFIX isn't empty, PATH=PREFIX:$PATH will be set in
553                 the beginning of the scripts (xzgrep and others).
554                 The default is empty except on Solaris the default is
555                 /usr/xpg4/bin.])],
556         [], [
557                 case $host_os in
558                         solaris*) enable_path_for_scripts=/usr/xpg4/bin ;;
559                         *)        enable_path_for_scripts= ;;
560                 esac
561         ])
562 if test -n "$enable_path_for_scripts" && test "x$enable_path_for_scripts" != xno ; then
563         enable_path_for_scripts="PATH=$enable_path_for_scripts:\$PATH"
564 else
565         enable_path_for_scripts=
567 AC_SUBST([enable_path_for_scripts])
570 ###############################################################################
571 # Checks for programs.
572 ###############################################################################
574 echo
575 case $host_os in
576         solaris*)
577                 # The gnulib POSIX shell macro below may pick a shell that
578                 # doesn't work with xzgrep. Workaround by picking a shell
579                 # that is known to work.
580                 if test -z "$gl_cv_posix_shell" && test -x /usr/xpg4/bin/sh; then
581                         gl_cv_posix_shell=/usr/xpg4/bin/sh
582                 fi
583                 ;;
584 esac
585 gl_POSIX_SHELL
586 if test -z "$POSIX_SHELL" && test "x$enable_scripts" = xyes ; then
587         AC_MSG_ERROR([No POSIX conforming shell (sh) was found.])
590 echo
591 echo "Initializing Automake:"
593 # We don't use "subdir-objects" yet because it breaks "make distclean" when
594 # dependencies are enabled (as of Automake 1.14.1) due to this bug:
595 # https://debbugs.gnu.org/cgi/bugreport.cgi?bug=17354
596 # The -Wno-unsupported is used to silence warnings about missing
597 # "subdir-objects".
598 AM_INIT_AUTOMAKE([1.12 foreign tar-v7 filename-length-max=99 -Wno-unsupported])
599 AC_PROG_LN_S
601 dnl # Autoconf >= 2.70 warns that AC_PROG_CC_C99 is obsolete. However,
602 dnl # we have to keep using AC_PROG_CC_C99 instead of AC_PROG_CC
603 dnl # as long as we try to be compatible with Autoconf 2.69.
604 AC_PROG_CC_C99
605 if test x$ac_cv_prog_cc_c99 = xno ; then
606         AC_MSG_ERROR([No C99 compiler was found.])
609 AM_PROG_CC_C_O
610 AM_PROG_AS
611 AC_USE_SYSTEM_EXTENSIONS
613 AS_CASE([$enable_threads],
614         [posix], [
615                 echo
616                 echo "POSIX threading support:"
617                 AX_PTHREAD([:]) dnl We don't need the HAVE_PTHREAD macro.
618                 LIBS="$LIBS $PTHREAD_LIBS"
619                 AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
621                 dnl NOTE: PTHREAD_CC is ignored. It would be useful on AIX,
622                 dnl but it's tricky to get it right together with
623                 dnl AC_PROG_CC_C99. Thus, this is handled by telling the
624                 dnl user in INSTALL to set the correct CC manually.
626                 AC_DEFINE([MYTHREAD_POSIX], [1],
627                         [Define to 1 when using POSIX threads (pthreads).])
629                 # This is nice to have but not mandatory.
630                 OLD_CFLAGS=$CFLAGS
631                 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
632                 AC_CHECK_FUNCS([pthread_condattr_setclock])
633                 CFLAGS=$OLD_CFLAGS
634         ],
635         [win95], [
636                 AC_DEFINE([MYTHREAD_WIN95], [1], [Define to 1 when using
637                         Windows 95 (and thus XP) compatible threads.
638                         This avoids use of features that were added in
639                         Windows Vista.])
640         ],
641         [vista], [
642                 AC_DEFINE([MYTHREAD_VISTA], [1], [Define to 1 when using
643                         Windows Vista compatible threads. This uses
644                         features that are not available on Windows XP.])
645         ]
647 AM_CONDITIONAL([COND_THREADS], [test "x$enable_threads" != xno])
649 echo
650 echo "Initializing Libtool:"
651 LT_PREREQ([2.4])
652 LT_INIT([win32-dll])
653 LT_LANG([Windows Resource])
655 # This is a bit wrong since it is possible to request that only some libs
656 # are built as shared. Using that feature isn't so common though, and this
657 # breaks only on Windows (at least for now) if the user enables only some
658 # libs as shared.
659 AM_CONDITIONAL([COND_SHARED], [test "x$enable_shared" != xno])
661 #####################
662 # Symbol versioning #
663 #####################
665 # NOTE: This checks if we are building shared or static library
666 # and if --with-pic or --without-pic was used. Thus this check
667 # must be after Libtool initialization.
668 AC_MSG_CHECKING([if library symbol versioning should be used])
669 AC_ARG_ENABLE([symbol-versions], [AS_HELP_STRING([--enable-symbol-versions],
670                 [Use symbol versioning for liblzma. Enabled by default on
671                 GNU/Linux, other GNU-based systems, and FreeBSD.])],
672         [], [enable_symbol_versions=auto])
673 if test "x$enable_symbol_versions" = xauto; then
674         case $host_os in
675                 # NOTE: Even if one omits -gnu on GNU/Linux (e.g.
676                 # i486-slackware-linux), configure will (via config.sub)
677                 # append -gnu (e.g. i486-slackware-linux-gnu), and this
678                 # test will work correctly.
679                 gnu* | *-gnu* | freebsd*)
680                         enable_symbol_versions=yes
681                         ;;
682                 *)
683                         enable_symbol_versions=no
684                         ;;
685         esac
688 # There are two variants for symbol versioning.
689 # See src/liblzma/validate_map.sh for details.
691 # On GNU/Linux, extra symbols are added in the C code. These extra symbols
692 # must not be put into a static library as they can cause problems (and
693 # even if they didn't cause problems, they would be useless). On other
694 # systems symbol versioning may be used too but there is no problem as only
695 # a linker script is specified in src/liblzma/Makefile.am and that isn't
696 # used when creating a static library.
698 # Libtool always uses -DPIC when building shared libraries by default and
699 # doesn't use it for static libs by default. This can be overridden with
700 # --with-pic and --without-pic though. As long as neither --with-pic nor
701 # --without-pic is used then we can use #ifdef PIC to detect if the file is
702 # being built for a shared library.
703 if test "x$enable_symbol_versions" = xno ; then
704         enable_symbol_versions=no
705         AC_MSG_RESULT([no])
706 elif test "x$enable_shared" = xno ; then
707         enable_symbol_versions=no
708         AC_MSG_RESULT([no (not building a shared library)])
709 else
710         case "$host_cpu-$host_os" in
711                 microblaze*)
712                         # GCC 12 on MicroBlaze doesn't support __symver__
713                         # attribute. It's simplest and safest to use the
714                         # generic version on that platform since then only
715                         # the linker script is needed. The RHEL/CentOS 7
716                         # compatibility symbols don't matter on MicroBlaze.
717                         enable_symbol_versions=generic
718                         ;;
719                 *-linux*)
720                         case "$pic_mode-$enable_static" in
721                                 default-*)
722                                         # Use symvers if PIC is defined.
723                                         have_symbol_versions_linux=2
724                                         ;;
725                                 *-no)
726                                         # Not building static library.
727                                         # Use symvers unconditionally.
728                                         have_symbol_versions_linux=1
729                                         ;;
730                                 *)
731                                         AC_MSG_RESULT([])
732                                         AC_MSG_ERROR([
733     On GNU/Linux, building both shared and static library at the same time
734     is not supported if --with-pic or --without-pic is used.
735     Use either --disable-shared or --disable-static to build one type
736     of library at a time. If both types are needed, build one at a time,
737     possibly picking only src/liblzma/.libs/liblzma.a from the static build.])
738                                         ;;
739                         esac
740                         enable_symbol_versions=linux
741                         AC_DEFINE_UNQUOTED([HAVE_SYMBOL_VERSIONS_LINUX],
742                                 [$have_symbol_versions_linux],
743                                 [Define to 1 to if GNU/Linux-specific details
744                                 are unconditionally wanted for symbol
745                                 versioning. Define to 2 to if these are wanted
746                                 only if also PIC is defined (allows building
747                                 both shared and static liblzma at the same
748                                 time with Libtool if neither --with-pic nor
749                                 --without-pic is used). This define must be
750                                 used together with liblzma_linux.map.])
751                         ;;
752                 *)
753                         enable_symbol_versions=generic
754                         ;;
755         esac
756         AC_MSG_RESULT([yes ($enable_symbol_versions)])
759 AM_CONDITIONAL([COND_SYMVERS_LINUX],
760         [test "x$enable_symbol_versions" = xlinux])
761 AM_CONDITIONAL([COND_SYMVERS_GENERIC],
762         [test "x$enable_symbol_versions" = xgeneric])
765 ###############################################################################
766 # Checks for libraries.
767 ###############################################################################
769 dnl Support for _REQUIRE_VERSION was added in gettext 0.19.6. If both
770 dnl _REQUIRE_VERSION and _VERSION are present, the _VERSION is ignored.
771 dnl We use both for compatibility with other programs in the Autotools family.
772 echo
773 echo "Initializing gettext:"
774 AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6])
775 AM_GNU_GETTEXT_VERSION([0.19.6])
776 AM_GNU_GETTEXT([external])
779 ###############################################################################
780 # Checks for header files.
781 ###############################################################################
783 echo
784 echo "System headers and functions:"
786 # There is currently no workarounds in this package if some of
787 # these headers are missing.
788 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
789         [],
790         [AC_MSG_ERROR([Required header file(s) are missing.])])
792 # immintrin.h allows the use of the intrinsic functions if they are available.
793 # cpuid.h may be used for detecting x86 processor features at runtime.
794 AC_CHECK_HEADERS([immintrin.h cpuid.h])
797 ###############################################################################
798 # Checks for typedefs, structures, and compiler characteristics.
799 ###############################################################################
801 AC_HEADER_STDBOOL
803 AC_TYPE_UINT8_T
804 AC_TYPE_UINT16_T
805 AC_TYPE_INT32_T
806 AC_TYPE_UINT32_T
807 AC_TYPE_INT64_T
808 AC_TYPE_UINT64_T
809 AC_TYPE_UINTPTR_T
811 AC_CHECK_SIZEOF([size_t])
813 # The command line tool can copy high resolution timestamps if such
814 # information is available in struct stat. Otherwise one second accuracy
815 # is used.
816 AC_CHECK_MEMBERS([
817         struct stat.st_atim.tv_nsec,
818         struct stat.st_atimespec.tv_nsec,
819         struct stat.st_atimensec,
820         struct stat.st_uatime,
821         struct stat.st_atim.st__tim.tv_nsec])
823 AC_SYS_LARGEFILE
824 AC_C_BIGENDIAN
826 # __attribute__((__constructor__)) can be used for one-time initializations.
827 # Use -Werror because some compilers accept unknown attributes and just
828 # give a warning.
830 # FIXME? Unfortunately -Werror can cause trouble if CFLAGS contains options
831 # that produce warnings for unrelated reasons. For example, GCC and Clang
832 # support -Wunused-macros which will warn about "#define _GNU_SOURCE 1"
833 # which will be among the #defines that Autoconf inserts to the beginning of
834 # the test program. There seems to be no nice way to prevent Autoconf from
835 # inserting the any defines to the test program.
836 AC_MSG_CHECKING([if __attribute__((__constructor__)) can be used])
837 have_func_attribute_constructor=no
838 OLD_CFLAGS="$CFLAGS"
839 CFLAGS="$CFLAGS -Werror"
840 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
841         __attribute__((__constructor__))
842         static void my_constructor_func(void) { return; }
843 ]])], [
844         AC_DEFINE([HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR], [1],
845                 [Define to 1 if __attribute__((__constructor__))
846                 is supported for functions.])
847         have_func_attribute_constructor=yes
848         AC_MSG_RESULT([yes])
849 ], [
850         AC_MSG_RESULT([no])
852 CFLAGS="$OLD_CFLAGS"
854 # The Win95 threading lacks a thread-safe one-time initialization function.
855 # The one-time initialization is needed for crc32_small.c and crc64_small.c
856 # create the CRC tables. So if small mode is enabled, the threading mode is
857 # win95, and the compiler does not support attribute constructor, then we
858 # would end up with a multithreaded build that is thread-unsafe. As a
859 # result this configuration is not allowed.
860 if test "x$enable_small$enable_threads$have_func_attribute_constructor" \
861                 = xyeswin95no; then
862         AC_MSG_ERROR([
863     --enable-threads=win95 and --enable-small cannot be used
864     at the same time with a compiler that doesn't support
865     __attribute__((__constructor__))])
868 # __attribute__((__ifunc__())) can be used to choose between different
869 # implementations of the same function at runtime. This is slightly more
870 # efficient than using __attribute__((__constructor__)) and setting
871 # a function pointer.
872 AC_ARG_ENABLE([ifunc], [AS_HELP_STRING([--enable-ifunc],
873                 [Use __attribute__((__ifunc__())). Enabled by default on
874                 GNU/Linux (glibc) and FreeBSD.])],
875         [], [enable_ifunc=auto])
877 # When enable_ifunc is 'auto', allow the use of __attribute__((__ifunc__()))
878 # if compiler support is detected and we are building for GNU/Linux (glibc)
879 # or FreeBSD. uClibc and musl don't support ifunc in their dynamic linkers
880 # but some compilers still accept the attribute when compiling for these
881 # C libraries, which results in broken binaries. That's why we need to
882 # check which libc is being used.
883 if test "x$enable_ifunc" = xauto ; then
884         OLD_CFLAGS="$CFLAGS"
885         CFLAGS="$CFLAGS -Werror"
886         AC_MSG_CHECKING([if __attribute__((__ifunc__())) can be used])
887         AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
888                 /*
889                  * Force a compilation error when not using glibc on Linux
890                  * or if we are not using FreeBSD. uClibc will define
891                  * __GLIBC__ but does not support ifunc, so we must have
892                  * an extra check to disable with uClibc.
893                  */
894                 #if defined(__linux__)
895                 #       include <features.h>
896                 #       if !defined(__GLIBC__) || defined(__UCLIBC__)
897                                 compile error
898                 #       endif
899                 #elif !defined(__FreeBSD__)
900                         compile error
901                 #endif
903                 static void func(void) { return; }
904                 static void (*resolve_func (void)) (void) { return func; }
905                 void func_ifunc (void)
906                                 __attribute__((__ifunc__("resolve_func")));
907                 /*
908                  * 'clang -Wall' incorrectly warns that resolve_func is
909                  * unused (-Wunused-function). Correct assembly output is
910                  * still produced. This problem exists at least in Clang
911                  * versions 4 to 17. The following silences the bogus warning:
912                  */
913                 void make_clang_quiet(void);
914                 void make_clang_quiet(void) { resolve_func()(); }
915         ]])], [
916                 enable_ifunc=yes
917         ], [
918                 enable_ifunc=no
919         ])
921         AC_MSG_RESULT([$enable_ifunc])
923         CFLAGS="$OLD_CFLAGS"
926 if test "x$enable_ifunc" = xyes ; then
927         AC_DEFINE([HAVE_FUNC_ATTRIBUTE_IFUNC], [1],
928                         [Define to 1 if __attribute__((__ifunc__()))
929                         is supported for functions.])
931         # ifunc explicitly does not work with -fsanitize=address.
932         # If configured, it will result in a liblzma build that will fail
933         # when liblzma is loaded at runtime (when the ifunc resolver
934         # executes).
935         AS_CASE([$CFLAGS], [*-fsanitize=*], [AC_MSG_ERROR([
936     CFLAGS contains '-fsanitize=' which is incompatible with ifunc.
937     Use --disable-ifunc when using '-fsanitize'.])])
941 ###############################################################################
942 # Checks for library functions.
943 ###############################################################################
945 # Gnulib replacements as needed
946 gl_GETOPT
948 # If clock_gettime() is available, liblzma with pthreads may use it, and
949 # xz may use it even when threading support is disabled. In XZ Utils 5.4.x
950 # and older, configure checked for clock_gettime() only when using pthreads.
951 # This way non-threaded builds of liblzma didn't get a useless dependency on
952 # librt which further had a dependency on libpthread. Avoiding these was
953 # useful when a small build was needed, for example, for initramfs use.
955 # The above reasoning is thoroughly obsolete: On GNU/Linux, librt hasn't
956 # been needed for clock_gettime() since glibc 2.17 (2012-12-25).
957 # Solaris 10 needs librt but Solaris 11 doesn't anymore.
958 AC_SEARCH_LIBS([clock_gettime], [rt])
959 AC_CHECK_FUNCS([clock_gettime])
960 AC_CHECK_DECL([CLOCK_MONOTONIC], [AC_DEFINE([HAVE_CLOCK_MONOTONIC], [1],
961         [Define to 1 if 'CLOCK_MONOTONIC' is declared in <time.h>.])], [],
962         [[#include <time.h>]])
964 # Find the best function to set timestamps.
965 AC_CHECK_FUNCS([futimens futimes futimesat utimes _futime utime], [break])
967 # This is nice to have but not mandatory.
968 AC_CHECK_FUNCS([posix_fadvise])
970 TUKLIB_PROGNAME
971 TUKLIB_INTEGER
972 TUKLIB_PHYSMEM
973 TUKLIB_CPUCORES
974 TUKLIB_MBSTR
976 # If requested, check for system-provided SHA-256. At least the following
977 # implementations are supported:
979 # OS       Headers                     Library  Type           Function
980 # FreeBSD  sys/types.h + sha256.h      libmd    SHA256_CTX     SHA256_Init
981 # NetBSD   sys/types.h + sha2.h                 SHA256_CTX     SHA256_Init
982 # OpenBSD  sys/types.h + sha2.h                 SHA2_CTX       SHA256Init
983 # Solaris  sys/types.h + sha2.h        libmd    SHA256_CTX     SHA256Init
984 # MINIX 3  sys/types.h + sha2.h                 SHA256_CTX     SHA256_Init
985 # Darwin   CommonCrypto/CommonDigest.h          CC_SHA256_CTX  CC_SHA256_Init
987 # Note that Darwin's CC_SHA256_Update takes buffer size as uint32_t instead
988 # of size_t.
990 sha256_header_found=no
991 sha256_type_found=no
992 sha256_func_found=no
993 AS_IF([test "x$enable_external_sha256" = "xyes"], [
994         # Test for Common Crypto before others, because Darwin has sha256.h
995         # too and we don't want to use that, because on older versions it
996         # uses OpenSSL functions, whose SHA256_Init is not guaranteed to
997         # succeed.
998         AC_CHECK_HEADERS(
999                 [CommonCrypto/CommonDigest.h sha256.h sha2.h],
1000                 [sha256_header_found=yes ; break])
1001         if test "x$sha256_header_found" = xyes; then
1002                 AC_CHECK_TYPES([CC_SHA256_CTX, SHA256_CTX, SHA2_CTX],
1003                         [sha256_type_found=yes], [],
1004                         [[#ifdef HAVE_SYS_TYPES_H
1005                           # include <sys/types.h>
1006                           #endif
1007                           #ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
1008                           # include <CommonCrypto/CommonDigest.h>
1009                           #endif
1010                           #ifdef HAVE_SHA256_H
1011                           # include <sha256.h>
1012                           #endif
1013                           #ifdef HAVE_SHA2_H
1014                           # include <sha2.h>
1015                           #endif]])
1016                 if test "x$sha256_type_found" = xyes ; then
1017                         AC_SEARCH_LIBS([SHA256Init], [md])
1018                         AC_SEARCH_LIBS([SHA256_Init], [md])
1019                         AC_CHECK_FUNCS([CC_SHA256_Init SHA256Init SHA256_Init],
1020                                 [sha256_func_found=yes ; break])
1021                 fi
1022         fi
1024 AM_CONDITIONAL([COND_INTERNAL_SHA256], [test "x$sha256_func_found" = xno])
1025 if test "x$enable_external_sha256$sha256_func_found" = xyesno; then
1026         AC_MSG_ERROR([--enable-external-sha256 was specified but no supported external SHA-256 implementation was found])
1029 # Check for SSE2 intrinsics. There is no run-time detection for SSE2 so if
1030 # compiler options enable SSE2 then SSE2 support is required by the binaries.
1031 # The compile-time check for SSE2 is done with #ifdefs because some compilers
1032 # (ICC, MSVC) allow SSE2 intrinsics even when SSE2 isn't enabled.
1033 AC_CHECK_DECL([_mm_movemask_epi8],
1034         [AC_DEFINE([HAVE__MM_MOVEMASK_EPI8], [1],
1035                 [Define to 1 if _mm_movemask_epi8 is available.])],
1036         [],
1037 [#ifdef HAVE_IMMINTRIN_H
1038 #include <immintrin.h>
1039 #endif])
1041 # For faster CRC on 32/64-bit x86 and E2K (see also crc64_fast.c):
1043 #   - Check for the CLMUL intrinsic _mm_clmulepi64_si128 in <immintrin.h>.
1044 #     Check also for _mm_set_epi64x for consistency with CMake build
1045 #     where it's needed to disable CLMUL with VS2013.
1047 #   - Check that __attribute__((__target__("ssse3,sse4.1,pclmul"))) works
1048 #     together with _mm_clmulepi64_si128 from <immintrin.h>. The attribute
1049 #     was added in GCC 4.4 but some GCC 4.x versions don't allow intrinsics
1050 #     with it. Exception: it must be not be used with EDG-based compilers
1051 #     like ICC and the compiler on E2K.
1053 # If everything above is supported, runtime detection will be used to keep the
1054 # binaries working on systems that don't support the required extensions.
1055 AC_MSG_CHECKING([if _mm_clmulepi64_si128 is usable])
1056 AS_IF([test "x$enable_clmul_crc" = xno], [
1057         AC_MSG_RESULT([no, --disable-clmul-crc was used])
1058 ], [
1059         AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1060 #include <immintrin.h>
1062 // CLMUL works on older E2K instruction set but it is slow due to emulation.
1063 #if defined(__e2k__) && __iset__ < 6
1064 #       error
1065 #endif
1067 // Intel's old compiler (ICC) can define __GNUC__ but the attribute must not
1068 // be used with it. The new Clang-based ICX needs the attribute.
1069 // Checking for !defined(__EDG__) catches ICC and other EDG-based compilers.
1070 #if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__)
1071 __attribute__((__target__("ssse3,sse4.1,pclmul")))
1072 #endif
1073 __m128i my_clmul(__m128i a)
1075         const __m128i b = _mm_set_epi64x(1, 2);
1076         return _mm_clmulepi64_si128(a, b, 0);
1078         ]])], [
1079                 AC_DEFINE([HAVE_USABLE_CLMUL], [1],
1080                         [Define to 1 if _mm_set_epi64x and
1081                         _mm_clmulepi64_si128 are usable.
1082                         See configure.ac for details.])
1083                 enable_clmul_crc=yes
1084         ], [
1085                 enable_clmul_crc=no
1086         ])
1087         AC_MSG_RESULT([$enable_clmul_crc])
1090 # Check for sandbox support. If one is found, set enable_sandbox=found.
1092 # About -fsanitize: Of our three sandbox methods, only Landlock is
1093 # incompatible with -fsanitize. FreeBSD 13.2 with Capsicum was tested with
1094 # -fsanitize=address,undefined and had no issues. OpenBSD (as of version
1095 # 7.4) has minimal support for process instrumentation. OpenBSD does not
1096 # distribute the additional libraries needed (libasan, libubsan, etc.) with
1097 # GCC or Clang needed for runtime sanitization support and instead only
1098 # support -fsanitize-minimal-runtime for minimal undefined behavior
1099 # sanitization. This minimal support is compatible with our use of the
1100 # Pledge sandbox. So only Landlock will result in a build that cannot
1101 # compress or decompress a single file to standard out.
1102 AS_CASE([$enable_sandbox],
1103         [auto | capsicum], [
1104                 AC_CHECK_FUNCS([cap_rights_limit], [enable_sandbox=found])
1105         ]
1107 AS_CASE([$enable_sandbox],
1108         [auto | pledge], [
1109                 AC_CHECK_FUNCS([pledge], [enable_sandbox=found])
1110         ]
1112 AS_CASE([$enable_sandbox],
1113         [auto | landlock], [
1114                 AC_CHECK_HEADERS([linux/landlock.h], [
1115                         enable_sandbox=found
1117                         AS_CASE([$CFLAGS], [*-fsanitize=*], [AC_MSG_ERROR([
1118     CFLAGS contains '-fsanitize=' which is incompatible with the Landlock
1119     sandboxing. Use --disable-sandbox when using '-fsanitize'.])])
1120                 ])
1121         ]
1124 # If a specific sandboxing method was explicitly requested and it wasn't
1125 # found, give an error.
1126 case $enable_sandbox in
1127         auto | no | found)
1128                 ;;
1129         *)
1130                 AC_MSG_ERROR([$enable_sandbox support not found])
1131                 ;;
1132 esac
1135 ###############################################################################
1136 # If using GCC, set some additional AM_CFLAGS:
1137 ###############################################################################
1139 if test "$GCC" = yes ; then
1140         echo
1141         echo "GCC extensions:"
1144 # Always do the visibility check but don't set AM_CFLAGS on Windows.
1145 # This way things get set properly even on Windows.
1146 gl_VISIBILITY
1147 if test -n "$CFLAG_VISIBILITY" && test "$is_w32" = no; then
1148         AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
1151 AS_IF([test "$GCC" = yes], [
1152         # Enable as much warnings as possible. These commented warnings won't
1153         # work for this package though:
1154         #   * -Wunreachable-code breaks several assert(0) cases, which are
1155         #     backed up with "return LZMA_PROG_ERROR".
1156         #   * -Wcast-qual would break various things where we need a non-const
1157         #     pointer although we don't modify anything through it.
1158         #   * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
1159         #     don't seem so useful here; at least the last one gives some
1160         #     warnings which are not bugs.
1161         #   * -Wconversion still shows too many warnings.
1162         #
1163         # The flags before the empty line are for GCC and many of them
1164         # are supported by Clang too. The flags after the empty line are
1165         # for Clang.
1166         for NEW_FLAG in \
1167                         -Wall \
1168                         -Wextra \
1169                         -Wvla \
1170                         -Wformat=2 \
1171                         -Winit-self \
1172                         -Wmissing-include-dirs \
1173                         -Wshift-overflow=2 \
1174                         -Wstrict-overflow=3 \
1175                         -Walloc-zero \
1176                         -Wduplicated-cond \
1177                         -Wfloat-equal \
1178                         -Wundef \
1179                         -Wshadow \
1180                         -Wpointer-arith \
1181                         -Wbad-function-cast \
1182                         -Wwrite-strings \
1183                         -Wdate-time \
1184                         -Wsign-conversion \
1185                         -Wfloat-conversion \
1186                         -Wlogical-op \
1187                         -Waggregate-return \
1188                         -Wstrict-prototypes \
1189                         -Wold-style-definition \
1190                         -Wmissing-prototypes \
1191                         -Wmissing-declarations \
1192                         -Wredundant-decls \
1193                         \
1194                         -Wc99-compat \
1195                         -Wc11-extensions \
1196                         -Wc2x-compat \
1197                         -Wc2x-extensions \
1198                         -Wpre-c2x-compat \
1199                         -Warray-bounds-pointer-arithmetic \
1200                         -Wassign-enum \
1201                         -Wconditional-uninitialized \
1202                         -Wdocumentation \
1203                         -Wduplicate-enum \
1204                         -Wempty-translation-unit \
1205                         -Wflexible-array-extensions \
1206                         -Wmissing-variable-declarations \
1207                         -Wnewline-eof \
1208                         -Wshift-sign-overflow \
1209                         -Wstring-conversion
1210         do
1211                 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
1212                 OLD_CFLAGS="$CFLAGS"
1213                 CFLAGS="$CFLAGS $NEW_FLAG -Werror"
1214                 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1215                                 [[void foo(void); void foo(void) { }]])], [
1216                         AM_CFLAGS="$AM_CFLAGS $NEW_FLAG"
1217                         AC_MSG_RESULT([yes])
1218                 ], [
1219                         AC_MSG_RESULT([no])
1220                 ])
1221                 CFLAGS="$OLD_CFLAGS"
1222         done
1224         AC_ARG_ENABLE([werror],
1225                 AS_HELP_STRING([--enable-werror], [Enable -Werror to abort
1226                         compilation on all compiler warnings.]),
1227                 [], [enable_werror=no])
1228         if test "x$enable_werror" = "xyes"; then
1229                 AM_CFLAGS="$AM_CFLAGS -Werror"
1230         fi
1234 ###############################################################################
1235 # Create the makefiles and config.h
1236 ###############################################################################
1238 echo
1240 # Don't build the lib directory at all if we don't need any replacement
1241 # functions.
1242 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
1244 # Add default AM_CFLAGS.
1245 AC_SUBST([AM_CFLAGS])
1247 # This is needed for src/scripts.
1248 xz=`echo xz | sed "$program_transform_name"`
1249 AC_SUBST([xz])
1251 AC_CONFIG_FILES([
1252         Makefile
1253         po/Makefile.in
1254         lib/Makefile
1255         src/Makefile
1256         src/liblzma/Makefile
1257         src/liblzma/api/Makefile
1258         src/xz/Makefile
1259         src/xzdec/Makefile
1260         src/lzmainfo/Makefile
1261         src/scripts/Makefile
1262         tests/Makefile
1263         debug/Makefile
1265 AC_CONFIG_FILES([src/scripts/xzdiff], [chmod +x src/scripts/xzdiff])
1266 AC_CONFIG_FILES([src/scripts/xzgrep], [chmod +x src/scripts/xzgrep])
1267 AC_CONFIG_FILES([src/scripts/xzmore], [chmod +x src/scripts/xzmore])
1268 AC_CONFIG_FILES([src/scripts/xzless], [chmod +x src/scripts/xzless])
1270 AC_OUTPUT
1272 # Some warnings
1273 if test x$tuklib_cv_physmem_method = xunknown; then
1274         echo
1275         echo "WARNING:"
1276         echo "No supported method to detect the amount of RAM."
1277         echo "Consider using --enable-assume-ram (if you didn't already)"
1278         echo "or make a patch to add support for this operating system."
1281 if test x$tuklib_cv_cpucores_method = xunknown; then
1282         echo
1283         echo "WARNING:"
1284         echo "No supported method to detect the number of CPU cores."
1287 if test "x$enable_threads$enable_small$have_func_attribute_constructor" \
1288                 = xnoyesno; then
1289         echo
1290         echo "NOTE:"
1291         echo "liblzma will be thread-unsafe due to the combination"
1292         echo "of --disable-threads --enable-small when using a compiler"
1293         echo "that doesn't support __attribute__((__constructor__))."