liblzma: skip ABI-incompatible check when liblzma.so.2 is loaded
[xz/debian.git] / configure.ac
blob6dae0b9756d6d4e40b8a4aea6210dba45ce01559
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.64])
20 AC_INIT([XZ Utils], m4_esyscmd([/bin/sh build-aux/version.sh]),
21         [lasse.collin@tukaani.org], [xz], [http://tukaani.org/xz/])
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_HEADER([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,sparc])dnl
83 m4_define([SIMPLE_FILTERS], [x86,powerpc,ia64,arm,armthumb,sparc])
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         AC_MSG_RESULT([(none)])
101 else
102         for arg in $enable_encoders
103         do
104                 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
105                         NAME)
106                                 enable_filter_[]NAME=yes
107                                 enable_encoder_[]NAME=yes
108                                 AC_DEFINE(HAVE_ENCODER_[]m4_toupper(NAME), [1],
109                                 [Define to 1 if] NAME [encoder is enabled.])
110                                 ;;])
111                         *)
112                                 AC_MSG_RESULT([])
113                                 AC_MSG_ERROR([unknown filter: $arg])
114                                 ;;
115                 esac
116         done
117         AC_MSG_RESULT([$enable_encoders])
120 AC_MSG_CHECKING([which decoders to build])
121 AC_ARG_ENABLE([decoders], AS_HELP_STRING([--enable-decoders=LIST],
122                 [Comma-separated list of decoders to build. Default=all.
123                 Available decoders are the same as available encoders.]),
124         [], [enable_decoders=SUPPORTED_FILTERS])
125 enable_decoders=`echo "$enable_decoders" | sed 's/,/ /g'`
126 if test "x$enable_decoders" = xno || test "x$enable_decoders" = x; then
127         AC_MSG_RESULT([(none)])
128 else
129         for arg in $enable_decoders
130         do
131                 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
132                         NAME)
133                                 enable_filter_[]NAME=yes
134                                 enable_decoder_[]NAME=yes
135                                 AC_DEFINE(HAVE_DECODER_[]m4_toupper(NAME), [1],
136                                 [Define to 1 if] NAME [decoder is enabled.])
137                                 ;;])
138                         *)
139                                 AC_MSG_RESULT([])
140                                 AC_MSG_ERROR([unknown filter: $arg])
141                                 ;;
142                 esac
143         done
145         # LZMA2 requires that LZMA1 is enabled.
146         test "x$enable_encoder_lzma2" = xyes && enable_encoder_lzma1=yes
147         test "x$enable_decoder_lzma2" = xyes && enable_decoder_lzma1=yes
149         AC_MSG_RESULT([$enable_decoders])
152 if test "x$enable_encoder_lzma2$enable_encoder_lzma1" = xyesno \
153                 || test "x$enable_decoder_lzma2$enable_decoder_lzma1" = xyesno; then
154         AC_MSG_ERROR([LZMA2 requires that LZMA1 is also enabled.])
157 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoders" != xno && test "x$enable_encoders" != x)
158 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoders" != xno && test "x$enable_decoders" != x)
160 m4_foreach([NAME], [SUPPORTED_FILTERS],
161 [AM_CONDITIONAL(COND_FILTER_[]m4_toupper(NAME), test "x$enable_filter_[]NAME" = xyes)
162 AM_CONDITIONAL(COND_ENCODER_[]m4_toupper(NAME), test "x$enable_encoder_[]NAME" = xyes)
163 AM_CONDITIONAL(COND_DECODER_[]m4_toupper(NAME), test "x$enable_decoder_[]NAME" = xyes)
164 ])dnl
166 # The so called "simple filters" share common code.
167 enable_filter_simple=no
168 enable_encoder_simple=no
169 enable_decoder_simple=no
170 m4_foreach([NAME], [SIMPLE_FILTERS],
171 [test "x$enable_filter_[]NAME" = xyes && enable_filter_simple=yes
172 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_simple=yes
173 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_simple=yes
174 ])dnl
175 AM_CONDITIONAL(COND_FILTER_SIMPLE, test "x$enable_filter_simple" = xyes)
176 AM_CONDITIONAL(COND_ENCODER_SIMPLE, test "x$enable_encoder_simple" = xyes)
177 AM_CONDITIONAL(COND_DECODER_SIMPLE, test "x$enable_decoder_simple" = xyes)
179 # LZ-based filters share common code.
180 enable_filter_lz=no
181 enable_encoder_lz=no
182 enable_decoder_lz=no
183 m4_foreach([NAME], [LZ_FILTERS],
184 [test "x$enable_filter_[]NAME" = xyes && enable_filter_lz=yes
185 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_lz=yes
186 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_lz=yes
187 ])dnl
188 AM_CONDITIONAL(COND_FILTER_LZ, test "x$enable_filter_lz" = xyes)
189 AM_CONDITIONAL(COND_ENCODER_LZ, test "x$enable_encoder_lz" = xyes)
190 AM_CONDITIONAL(COND_DECODER_LZ, test "x$enable_decoder_lz" = xyes)
193 #################
194 # Match finders #
195 #################
197 m4_define([SUPPORTED_MATCH_FINDERS], [hc3,hc4,bt2,bt3,bt4])
199 m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS],
200 [enable_match_finder_[]NAME=no
203 AC_MSG_CHECKING([which match finders to build])
204 AC_ARG_ENABLE([match-finders], AS_HELP_STRING([--enable-match-finders=LIST],
205                 [Comma-separated list of match finders to build. Default=all.
206                 At least one match finder is required for encoding with
207                 the LZMA1 and LZMA2 filters. Available match finders:]
208                 m4_translit(m4_defn([SUPPORTED_MATCH_FINDERS]), [,], [ ])), [],
209         [enable_match_finders=SUPPORTED_MATCH_FINDERS])
210 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
211 if test "x$enable_encoder_lz" = xyes ; then
212         for arg in $enable_match_finders
213                 do
214                 case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
215                         NAME)
216                                 enable_match_finder_[]NAME=yes
217                                 AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
218                                 [Define to 1 to enable] NAME [match finder.])
219                                 ;;])
220                         *)
221                                 AC_MSG_RESULT([])
222                                 AC_MSG_ERROR([unknown match finder: $arg])
223                                 ;;
224                 esac
225         done
226         AC_MSG_RESULT([$enable_match_finders])
227 else
228         AC_MSG_RESULT([(none because not building any LZ-based encoder)])
232 ####################
233 # Integrity checks #
234 ####################
236 m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
238 m4_foreach([NAME], [SUPPORTED_CHECKS],
239 [enable_check_[]NAME=no
240 ])dnl
242 AC_MSG_CHECKING([which integrity checks to build])
243 AC_ARG_ENABLE([checks], AS_HELP_STRING([--enable-checks=LIST],
244                 [Comma-separated list of integrity checks to build.
245                 Default=all. Available integrity checks:]
246                 m4_translit(m4_defn([SUPPORTED_CHECKS]), [,], [ ])),
247         [], [enable_checks=SUPPORTED_CHECKS])
248 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
249 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
250         AC_MSG_RESULT([(none)])
251 else
252         for arg in $enable_checks
253         do
254                 case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
255                         NAME)
256                                 enable_check_[]NAME=yes
257                                 AC_DEFINE(HAVE_CHECK_[]m4_toupper(NAME), [1],
258                                 [Define to 1 if] NAME
259                                 [integrity check is enabled.])
260                                 ;;])
261                         *)
262                                 AC_MSG_RESULT([])
263                                 AC_MSG_ERROR([unknown integrity check: $arg])
264                                 ;;
265                 esac
266         done
267         AC_MSG_RESULT([$enable_checks])
269 if test "x$enable_check_crc32" = xno ; then
270         AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
273 m4_foreach([NAME], [SUPPORTED_CHECKS],
274 [AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
275 ])dnl
278 ###########################
279 # Assembler optimizations #
280 ###########################
282 AC_MSG_CHECKING([if assembler optimizations should be used])
283 AC_ARG_ENABLE([assembler], AS_HELP_STRING([--disable-assembler],
284                 [Do not use assembler optimizations even if such exist
285                 for the architecture.]),
286         [], [enable_assembler=yes])
287 if test "x$enable_assembler" = xyes; then
288         enable_assembler=no
289         case $host_os in
290                 # Darwin should work too but only if not creating universal
291                 # binaries. Solaris x86 could work too but I cannot test.
292                 linux* | *bsd* | mingw* | cygwin | msys | *djgpp*)
293                         case $host_cpu in
294                                 i?86)   enable_assembler=x86 ;;
295                                 x86_64) enable_assembler=x86_64 ;;
296                         esac
297                         ;;
298         esac
300 case $enable_assembler in
301         x86 | x86_64 | no)
302                 AC_MSG_RESULT([$enable_assembler])
303                 ;;
304         *)
305                 AC_MSG_RESULT([])
306                 AC_MSG_ERROR([--enable-assembler accepts only `yes', `no', `x86', or `x86_64'.])
307                 ;;
308 esac
309 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
310 AM_CONDITIONAL(COND_ASM_X86_64, test "x$enable_assembler" = xx86_64)
313 #####################
314 # Size optimization #
315 #####################
317 AC_MSG_CHECKING([if small size is preferred over speed])
318 AC_ARG_ENABLE([small], AS_HELP_STRING([--enable-small],
319                 [Make liblzma smaller and a little slower.
320                 This is disabled by default to optimize for speed.]),
321         [], [enable_small=no])
322 if test "x$enable_small" = xyes; then
323         AC_DEFINE([HAVE_SMALL], [1], [Define to 1 if optimizing for size.])
324 elif test "x$enable_small" != xno; then
325         AC_MSG_RESULT([])
326         AC_MSG_ERROR([--enable-small accepts only `yes' or `no'])
328 AC_MSG_RESULT([$enable_small])
329 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
332 #############
333 # Threading #
334 #############
336 AC_MSG_CHECKING([if threading support is wanted])
337 AC_ARG_ENABLE([threads], AS_HELP_STRING([--enable-threads=METHOD],
338                 [Supported METHODS are `yes', `no', `posix', `win95', and
339                 `vista'. The default is `yes'. Using `no' together with
340                 --enable-small makes liblzma thread unsafe.]),
341         [], [enable_threads=yes])
343 if test "x$enable_threads" = xyes; then
344         case $host_os in
345                 mingw*)
346                         case $host_cpu in
347                                 i?86)   enable_threads=win95 ;;
348                                 *)      enable_threads=vista ;;
349                         esac
350                         ;;
351                 *)
352                         enable_threads=posix
353                         ;;
354         esac
357 case $enable_threads in
358         posix | win95 | vista)
359                 AC_MSG_RESULT([yes, $enable_threads])
360                 ;;
361         no)
362                 AC_MSG_RESULT([no])
363                 ;;
364         *)
365                 AC_MSG_RESULT([])
366                 AC_MSG_ERROR([--enable-threads only accepts `yes', `no', `posix', `win95', or `vista'])
367                 ;;
368 esac
370 # The Win95 threading lacks thread-safe one-time initialization function.
371 # It's better to disallow it instead of allowing threaded but thread-unsafe
372 # build.
373 if test "x$enable_small$enable_threads" = xyeswin95; then
374         AC_MSG_ERROR([--enable-threads=win95 and --enable-small cannot be
375                 used at the same time])
378 # We use the actual result a little later.
381 #########################
382 # Assumed amount of RAM #
383 #########################
385 # We use 128 MiB as default, because it will allow decompressing files
386 # created with "xz -9". It would be slightly safer to guess a lower value,
387 # but most systems, on which we don't have any way to determine the amount
388 # of RAM, will probably have at least 128 MiB of RAM.
389 AC_MSG_CHECKING([how much RAM to assume if the real amount is unknown])
390 AC_ARG_ENABLE([assume-ram], AS_HELP_STRING([--enable-assume-ram=SIZE],
391                 [If and only if the real amount of RAM cannot be determined,
392                 assume SIZE MiB. The default is 128 MiB. This affects the
393                 default memory usage limit.]),
394         [], [enable_assume_ram=128])
395 assume_ram_check=`echo "$enable_assume_ram" | tr -d 0123456789`
396 if test -z "$enable_assume_ram" || test -n "$assume_ram_check"; then
397         AC_MSG_RESULT([])
398         AC_MSG_ERROR([--enable-assume-ram accepts only an integer argument])
400 AC_MSG_RESULT([$enable_assume_ram MiB])
401 AC_DEFINE_UNQUOTED([ASSUME_RAM], [$enable_assume_ram],
402                 [How many MiB of RAM to assume if the real amount cannot
403                 be determined.])
406 #########################
407 # Components to install #
408 #########################
410 AC_ARG_ENABLE([xz], [AS_HELP_STRING([--disable-xz],
411                 [do not build the xz tool])],
412         [], [enable_xz=yes])
413 AM_CONDITIONAL([COND_XZ], [test x$enable_xz != xno])
415 AC_ARG_ENABLE([xzdec], [AS_HELP_STRING([--disable-xzdec],
416                 [do not build xzdec])],
417         [], [enable_xzdec=yes])
418 AM_CONDITIONAL([COND_XZDEC], [test x$enable_xzdec != xno])
420 AC_ARG_ENABLE([lzmadec], [AS_HELP_STRING([--disable-lzmadec],
421                 [do not build lzmadec
422                 (it exists primarily for LZMA Utils compatibility)])],
423         [], [enable_lzmadec=yes])
424 AM_CONDITIONAL([COND_LZMADEC], [test x$enable_lzmadec != xno])
426 AC_ARG_ENABLE([lzmainfo], [AS_HELP_STRING([--disable-lzmainfo],
427                 [do not build lzmainfo
428                 (it exists primarily for LZMA Utils compatibility)])],
429         [], [enable_lzmainfo=yes])
430 AM_CONDITIONAL([COND_LZMAINFO], [test x$enable_lzmainfo != xno])
432 AC_ARG_ENABLE([lzma-links], [AS_HELP_STRING([--disable-lzma-links],
433                 [do not create symlinks for LZMA Utils compatibility])],
434         [], [enable_lzma_links=yes])
435 AM_CONDITIONAL([COND_LZMALINKS], [test x$enable_lzma_links != xno])
437 AC_ARG_ENABLE([scripts], [AS_HELP_STRING([--disable-scripts],
438                 [do not install the scripts xzdiff, xzgrep, xzless, xzmore,
439                 and their symlinks])],
440         [], [enable_scripts=yes])
441 AM_CONDITIONAL([COND_SCRIPTS], [test x$enable_scripts != xno])
443 AC_ARG_ENABLE([doc], [AS_HELP_STRING([--disable-doc],
444                 [do not install documentation files to docdir
445                 (man pages will still be installed)])],
446         [], [enable_doc=yes])
447 AM_CONDITIONAL([COND_DOC], [test x$enable_doc != xno])
450 #####################
451 # Symbol versioning #
452 #####################
454 AC_MSG_CHECKING([if library symbol versioning should be used])
455 AC_ARG_ENABLE([symbol-versions], [AS_HELP_STRING([--enable-symbol-versions],
456                 [Use symbol versioning for liblzma. Enabled by default on
457                 GNU/Linux, other GNU-based systems, and FreeBSD.])],
458         [], [enable_symbol_versions=auto])
459 if test "x$enable_symbol_versions" = xauto; then
460         case $host_os in
461                 # NOTE: Even if one omits -gnu on GNU/Linux (e.g.
462                 # i486-slackware-linux), configure will (via config.sub)
463                 # append -gnu (e.g. i486-slackware-linux-gnu), and this
464                 # test will work correctly.
465                 gnu* | *-gnu* | freebsd*)
466                         enable_symbol_versions=yes
467                         ;;
468                 *)
469                         enable_symbol_versions=no
470                         ;;
471         esac
473 AC_MSG_RESULT([$enable_symbol_versions])
474 AM_CONDITIONAL([COND_SYMVERS], [test "x$enable_symbol_versions" = xyes])
477 ###############################################################################
478 # Checks for programs.
479 ###############################################################################
481 echo
482 gl_POSIX_SHELL
483 if test -z "$POSIX_SHELL" && test "x$enable_scripts" = xyes ; then
484         AC_MSG_ERROR([No POSIX conforming shell (sh) was found.])
487 echo
488 echo "Initializing Automake:"
490 # We don't use "subdir-objects" yet because it breaks "make distclean" when
491 # dependencies are enabled (as of Automake 1.14.1) due to this bug:
492 # http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17354
493 # The -Wno-unsupported is used to silence warnings about missing
494 # "subdir-objects".
495 AM_INIT_AUTOMAKE([1.12 foreign tar-v7 filename-length-max=99 serial-tests -Wno-unsupported])
496 AC_PROG_LN_S
498 AC_PROG_CC_C99
499 if test x$ac_cv_prog_cc_c99 = xno ; then
500         AC_MSG_ERROR([No C99 compiler was found.])
503 AM_PROG_CC_C_O
504 AM_PROG_AS
505 AC_USE_SYSTEM_EXTENSIONS
507 case $enable_threads in
508         posix)
509                 echo
510                 echo "POSIX threading support:"
511                 AX_PTHREAD([:]) dnl We don't need the HAVE_PTHREAD macro.
512                 LIBS="$LIBS $PTHREAD_LIBS"
513                 AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
515                 dnl NOTE: PTHREAD_CC is ignored. It would be useful on AIX,
516                 dnl but it's tricky to get it right together with
517                 dnl AC_PROG_CC_C99. Thus, this is handled by telling the
518                 dnl user in INSTALL to set the correct CC manually.
520                 AC_DEFINE([MYTHREAD_POSIX], [1],
521                         [Define to 1 when using POSIX threads (pthreads).])
523                 # These are nice to have but not mandatory.
524                 #
525                 # FIXME: xz uses clock_gettime if it is available and can do
526                 # it even when threading is disabled. Moving this outside
527                 # of pthread detection may be undesirable because then
528                 # liblzma may get linked against librt even when librt isn't
529                 # needed by liblzma.
530                 OLD_CFLAGS=$CFLAGS
531                 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
532                 AC_SEARCH_LIBS([clock_gettime], [rt])
533                 AC_CHECK_FUNCS([clock_gettime pthread_condattr_setclock])
534                 AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
535                 CFLAGS=$OLD_CFLAGS
536                 ;;
537         win95)
538                 AC_DEFINE([MYTHREAD_WIN95], [1], [Define to 1 when using
539                         Windows 95 (and thus XP) compatible threads.
540                         This avoids use of features that were added in
541                         Windows Vista.])
542                 ;;
543         vista)
544                 AC_DEFINE([MYTHREAD_VISTA], [1], [Define to 1 when using
545                         Windows Vista compatible threads. This uses
546                         features that are not available on Windows XP.])
547                 ;;
548 esac
549 AM_CONDITIONAL([COND_THREADS], [test "x$enable_threads" != xno])
551 # As a Debian-specific hack, liblzma uses dlopen() to check if extra
552 # paranoia is needed because unversioned symbols from liblzma.so.2 are
553 # present in the same process.  See src/liblzma/common/common.c.
554 AC_SEARCH_LIBS([dlopen], [dl])
556 echo
557 echo "Initializing Libtool:"
558 LT_PREREQ([2.2])
559 LT_INIT([win32-dll])
560 LT_LANG([Windows Resource])
562 # This is a bit wrong since it is possible to request that only some libs
563 # are built as shared. Using that feature isn't so common though, and this
564 # breaks only on Windows (at least for now) if the user enables only some
565 # libs as shared.
566 AM_CONDITIONAL([COND_SHARED], [test "x$enable_shared" != xno])
569 ###############################################################################
570 # Checks for libraries.
571 ###############################################################################
573 echo
574 echo "Initializing gettext:"
575 AM_GNU_GETTEXT_VERSION([0.18])
576 AM_GNU_GETTEXT([external])
579 ###############################################################################
580 # Checks for header files.
581 ###############################################################################
583 echo
584 echo "System headers and functions:"
586 # There is currently no workarounds in this package if some of
587 # these headers are missing.
588 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
589         [],
590         [AC_MSG_ERROR([Required header file(s) are missing.])])
592 # This allows the use of the intrinsic functions if they are available.
593 AC_CHECK_HEADERS([immintrin.h])
596 ###############################################################################
597 # Checks for typedefs, structures, and compiler characteristics.
598 ###############################################################################
600 dnl We don't need these as long as we need a C99 compiler anyway.
601 dnl AC_C_INLINE
602 dnl AC_C_RESTRICT
604 AC_HEADER_STDBOOL
606 AC_TYPE_UINT8_T
607 AC_TYPE_UINT16_T
608 AC_TYPE_INT32_T
609 AC_TYPE_UINT32_T
610 AC_TYPE_INT64_T
611 AC_TYPE_UINT64_T
612 AC_TYPE_UINTPTR_T
614 AC_CHECK_SIZEOF([size_t])
616 # The command line tool can copy high resolution timestamps if such
617 # information is available in struct stat. Otherwise one second accuracy
618 # is used.
619 AC_CHECK_MEMBERS([
620         struct stat.st_atim.tv_nsec,
621         struct stat.st_atimespec.tv_nsec,
622         struct stat.st_atimensec,
623         struct stat.st_uatime,
624         struct stat.st_atim.st__tim.tv_nsec])
626 AC_SYS_LARGEFILE
627 AC_C_BIGENDIAN
630 ###############################################################################
631 # Checks for library functions.
632 ###############################################################################
634 # Gnulib replacements as needed
635 gl_GETOPT
637 # Find the best function to set timestamps.
638 AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
640 # This is nice to have but not mandatory.
641 AC_CHECK_FUNCS([posix_fadvise])
643 TUKLIB_PROGNAME
644 TUKLIB_INTEGER
645 TUKLIB_PHYSMEM
646 TUKLIB_CPUCORES
647 TUKLIB_MBSTR
649 # Check for system-provided SHA-256. At least the following is supported:
651 # OS       Headers                     Library  Type           Function
652 # FreeBSD  sys/types.h + sha256.h      libmd    SHA256_CTX     SHA256_Init
653 # NetBSD   sys/types.h + sha2.h                 SHA256_CTX     SHA256_Init
654 # OpenBSD  sys/types.h + sha2.h                 SHA2_CTX       SHA256Init
655 # Solaris  sys/types.h + sha2.h        libmd    SHA256_CTX     SHA256Init
656 # MINIX 3  sys/types.h + minix/sha2.h  libutil  SHA256_CTX     SHA256_Init
657 # Darwin   CommonCrypto/CommonDigest.h          CC_SHA256_CTX  CC_SHA256_Init
659 # Note that Darwin's CC_SHA256_Update takes buffer size as uint32_t instead
660 # of size_t.
662 # We don't check for e.g. OpenSSL or libgcrypt because we don't want
663 # to introduce dependencies to other packages by default. Maybe such
664 # libraries could be supported via additional configure options though.
666 if test "x$enable_check_sha256" = "xyes"; then
667         # Test for Common Crypto before others, because Darwin has sha256.h
668         # too and we don't want to use that, because on older versions it
669         # uses OpenSSL functions, whose SHA256_Init is not guaranteed to
670         # succeed.
671         sha256_header_found=no
672         AC_CHECK_HEADERS(
673                 [CommonCrypto/CommonDigest.h sha256.h sha2.h minix/sha2.h],
674                 [sha256_header_found=yes ; break])
675         if test "x$sha256_header_found" = xyes; then
676                 AC_CHECK_TYPES([CC_SHA256_CTX, SHA256_CTX, SHA2_CTX], [], [],
677                         [[#ifdef HAVE_SYS_TYPES_H
678                           # include <sys/types.h>
679                           #endif
680                           #ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
681                           # include <CommonCrypto/CommonDigest.h>
682                           #endif
683                           #ifdef HAVE_SHA256_H
684                           # include <sha256.h>
685                           #endif
686                           #ifdef HAVE_SHA2_H
687                           # include <sha2.h>
688                           #endif
689                           #ifdef HAVE_MINIX_SHA2_H
690                           # include <minix/sha2.h>
691                           #endif]])
692                 AC_SEARCH_LIBS([SHA256_Init], [md util])
693                 AC_SEARCH_LIBS([SHA256Init], [md])
694                 AC_CHECK_FUNCS([CC_SHA256_Init SHA256_Init SHA256Init],
695                         [break])
696         fi
698 AM_CONDITIONAL([COND_INTERNAL_SHA256],
699         [test "x$ac_cv_func_SHA256_Init" != xyes \
700                 && test "x$ac_cv_func_SHA256Init" != xyes \
701                 && test "x$ac_cv_func_CC_SHA256_Init" != xyes])
703 # Check for SSE2 intrinsics.
704 AC_CHECK_DECL([_mm_movemask_epi8],
705         [AC_DEFINE([HAVE__MM_MOVEMASK_EPI8], [1],
706                 [Define to 1 if _mm_movemask_epi8 is available.])],
707         [],
708 [#ifdef HAVE_IMMINTRIN_H
709 #include <immintrin.h>
710 #endif])
713 ###############################################################################
714 # If using GCC, set some additional AM_CFLAGS:
715 ###############################################################################
717 if test "$GCC" = yes ; then
718         echo
719         echo "GCC extensions:"
722 # Always do the visibility check but don't set AM_CFLAGS on Windows.
723 # This way things get set properly even on Windows.
724 gl_VISIBILITY
725 if test -n "$CFLAG_VISIBILITY" && test "$is_w32" = no; then
726         AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
729 if test "$GCC" = yes ; then
730         # Enable as much warnings as possible. These commented warnings won't
731         # work for this package though:
732         #   * -Wunreachable-code breaks several assert(0) cases, which are
733         #     backed up with "return LZMA_PROG_ERROR".
734         #   * -Wcast-qual would break various things where we need a non-const
735         #     pointer although we don't modify anything through it.
736         #   * -Wcast-align breaks optimized CRC32 and CRC64 implementation
737         #     on some architectures (not on x86), where this warning is bogus,
738         #     because we take care of correct alignment.
739         #   * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
740         #     don't seem so useful here; at least the last one gives some
741         #     warnings which are not bugs.
742         for NEW_FLAG in \
743                         -Wall \
744                         -Wextra \
745                         -Wvla \
746                         -Wformat=2 \
747                         -Winit-self \
748                         -Wmissing-include-dirs \
749                         -Wstrict-aliasing \
750                         -Wfloat-equal \
751                         -Wundef \
752                         -Wshadow \
753                         -Wpointer-arith \
754                         -Wbad-function-cast \
755                         -Wwrite-strings \
756                         -Wlogical-op \
757                         -Waggregate-return \
758                         -Wstrict-prototypes \
759                         -Wold-style-definition \
760                         -Wmissing-prototypes \
761                         -Wmissing-declarations \
762                         -Wmissing-noreturn \
763                         -Wredundant-decls
764         do
765                 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
766                 OLD_CFLAGS="$CFLAGS"
767                 CFLAGS="$CFLAGS $NEW_FLAG -Werror"
768                 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
769                                 [void foo(void); void foo(void) { }])], [
770                         AM_CFLAGS="$AM_CFLAGS $NEW_FLAG"
771                         AC_MSG_RESULT([yes])
772                 ], [
773                         AC_MSG_RESULT([no])
774                 ])
775                 CFLAGS="$OLD_CFLAGS"
776         done
778         AC_ARG_ENABLE([werror],
779                 AS_HELP_STRING([--enable-werror], [Enable -Werror to abort
780                         compilation on all compiler warnings.]),
781                 [], [enable_werror=no])
782         if test "x$enable_werror" = "xyes"; then
783                 AM_CFLAGS="$AM_CFLAGS -Werror"
784         fi
788 ###############################################################################
789 # Create the makefiles and config.h
790 ###############################################################################
792 echo
794 # Don't build the lib directory at all if we don't need any replacement
795 # functions.
796 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
798 # Add default AM_CFLAGS.
799 AC_SUBST([AM_CFLAGS])
801 # This is needed for src/scripts.
802 xz=`echo xz | sed "$program_transform_name"`
803 AC_SUBST([xz])
805 AC_CONFIG_FILES([
806         Doxyfile
807         Makefile
808         po/Makefile.in
809         lib/Makefile
810         src/Makefile
811         src/liblzma/Makefile
812         src/liblzma/api/Makefile
813         src/xz/Makefile
814         src/xzdec/Makefile
815         src/lzmainfo/Makefile
816         src/scripts/Makefile
817         tests/Makefile
818         debug/Makefile
820 AC_CONFIG_FILES([src/scripts/xzdiff], [chmod +x src/scripts/xzdiff])
821 AC_CONFIG_FILES([src/scripts/xzgrep], [chmod +x src/scripts/xzgrep])
822 AC_CONFIG_FILES([src/scripts/xzmore], [chmod +x src/scripts/xzmore])
823 AC_CONFIG_FILES([src/scripts/xzless], [chmod +x src/scripts/xzless])
825 AC_OUTPUT
827 # Some warnings
828 if test x$tuklib_cv_physmem_method = xunknown; then
829         echo
830         echo "WARNING:"
831         echo "No supported method to detect the amount of RAM."
832         echo "Consider using --enable-assume-ram (if you didn't already)"
833         echo "or make a patch to add support for this operating system."
836 if test x$tuklib_cv_cpucores_method = xunknown; then
837         echo
838         echo "WARNING:"
839         echo "No supported method to detect the number of CPU cores."
842 if test "x$enable_threads$enable_small" = xnoyes; then
843         echo
844         echo "NOTE:"
845         echo "liblzma will be thread unsafe due the combination"
846         echo "of --disable-threads --enable-small."