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 # [LZMA] instead of [LZMA utils] since I prefer to have lzma-version.tar.gz
28 # instead of lzma-utils-version.tar.gz.
29 AC_INIT([LZMA], [4.999.6alpha], [lasse.collin@tukaani.org])
31 AC_CONFIG_SRCDIR([src/liblzma/common/common.h])
32 AC_CONFIG_HEADER([config.h])
35 echo "LZMA Utils $PACKAGE_VERSION"
39 # This is needed to know if assembler optimizations can be used.
44 echo "Configure options:"
51 AC_MSG_CHECKING([if debugging code should be compiled])
52 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging code.]),
54 if test "x$enable_debug" = xyes; then
57 AC_DEFINE(NDEBUG, 1, [Define to 1 to disable debugging code.])
66 AC_MSG_CHECKING([if encoder components should be built])
67 AC_ARG_ENABLE(encoder, AC_HELP_STRING([--disable-encoder],
68 [Do not build the encoder components.]),
69 [], enable_encoder=yes)
70 if test "x$enable_encoder" = xyes; then
71 AC_DEFINE([HAVE_ENCODER], 1,
72 [Define to 1 if encoder components are enabled.])
77 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoder" = xyes)
84 AC_MSG_CHECKING([if decoder components should be built])
85 AC_ARG_ENABLE(decoder, AC_HELP_STRING([--disable-decoder],
86 [Do not build the decoder components.]),
87 [], enable_decoder=yes)
88 if test "x$enable_decoder" = xyes; then
89 AC_DEFINE([HAVE_DECODER], 1,
90 [Define to 1 if decoder components are enabled.])
94 if test "x$enable_encoder" = xno; then
95 AC_MSG_ERROR([Do not disable both encoder and decoder.])
98 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoder" = xyes)
105 m4_define([SUPPORTED_FILTERS], [lzma1,lzma2,subblock,delta,x86,powerpc,ia64,arm,armthumb,sparc])dnl
106 m4_define([SIMPLE_FILTERS], [x86,powerpc,ia64,arm,armthumb,sparc])
107 m4_define([LZ_FILTERS], [lzma1,lzma2])
109 m4_foreach([NAME], [SUPPORTED_FILTERS],
110 [enable_filter_[]NAME=no
111 enable_encoder_[]NAME=no
112 enable_decoder_[]NAME=no
115 AC_MSG_CHECKING([which encoders to build])
116 AC_ARG_ENABLE([encoders], AC_HELP_STRING([--enable-encoders=LIST],
117 [Comma-separated list of encoders to build. Default=all.
119 m4_translit(m4_defn([SUPPORTED_FILTERS]), [,], [ ])),
120 [], [enable_encoders=SUPPORTED_FILTERS])
121 enable_encoders=`echo "$enable_encoders" | sed 's/,/ /g'`
122 if test "x$enable_encoders" = xno || test "x$enable_encoders" = x; then
123 AC_MSG_RESULT([(none)])
125 for arg in $enable_encoders
127 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
129 enable_filter_[]NAME=yes
130 enable_encoder_[]NAME=yes
131 AC_DEFINE(HAVE_ENCODER_[]m4_toupper(NAME), [1],
132 [Define to 1 if] NAME [encoder is enabled.])
136 AC_MSG_ERROR([unknown filter: $arg])
140 AC_MSG_RESULT([$enable_encoders])
143 AC_MSG_CHECKING([which decoders to build])
144 AC_ARG_ENABLE([decoders], AC_HELP_STRING([--enable-decoders=LIST],
145 [Comma-separated list of decoders to build. Default=all.
146 Available decoders are the same as available encoders.]),
147 [], [enable_decoders=SUPPORTED_FILTERS])
148 enable_decoders=`echo "$enable_decoders" | sed 's/,/ /g'`
149 if test "x$enable_decoders" = xno || test "x$enable_decoders" = x; then
150 AC_MSG_RESULT([(none)])
152 for arg in $enable_decoders
154 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
156 enable_filter_[]NAME=yes
157 enable_decoder_[]NAME=yes
158 AC_DEFINE(HAVE_DECODER_[]m4_toupper(NAME), [1],
159 [Define to 1 if] NAME [decoder is enabled.])
163 AC_MSG_ERROR([unknown filter: $arg])
168 # LZMA2 requires that LZMA1 is enabled.
169 test "x$enable_encoder_lzma2" = xyes && enable_encoder_lzma1=yes
170 test "x$enable_decoder_lzma2" = xyes && enable_decoder_lzma1=yes
172 AC_MSG_RESULT([$enable_decoders])
175 if test "x$enable_encoder_lzma2$enable_encoder_lzma1" = xyesno \
176 || test "x$enable_decoder_lzma2$enable_decoder_lzma1" = xyesno; then
177 AC_MSG_ERROR([LZMA2 requires that LZMA1 is also enabled.])
180 m4_foreach([NAME], [SUPPORTED_FILTERS],
181 [AM_CONDITIONAL(COND_FILTER_[]m4_toupper(NAME), test "x$enable_filter_[]NAME" = xyes)
182 AM_CONDITIONAL(COND_ENCODER_[]m4_toupper(NAME), test "x$enable_encoder_[]NAME" = xyes)
183 AM_CONDITIONAL(COND_DECODER_[]m4_toupper(NAME), test "x$enable_decoder_[]NAME" = xyes)
186 # The so called "simple filters" share common code.
187 enable_filter_simple=no
188 enable_encoder_simple=no
189 enable_decoder_simple=no
190 m4_foreach([NAME], [SIMPLE_FILTERS],
191 [test "x$enable_filter_[]NAME" = xyes && enable_filter_simple=yes
192 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_simple=yes
193 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_simple=yes
195 AM_CONDITIONAL(COND_FILTER_SIMPLE, test "x$enable_filter_simple" = xyes)
196 AM_CONDITIONAL(COND_ENCODER_SIMPLE, test "x$enable_encoder_simple" = xyes)
197 AM_CONDITIONAL(COND_DECODER_SIMPLE, test "x$enable_decoder_simple" = xyes)
199 # LZ-based filters share common code.
203 m4_foreach([NAME], [LZ_FILTERS],
204 [test "x$enable_filter_[]NAME" = xyes && enable_filter_lz=yes
205 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_lz=yes
206 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_lz=yes
208 AM_CONDITIONAL(COND_FILTER_LZ, test "x$enable_filter_lz" = xyes)
209 AM_CONDITIONAL(COND_ENCODER_LZ, test "x$enable_encoder_lz" = xyes)
210 AM_CONDITIONAL(COND_DECODER_LZ, test "x$enable_decoder_lz" = xyes)
217 m4_define([SUPPORTED_MATCH_FINDERS], [hc3,hc4,bt2,bt3,bt4])
219 m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS],
220 [enable_match_finder_[]NAME=no
223 AC_MSG_CHECKING([which match finders to build])
224 AC_ARG_ENABLE(match-finders, AC_HELP_STRING([--enable-match-finders=LIST],
225 [Comma-separated list of match finders to build. Default=all.
226 At least one match finder is required for encoding with
227 the LZMA1 and LZMA2 filters. Available match finders:]
228 m4_translit(m4_defn([SUPPORTED_MATCH_FINDERS]), [,], [ ])), [],
229 [enable_match_finders=SUPPORTED_MATCH_FINDERS])
230 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
231 if test "x$enable_encoder" = xyes && test "x$enable_encoder_lz" = xyes ; then
232 for arg in $enable_match_finders
234 case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
236 enable_match_finder_[]NAME=yes
237 AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
238 [Define to 1 to enable] NAME [match finder.])
242 AC_MSG_ERROR([unknown match finder: $arg])
246 AC_MSG_RESULT([$enable_match_finders])
248 AC_MSG_RESULT([(none because not building any LZ-based encoder)])
256 m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
258 m4_foreach([NAME], [SUPPORTED_FILTERS],
259 [enable_check_[]NAME=no
262 AC_MSG_CHECKING([which integrity checks to build])
263 AC_ARG_ENABLE(checks, AC_HELP_STRING([--enable-checks=LIST],
264 [Comma-separated list of integrity checks to build.
265 Default=all. Available integrity checks:]
266 m4_translit(m4_defn([SUPPORTED_CHECKS]), [,], [ ])),
267 [], [enable_checks=SUPPORTED_CHECKS])
268 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
269 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
270 AC_MSG_RESULT([(none)])
272 for arg in $enable_checks
274 case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
276 enable_check_[]NAME=yes
277 AC_DEFINE(HAVE_CHECK_[]m4_toupper(NAME), [1],
278 [Define to 1 if] NAME
279 [integrity check is enabled.])
283 AC_MSG_ERROR([unknown integrity check: $arg])
287 AC_MSG_RESULT([$enable_checks])
289 if test "x$enable_checks_crc32" = xno ; then
290 AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
293 m4_foreach([NAME], [SUPPORTED_CHECKS],
294 [AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
298 ###########################
299 # Assembler optimizations #
300 ###########################
302 AC_MSG_CHECKING([if assembler optimizations should be used])
303 AC_ARG_ENABLE(assembler, AC_HELP_STRING([--disable-assembler],
304 [Do not use assembler optimizations even if such exist
305 for the architecture.]),
306 [], [enable_assembler=yes])
307 if test "x$enable_assembler" = xyes; then
309 i?86) enable_assembler=x86 ;;
310 x86_64) enable_assembler=x86_64 ;;
311 *) enable_assembler=no ;;
313 # Darwin has different ABI than GNU+Linux and Solaris,
314 # and the assembler code doesn't assemble.
316 darwin*) enable_assembler=no ;;
320 case $enable_assembler in
322 AC_DEFINE([HAVE_ASM_X86], 1,
323 [Define to 1 if using x86 assembler optimizations.])
326 AC_DEFINE([HAVE_ASM_X86_64], 1,
327 [Define to 1 if using x86_64 assembler optimizations.])
333 AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', \`x86', or \`x86_64'.])
336 AC_MSG_RESULT([$enable_assembler])
337 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
338 AM_CONDITIONAL(COND_ASM_X86_64, test "x$enable_assembler" = xx86_64)
341 ################################
342 # Fast unaligned memory access #
343 ################################
345 AC_MSG_CHECKING([if unaligned memory access should be used])
346 AC_ARG_ENABLE(unaligned-access, AC_HELP_STRING([--enable-unaligned-access],
347 [Enable if the system supports *fast* unaligned memory access
348 with 16-bit and 32-bit integers. By default, this is enabled
349 only on x86, x86_64, and big endian PowerPC.]),
350 [], [enable_unaligned_access=auto])
351 if test "x$enable_unaligned_access" = xauto ; then
353 i?86|x86_64|powerpc|powerpc64)
354 enable_unaligned_access=yes
357 enable_unaligned_access=no
361 if test "x$enable_unaligned_access" = xyes ; then
362 AC_DEFINE([HAVE_FAST_UNALIGNED_ACCESS], [1], [Define to 1 if
363 the system supports fast unaligned memory access.])
370 #####################
371 # Size optimization #
372 #####################
374 AC_MSG_CHECKING([if small size is preferred over speed])
375 AC_ARG_ENABLE(small, AC_HELP_STRING([--enable-small],
376 [Make liblzma smaller and a little slower.
377 This is disabled by default to optimize for speed.]),
378 [], [enable_small=no])
379 if test "x$enable_small" = xyes; then
380 AC_DEFINE([HAVE_SMALL], 1, [Define to 1 if optimizing for size.])
381 elif test "x$enable_small" != xno; then
383 AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
385 AC_MSG_RESULT([$enable_small])
386 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
389 ###############################################################################
390 # Checks for programs.
391 ###############################################################################
394 echo "Initializing Automake:"
396 AM_INIT_AUTOMAKE([1.10 foreign tar-v7 filename-length-max=99])
400 if test x$ac_cv_prog_cc_c99 = xno ; then
401 AC_MSG_ERROR([No C99 compiler was found.])
406 AC_USE_SYSTEM_EXTENSIONS
409 echo "Threading support:"
414 echo "Initializing Libtool:"
420 ###############################################################################
421 # Checks for libraries.
422 ###############################################################################
425 echo "Initializing gettext:"
426 AM_GNU_GETTEXT_VERSION([0.16.1])
427 AM_GNU_GETTEXT([external])
429 ###############################################################################
430 # Checks for header files.
431 ###############################################################################
434 echo "System headers and functions:"
436 # There is currently no workarounds in this package if some of
437 # these headers are missing.
438 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
440 [AC_MSG_ERROR([Required header file(s) are missing.])])
442 # If any of these headers are missing, things should still work correctly:
443 AC_CHECK_HEADERS([sys/param.h sys/sysctl.h byteswap.h],
445 #ifdef HAVE_SYS_PARAM_H
446 # include <sys/param.h>
450 # Even if we have byteswap.h, we may lack the specific macros/functions.
451 if test x$ac_cv_header_byteswap_h = xyes ; then
452 m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
453 AC_MSG_CHECKING([if FUNC is available])
454 AC_LINK_IFELSE([AC_LANG_SOURCE([
455 #include <byteswap.h>
463 AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
464 [Define to 1 if] FUNC [is available.])
466 ], [AC_MSG_RESULT([no])])
472 ###############################################################################
473 # Checks for typedefs, structures, and compiler characteristics.
474 ###############################################################################
476 dnl We don't need these as long as we need a C99 compiler anyway.
490 AC_CHECK_SIZEOF([size_t])
492 # The command line tool can copy high resolution timestamps if such
493 # information is availabe in struct stat. Otherwise one second accuracy
496 struct stat.st_atim.tv_nsec,
497 struct stat.st_atimespec.tv_nsec,
498 struct stat.st_atimensec,
499 struct stat.st_uatime,
500 struct stat.st_atim.st__tim.tv_nsec])
506 ###############################################################################
507 # Checks for library functions.
508 ###############################################################################
510 # Gnulib replacements as needed
513 # Find the best function to set timestamps.
514 AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
516 # Check how to find out the amount of physical memory in the system. The
517 # lzma command line tool uses this to automatically limits its memory usage.
518 # - sysconf() gives all the needed info on GNU+Linux and Solaris.
519 # - BSDs use sysctl().
520 AC_MSG_CHECKING([how to detect the amount of physical memory])
521 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
527 i = sysconf(_SC_PAGESIZE);
528 i = sysconf(_SC_PHYS_PAGES);
532 AC_DEFINE([HAVE_PHYSMEM_SYSCONF], 1,
533 [Define to 1 if the amount of physical memory can be detected
534 with sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES).])
535 AC_MSG_RESULT([sysconf])
537 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
538 #include <sys/types.h>
539 #ifdef HAVE_SYS_PARAM_H
540 # include <sys/param.h>
542 #include <sys/sysctl.h>
546 int name[2] = { CTL_HW, HW_PHYSMEM };
548 size_t mem_ptr_size = sizeof(mem);
549 sysctl(name, 2, &mem, &mem_ptr_size, NULL, NULL);
553 AC_DEFINE([HAVE_PHYSMEM_SYSCTL], 1,
554 [Define to 1 if the amount of physical memory can be detected
556 AC_MSG_RESULT([sysctl])
558 AC_MSG_RESULT([unknown])
561 # Check how to find out the number of available CPU cores in the system.
562 # sysconf(_SC_NPROCESSORS_ONLN) works on most systems, except that BSDs
564 AC_MSG_CHECKING([how to detect the number of available CPU cores])
565 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
571 i = sysconf(_SC_NPROCESSORS_ONLN);
575 AC_DEFINE([HAVE_NCPU_SYSCONF], 1,
576 [Define to 1 if the number of available CPU cores can be
577 detected with sysconf(_SC_NPROCESSORS_ONLN).])
578 AC_MSG_RESULT([sysconf])
580 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
581 #include <sys/types.h>
582 #ifdef HAVE_SYS_PARAM_H
583 # include <sys/param.h>
585 #include <sys/sysctl.h>
589 int name[2] = { CTL_HW, HW_NCPU };
591 size_t cpus_size = sizeof(cpus);
592 sysctl(name, 2, &cpus, &cpus_size, NULL, NULL);
596 AC_DEFINE([HAVE_NCPU_SYSCTL], 1,
597 [Define to 1 if the number of available CPU cores can be
598 detected with sysctl().])
599 AC_MSG_RESULT([sysctl])
601 AC_MSG_RESULT([unknown])
605 ###############################################################################
606 # If using GCC, set some additional CFLAGS:
607 ###############################################################################
611 if test "x$GCC" = xyes ; then
613 echo "GCC extensions:"
615 if test -n "$CFLAG_VISIBILITY" ; then
616 CFLAGS="$CFLAG_VISIBILITY $CFLAGS"
619 # -Wno-uninitialized is needed with -Werror with SHA256 code
620 # to omit a bogus warning.
621 AC_MSG_CHECKING([if $CC accepts -Wno-uninitialized])
623 CFLAGS="$CFLAGS -Wno-uninitialized"
624 AC_COMPILE_IFELSE([void foo(void) { }], [Wno_uninitialized=yes])
626 AC_MSG_RESULT([$Wno_uninitialized])
628 # Enable as much warnings as possible. These commented warnings won't
629 # work for LZMA Utils though:
630 # * -Wunreachable-code breaks several assert(0) cases, which are
631 # backed up with "return LZMA_PROG_ERROR".
632 # * -Wcast-qual would break various things where we need a non-const
633 # pointer although we don't modify anything through it.
634 # * -Wcast-align breaks optimized CRC32 and CRC64 implementation
635 # on some architectures (not on x86), where this warning is bogus,
636 # because we take care of correct alignment.
637 # * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
638 # don't seem so useful here; at least the last one gives some
639 # warnings which are not bugs.
641 # The flags are in reverse order below so they end up in "beautiful"
642 # order on the actual command line.
646 -Wmissing-declarations \
647 -Wmissing-prototypes \
648 -Wold-style-definition \
649 -Wstrict-prototypes \
652 -Wbad-function-cast \
656 -Wstrict-aliasing=2 \
663 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
665 CFLAGS="$NEW_FLAG $CFLAGS"
666 AC_COMPILE_IFELSE([void foo(void) { }], [
674 AC_ARG_ENABLE([werror],
675 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
676 compilation on all compiler warnings.]),
677 [], [enable_werror=no])
678 if test "x$enable_werror" = "xyes"; then
679 CFLAGS="-Werror $CFLAGS"
683 AM_CONDITIONAL([COND_WNO_UNINITIALIZED], test "x$Wno_uninitialized" = "xyes")
686 ###############################################################################
687 # Create the makefiles and config.h
688 ###############################################################################
692 # Don't build the lib directory at all if we don't need any replacement
694 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
704 src/liblzma/api/Makefile
705 src/liblzma/common/Makefile
706 src/liblzma/check/Makefile
707 src/liblzma/rangecoder/Makefile
708 src/liblzma/lz/Makefile
709 src/liblzma/lzma/Makefile
710 src/liblzma/subblock/Makefile
711 src/liblzma/delta/Makefile
712 src/liblzma/simple/Makefile