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