2 # Process this file with autoconf to produce a configure script.
4 ###############################################################################
6 # Copyright (C) 2007 Lasse Collin
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 ###############################################################################
20 # NOTE: Don't add useless checks. autoscan detects this and that, but don't
21 # let it confuse you. For example, we don't care about checking for behavior
22 # of malloc(), stat(), or lstat(), since we don't use those functions in
23 # a way that would cause the problems the autoconf macros check.
27 AC_INIT([XZ Utils], m4_esyscmd([/bin/sh version.sh]),
28 [lasse.collin@tukaani.org], [xz])
29 AC_CONFIG_SRCDIR([src/liblzma/common/common.h])
30 AC_CONFIG_HEADER([config.h])
33 echo "$PACKAGE_STRING"
37 # This is needed to know if assembler optimizations can be used.
42 echo "Configure options:"
50 AC_MSG_CHECKING([if debugging code should be compiled])
51 AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable debugging code.]),
53 if test "x$enable_debug" = xyes; then
56 AC_DEFINE([NDEBUG], [1], [Define to 1 to disable debugging code.])
65 AC_MSG_CHECKING([if encoder components should be built])
66 AC_ARG_ENABLE([encoder], AC_HELP_STRING([--disable-encoder],
67 [Do not build the encoder components.]),
68 [], enable_encoder=yes)
69 if test "x$enable_encoder" = xyes; then
70 AC_DEFINE([HAVE_ENCODER], [1],
71 [Define to 1 if encoder components are enabled.])
76 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoder" = xyes)
83 AC_MSG_CHECKING([if decoder components should be built])
84 AC_ARG_ENABLE([decoder], AC_HELP_STRING([--disable-decoder],
85 [Do not build the decoder components.]),
86 [], enable_decoder=yes)
87 if test "x$enable_decoder" = xyes; then
88 AC_DEFINE([HAVE_DECODER], [1],
89 [Define to 1 if decoder components are enabled.])
93 if test "x$enable_encoder" = xno; then
94 AC_MSG_ERROR([Do not disable both encoder and decoder.])
97 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoder" = xyes)
104 m4_define([SUPPORTED_FILTERS], [lzma1,lzma2,subblock,delta,x86,powerpc,ia64,arm,armthumb,sparc])dnl
105 m4_define([SIMPLE_FILTERS], [x86,powerpc,ia64,arm,armthumb,sparc])
106 m4_define([LZ_FILTERS], [lzma1,lzma2])
108 m4_foreach([NAME], [SUPPORTED_FILTERS],
109 [enable_filter_[]NAME=no
110 enable_encoder_[]NAME=no
111 enable_decoder_[]NAME=no
114 AC_MSG_CHECKING([which encoders to build])
115 AC_ARG_ENABLE([encoders], AC_HELP_STRING([--enable-encoders=LIST],
116 [Comma-separated list of encoders to build. Default=all.
118 m4_translit(m4_defn([SUPPORTED_FILTERS]), [,], [ ])),
119 [], [enable_encoders=SUPPORTED_FILTERS])
120 enable_encoders=`echo "$enable_encoders" | sed 's/,subblock//; s/,/ /g'`
121 if test "x$enable_encoders" = xno || test "x$enable_encoders" = x; then
122 AC_MSG_RESULT([(none)])
124 for arg in $enable_encoders
126 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
128 enable_filter_[]NAME=yes
129 enable_encoder_[]NAME=yes
130 AC_DEFINE(HAVE_ENCODER_[]m4_toupper(NAME), [1],
131 [Define to 1 if] NAME [encoder is enabled.])
135 AC_MSG_ERROR([unknown filter: $arg])
139 AC_MSG_RESULT([$enable_encoders])
142 AC_MSG_CHECKING([which decoders to build])
143 AC_ARG_ENABLE([decoders], AC_HELP_STRING([--enable-decoders=LIST],
144 [Comma-separated list of decoders to build. Default=all.
145 Available decoders are the same as available encoders.]),
146 [], [enable_decoders=SUPPORTED_FILTERS])
147 enable_decoders=`echo "$enable_decoders" | sed 's/,subblock//; s/,/ /g'`
148 if test "x$enable_decoders" = xno || test "x$enable_decoders" = x; then
149 AC_MSG_RESULT([(none)])
151 for arg in $enable_decoders
153 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
155 enable_filter_[]NAME=yes
156 enable_decoder_[]NAME=yes
157 AC_DEFINE(HAVE_DECODER_[]m4_toupper(NAME), [1],
158 [Define to 1 if] NAME [decoder is enabled.])
162 AC_MSG_ERROR([unknown filter: $arg])
167 # LZMA2 requires that LZMA1 is enabled.
168 test "x$enable_encoder_lzma2" = xyes && enable_encoder_lzma1=yes
169 test "x$enable_decoder_lzma2" = xyes && enable_decoder_lzma1=yes
171 AC_MSG_RESULT([$enable_decoders])
174 if test "x$enable_encoder_lzma2$enable_encoder_lzma1" = xyesno \
175 || test "x$enable_decoder_lzma2$enable_decoder_lzma1" = xyesno; then
176 AC_MSG_ERROR([LZMA2 requires that LZMA1 is also enabled.])
179 m4_foreach([NAME], [SUPPORTED_FILTERS],
180 [AM_CONDITIONAL(COND_FILTER_[]m4_toupper(NAME), test "x$enable_filter_[]NAME" = xyes)
181 AM_CONDITIONAL(COND_ENCODER_[]m4_toupper(NAME), test "x$enable_encoder_[]NAME" = xyes)
182 AM_CONDITIONAL(COND_DECODER_[]m4_toupper(NAME), test "x$enable_decoder_[]NAME" = xyes)
185 # The so called "simple filters" share common code.
186 enable_filter_simple=no
187 enable_encoder_simple=no
188 enable_decoder_simple=no
189 m4_foreach([NAME], [SIMPLE_FILTERS],
190 [test "x$enable_filter_[]NAME" = xyes && enable_filter_simple=yes
191 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_simple=yes
192 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_simple=yes
194 AM_CONDITIONAL(COND_FILTER_SIMPLE, test "x$enable_filter_simple" = xyes)
195 AM_CONDITIONAL(COND_ENCODER_SIMPLE, test "x$enable_encoder_simple" = xyes)
196 AM_CONDITIONAL(COND_DECODER_SIMPLE, test "x$enable_decoder_simple" = xyes)
198 # LZ-based filters share common code.
202 m4_foreach([NAME], [LZ_FILTERS],
203 [test "x$enable_filter_[]NAME" = xyes && enable_filter_lz=yes
204 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_lz=yes
205 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_lz=yes
207 AM_CONDITIONAL(COND_FILTER_LZ, test "x$enable_filter_lz" = xyes)
208 AM_CONDITIONAL(COND_ENCODER_LZ, test "x$enable_encoder_lz" = xyes)
209 AM_CONDITIONAL(COND_DECODER_LZ, test "x$enable_decoder_lz" = xyes)
216 m4_define([SUPPORTED_MATCH_FINDERS], [hc3,hc4,bt2,bt3,bt4])
218 m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS],
219 [enable_match_finder_[]NAME=no
222 AC_MSG_CHECKING([which match finders to build])
223 AC_ARG_ENABLE([match-finders], AC_HELP_STRING([--enable-match-finders=LIST],
224 [Comma-separated list of match finders to build. Default=all.
225 At least one match finder is required for encoding with
226 the LZMA1 and LZMA2 filters. Available match finders:]
227 m4_translit(m4_defn([SUPPORTED_MATCH_FINDERS]), [,], [ ])), [],
228 [enable_match_finders=SUPPORTED_MATCH_FINDERS])
229 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
230 if test "x$enable_encoder" = xyes && test "x$enable_encoder_lz" = xyes ; then
231 for arg in $enable_match_finders
233 case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
235 enable_match_finder_[]NAME=yes
236 AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
237 [Define to 1 to enable] NAME [match finder.])
241 AC_MSG_ERROR([unknown match finder: $arg])
245 AC_MSG_RESULT([$enable_match_finders])
247 AC_MSG_RESULT([(none because not building any LZ-based encoder)])
255 m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
257 m4_foreach([NAME], [SUPPORTED_FILTERS],
258 [enable_check_[]NAME=no
261 AC_MSG_CHECKING([which integrity checks to build])
262 AC_ARG_ENABLE([checks], AC_HELP_STRING([--enable-checks=LIST],
263 [Comma-separated list of integrity checks to build.
264 Default=all. Available integrity checks:]
265 m4_translit(m4_defn([SUPPORTED_CHECKS]), [,], [ ])),
266 [], [enable_checks=SUPPORTED_CHECKS])
267 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
268 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
269 AC_MSG_RESULT([(none)])
271 for arg in $enable_checks
273 case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
275 enable_check_[]NAME=yes
276 AC_DEFINE(HAVE_CHECK_[]m4_toupper(NAME), [1],
277 [Define to 1 if] NAME
278 [integrity check is enabled.])
282 AC_MSG_ERROR([unknown integrity check: $arg])
286 AC_MSG_RESULT([$enable_checks])
288 if test "x$enable_checks_crc32" = xno ; then
289 AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
292 m4_foreach([NAME], [SUPPORTED_CHECKS],
293 [AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
297 ###########################
298 # Assembler optimizations #
299 ###########################
301 AC_MSG_CHECKING([if assembler optimizations should be used])
302 AC_ARG_ENABLE([assembler], AC_HELP_STRING([--disable-assembler],
303 [Do not use assembler optimizations even if such exist
304 for the architecture.]),
305 [], [enable_assembler=yes])
306 if test "x$enable_assembler" = xyes; then
308 i?86) enable_assembler=x86 ;;
309 x86_64) enable_assembler=x86_64 ;;
310 *) enable_assembler=no ;;
313 case $enable_assembler in
315 AC_DEFINE([HAVE_ASM_X86], [1],
316 [Define to 1 if using x86 assembler optimizations.])
319 AC_DEFINE([HAVE_ASM_X86_64], [1],
320 [Define to 1 if using x86_64 assembler optimizations.])
326 AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', \`x86', or \`x86_64'.])
329 AC_MSG_RESULT([$enable_assembler])
330 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
331 AM_CONDITIONAL(COND_ASM_X86_64, test "x$enable_assembler" = xx86_64)
334 ################################
335 # Fast unaligned memory access #
336 ################################
338 AC_MSG_CHECKING([if unaligned memory access should be used])
339 AC_ARG_ENABLE([unaligned-access], AC_HELP_STRING([--enable-unaligned-access],
340 [Enable if the system supports *fast* unaligned memory access
341 with 16-bit and 32-bit integers. By default, this is enabled
342 only on x86, x86_64, and big endian PowerPC.]),
343 [], [enable_unaligned_access=auto])
344 if test "x$enable_unaligned_access" = xauto ; then
346 i?86|x86_64|powerpc|powerpc64)
347 enable_unaligned_access=yes
350 enable_unaligned_access=no
354 if test "x$enable_unaligned_access" = xyes ; then
355 AC_DEFINE([HAVE_FAST_UNALIGNED_ACCESS], [1], [Define to 1 if
356 the system supports fast unaligned memory access.])
363 #####################
364 # Size optimization #
365 #####################
367 AC_MSG_CHECKING([if small size is preferred over speed])
368 AC_ARG_ENABLE([small], AC_HELP_STRING([--enable-small],
369 [Make liblzma smaller and a little slower.
370 This is disabled by default to optimize for speed.]),
371 [], [enable_small=no])
372 if test "x$enable_small" = xyes; then
373 AC_DEFINE([HAVE_SMALL], [1], [Define to 1 if optimizing for size.])
374 elif test "x$enable_small" != xno; then
376 AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
378 AC_MSG_RESULT([$enable_small])
379 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
386 AC_MSG_CHECKING([if threading support is wanted])
387 AC_ARG_ENABLE([threads], AC_HELP_STRING([--disable-threads],
388 [Disable threading support.
389 This makes some things thread-unsafe.]),
390 [], [enable_threads=yes])
391 if test "x$enable_threads" != xyes && test "x$enable_threads" != xno; then
393 AC_MSG_ERROR([--enable-threads accepts only \`yes' or \`no'])
395 AC_MSG_RESULT([$enable_threads])
396 # We use the actual result a little later.
399 ############################################
400 # xz/xzdec/lzmadec linkage against liblzma #
401 ############################################
403 # Link the command line tool statically against liblzma unless using
404 # --enable-dynamic. Using static liblzma gives a little bit faster executable
405 # on x86, because no register is wasted for PIC. We also have one dependency
406 # less, which allows users to more freely copy the xz binary to other boxes.
407 # However, I wouldn't be surprised if distro maintainers still prefer dynamic
408 # linking, so let's make it easy for them.
410 AC_MSG_CHECKING([how command line tools should be linked against liblzma])
411 AC_ARG_ENABLE([dynamic], [AC_HELP_STRING([--enable-dynamic],
412 [Link command line tools dynamically against liblzma.
413 The default is to use static liblzma if it was
415 [], [enable_dynamic=no])
416 case $enable_dynamic in
420 AC_MSG_RESULT([dynamically])
423 STATIC_CPPFLAGS="-DLZMA_API_STATIC"
424 STATIC_LDFLAGS="-static"
425 AC_MSG_RESULT([statically])
429 AC_MSG_ERROR([--enable-dynamic accepts only \`yes' or \`no'])
432 AC_SUBST([STATIC_CPPFLAGS])
433 AC_SUBST([STATIC_LDFLAGS])
436 ###############################################################################
437 # Checks for programs.
438 ###############################################################################
441 echo "Initializing Automake:"
443 AM_INIT_AUTOMAKE([1.10 foreign tar-v7 filename-length-max=99])
447 if test x$ac_cv_prog_cc_c99 = xno ; then
448 AC_MSG_ERROR([No C99 compiler was found.])
453 AC_USE_SYSTEM_EXTENSIONS
455 if test "x$enable_threads" = xyes; then
457 echo "Threading support:"
459 LIBS="$LIBS $PTHREAD_LIBS"
460 AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
465 echo "Initializing Libtool:"
471 ###############################################################################
472 # Checks for libraries.
473 ###############################################################################
476 echo "Initializing gettext:"
477 AM_GNU_GETTEXT_VERSION([0.16.1])
478 AM_GNU_GETTEXT([external])
480 ###############################################################################
481 # Checks for header files.
482 ###############################################################################
485 echo "System headers and functions:"
487 # There is currently no workarounds in this package if some of
488 # these headers are missing.
489 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
491 [AC_MSG_ERROR([Required header file(s) are missing.])])
493 # If any of these headers are missing, things should still work correctly:
494 AC_CHECK_HEADERS([sys/param.h sys/sysctl.h byteswap.h],
496 #ifdef HAVE_SYS_PARAM_H
497 # include <sys/param.h>
501 # Even if we have byteswap.h, we may lack the specific macros/functions.
502 if test x$ac_cv_header_byteswap_h = xyes ; then
503 m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
504 AC_MSG_CHECKING([if FUNC is available])
505 AC_LINK_IFELSE([AC_LANG_SOURCE([
506 #include <byteswap.h>
514 AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
515 [Define to 1 if] FUNC [is available.])
517 ], [AC_MSG_RESULT([no])])
523 ###############################################################################
524 # Checks for typedefs, structures, and compiler characteristics.
525 ###############################################################################
527 dnl We don't need these as long as we need a C99 compiler anyway.
541 AC_CHECK_SIZEOF([size_t])
543 # The command line tool can copy high resolution timestamps if such
544 # information is availabe in struct stat. Otherwise one second accuracy
547 struct stat.st_atim.tv_nsec,
548 struct stat.st_atimespec.tv_nsec,
549 struct stat.st_atimensec,
550 struct stat.st_uatime,
551 struct stat.st_atim.st__tim.tv_nsec])
557 ###############################################################################
558 # Checks for library functions.
559 ###############################################################################
561 # Gnulib replacements as needed
564 # Find the best function to set timestamps.
565 AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
567 # Check how to find out the amount of physical memory in the system. The
568 # xz command line tool uses this to automatically limit its memory usage.
569 # - sysconf() gives all the needed info on GNU+Linux and Solaris.
570 # - BSDs use sysctl().
571 AC_MSG_CHECKING([how to detect the amount of physical memory])
572 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
578 i = sysconf(_SC_PAGESIZE);
579 i = sysconf(_SC_PHYS_PAGES);
583 AC_DEFINE([HAVE_PHYSMEM_SYSCONF], [1],
584 [Define to 1 if the amount of physical memory can be detected
585 with sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES).])
586 AC_MSG_RESULT([sysconf])
588 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
589 #include <sys/types.h>
590 #ifdef HAVE_SYS_PARAM_H
591 # include <sys/param.h>
593 #include <sys/sysctl.h>
597 int name[2] = { CTL_HW, HW_PHYSMEM };
599 size_t mem_ptr_size = sizeof(mem);
600 sysctl(name, 2, &mem, &mem_ptr_size, NULL, NULL);
604 AC_DEFINE([HAVE_PHYSMEM_SYSCTL], [1],
605 [Define to 1 if the amount of physical memory can be detected
607 AC_MSG_RESULT([sysctl])
609 AC_MSG_RESULT([unknown])
612 # Check how to find out the number of available CPU cores in the system.
613 # sysconf(_SC_NPROCESSORS_ONLN) works on most systems, except that BSDs
615 AC_MSG_CHECKING([how to detect the number of available CPU cores])
616 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
622 i = sysconf(_SC_NPROCESSORS_ONLN);
626 AC_DEFINE([HAVE_NCPU_SYSCONF], [1],
627 [Define to 1 if the number of available CPU cores can be
628 detected with sysconf(_SC_NPROCESSORS_ONLN).])
629 AC_MSG_RESULT([sysconf])
631 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
632 #include <sys/types.h>
633 #ifdef HAVE_SYS_PARAM_H
634 # include <sys/param.h>
636 #include <sys/sysctl.h>
640 int name[2] = { CTL_HW, HW_NCPU };
642 size_t cpus_size = sizeof(cpus);
643 sysctl(name, 2, &cpus, &cpus_size, NULL, NULL);
647 AC_DEFINE([HAVE_NCPU_SYSCTL], [1],
648 [Define to 1 if the number of available CPU cores can be
649 detected with sysctl().])
650 AC_MSG_RESULT([sysctl])
652 AC_MSG_RESULT([unknown])
656 ###############################################################################
657 # If using GCC, set some additional AM_CFLAGS:
658 ###############################################################################
662 if test "x$GCC" = xyes ; then
664 echo "GCC extensions:"
666 if test -n "$CFLAG_VISIBILITY" ; then
667 AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
670 # -Wno-uninitialized is needed with -Werror with SHA256 code
671 # to omit a bogus warning.
672 AC_MSG_CHECKING([if $CC accepts -Wno-uninitialized])
674 CFLAGS="$CFLAGS -Wno-uninitialized"
675 AC_COMPILE_IFELSE([void foo(void) { }], [Wno_uninitialized=yes])
677 AC_MSG_RESULT([$Wno_uninitialized])
679 # Enable as much warnings as possible. These commented warnings won't
680 # work for this package though:
681 # * -Wunreachable-code breaks several assert(0) cases, which are
682 # backed up with "return LZMA_PROG_ERROR".
683 # * -Wcast-qual would break various things where we need a non-const
684 # pointer although we don't modify anything through it.
685 # * -Wcast-align breaks optimized CRC32 and CRC64 implementation
686 # on some architectures (not on x86), where this warning is bogus,
687 # because we take care of correct alignment.
688 # * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
689 # don't seem so useful here; at least the last one gives some
690 # warnings which are not bugs.
696 -Wmissing-include-dirs \
702 -Wbad-function-cast \
706 -Wstrict-prototypes \
707 -Wold-style-definition \
708 -Wmissing-prototypes \
709 -Wmissing-declarations \
713 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
715 CFLAGS="$CFLAGS $NEW_FLAG"
716 AC_COMPILE_IFELSE([void foo(void) { }], [
717 AM_CFLAGS="$AM_CFLAGS $NEW_FLAG"
725 AC_ARG_ENABLE([werror],
726 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
727 compilation on all compiler warnings.]),
728 [], [enable_werror=no])
729 if test "x$enable_werror" = "xyes"; then
730 AM_CFLAGS="$AM_CFLAGS -Werror"
734 AM_CONDITIONAL([COND_WNO_UNINITIALIZED], test "x$Wno_uninitialized" = "xyes")
737 ###############################################################################
738 # Create the makefiles and config.h
739 ###############################################################################
743 # Don't build the lib directory at all if we don't need any replacement
745 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
747 # Add default AM_CFLAGS.
748 AC_SUBST([AM_CFLAGS])
756 src/liblzma/liblzma.pc
758 src/liblzma/api/Makefile
759 src/liblzma/common/Makefile
760 src/liblzma/check/Makefile
761 src/liblzma/rangecoder/Makefile
762 src/liblzma/lz/Makefile
763 src/liblzma/lzma/Makefile
764 src/liblzma/subblock/Makefile
765 src/liblzma/delta/Makefile
766 src/liblzma/simple/Makefile