debian: Prepare for upload
[xz/debian.git] / configure.ac
blobc4f8a4ccc8f7d9626591b9408283e5eb5e20b8d8
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], [https://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         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         for arg in $enable_match_finders
214                 do
215                 case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
216                         NAME)
217                                 enable_match_finder_[]NAME=yes
218                                 AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
219                                 [Define to 1 to enable] NAME [match finder.])
220                                 ;;])
221                         *)
222                                 AC_MSG_RESULT([])
223                                 AC_MSG_ERROR([unknown match finder: $arg])
224                                 ;;
225                 esac
226         done
227         AC_MSG_RESULT([$enable_match_finders])
228 else
229         AC_MSG_RESULT([(none because not building any LZ-based encoder)])
233 ####################
234 # Integrity checks #
235 ####################
237 m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
239 m4_foreach([NAME], [SUPPORTED_CHECKS],
240 [enable_check_[]NAME=no
241 ])dnl
243 AC_MSG_CHECKING([which integrity checks to build])
244 AC_ARG_ENABLE([checks], AS_HELP_STRING([--enable-checks=LIST],
245                 [Comma-separated list of integrity checks to build.
246                 Default=all. Available integrity checks:]
247                 m4_translit(m4_defn([SUPPORTED_CHECKS]), [,], [ ])),
248         [], [enable_checks=SUPPORTED_CHECKS])
249 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
250 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
251         AC_MSG_RESULT([(none)])
252 else
253         for arg in $enable_checks
254         do
255                 case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
256                         NAME)
257                                 enable_check_[]NAME=yes
258                                 AC_DEFINE(HAVE_CHECK_[]m4_toupper(NAME), [1],
259                                 [Define to 1 if] NAME
260                                 [integrity check is enabled.])
261                                 ;;])
262                         *)
263                                 AC_MSG_RESULT([])
264                                 AC_MSG_ERROR([unknown integrity check: $arg])
265                                 ;;
266                 esac
267         done
268         AC_MSG_RESULT([$enable_checks])
270 if test "x$enable_check_crc32" = xno ; then
271         AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
274 m4_foreach([NAME], [SUPPORTED_CHECKS],
275 [AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
276 ])dnl
278 AC_MSG_CHECKING([if external SHA-256 should be used])
279 AC_ARG_ENABLE([external-sha256], AS_HELP_STRING([--enable-external-sha256],
280                 [Use SHA-256 code from the operating system.
281                 See INSTALL for possible subtle problems.]),
282                 [], [enable_external_sha256=no])
283 if test "x$enable_check_sha256" != "xyes"; then
284         enable_external_sha256=no
286 if test "x$enable_external_sha256" = xyes; then
287         AC_MSG_RESULT([yes])
288 else
289         AC_MSG_RESULT([no])
293 ###########################
294 # Assembler optimizations #
295 ###########################
297 AC_MSG_CHECKING([if assembler optimizations should be used])
298 AC_ARG_ENABLE([assembler], AS_HELP_STRING([--disable-assembler],
299                 [Do not use assembler optimizations even if such exist
300                 for the architecture.]),
301         [], [enable_assembler=yes])
302 if test "x$enable_assembler" = xyes; then
303         enable_assembler=no
304         case $host_os in
305                 # Darwin should work too but only if not creating universal
306                 # binaries. Solaris x86 could work too but I cannot test.
307                 linux* | *bsd* | mingw* | cygwin | msys | *djgpp*)
308                         case $host_cpu in
309                                 i?86)   enable_assembler=x86 ;;
310                                 x86_64) enable_assembler=x86_64 ;;
311                         esac
312                         ;;
313         esac
315 case $enable_assembler in
316         x86 | x86_64 | no)
317                 AC_MSG_RESULT([$enable_assembler])
318                 ;;
319         *)
320                 AC_MSG_RESULT([])
321                 AC_MSG_ERROR([--enable-assembler accepts only `yes', `no', `x86', or `x86_64'.])
322                 ;;
323 esac
324 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
325 AM_CONDITIONAL(COND_ASM_X86_64, test "x$enable_assembler" = xx86_64)
328 #####################
329 # Size optimization #
330 #####################
332 AC_MSG_CHECKING([if small size is preferred over speed])
333 AC_ARG_ENABLE([small], AS_HELP_STRING([--enable-small],
334                 [Make liblzma smaller and a little slower.
335                 This is disabled by default to optimize for speed.]),
336         [], [enable_small=no])
337 if test "x$enable_small" = xyes; then
338         AC_DEFINE([HAVE_SMALL], [1], [Define to 1 if optimizing for size.])
339 elif test "x$enable_small" != xno; then
340         AC_MSG_RESULT([])
341         AC_MSG_ERROR([--enable-small accepts only `yes' or `no'])
343 AC_MSG_RESULT([$enable_small])
344 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
347 #############
348 # Threading #
349 #############
351 AC_MSG_CHECKING([if threading support is wanted])
352 AC_ARG_ENABLE([threads], AS_HELP_STRING([--enable-threads=METHOD],
353                 [Supported METHODS are `yes', `no', `posix', `win95', and
354                 `vista'. The default is `yes'. Using `no' together with
355                 --enable-small makes liblzma thread unsafe.]),
356         [], [enable_threads=yes])
358 if test "x$enable_threads" = xyes; then
359         case $host_os in
360                 mingw*)
361                         case $host_cpu in
362                                 i?86)   enable_threads=win95 ;;
363                                 *)      enable_threads=vista ;;
364                         esac
365                         ;;
366                 *)
367                         enable_threads=posix
368                         ;;
369         esac
372 case $enable_threads in
373         posix | win95 | vista)
374                 AC_MSG_RESULT([yes, $enable_threads])
375                 ;;
376         no)
377                 AC_MSG_RESULT([no])
378                 ;;
379         *)
380                 AC_MSG_RESULT([])
381                 AC_MSG_ERROR([--enable-threads only accepts `yes', `no', `posix', `win95', or `vista'])
382                 ;;
383 esac
385 # The Win95 threading lacks thread-safe one-time initialization function.
386 # It's better to disallow it instead of allowing threaded but thread-unsafe
387 # build.
388 if test "x$enable_small$enable_threads" = xyeswin95; then
389         AC_MSG_ERROR([--enable-threads=win95 and --enable-small cannot be
390                 used at the same time])
393 # We use the actual result a little later.
396 #########################
397 # Assumed amount of RAM #
398 #########################
400 # We use 128 MiB as default, because it will allow decompressing files
401 # created with "xz -9". It would be slightly safer to guess a lower value,
402 # but most systems, on which we don't have any way to determine the amount
403 # of RAM, will probably have at least 128 MiB of RAM.
404 AC_MSG_CHECKING([how much RAM to assume if the real amount is unknown])
405 AC_ARG_ENABLE([assume-ram], AS_HELP_STRING([--enable-assume-ram=SIZE],
406                 [If and only if the real amount of RAM cannot be determined,
407                 assume SIZE MiB. The default is 128 MiB. This affects the
408                 default memory usage limit.]),
409         [], [enable_assume_ram=128])
410 assume_ram_check=`echo "$enable_assume_ram" | tr -d 0123456789`
411 if test -z "$enable_assume_ram" || test -n "$assume_ram_check"; then
412         AC_MSG_RESULT([])
413         AC_MSG_ERROR([--enable-assume-ram accepts only an integer argument])
415 AC_MSG_RESULT([$enable_assume_ram MiB])
416 AC_DEFINE_UNQUOTED([ASSUME_RAM], [$enable_assume_ram],
417                 [How many MiB of RAM to assume if the real amount cannot
418                 be determined.])
421 #########################
422 # Components to install #
423 #########################
425 AC_ARG_ENABLE([xz], [AS_HELP_STRING([--disable-xz],
426                 [do not build the xz tool])],
427         [], [enable_xz=yes])
428 AM_CONDITIONAL([COND_XZ], [test x$enable_xz != xno])
430 AC_ARG_ENABLE([xzdec], [AS_HELP_STRING([--disable-xzdec],
431                 [do not build xzdec])],
432         [], [enable_xzdec=yes])
433 test "x$enable_decoders" = xno && enable_xzdec=no
434 AM_CONDITIONAL([COND_XZDEC], [test x$enable_xzdec != xno])
436 AC_ARG_ENABLE([lzmadec], [AS_HELP_STRING([--disable-lzmadec],
437                 [do not build lzmadec
438                 (it exists primarily for LZMA Utils compatibility)])],
439         [], [enable_lzmadec=yes])
440 test "x$enable_decoder_lzma1" = xno && enable_lzmadec=no
441 AM_CONDITIONAL([COND_LZMADEC], [test x$enable_lzmadec != xno])
443 AC_ARG_ENABLE([lzmainfo], [AS_HELP_STRING([--disable-lzmainfo],
444                 [do not build lzmainfo
445                 (it exists primarily for LZMA Utils compatibility)])],
446         [], [enable_lzmainfo=yes])
447 test "x$enable_decoder_lzma1" = xno && enable_lzmainfo=no
448 AM_CONDITIONAL([COND_LZMAINFO], [test x$enable_lzmainfo != xno])
450 AC_ARG_ENABLE([lzma-links], [AS_HELP_STRING([--disable-lzma-links],
451                 [do not create symlinks for LZMA Utils compatibility])],
452         [], [enable_lzma_links=yes])
453 AM_CONDITIONAL([COND_LZMALINKS], [test x$enable_lzma_links != xno])
455 AC_ARG_ENABLE([scripts], [AS_HELP_STRING([--disable-scripts],
456                 [do not install the scripts xzdiff, xzgrep, xzless, xzmore,
457                 and their symlinks])],
458         [], [enable_scripts=yes])
459 AM_CONDITIONAL([COND_SCRIPTS], [test x$enable_scripts != xno])
461 AC_ARG_ENABLE([doc], [AS_HELP_STRING([--disable-doc],
462                 [do not install documentation files to docdir
463                 (man pages will still be installed)])],
464         [], [enable_doc=yes])
465 AM_CONDITIONAL([COND_DOC], [test x$enable_doc != xno])
468 #####################
469 # Symbol versioning #
470 #####################
472 AC_MSG_CHECKING([if library symbol versioning should be used])
473 AC_ARG_ENABLE([symbol-versions], [AS_HELP_STRING([--enable-symbol-versions],
474                 [Use symbol versioning for liblzma. Enabled by default on
475                 GNU/Linux, other GNU-based systems, and FreeBSD.])],
476         [], [enable_symbol_versions=auto])
477 if test "x$enable_symbol_versions" = xauto; then
478         case $host_os in
479                 # NOTE: Even if one omits -gnu on GNU/Linux (e.g.
480                 # i486-slackware-linux), configure will (via config.sub)
481                 # append -gnu (e.g. i486-slackware-linux-gnu), and this
482                 # test will work correctly.
483                 gnu* | *-gnu* | freebsd*)
484                         enable_symbol_versions=yes
485                         ;;
486                 *)
487                         enable_symbol_versions=no
488                         ;;
489         esac
491 AC_MSG_RESULT([$enable_symbol_versions])
492 AM_CONDITIONAL([COND_SYMVERS], [test "x$enable_symbol_versions" = xyes])
495 ##############
496 # Sandboxing #
497 ##############
499 AC_MSG_CHECKING([if sandboxing should be used])
500 AC_ARG_ENABLE([sandbox], [AS_HELP_STRING([--enable-sandbox=METHOD],
501                 [This is an experimental feature.
502                 Sandboxing METHOD can be `auto', `no', or `capsicum'.
503                 The default is `no'.])],
504         [], [enable_sandbox=no])
505 case $enable_sandbox in
506         auto)
507                 AC_MSG_RESULT([maybe (autodetect)])
508                 ;;
509         no | capsicum)
510                 AC_MSG_RESULT([$enable_sandbox])
511                 ;;
512         *)
513                 AC_MSG_RESULT([])
514                 AC_MSG_ERROR([--enable-sandbox only accepts `auto', `no', or `capsicum'.])
515                 ;;
516 esac
519 ###############################################################################
520 # Checks for programs.
521 ###############################################################################
523 echo
524 gl_POSIX_SHELL
525 if test -z "$POSIX_SHELL" && test "x$enable_scripts" = xyes ; then
526         AC_MSG_ERROR([No POSIX conforming shell (sh) was found.])
529 echo
530 echo "Initializing Automake:"
532 # We don't use "subdir-objects" yet because it breaks "make distclean" when
533 # dependencies are enabled (as of Automake 1.14.1) due to this bug:
534 # http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17354
535 # The -Wno-unsupported is used to silence warnings about missing
536 # "subdir-objects".
537 AM_INIT_AUTOMAKE([1.12 foreign tar-v7 filename-length-max=99 serial-tests -Wno-unsupported])
538 AC_PROG_LN_S
540 AC_PROG_CC_C99
541 if test x$ac_cv_prog_cc_c99 = xno ; then
542         AC_MSG_ERROR([No C99 compiler was found.])
545 AM_PROG_CC_C_O
546 AM_PROG_AS
547 AC_USE_SYSTEM_EXTENSIONS
549 case $enable_threads in
550         posix)
551                 echo
552                 echo "POSIX threading support:"
553                 AX_PTHREAD([:]) dnl We don't need the HAVE_PTHREAD macro.
554                 LIBS="$LIBS $PTHREAD_LIBS"
555                 AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
557                 dnl NOTE: PTHREAD_CC is ignored. It would be useful on AIX,
558                 dnl but it's tricky to get it right together with
559                 dnl AC_PROG_CC_C99. Thus, this is handled by telling the
560                 dnl user in INSTALL to set the correct CC manually.
562                 AC_DEFINE([MYTHREAD_POSIX], [1],
563                         [Define to 1 when using POSIX threads (pthreads).])
565                 # These are nice to have but not mandatory.
566                 #
567                 # FIXME: xz uses clock_gettime if it is available and can do
568                 # it even when threading is disabled. Moving this outside
569                 # of pthread detection may be undesirable because then
570                 # liblzma may get linked against librt even when librt isn't
571                 # needed by liblzma.
572                 OLD_CFLAGS=$CFLAGS
573                 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
574                 AC_SEARCH_LIBS([clock_gettime], [rt])
575                 AC_CHECK_FUNCS([clock_gettime pthread_condattr_setclock])
576                 AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
577                 CFLAGS=$OLD_CFLAGS
578                 ;;
579         win95)
580                 AC_DEFINE([MYTHREAD_WIN95], [1], [Define to 1 when using
581                         Windows 95 (and thus XP) compatible threads.
582                         This avoids use of features that were added in
583                         Windows Vista.])
584                 ;;
585         vista)
586                 AC_DEFINE([MYTHREAD_VISTA], [1], [Define to 1 when using
587                         Windows Vista compatible threads. This uses
588                         features that are not available on Windows XP.])
589                 ;;
590 esac
591 AM_CONDITIONAL([COND_THREADS], [test "x$enable_threads" != xno])
593 echo
594 echo "Initializing Libtool:"
595 LT_PREREQ([2.2])
596 LT_INIT([win32-dll])
597 LT_LANG([Windows Resource])
599 # This is a bit wrong since it is possible to request that only some libs
600 # are built as shared. Using that feature isn't so common though, and this
601 # breaks only on Windows (at least for now) if the user enables only some
602 # libs as shared.
603 AM_CONDITIONAL([COND_SHARED], [test "x$enable_shared" != xno])
606 ###############################################################################
607 # Checks for libraries.
608 ###############################################################################
610 echo
611 echo "Initializing gettext:"
612 AM_GNU_GETTEXT_VERSION([0.19])
613 AM_GNU_GETTEXT([external])
616 ###############################################################################
617 # Checks for header files.
618 ###############################################################################
620 echo
621 echo "System headers and functions:"
623 # There is currently no workarounds in this package if some of
624 # these headers are missing.
625 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
626         [],
627         [AC_MSG_ERROR([Required header file(s) are missing.])])
629 # This allows the use of the intrinsic functions if they are available.
630 AC_CHECK_HEADERS([immintrin.h])
633 ###############################################################################
634 # Checks for typedefs, structures, and compiler characteristics.
635 ###############################################################################
637 dnl We don't need these as long as we need a C99 compiler anyway.
638 dnl AC_C_INLINE
639 dnl AC_C_RESTRICT
641 AC_HEADER_STDBOOL
643 AC_TYPE_UINT8_T
644 AC_TYPE_UINT16_T
645 AC_TYPE_INT32_T
646 AC_TYPE_UINT32_T
647 AC_TYPE_INT64_T
648 AC_TYPE_UINT64_T
649 AC_TYPE_UINTPTR_T
651 AC_CHECK_SIZEOF([size_t])
653 # The command line tool can copy high resolution timestamps if such
654 # information is available in struct stat. Otherwise one second accuracy
655 # is used.
656 AC_CHECK_MEMBERS([
657         struct stat.st_atim.tv_nsec,
658         struct stat.st_atimespec.tv_nsec,
659         struct stat.st_atimensec,
660         struct stat.st_uatime,
661         struct stat.st_atim.st__tim.tv_nsec])
663 AC_SYS_LARGEFILE
664 AC_C_BIGENDIAN
667 ###############################################################################
668 # Checks for library functions.
669 ###############################################################################
671 # Gnulib replacements as needed
672 gl_GETOPT
674 # Find the best function to set timestamps.
675 AC_CHECK_FUNCS([futimens futimes futimesat utimes _futime utime], [break])
677 # This is nice to have but not mandatory.
678 AC_CHECK_FUNCS([posix_fadvise])
680 TUKLIB_PROGNAME
681 TUKLIB_INTEGER
682 TUKLIB_PHYSMEM
683 TUKLIB_CPUCORES
684 TUKLIB_MBSTR
686 # If requsted, check for system-provided SHA-256. At least the following
687 # implementations are supported:
689 # OS       Headers                     Library  Type           Function
690 # FreeBSD  sys/types.h + sha256.h      libmd    SHA256_CTX     SHA256_Init
691 # NetBSD   sys/types.h + sha2.h                 SHA256_CTX     SHA256_Init
692 # OpenBSD  sys/types.h + sha2.h                 SHA2_CTX       SHA256Init
693 # Solaris  sys/types.h + sha2.h        libmd    SHA256_CTX     SHA256Init
694 # MINIX 3  sys/types.h + sha2.h                 SHA256_CTX     SHA256_Init
695 # Darwin   CommonCrypto/CommonDigest.h          CC_SHA256_CTX  CC_SHA256_Init
697 # Note that Darwin's CC_SHA256_Update takes buffer size as uint32_t instead
698 # of size_t.
700 sha256_header_found=no
701 sha256_type_found=no
702 sha256_func_found=no
703 if test "x$enable_external_sha256" = "xyes"; then
704         # Test for Common Crypto before others, because Darwin has sha256.h
705         # too and we don't want to use that, because on older versions it
706         # uses OpenSSL functions, whose SHA256_Init is not guaranteed to
707         # succeed.
708         AC_CHECK_HEADERS(
709                 [CommonCrypto/CommonDigest.h sha256.h sha2.h],
710                 [sha256_header_found=yes ; break])
711         if test "x$sha256_header_found" = xyes; then
712                 AC_CHECK_TYPES([CC_SHA256_CTX, SHA256_CTX, SHA2_CTX],
713                         [sha256_type_found=yes], [],
714                         [[#ifdef HAVE_SYS_TYPES_H
715                           # include <sys/types.h>
716                           #endif
717                           #ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
718                           # include <CommonCrypto/CommonDigest.h>
719                           #endif
720                           #ifdef HAVE_SHA256_H
721                           # include <sha256.h>
722                           #endif
723                           #ifdef HAVE_SHA2_H
724                           # include <sha2.h>
725                           #endif]])
726                 if test "x$sha256_type_found" = xyes ; then
727                         AC_SEARCH_LIBS([SHA256Init], [md])
728                         AC_SEARCH_LIBS([SHA256_Init], [md])
729                         AC_CHECK_FUNCS([CC_SHA256_Init SHA256Init SHA256_Init],
730                                 [sha256_func_found=yes ; break])
731                 fi
732         fi
734 AM_CONDITIONAL([COND_INTERNAL_SHA256], [test "x$sha256_func_found" = xno])
735 if test "x$enable_external_sha256$sha256_func_found" = xyesno; then
736         AC_MSG_ERROR([--enable-external-sha256 was specified but no supported external SHA-256 implementation was found])
739 # Check for SSE2 intrinsics.
740 AC_CHECK_DECL([_mm_movemask_epi8],
741         [AC_DEFINE([HAVE__MM_MOVEMASK_EPI8], [1],
742                 [Define to 1 if _mm_movemask_epi8 is available.])],
743         [],
744 [#ifdef HAVE_IMMINTRIN_H
745 #include <immintrin.h>
746 #endif])
748 # Check for sandbox support. If one is found, set enable_sandbox=found.
749 case $enable_sandbox in
750         auto | capsicum)
751                 AX_CHECK_CAPSICUM([enable_sandbox=found], [:])
752                 ;;
753 esac
755 # If a specific sandboxing method was explicitly requested and it wasn't
756 # found, give an error.
757 case $enable_sandbox in
758         auto | no | found)
759                 ;;
760         *)
761                 AC_MSG_ERROR([$enable_sandbox support not found])
762                 ;;
763 esac
766 ###############################################################################
767 # If using GCC, set some additional AM_CFLAGS:
768 ###############################################################################
770 if test "$GCC" = yes ; then
771         echo
772         echo "GCC extensions:"
775 # Always do the visibility check but don't set AM_CFLAGS on Windows.
776 # This way things get set properly even on Windows.
777 gl_VISIBILITY
778 if test -n "$CFLAG_VISIBILITY" && test "$is_w32" = no; then
779         AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
782 if test "$GCC" = yes ; then
783         # Enable as much warnings as possible. These commented warnings won't
784         # work for this package though:
785         #   * -Wunreachable-code breaks several assert(0) cases, which are
786         #     backed up with "return LZMA_PROG_ERROR".
787         #   * -Wcast-qual would break various things where we need a non-const
788         #     pointer although we don't modify anything through it.
789         #   * -Wcast-align breaks optimized CRC32 and CRC64 implementation
790         #     on some architectures (not on x86), where this warning is bogus,
791         #     because we take care of correct alignment.
792         #   * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
793         #     don't seem so useful here; at least the last one gives some
794         #     warnings which are not bugs.
795         for NEW_FLAG in \
796                         -Wall \
797                         -Wextra \
798                         -Wvla \
799                         -Wformat=2 \
800                         -Winit-self \
801                         -Wmissing-include-dirs \
802                         -Wstrict-aliasing \
803                         -Wfloat-equal \
804                         -Wundef \
805                         -Wshadow \
806                         -Wpointer-arith \
807                         -Wbad-function-cast \
808                         -Wwrite-strings \
809                         -Wlogical-op \
810                         -Waggregate-return \
811                         -Wstrict-prototypes \
812                         -Wold-style-definition \
813                         -Wmissing-prototypes \
814                         -Wmissing-declarations \
815                         -Wmissing-noreturn \
816                         -Wredundant-decls
817         do
818                 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
819                 OLD_CFLAGS="$CFLAGS"
820                 CFLAGS="$CFLAGS $NEW_FLAG -Werror"
821                 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
822                                 [void foo(void); void foo(void) { }])], [
823                         AM_CFLAGS="$AM_CFLAGS $NEW_FLAG"
824                         AC_MSG_RESULT([yes])
825                 ], [
826                         AC_MSG_RESULT([no])
827                 ])
828                 CFLAGS="$OLD_CFLAGS"
829         done
831         AC_ARG_ENABLE([werror],
832                 AS_HELP_STRING([--enable-werror], [Enable -Werror to abort
833                         compilation on all compiler warnings.]),
834                 [], [enable_werror=no])
835         if test "x$enable_werror" = "xyes"; then
836                 AM_CFLAGS="$AM_CFLAGS -Werror"
837         fi
841 ###############################################################################
842 # Create the makefiles and config.h
843 ###############################################################################
845 echo
847 # Don't build the lib directory at all if we don't need any replacement
848 # functions.
849 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
851 # Add default AM_CFLAGS.
852 AC_SUBST([AM_CFLAGS])
854 # This is needed for src/scripts.
855 xz=`echo xz | sed "$program_transform_name"`
856 AC_SUBST([xz])
858 AC_CONFIG_FILES([
859         Doxyfile
860         Makefile
861         po/Makefile.in
862         lib/Makefile
863         src/Makefile
864         src/liblzma/Makefile
865         src/liblzma/api/Makefile
866         src/xz/Makefile
867         src/xzdec/Makefile
868         src/lzmainfo/Makefile
869         src/scripts/Makefile
870         tests/Makefile
871         debug/Makefile
873 AC_CONFIG_FILES([src/scripts/xzdiff], [chmod +x src/scripts/xzdiff])
874 AC_CONFIG_FILES([src/scripts/xzgrep], [chmod +x src/scripts/xzgrep])
875 AC_CONFIG_FILES([src/scripts/xzmore], [chmod +x src/scripts/xzmore])
876 AC_CONFIG_FILES([src/scripts/xzless], [chmod +x src/scripts/xzless])
878 AC_OUTPUT
880 # Some warnings
881 if test x$tuklib_cv_physmem_method = xunknown; then
882         echo
883         echo "WARNING:"
884         echo "No supported method to detect the amount of RAM."
885         echo "Consider using --enable-assume-ram (if you didn't already)"
886         echo "or make a patch to add support for this operating system."
889 if test x$tuklib_cv_cpucores_method = xunknown; then
890         echo
891         echo "WARNING:"
892         echo "No supported method to detect the number of CPU cores."
895 if test "x$enable_threads$enable_small" = xnoyes; then
896         echo
897         echo "NOTE:"
898         echo "liblzma will be thread unsafe due the combination"
899         echo "of --disable-threads --enable-small."