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], [4.999.8beta], [lasse.collin@tukaani.org], [xz])
28 AC_CONFIG_SRCDIR([src/liblzma/common/common.h])
29 AC_CONFIG_HEADER([config.h])
32 echo "$PACKAGE_STRING"
36 # This is needed to know if assembler optimizations can be used.
41 echo "Configure options:"
48 AC_MSG_CHECKING([if debugging code should be compiled])
49 AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable debugging code.]),
51 if test "x$enable_debug" = xyes; then
54 AC_DEFINE([NDEBUG], [1], [Define to 1 to disable debugging code.])
63 AC_MSG_CHECKING([if encoder components should be built])
64 AC_ARG_ENABLE([encoder], AC_HELP_STRING([--disable-encoder],
65 [Do not build the encoder components.]),
66 [], enable_encoder=yes)
67 if test "x$enable_encoder" = xyes; then
68 AC_DEFINE([HAVE_ENCODER], [1],
69 [Define to 1 if encoder components are enabled.])
74 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoder" = xyes)
81 AC_MSG_CHECKING([if decoder components should be built])
82 AC_ARG_ENABLE([decoder], AC_HELP_STRING([--disable-decoder],
83 [Do not build the decoder components.]),
84 [], enable_decoder=yes)
85 if test "x$enable_decoder" = xyes; then
86 AC_DEFINE([HAVE_DECODER], [1],
87 [Define to 1 if decoder components are enabled.])
91 if test "x$enable_encoder" = xno; then
92 AC_MSG_ERROR([Do not disable both encoder and decoder.])
95 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoder" = xyes)
102 m4_define([SUPPORTED_FILTERS], [lzma1,lzma2,subblock,delta,x86,powerpc,ia64,arm,armthumb,sparc])dnl
103 m4_define([SIMPLE_FILTERS], [x86,powerpc,ia64,arm,armthumb,sparc])
104 m4_define([LZ_FILTERS], [lzma1,lzma2])
106 m4_foreach([NAME], [SUPPORTED_FILTERS],
107 [enable_filter_[]NAME=no
108 enable_encoder_[]NAME=no
109 enable_decoder_[]NAME=no
112 AC_MSG_CHECKING([which encoders to build])
113 AC_ARG_ENABLE([encoders], AC_HELP_STRING([--enable-encoders=LIST],
114 [Comma-separated list of encoders to build. Default=all.
116 m4_translit(m4_defn([SUPPORTED_FILTERS]), [,], [ ])),
117 [], [enable_encoders=SUPPORTED_FILTERS])
118 enable_encoders=`echo "$enable_encoders" | sed 's/,subblock//; s/,/ /g'`
119 if test "x$enable_encoders" = xno || test "x$enable_encoders" = x; then
120 AC_MSG_RESULT([(none)])
122 for arg in $enable_encoders
124 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
126 enable_filter_[]NAME=yes
127 enable_encoder_[]NAME=yes
128 AC_DEFINE(HAVE_ENCODER_[]m4_toupper(NAME), [1],
129 [Define to 1 if] NAME [encoder is enabled.])
133 AC_MSG_ERROR([unknown filter: $arg])
137 AC_MSG_RESULT([$enable_encoders])
140 AC_MSG_CHECKING([which decoders to build])
141 AC_ARG_ENABLE([decoders], AC_HELP_STRING([--enable-decoders=LIST],
142 [Comma-separated list of decoders to build. Default=all.
143 Available decoders are the same as available encoders.]),
144 [], [enable_decoders=SUPPORTED_FILTERS])
145 enable_decoders=`echo "$enable_decoders" | sed 's/,subblock//; s/,/ /g'`
146 if test "x$enable_decoders" = xno || test "x$enable_decoders" = x; then
147 AC_MSG_RESULT([(none)])
149 for arg in $enable_decoders
151 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
153 enable_filter_[]NAME=yes
154 enable_decoder_[]NAME=yes
155 AC_DEFINE(HAVE_DECODER_[]m4_toupper(NAME), [1],
156 [Define to 1 if] NAME [decoder is enabled.])
160 AC_MSG_ERROR([unknown filter: $arg])
165 # LZMA2 requires that LZMA1 is enabled.
166 test "x$enable_encoder_lzma2" = xyes && enable_encoder_lzma1=yes
167 test "x$enable_decoder_lzma2" = xyes && enable_decoder_lzma1=yes
169 AC_MSG_RESULT([$enable_decoders])
172 if test "x$enable_encoder_lzma2$enable_encoder_lzma1" = xyesno \
173 || test "x$enable_decoder_lzma2$enable_decoder_lzma1" = xyesno; then
174 AC_MSG_ERROR([LZMA2 requires that LZMA1 is also enabled.])
177 m4_foreach([NAME], [SUPPORTED_FILTERS],
178 [AM_CONDITIONAL(COND_FILTER_[]m4_toupper(NAME), test "x$enable_filter_[]NAME" = xyes)
179 AM_CONDITIONAL(COND_ENCODER_[]m4_toupper(NAME), test "x$enable_encoder_[]NAME" = xyes)
180 AM_CONDITIONAL(COND_DECODER_[]m4_toupper(NAME), test "x$enable_decoder_[]NAME" = xyes)
183 # The so called "simple filters" share common code.
184 enable_filter_simple=no
185 enable_encoder_simple=no
186 enable_decoder_simple=no
187 m4_foreach([NAME], [SIMPLE_FILTERS],
188 [test "x$enable_filter_[]NAME" = xyes && enable_filter_simple=yes
189 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_simple=yes
190 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_simple=yes
192 AM_CONDITIONAL(COND_FILTER_SIMPLE, test "x$enable_filter_simple" = xyes)
193 AM_CONDITIONAL(COND_ENCODER_SIMPLE, test "x$enable_encoder_simple" = xyes)
194 AM_CONDITIONAL(COND_DECODER_SIMPLE, test "x$enable_decoder_simple" = xyes)
196 # LZ-based filters share common code.
200 m4_foreach([NAME], [LZ_FILTERS],
201 [test "x$enable_filter_[]NAME" = xyes && enable_filter_lz=yes
202 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_lz=yes
203 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_lz=yes
205 AM_CONDITIONAL(COND_FILTER_LZ, test "x$enable_filter_lz" = xyes)
206 AM_CONDITIONAL(COND_ENCODER_LZ, test "x$enable_encoder_lz" = xyes)
207 AM_CONDITIONAL(COND_DECODER_LZ, test "x$enable_decoder_lz" = xyes)
214 m4_define([SUPPORTED_MATCH_FINDERS], [hc3,hc4,bt2,bt3,bt4])
216 m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS],
217 [enable_match_finder_[]NAME=no
220 AC_MSG_CHECKING([which match finders to build])
221 AC_ARG_ENABLE([match-finders], AC_HELP_STRING([--enable-match-finders=LIST],
222 [Comma-separated list of match finders to build. Default=all.
223 At least one match finder is required for encoding with
224 the LZMA1 and LZMA2 filters. Available match finders:]
225 m4_translit(m4_defn([SUPPORTED_MATCH_FINDERS]), [,], [ ])), [],
226 [enable_match_finders=SUPPORTED_MATCH_FINDERS])
227 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
228 if test "x$enable_encoder" = xyes && test "x$enable_encoder_lz" = xyes ; then
229 for arg in $enable_match_finders
231 case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
233 enable_match_finder_[]NAME=yes
234 AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
235 [Define to 1 to enable] NAME [match finder.])
239 AC_MSG_ERROR([unknown match finder: $arg])
243 AC_MSG_RESULT([$enable_match_finders])
245 AC_MSG_RESULT([(none because not building any LZ-based encoder)])
253 m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
255 m4_foreach([NAME], [SUPPORTED_FILTERS],
256 [enable_check_[]NAME=no
259 AC_MSG_CHECKING([which integrity checks to build])
260 AC_ARG_ENABLE([checks], AC_HELP_STRING([--enable-checks=LIST],
261 [Comma-separated list of integrity checks to build.
262 Default=all. Available integrity checks:]
263 m4_translit(m4_defn([SUPPORTED_CHECKS]), [,], [ ])),
264 [], [enable_checks=SUPPORTED_CHECKS])
265 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
266 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
267 AC_MSG_RESULT([(none)])
269 for arg in $enable_checks
271 case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
273 enable_check_[]NAME=yes
274 AC_DEFINE(HAVE_CHECK_[]m4_toupper(NAME), [1],
275 [Define to 1 if] NAME
276 [integrity check is enabled.])
280 AC_MSG_ERROR([unknown integrity check: $arg])
284 AC_MSG_RESULT([$enable_checks])
286 if test "x$enable_checks_crc32" = xno ; then
287 AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
290 m4_foreach([NAME], [SUPPORTED_CHECKS],
291 [AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
295 ###########################
296 # Assembler optimizations #
297 ###########################
299 AC_MSG_CHECKING([if assembler optimizations should be used])
300 AC_ARG_ENABLE([assembler], AC_HELP_STRING([--disable-assembler],
301 [Do not use assembler optimizations even if such exist
302 for the architecture.]),
303 [], [enable_assembler=yes])
304 if test "x$enable_assembler" = xyes; then
306 i?86) enable_assembler=x86 ;;
307 x86_64) enable_assembler=x86_64 ;;
308 *) enable_assembler=no ;;
310 # Darwin has different ABI than GNU+Linux and Solaris,
311 # and the assembler code doesn't assemble.
313 darwin*) enable_assembler=no ;;
317 case $enable_assembler in
319 AC_DEFINE([HAVE_ASM_X86], [1],
320 [Define to 1 if using x86 assembler optimizations.])
323 AC_DEFINE([HAVE_ASM_X86_64], [1],
324 [Define to 1 if using x86_64 assembler optimizations.])
330 AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', \`x86', or \`x86_64'.])
333 AC_MSG_RESULT([$enable_assembler])
334 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
335 AM_CONDITIONAL(COND_ASM_X86_64, test "x$enable_assembler" = xx86_64)
338 ################################
339 # Fast unaligned memory access #
340 ################################
342 AC_MSG_CHECKING([if unaligned memory access should be used])
343 AC_ARG_ENABLE([unaligned-access], AC_HELP_STRING([--enable-unaligned-access],
344 [Enable if the system supports *fast* unaligned memory access
345 with 16-bit and 32-bit integers. By default, this is enabled
346 only on x86, x86_64, and big endian PowerPC.]),
347 [], [enable_unaligned_access=auto])
348 if test "x$enable_unaligned_access" = xauto ; then
350 i?86|x86_64|powerpc|powerpc64)
351 enable_unaligned_access=yes
354 enable_unaligned_access=no
358 if test "x$enable_unaligned_access" = xyes ; then
359 AC_DEFINE([HAVE_FAST_UNALIGNED_ACCESS], [1], [Define to 1 if
360 the system supports fast unaligned memory access.])
367 #####################
368 # Size optimization #
369 #####################
371 AC_MSG_CHECKING([if small size is preferred over speed])
372 AC_ARG_ENABLE([small], AC_HELP_STRING([--enable-small],
373 [Make liblzma smaller and a little slower.
374 This is disabled by default to optimize for speed.]),
375 [], [enable_small=no])
376 if test "x$enable_small" = xyes; then
377 AC_DEFINE([HAVE_SMALL], [1], [Define to 1 if optimizing for size.])
378 elif test "x$enable_small" != xno; then
380 AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
382 AC_MSG_RESULT([$enable_small])
383 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
390 AC_MSG_CHECKING([if threading support is wanted])
391 AC_ARG_ENABLE([threads], AC_HELP_STRING([--disable-threads],
392 [Disable threading support.
393 This makes some things thread-unsafe.]),
394 [], [enable_threads=yes])
395 if test "x$enable_threads" != xyes && test "x$enable_threads" != xno; then
396 AC_MSG_ERROR([--enable-threads accepts only \`yes' or \`no'])
398 # We use the actual result a little later.
401 ###############################################################################
402 # Checks for programs.
403 ###############################################################################
406 echo "Initializing Automake:"
408 AM_INIT_AUTOMAKE([1.10 foreign tar-v7 filename-length-max=99])
412 if test x$ac_cv_prog_cc_c99 = xno ; then
413 AC_MSG_ERROR([No C99 compiler was found.])
418 AC_USE_SYSTEM_EXTENSIONS
420 if test "x$enable_threads" = xyes; then
422 echo "Threading support:"
424 LIBS="$LIBS $PTHREAD_LIBS"
425 CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
430 echo "Initializing Libtool:"
436 ###############################################################################
437 # Checks for libraries.
438 ###############################################################################
441 echo "Initializing gettext:"
442 AM_GNU_GETTEXT_VERSION([0.16.1])
443 AM_GNU_GETTEXT([external])
445 ###############################################################################
446 # Checks for header files.
447 ###############################################################################
450 echo "System headers and functions:"
452 # There is currently no workarounds in this package if some of
453 # these headers are missing.
454 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
456 [AC_MSG_ERROR([Required header file(s) are missing.])])
458 # If any of these headers are missing, things should still work correctly:
459 AC_CHECK_HEADERS([sys/param.h sys/sysctl.h byteswap.h],
461 #ifdef HAVE_SYS_PARAM_H
462 # include <sys/param.h>
466 # Even if we have byteswap.h, we may lack the specific macros/functions.
467 if test x$ac_cv_header_byteswap_h = xyes ; then
468 m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
469 AC_MSG_CHECKING([if FUNC is available])
470 AC_LINK_IFELSE([AC_LANG_SOURCE([
471 #include <byteswap.h>
479 AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
480 [Define to 1 if] FUNC [is available.])
482 ], [AC_MSG_RESULT([no])])
488 ###############################################################################
489 # Checks for typedefs, structures, and compiler characteristics.
490 ###############################################################################
492 dnl We don't need these as long as we need a C99 compiler anyway.
506 AC_CHECK_SIZEOF([size_t])
508 # The command line tool can copy high resolution timestamps if such
509 # information is availabe in struct stat. Otherwise one second accuracy
512 struct stat.st_atim.tv_nsec,
513 struct stat.st_atimespec.tv_nsec,
514 struct stat.st_atimensec,
515 struct stat.st_uatime,
516 struct stat.st_atim.st__tim.tv_nsec])
522 ###############################################################################
523 # Checks for library functions.
524 ###############################################################################
526 # Gnulib replacements as needed
529 # Find the best function to set timestamps.
530 AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
532 # Check how to find out the amount of physical memory in the system. The
533 # xz command line tool uses this to automatically limit its memory usage.
534 # - sysconf() gives all the needed info on GNU+Linux and Solaris.
535 # - BSDs use sysctl().
536 AC_MSG_CHECKING([how to detect the amount of physical memory])
537 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
543 i = sysconf(_SC_PAGESIZE);
544 i = sysconf(_SC_PHYS_PAGES);
548 AC_DEFINE([HAVE_PHYSMEM_SYSCONF], [1],
549 [Define to 1 if the amount of physical memory can be detected
550 with sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES).])
551 AC_MSG_RESULT([sysconf])
553 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
554 #include <sys/types.h>
555 #ifdef HAVE_SYS_PARAM_H
556 # include <sys/param.h>
558 #include <sys/sysctl.h>
562 int name[2] = { CTL_HW, HW_PHYSMEM };
564 size_t mem_ptr_size = sizeof(mem);
565 sysctl(name, 2, &mem, &mem_ptr_size, NULL, NULL);
569 AC_DEFINE([HAVE_PHYSMEM_SYSCTL], [1],
570 [Define to 1 if the amount of physical memory can be detected
572 AC_MSG_RESULT([sysctl])
574 AC_MSG_RESULT([unknown])
577 # Check how to find out the number of available CPU cores in the system.
578 # sysconf(_SC_NPROCESSORS_ONLN) works on most systems, except that BSDs
580 AC_MSG_CHECKING([how to detect the number of available CPU cores])
581 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
587 i = sysconf(_SC_NPROCESSORS_ONLN);
591 AC_DEFINE([HAVE_NCPU_SYSCONF], [1],
592 [Define to 1 if the number of available CPU cores can be
593 detected with sysconf(_SC_NPROCESSORS_ONLN).])
594 AC_MSG_RESULT([sysconf])
596 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
597 #include <sys/types.h>
598 #ifdef HAVE_SYS_PARAM_H
599 # include <sys/param.h>
601 #include <sys/sysctl.h>
605 int name[2] = { CTL_HW, HW_NCPU };
607 size_t cpus_size = sizeof(cpus);
608 sysctl(name, 2, &cpus, &cpus_size, NULL, NULL);
612 AC_DEFINE([HAVE_NCPU_SYSCTL], [1],
613 [Define to 1 if the number of available CPU cores can be
614 detected with sysctl().])
615 AC_MSG_RESULT([sysctl])
617 AC_MSG_RESULT([unknown])
621 ###############################################################################
622 # If using GCC, set some additional CFLAGS:
623 ###############################################################################
627 if test "x$GCC" = xyes ; then
629 echo "GCC extensions:"
631 if test -n "$CFLAG_VISIBILITY" ; then
632 CFLAGS="$CFLAG_VISIBILITY $CFLAGS"
635 # -Wno-uninitialized is needed with -Werror with SHA256 code
636 # to omit a bogus warning.
637 AC_MSG_CHECKING([if $CC accepts -Wno-uninitialized])
639 CFLAGS="$CFLAGS -Wno-uninitialized"
640 AC_COMPILE_IFELSE([void foo(void) { }], [Wno_uninitialized=yes])
642 AC_MSG_RESULT([$Wno_uninitialized])
644 # Enable as much warnings as possible. These commented warnings won't
645 # work for this package though:
646 # * -Wunreachable-code breaks several assert(0) cases, which are
647 # backed up with "return LZMA_PROG_ERROR".
648 # * -Wcast-qual would break various things where we need a non-const
649 # pointer although we don't modify anything through it.
650 # * -Wcast-align breaks optimized CRC32 and CRC64 implementation
651 # on some architectures (not on x86), where this warning is bogus,
652 # because we take care of correct alignment.
653 # * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
654 # don't seem so useful here; at least the last one gives some
655 # warnings which are not bugs.
657 # The flags are in reverse order below so they end up in "beautiful"
658 # order on the actual command line.
662 -Wmissing-declarations \
663 -Wmissing-prototypes \
664 -Wold-style-definition \
665 -Wstrict-prototypes \
669 -Wbad-function-cast \
675 -Wmissing-include-dirs \
681 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
683 CFLAGS="$NEW_FLAG $CFLAGS"
684 AC_COMPILE_IFELSE([void foo(void) { }], [
692 AC_ARG_ENABLE([werror],
693 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
694 compilation on all compiler warnings.]),
695 [], [enable_werror=no])
696 if test "x$enable_werror" = "xyes"; then
697 CFLAGS="-Werror $CFLAGS"
701 AM_CONDITIONAL([COND_WNO_UNINITIALIZED], test "x$Wno_uninitialized" = "xyes")
704 ###############################################################################
705 # Create the makefiles and config.h
706 ###############################################################################
710 # Don't build the lib directory at all if we don't need any replacement
712 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
720 src/liblzma/liblzma.pc
722 src/liblzma/api/Makefile
723 src/liblzma/common/Makefile
724 src/liblzma/check/Makefile
725 src/liblzma/rangecoder/Makefile
726 src/liblzma/lz/Makefile
727 src/liblzma/lzma/Makefile
728 src/liblzma/subblock/Makefile
729 src/liblzma/delta/Makefile
730 src/liblzma/simple/Makefile