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.42.3alpha], [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.
43 echo "Configure options:"
45 # Enable/disable debugging code:
46 AC_MSG_CHECKING([if debugging code should be compiled])
47 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging code.]),
49 if test "x$enable_debug" = xyes; then
53 AC_DEFINE(NDEBUG, 1, [Define to disable debugging code.])
57 # Enable/disable the encoder components:
58 AC_MSG_CHECKING([if encoder components should be built])
59 AC_ARG_ENABLE(encoder, AC_HELP_STRING([--disable-encoder],
60 [Do not build the encoder components.]),
61 [], enable_encoder=yes)
62 if test "x$enable_encoder" = xyes; then
63 AC_DEFINE([HAVE_ENCODER], 1,
64 [Define to 1 if encoder components are enabled.])
69 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoder" = xyes)
71 # Enable/disable the decoder components:
72 AC_MSG_CHECKING([if decoder components should be built])
73 AC_ARG_ENABLE(decoder, AC_HELP_STRING([--disable-decoder],
74 [Do not build the decoder components.]),
75 [], enable_decoder=yes)
76 if test "x$enable_decoder" = xyes; then
77 AC_DEFINE([HAVE_DECODER], 1,
78 [Define to 1 if decoder components are enabled.])
82 if test "x$enable_encoder" = xno; then
83 AC_MSG_ERROR([Do not disable both encoder and decoder.])
86 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoder" = xyes)
89 AC_MSG_CHECKING([which filters to build])
90 AC_ARG_ENABLE(filters, AC_HELP_STRING([--enable-filters=],
91 [Comma-separated list of filters to build. Default=all.
92 Filters used in encoding are needed also in decoding.
93 Available filters: copy subblock x86 powerpc ia64
94 arm armthumb sparc delta lzma]),
95 [], [enable_filters=copy,subblock,x86,powerpc,ia64,arm,armthumb,sparc,delta,lzma])
96 enable_filters=`echo "$enable_filters" | sed 's/,/ /g'`
97 enable_filters_copy=no
98 enable_filters_subblock=no
100 enable_filters_powerpc=no
101 enable_filters_ia64=no
102 enable_filters_arm=no
103 enable_filters_armthumb=no
104 enable_filters_sparc=no
105 enable_filters_delta=no
106 enable_filters_lzma=no
107 enable_simple_filters=no
108 if test "x$enable_filters" = xno || test "x$enable_filters" = x; then
110 AC_MSG_ERROR([Please enable at least one filter.])
112 for arg in $enable_filters
116 enable_filters_copy=yes
117 AC_DEFINE([HAVE_FILTER_COPY], 1,
118 [Define to 1 if support for the
119 Copy filter is enabled.])
122 enable_filters_subblock=yes
123 AC_DEFINE([HAVE_FILTER_SUBBLOCK], 1,
124 [Define to 1 if support for the
125 Subblock filter is enabled.])
128 enable_filters_x86=yes
129 enable_simple_filters=yes
130 AC_DEFINE([HAVE_FILTER_X86], 1,
131 [Define to 1 if support for the
132 x86 (BCJ) filter is enabled.])
135 enable_filters_powerpc=yes
136 enable_simple_filters=yes
137 AC_DEFINE([HAVE_FILTER_POWERPC], 1,
138 [Define to 1 if support for the
139 PowerPC filter is enabled.])
142 enable_filters_ia64=yes
143 enable_simple_filters=yes
144 AC_DEFINE([HAVE_FILTER_IA64], 1,
145 [Define to 1 if support for the
146 IA64 filter is enabled.])
149 enable_filters_arm=yes
150 enable_simple_filters=yes
151 AC_DEFINE([HAVE_FILTER_ARM], 1,
152 [Define to 1 if support for the
153 ARM filter is enabled.])
156 enable_filters_armthumb=yes
157 enable_simple_filters=yes
158 AC_DEFINE([HAVE_FILTER_ARMTHUMB], 1,
159 [Define to 1 if support for the
160 ARMThumb filter is enabled.])
163 enable_filters_sparc=yes
164 enable_simple_filters=yes
165 AC_DEFINE([HAVE_FILTER_SPARC], 1,
166 [Define to 1 if support for the
167 SPARC filter is enabled.])
170 enable_filters_delta=yes
171 AC_DEFINE([HAVE_FILTER_DELTA], 1,
172 [Define to 1 if support for the
173 Delta filter is enabled.])
176 enable_filters_lzma=yes
177 AC_DEFINE([HAVE_FILTER_LZMA], 1,
178 [Define to 1 if support for the
179 LZMA filter is enabled.])
183 AC_MSG_ERROR([unknown filter: $arg])
187 AC_MSG_RESULT([$enable_filters])
189 if test "x$enable_simple_filters" = xyes ; then
190 AC_DEFINE([HAVE_FILTER_SIMPLE], 1, [Define to 1 if support for any
191 of the so called simple filters is enabled.])
193 AM_CONDITIONAL(COND_FILTER_COPY, test "x$enable_filters_copy" = xyes)
194 AM_CONDITIONAL(COND_FILTER_SUBBLOCK, test "x$enable_filters_subblock" = xyes)
195 AM_CONDITIONAL(COND_FILTER_X86, test "x$enable_filters_x86" = xyes)
196 AM_CONDITIONAL(COND_FILTER_POWERPC, test "x$enable_filters_powerpc" = xyes)
197 AM_CONDITIONAL(COND_FILTER_IA64, test "x$enable_filters_ia64" = xyes)
198 AM_CONDITIONAL(COND_FILTER_ARM, test "x$enable_filters_arm" = xyes)
199 AM_CONDITIONAL(COND_FILTER_ARMTHUMB, test "x$enable_filters_armthumb" = xyes)
200 AM_CONDITIONAL(COND_FILTER_SPARC, test "x$enable_filters_sparc" = xyes)
201 AM_CONDITIONAL(COND_FILTER_DELTA, test "x$enable_filters_delta" = xyes)
202 AM_CONDITIONAL(COND_FILTER_LZMA, test "x$enable_filters_lzma" = xyes)
203 AM_CONDITIONAL(COND_MAIN_SIMPLE, test "x$enable_simple_filters" = xyes)
205 # Which match finders should be enabled:
206 AC_MSG_CHECKING([which match finders to build])
207 AC_ARG_ENABLE(match-finders, AC_HELP_STRING([--enable-match-finders=],
208 [Comma-separated list of match finders to build. Default=all.
209 At least one match finder is required for encoding with
211 Available match finders: hc3 hc4 bt2 bt3 bt4]), [],
212 [enable_match_finders=hc3,hc4,bt2,bt3,bt4])
213 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
214 enable_match_finders_hc3=no
215 enable_match_finders_hc4=no
216 enable_match_finders_bt2=no
217 enable_match_finders_bt3=no
218 enable_match_finders_bt4=no
219 if test "x$enable_encoder" = xyes && test "x$enable_filters_lzma" = xyes ; then
220 for arg in $enable_match_finders
223 hc3) enable_match_finders_hc3=yes ;;
224 hc4) enable_match_finders_hc4=yes ;;
225 bt2) enable_match_finders_bt2=yes ;;
226 bt3) enable_match_finders_bt3=yes ;;
227 bt4) enable_match_finders_bt4=yes ;;
230 AC_MSG_ERROR([unknown match finder: $arg])
234 AC_MSG_RESULT([$enable_match_finders])
236 AC_MSG_RESULT([(none because not building the LZMA encoder)])
238 AM_CONDITIONAL(COND_MF_HC3, test "x$enable_match_finders_hc3" = xyes)
239 AM_CONDITIONAL(COND_MF_HC4, test "x$enable_match_finders_hc4" = xyes)
240 AM_CONDITIONAL(COND_MF_BT2, test "x$enable_match_finders_bt2" = xyes)
241 AM_CONDITIONAL(COND_MF_BT3, test "x$enable_match_finders_bt3" = xyes)
242 AM_CONDITIONAL(COND_MF_BT4, test "x$enable_match_finders_bt4" = xyes)
244 # Which integrity checks to build
245 AC_MSG_CHECKING([which integrity checks to build])
246 AC_ARG_ENABLE(checks, AC_HELP_STRING([--enable-checks=],
247 [Comma-separated list of integrity checks to build.
248 Default=all. Available integrity checks: crc32 crc64 sha256]),
249 [], [enable_checks=crc32,crc64,sha256])
250 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
251 enable_checks_crc32=no
252 enable_checks_crc64=no
253 enable_checks_sha256=no
254 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
255 AC_MSG_RESULT([(none)])
257 for arg in $enable_checks
261 enable_checks_crc32=yes
262 AC_DEFINE([HAVE_CHECK_CRC32], 1,
263 [Define to 1 if CRC32 support
267 enable_checks_crc64=yes
268 AC_DEFINE([HAVE_CHECK_CRC64], 1,
269 [Define to 1 if CRC64 support
273 enable_checks_sha256=yes
274 AC_DEFINE([HAVE_CHECK_SHA256], 1,
275 [Define to 1 if SHA256 support
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.])
289 AM_CONDITIONAL(COND_CHECK_CRC32, test "x$enable_checks_crc32" = xyes)
290 AM_CONDITIONAL(COND_CHECK_CRC64, test "x$enable_checks_crc64" = xyes)
291 AM_CONDITIONAL(COND_CHECK_SHA256, test "x$enable_checks_sha256" = xyes)
293 # Assembler optimizations
294 AC_MSG_CHECKING([if assembler optimizations should be used])
295 AC_ARG_ENABLE(assembler, AC_HELP_STRING([--disable-assembler],
296 [Do not use assembler optimizations even if such exist
297 for the architecture.]),
298 [], [enable_assembler=yes])
299 if test "x$enable_assembler" = xyes; then
302 # Darwin has different ABI than GNU+Linux and Solaris,
303 # and the x86 assembler code doesn't assemble.
318 case $enable_assembler in
322 AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', or \`x86'.])
325 AC_MSG_RESULT([$enable_assembler])
326 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
329 AC_MSG_CHECKING([if small size is preferred over speed])
330 AC_ARG_ENABLE(small, AC_HELP_STRING([--enable-small],
331 [Omit precomputed tables to make liblzma a few kilobytes
332 smaller. This will increase startup time of applications
333 slightly, because the tables need to be computed first.]),
334 [], [enable_small=no])
335 if test "x$enable_small" = xyes; then
336 AC_DEFINE([HAVE_SMALL], 1, [Define to 1 if optimizing for size.])
337 elif test "x$enable_small" != xno; then
339 AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
341 AC_MSG_RESULT([$enable_small])
342 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
344 ###############################################################################
345 # Checks for programs.
346 ###############################################################################
349 echo "Initializing Automake:"
351 # There's no C++ or Fortran in LZMA Utils:
359 AC_USE_SYSTEM_EXTENSIONS
362 echo "Threading support:"
367 echo "Initializing Libtool:"
371 ###############################################################################
372 # Checks for libraries.
373 ###############################################################################
376 echo "Initializing gettext:"
377 AM_GNU_GETTEXT_VERSION([0.16.1])
378 AM_GNU_GETTEXT([external])
380 ###############################################################################
381 # Checks for header files.
382 ###############################################################################
385 echo "System headers and functions:"
387 # There is currently no workarounds in this package if some of
388 # these headers are missing.
389 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
391 [AC_MSG_ERROR([Required header file(s) are missing.])])
393 # If any of these headers are missing, things should still work correctly:
394 AC_CHECK_HEADERS([assert.h errno.h byteswap.h sys/param.h sys/sysctl.h],
396 #ifdef HAVE_SYS_PARAM_H
397 # include <sys/param.h>
402 ###############################################################################
403 # Checks for typedefs, structures, and compiler characteristics.
404 ###############################################################################
418 AC_CHECK_SIZEOF([unsigned long])
419 AC_CHECK_SIZEOF([size_t])
421 # The command line tool can copy high resolution timestamps if such
422 # information is availabe in struct stat. Otherwise one second accuracy
423 # is used. Most systems seem to have st_xtim but BSDs have st_xtimespec.
424 AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec, struct stat.st_mtim.tv_nsec,
425 struct stat.st_atimespec.tv_nsec, struct stat.st_mtimespec.tv_nsec])
427 # It is very unlikely that you want to build liblzma without
428 # large file support.
431 # At the moment, the only endian-dependent part should be the integrity checks.
435 ###############################################################################
436 # Checks for library functions.
437 ###############################################################################
439 # Gnulib replacements as needed
442 # Functions that are not mandatory i.e. we have alternatives for them
443 # or we can just drop some functionality:
444 AC_CHECK_FUNCS([memcpy memmove memset futimes futimesat])
446 # Check how to find out the amount of physical memory in the system. The
447 # lzma command line tool uses this to automatically limits its memory usage.
448 # - sysconf() gives all the needed info on GNU+Linux and Solaris.
449 # - BSDs use sysctl().
450 AC_MSG_CHECKING([how to detect the amount of physical memory])
457 i = sysconf(_SC_PAGESIZE);
458 i = sysconf(_SC_PHYS_PAGES);
462 AC_DEFINE([HAVE_PHYSMEM_SYSCONF], 1,
463 [Define to 1 if the amount of physical memory can be detected
464 with sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES).])
465 AC_MSG_RESULT([sysconf])
467 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
468 #include <sys/types.h>
469 #ifdef HAVE_SYS_PARAM_H
470 # include <sys/param.h>
472 #include <sys/sysctl.h>
476 int name[2] = { CTL_HW, HW_PHYSMEM };
478 size_t mem_ptr_size = sizeof(mem);
479 sysctl(name, 2, &mem, &mem_ptr_size, NULL, NULL);
483 AC_DEFINE([HAVE_PHYSMEM_SYSCTL], 1,
484 [Define to 1 if the amount of physical memory can be detected
486 AC_MSG_RESULT([sysctl])
488 AC_MSG_RESULT([unknown])
491 # Check how to find out the number of available CPU cores in the system.
492 # sysconf(_SC_NPROCESSORS_ONLN) works on most systems, except that BSDs
494 AC_MSG_CHECKING([how to detect the number of available CPU cores])
501 i = sysconf(_SC_NPROCESSORS_ONLN);
505 AC_DEFINE([HAVE_NCPU_SYSCONF], 1,
506 [Define to 1 if the number of available CPU cores can be
507 detected with sysconf(_SC_NPROCESSORS_ONLN).])
508 AC_MSG_RESULT([sysconf])
510 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
511 #include <sys/types.h>
512 #ifdef HAVE_SYS_PARAM_H
513 # include <sys/param.h>
515 #include <sys/sysctl.h>
519 int name[2] = { CTL_HW, HW_NCPU };
521 size_t cpus_size = sizeof(cpus);
522 sysctl(name, 2, &cpus, &cpus_size, NULL, NULL);
526 AC_DEFINE([HAVE_NCPU_SYSCTL], 1,
527 [Define to 1 if the number of available CPU cores can be
528 detected with sysctl().])
529 AC_MSG_RESULT([sysctl])
531 AC_MSG_RESULT([unknown])
535 ###############################################################################
536 # If using GCC, set some additional CFLAGS:
537 ###############################################################################
541 if test -n "$GCC" ; then
543 echo "GCC extensions:"
545 if test -n "$CFLAG_VISIBILITY" ; then
546 CFLAGS="$CFLAG_VISIBILITY $CFLAGS"
549 # -Wno-uninitialized is needed with -Werror with SHA256 code
550 # to omit a bogus warning.
551 AC_MSG_CHECKING([if $CC accepts -Wno-uninitialized])
553 CFLAGS="$CFLAGS -Wno-uninitialized"
554 AC_COMPILE_IFELSE([void foo(void) { }], [Wno_uninitialized=yes])
556 AC_MSG_RESULT([$Wno_uninitialized])
558 # Enable as much warnings as possible. These commented warnings won't
559 # work for LZMA Utils though:
560 # * -Wunreachable-code breaks several assert(0) cases, which are
561 # backed up with "return LZMA_PROG_ERROR".
562 # * -Wcast-qual would break various things where we need a non-const
563 # pointer although we don't modify anything through it.
564 # * -Wcast-align breaks optimized CRC32 and CRC64 implementation
565 # on some architectures (not on x86), where this warning is bogus,
566 # because we take care of correct alignment.
567 # * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
568 # don't seem so useful here; at least the last one gives some
569 # warnings which are not bugs.
571 # The flags are in reverse order below so they end up in "beautiful"
572 # order on the actual command line.
576 -Wmissing-declarations \
577 -Wmissing-prototypes \
578 -Wold-style-definition \
579 -Wstrict-prototypes \
582 -Wbad-function-cast \
586 -Wstrict-aliasing=2 \
594 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
596 CFLAGS="$NEW_FLAG $CFLAGS"
597 AC_COMPILE_IFELSE([void foo(void) { }], [
605 AC_ARG_ENABLE([werror],
606 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
607 compilation on all compiler warnings.]),
608 [], [enable_werror=no])
609 if test "x$enable_werror" = "xyes"; then
610 CFLAGS="-Werror $CFLAGS"
614 AM_CONDITIONAL([COND_WNO_UNINITIALIZED], test "x$Wno_uninitialized" = "xyes")
617 ###############################################################################
618 # Create the makefiles and config.h
619 ###############################################################################
623 # Don't build the lib directory at all if we don't need any replacement
625 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
635 src/liblzma/api/Makefile
636 src/liblzma/common/Makefile
637 src/liblzma/check/Makefile
638 src/liblzma/lz/Makefile
639 src/liblzma/lzma/Makefile
640 src/liblzma/simple/Makefile
641 src/liblzma/subblock/Makefile
642 src/liblzma/rangecoder/Makefile