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.5alpha], [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
52 AC_DEFINE(NDEBUG, 1, [Define to disable debugging code.])
56 # Enable/disable the encoder components:
57 AC_MSG_CHECKING([if encoder components should be built])
58 AC_ARG_ENABLE(encoder, AC_HELP_STRING([--disable-encoder],
59 [Do not build the encoder components.]),
60 [], enable_encoder=yes)
61 if test "x$enable_encoder" = xyes; then
62 AC_DEFINE([HAVE_ENCODER], 1,
63 [Define to 1 if encoder components are enabled.])
68 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoder" = xyes)
70 # Enable/disable the decoder components:
71 AC_MSG_CHECKING([if decoder components should be built])
72 AC_ARG_ENABLE(decoder, AC_HELP_STRING([--disable-decoder],
73 [Do not build the decoder components.]),
74 [], enable_decoder=yes)
75 if test "x$enable_decoder" = xyes; then
76 AC_DEFINE([HAVE_DECODER], 1,
77 [Define to 1 if decoder components are enabled.])
81 if test "x$enable_encoder" = xno; then
82 AC_MSG_ERROR([Do not disable both encoder and decoder.])
85 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoder" = xyes)
88 AC_MSG_CHECKING([which filters to build])
89 AC_ARG_ENABLE(filters, AC_HELP_STRING([--enable-filters=LIST],
90 [Comma-separated list of filters to build. Default=all.
91 Filters used in encoding are needed also in decoding.
92 Available filters: copy subblock x86 powerpc ia64
93 arm armthumb sparc delta lzma]),
94 [], [enable_filters=copy,subblock,x86,powerpc,ia64,arm,armthumb,sparc,delta,lzma])
95 enable_filters=`echo "$enable_filters" | sed 's/,/ /g'`
96 enable_filters_copy=no
97 enable_filters_subblock=no
99 enable_filters_powerpc=no
100 enable_filters_ia64=no
101 enable_filters_arm=no
102 enable_filters_armthumb=no
103 enable_filters_sparc=no
104 enable_filters_delta=no
105 enable_filters_lzma=no
106 enable_simple_filters=no
107 if test "x$enable_filters" = xno || test "x$enable_filters" = x; then
109 AC_MSG_ERROR([Please enable at least one filter.])
111 for arg in $enable_filters
115 enable_filters_copy=yes
116 AC_DEFINE([HAVE_FILTER_COPY], 1,
117 [Define to 1 if support for the
118 Copy filter is enabled.])
121 enable_filters_subblock=yes
122 AC_DEFINE([HAVE_FILTER_SUBBLOCK], 1,
123 [Define to 1 if support for the
124 Subblock filter is enabled.])
127 enable_filters_x86=yes
128 enable_simple_filters=yes
129 AC_DEFINE([HAVE_FILTER_X86], 1,
130 [Define to 1 if support for the
131 x86 (BCJ) filter is enabled.])
134 enable_filters_powerpc=yes
135 enable_simple_filters=yes
136 AC_DEFINE([HAVE_FILTER_POWERPC], 1,
137 [Define to 1 if support for the
138 PowerPC filter is enabled.])
141 enable_filters_ia64=yes
142 enable_simple_filters=yes
143 AC_DEFINE([HAVE_FILTER_IA64], 1,
144 [Define to 1 if support for the
145 IA64 filter is enabled.])
148 enable_filters_arm=yes
149 enable_simple_filters=yes
150 AC_DEFINE([HAVE_FILTER_ARM], 1,
151 [Define to 1 if support for the
152 ARM filter is enabled.])
155 enable_filters_armthumb=yes
156 enable_simple_filters=yes
157 AC_DEFINE([HAVE_FILTER_ARMTHUMB], 1,
158 [Define to 1 if support for the
159 ARMThumb filter is enabled.])
162 enable_filters_sparc=yes
163 enable_simple_filters=yes
164 AC_DEFINE([HAVE_FILTER_SPARC], 1,
165 [Define to 1 if support for the
166 SPARC filter is enabled.])
169 enable_filters_delta=yes
170 AC_DEFINE([HAVE_FILTER_DELTA], 1,
171 [Define to 1 if support for the
172 Delta filter is enabled.])
175 enable_filters_lzma=yes
176 AC_DEFINE([HAVE_FILTER_LZMA], 1,
177 [Define to 1 if support for the
178 LZMA filter is enabled.])
182 AC_MSG_ERROR([unknown filter: $arg])
186 AC_MSG_RESULT([$enable_filters])
188 if test "x$enable_simple_filters" = xyes ; then
189 AC_DEFINE([HAVE_FILTER_SIMPLE], 1, [Define to 1 if support for any
190 of the so called simple filters is enabled.])
192 AM_CONDITIONAL(COND_FILTER_COPY, test "x$enable_filters_copy" = xyes)
193 AM_CONDITIONAL(COND_FILTER_SUBBLOCK, test "x$enable_filters_subblock" = xyes)
194 AM_CONDITIONAL(COND_FILTER_X86, test "x$enable_filters_x86" = xyes)
195 AM_CONDITIONAL(COND_FILTER_POWERPC, test "x$enable_filters_powerpc" = xyes)
196 AM_CONDITIONAL(COND_FILTER_IA64, test "x$enable_filters_ia64" = xyes)
197 AM_CONDITIONAL(COND_FILTER_ARM, test "x$enable_filters_arm" = xyes)
198 AM_CONDITIONAL(COND_FILTER_ARMTHUMB, test "x$enable_filters_armthumb" = xyes)
199 AM_CONDITIONAL(COND_FILTER_SPARC, test "x$enable_filters_sparc" = xyes)
200 AM_CONDITIONAL(COND_FILTER_DELTA, test "x$enable_filters_delta" = xyes)
201 AM_CONDITIONAL(COND_FILTER_LZMA, test "x$enable_filters_lzma" = xyes)
202 AM_CONDITIONAL(COND_MAIN_SIMPLE, test "x$enable_simple_filters" = xyes)
204 # Which match finders should be enabled:
205 AC_MSG_CHECKING([which match finders to build])
206 AC_ARG_ENABLE(match-finders, AC_HELP_STRING([--enable-match-finders=LIST],
207 [Comma-separated list of match finders to build. Default=all.
208 At least one match finder is required for encoding with
210 Available match finders: hc3 hc4 bt2 bt3 bt4]), [],
211 [enable_match_finders=hc3,hc4,bt2,bt3,bt4])
212 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
213 enable_match_finders_hc3=no
214 enable_match_finders_hc4=no
215 enable_match_finders_bt2=no
216 enable_match_finders_bt3=no
217 enable_match_finders_bt4=no
218 if test "x$enable_encoder" = xyes && test "x$enable_filters_lzma" = xyes ; then
219 for arg in $enable_match_finders
222 hc3) enable_match_finders_hc3=yes ;;
223 hc4) enable_match_finders_hc4=yes ;;
224 bt2) enable_match_finders_bt2=yes ;;
225 bt3) enable_match_finders_bt3=yes ;;
226 bt4) enable_match_finders_bt4=yes ;;
229 AC_MSG_ERROR([unknown match finder: $arg])
233 AC_MSG_RESULT([$enable_match_finders])
235 AC_MSG_RESULT([(none because not building the LZMA encoder)])
237 AM_CONDITIONAL(COND_MF_HC3, test "x$enable_match_finders_hc3" = xyes)
238 AM_CONDITIONAL(COND_MF_HC4, test "x$enable_match_finders_hc4" = xyes)
239 AM_CONDITIONAL(COND_MF_BT2, test "x$enable_match_finders_bt2" = xyes)
240 AM_CONDITIONAL(COND_MF_BT3, test "x$enable_match_finders_bt3" = xyes)
241 AM_CONDITIONAL(COND_MF_BT4, test "x$enable_match_finders_bt4" = xyes)
243 # Which integrity checks to build
244 AC_MSG_CHECKING([which integrity checks to build])
245 AC_ARG_ENABLE(checks, AC_HELP_STRING([--enable-checks=LIST],
246 [Comma-separated list of integrity checks to build.
247 Default=all. Available integrity checks: crc32 crc64 sha256]),
248 [], [enable_checks=crc32,crc64,sha256])
249 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
250 enable_checks_crc32=no
251 enable_checks_crc64=no
252 enable_checks_sha256=no
253 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
254 AC_MSG_RESULT([(none)])
256 for arg in $enable_checks
260 enable_checks_crc32=yes
261 AC_DEFINE([HAVE_CHECK_CRC32], 1,
262 [Define to 1 if CRC32 support
266 enable_checks_crc64=yes
267 AC_DEFINE([HAVE_CHECK_CRC64], 1,
268 [Define to 1 if CRC64 support
272 enable_checks_sha256=yes
273 AC_DEFINE([HAVE_CHECK_SHA256], 1,
274 [Define to 1 if SHA256 support
279 AC_MSG_ERROR([unknown integrity check: $arg])
283 AC_MSG_RESULT([$enable_checks])
285 if test "x$enable_checks_crc32" = xno ; then
286 AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
288 AM_CONDITIONAL(COND_CHECK_CRC32, test "x$enable_checks_crc32" = xyes)
289 AM_CONDITIONAL(COND_CHECK_CRC64, test "x$enable_checks_crc64" = xyes)
290 AM_CONDITIONAL(COND_CHECK_SHA256, test "x$enable_checks_sha256" = xyes)
292 # Assembler optimizations
293 AC_MSG_CHECKING([if assembler optimizations should be used])
294 AC_ARG_ENABLE(assembler, AC_HELP_STRING([--disable-assembler],
295 [Do not use assembler optimizations even if such exist
296 for the architecture.]),
297 [], [enable_assembler=yes])
298 if test "x$enable_assembler" = xyes; then
300 i?86) enable_assembler=x86 ;;
301 x86_64) enable_assembler=x86_64 ;;
302 *) enable_assembler=no ;;
304 # Darwin has different ABI than GNU+Linux and Solaris,
305 # and the assembler code doesn't assemble.
307 darwin*) enable_assembler=no ;;
311 case $enable_assembler in
313 AC_DEFINE([HAVE_ASM_X86], 1,
314 [Define to 1 if using x86 assembler optimizations.])
317 AC_DEFINE([HAVE_ASM_X86_64], 1,
318 [Define to 1 if using x86_64 assembler optimizations.])
324 AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', or \`x86'.])
327 AC_MSG_RESULT([$enable_assembler])
328 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
330 # Fast unaligned memory access
331 AC_MSG_CHECKING([if unaligned memory access should be used])
332 AC_ARG_ENABLE(unaligned-access, AC_HELP_STRING([--enable-unaligned-access],
333 [Enable if the system supports *fast* unaligned memory access
334 with 16-bit and 32-bit integers. By default, this is enabled
335 only on x86, x86_64, and big endian PowerPC.]),
336 [], [enable_unaligned_access=auto])
337 if test "x$enable_unaligned_access" = xauto ; then
339 i?86|x86_64|powerpc|powerpc64)
340 enable_unaligned_access=yes
343 enable_unaligned_access=no
347 if test "x$enable_unaligned_access" = xyes ; then
348 AC_DEFINE([HAVE_FAST_UNALIGNED_ACCESS], [1], [Define to 1 if
349 the system supports fast unaligned memory access.])
356 AC_MSG_CHECKING([if small size is preferred over speed])
357 AC_ARG_ENABLE(small, AC_HELP_STRING([--enable-small],
358 [Omit precomputed tables to make liblzma a few kilobytes
359 smaller. This will increase startup time of applications
360 slightly, because the tables need to be computed first.]),
361 [], [enable_small=no])
362 if test "x$enable_small" = xyes; then
363 AC_DEFINE([HAVE_SMALL], 1, [Define to 1 if optimizing for size.])
364 elif test "x$enable_small" != xno; then
366 AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
368 AC_MSG_RESULT([$enable_small])
369 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
371 ###############################################################################
372 # Checks for programs.
373 ###############################################################################
376 echo "Initializing Automake:"
378 AM_INIT_AUTOMAKE([1.10 foreign tar-v7 filename-length-max=99])
382 if test x$ac_cv_prog_cc_c99 = xno ; then
383 AC_MSG_ERROR([No C99 compiler was found.])
388 AC_USE_SYSTEM_EXTENSIONS
391 echo "Threading support:"
396 echo "Initializing Libtool:"
402 ###############################################################################
403 # Checks for libraries.
404 ###############################################################################
407 echo "Initializing gettext:"
408 AM_GNU_GETTEXT_VERSION([0.16.1])
409 AM_GNU_GETTEXT([external])
411 ###############################################################################
412 # Checks for header files.
413 ###############################################################################
416 echo "System headers and functions:"
418 # There is currently no workarounds in this package if some of
419 # these headers are missing.
420 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
422 [AC_MSG_ERROR([Required header file(s) are missing.])])
424 # If any of these headers are missing, things should still work correctly:
425 AC_CHECK_HEADERS([assert.h errno.h byteswap.h sys/param.h sys/sysctl.h],
427 #ifdef HAVE_SYS_PARAM_H
428 # include <sys/param.h>
433 ###############################################################################
434 # Checks for typedefs, structures, and compiler characteristics.
435 ###############################################################################
437 dnl We don't need these as long as we need a C99 compiler anyway.
450 AC_CHECK_SIZEOF([unsigned long])
451 AC_CHECK_SIZEOF([size_t])
453 # The command line tool can copy high resolution timestamps if such
454 # information is availabe in struct stat. Otherwise one second accuracy
455 # is used. Most systems seem to have st_xtim but BSDs have st_xtimespec.
456 AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec, struct stat.st_mtim.tv_nsec,
457 struct stat.st_atimespec.tv_nsec, struct stat.st_mtimespec.tv_nsec])
463 ###############################################################################
464 # Checks for library functions.
465 ###############################################################################
467 # Gnulib replacements as needed
470 # Functions that are not mandatory i.e. we have alternatives for them
471 # or we can just drop some functionality:
472 AC_CHECK_FUNCS([futimes futimesat])
474 # Check how to find out the amount of physical memory in the system. The
475 # lzma command line tool uses this to automatically limits its memory usage.
476 # - sysconf() gives all the needed info on GNU+Linux and Solaris.
477 # - BSDs use sysctl().
478 AC_MSG_CHECKING([how to detect the amount of physical memory])
485 i = sysconf(_SC_PAGESIZE);
486 i = sysconf(_SC_PHYS_PAGES);
490 AC_DEFINE([HAVE_PHYSMEM_SYSCONF], 1,
491 [Define to 1 if the amount of physical memory can be detected
492 with sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES).])
493 AC_MSG_RESULT([sysconf])
495 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
496 #include <sys/types.h>
497 #ifdef HAVE_SYS_PARAM_H
498 # include <sys/param.h>
500 #include <sys/sysctl.h>
504 int name[2] = { CTL_HW, HW_PHYSMEM };
506 size_t mem_ptr_size = sizeof(mem);
507 sysctl(name, 2, &mem, &mem_ptr_size, NULL, NULL);
511 AC_DEFINE([HAVE_PHYSMEM_SYSCTL], 1,
512 [Define to 1 if the amount of physical memory can be detected
514 AC_MSG_RESULT([sysctl])
516 AC_MSG_RESULT([unknown])
519 # Check how to find out the number of available CPU cores in the system.
520 # sysconf(_SC_NPROCESSORS_ONLN) works on most systems, except that BSDs
522 AC_MSG_CHECKING([how to detect the number of available CPU cores])
529 i = sysconf(_SC_NPROCESSORS_ONLN);
533 AC_DEFINE([HAVE_NCPU_SYSCONF], 1,
534 [Define to 1 if the number of available CPU cores can be
535 detected with sysconf(_SC_NPROCESSORS_ONLN).])
536 AC_MSG_RESULT([sysconf])
538 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
539 #include <sys/types.h>
540 #ifdef HAVE_SYS_PARAM_H
541 # include <sys/param.h>
543 #include <sys/sysctl.h>
547 int name[2] = { CTL_HW, HW_NCPU };
549 size_t cpus_size = sizeof(cpus);
550 sysctl(name, 2, &cpus, &cpus_size, NULL, NULL);
554 AC_DEFINE([HAVE_NCPU_SYSCTL], 1,
555 [Define to 1 if the number of available CPU cores can be
556 detected with sysctl().])
557 AC_MSG_RESULT([sysctl])
559 AC_MSG_RESULT([unknown])
563 ###############################################################################
564 # If using GCC, set some additional CFLAGS:
565 ###############################################################################
569 if test "x$GCC" = xyes ; then
571 echo "GCC extensions:"
573 if test -n "$CFLAG_VISIBILITY" ; then
574 CFLAGS="$CFLAG_VISIBILITY $CFLAGS"
577 # -Wno-uninitialized is needed with -Werror with SHA256 code
578 # to omit a bogus warning.
579 AC_MSG_CHECKING([if $CC accepts -Wno-uninitialized])
581 CFLAGS="$CFLAGS -Wno-uninitialized"
582 AC_COMPILE_IFELSE([void foo(void) { }], [Wno_uninitialized=yes])
584 AC_MSG_RESULT([$Wno_uninitialized])
586 # Enable as much warnings as possible. These commented warnings won't
587 # work for LZMA Utils though:
588 # * -Wunreachable-code breaks several assert(0) cases, which are
589 # backed up with "return LZMA_PROG_ERROR".
590 # * -Wcast-qual would break various things where we need a non-const
591 # pointer although we don't modify anything through it.
592 # * -Wcast-align breaks optimized CRC32 and CRC64 implementation
593 # on some architectures (not on x86), where this warning is bogus,
594 # because we take care of correct alignment.
595 # * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
596 # don't seem so useful here; at least the last one gives some
597 # warnings which are not bugs.
599 # The flags are in reverse order below so they end up in "beautiful"
600 # order on the actual command line.
604 -Wmissing-declarations \
605 -Wmissing-prototypes \
606 -Wold-style-definition \
607 -Wstrict-prototypes \
610 -Wbad-function-cast \
614 -Wstrict-aliasing=2 \
621 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
623 CFLAGS="$NEW_FLAG $CFLAGS"
624 AC_COMPILE_IFELSE([void foo(void) { }], [
632 AC_ARG_ENABLE([werror],
633 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
634 compilation on all compiler warnings.]),
635 [], [enable_werror=no])
636 if test "x$enable_werror" = "xyes"; then
637 CFLAGS="-Werror $CFLAGS"
641 AM_CONDITIONAL([COND_WNO_UNINITIALIZED], test "x$Wno_uninitialized" = "xyes")
644 ###############################################################################
645 # Create the makefiles and config.h
646 ###############################################################################
650 # Don't build the lib directory at all if we don't need any replacement
652 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
662 src/liblzma/api/Makefile
663 src/liblzma/common/Makefile
664 src/liblzma/check/Makefile
665 src/liblzma/lz/Makefile
666 src/liblzma/lzma/Makefile
667 src/liblzma/simple/Makefile
668 src/liblzma/subblock/Makefile
669 src/liblzma/rangecoder/Makefile