2 # Process this file with autoconf to produce a configure script.
4 ###############################################################################
8 # This file has been put into the public domain.
9 # You can do whatever you want with this file.
11 ###############################################################################
13 # NOTE: Don't add useless checks. autoscan detects this and that, but don't
14 # let it confuse you. For example, we don't care about checking for behavior
15 # of malloc(), stat(), or lstat(), since we don't use those functions in
16 # a way that would cause the problems the autoconf macros check.
20 AC_INIT([XZ Utils], m4_esyscmd([/bin/sh version.sh]),
21 [lasse.collin@tukaani.org], [xz])
22 AC_CONFIG_SRCDIR([src/liblzma/common/common.h])
23 AC_CONFIG_HEADER([config.h])
24 AC_CONFIG_MACRO_DIR([m4])
27 echo "$PACKAGE_STRING"
31 # This is needed to know if assembler optimizations can be used.
36 echo "Configure options:"
44 AC_MSG_CHECKING([if debugging code should be compiled])
45 AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable debugging code.]),
47 if test "x$enable_debug" = xyes; then
50 AC_DEFINE([NDEBUG], [1], [Define to 1 to disable debugging code.])
59 AC_MSG_CHECKING([if encoder components should be built])
60 AC_ARG_ENABLE([encoder], AC_HELP_STRING([--disable-encoder],
61 [Do not build the encoder components.]),
62 [], enable_encoder=yes)
63 if test "x$enable_encoder" = xyes; then
64 AC_DEFINE([HAVE_ENCODER], [1],
65 [Define to 1 if encoder components are enabled.])
70 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoder" = xyes)
77 AC_MSG_CHECKING([if decoder components should be built])
78 AC_ARG_ENABLE([decoder], AC_HELP_STRING([--disable-decoder],
79 [Do not build the decoder components.]),
80 [], enable_decoder=yes)
81 if test "x$enable_decoder" = xyes; then
82 AC_DEFINE([HAVE_DECODER], [1],
83 [Define to 1 if decoder components are enabled.])
87 if test "x$enable_encoder" = xno; then
88 AC_MSG_ERROR([Do not disable both encoder and decoder.])
91 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoder" = xyes)
98 m4_define([SUPPORTED_FILTERS], [lzma1,lzma2,subblock,delta,x86,powerpc,ia64,arm,armthumb,sparc])dnl
99 m4_define([SIMPLE_FILTERS], [x86,powerpc,ia64,arm,armthumb,sparc])
100 m4_define([LZ_FILTERS], [lzma1,lzma2])
102 m4_foreach([NAME], [SUPPORTED_FILTERS],
103 [enable_filter_[]NAME=no
104 enable_encoder_[]NAME=no
105 enable_decoder_[]NAME=no
108 AC_MSG_CHECKING([which encoders to build])
109 AC_ARG_ENABLE([encoders], AC_HELP_STRING([--enable-encoders=LIST],
110 [Comma-separated list of encoders to build. Default=all.
112 m4_translit(m4_defn([SUPPORTED_FILTERS]), [,], [ ])),
113 [], [enable_encoders=SUPPORTED_FILTERS])
114 enable_encoders=`echo "$enable_encoders" | sed 's/,subblock//; s/,/ /g'`
115 if test "x$enable_encoders" = xno || test "x$enable_encoders" = x; then
116 AC_MSG_RESULT([(none)])
118 for arg in $enable_encoders
120 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
122 enable_filter_[]NAME=yes
123 enable_encoder_[]NAME=yes
124 AC_DEFINE(HAVE_ENCODER_[]m4_toupper(NAME), [1],
125 [Define to 1 if] NAME [encoder is enabled.])
129 AC_MSG_ERROR([unknown filter: $arg])
133 AC_MSG_RESULT([$enable_encoders])
136 AC_MSG_CHECKING([which decoders to build])
137 AC_ARG_ENABLE([decoders], AC_HELP_STRING([--enable-decoders=LIST],
138 [Comma-separated list of decoders to build. Default=all.
139 Available decoders are the same as available encoders.]),
140 [], [enable_decoders=SUPPORTED_FILTERS])
141 enable_decoders=`echo "$enable_decoders" | sed 's/,subblock//; s/,/ /g'`
142 if test "x$enable_decoders" = xno || test "x$enable_decoders" = x; then
143 AC_MSG_RESULT([(none)])
145 for arg in $enable_decoders
147 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
149 enable_filter_[]NAME=yes
150 enable_decoder_[]NAME=yes
151 AC_DEFINE(HAVE_DECODER_[]m4_toupper(NAME), [1],
152 [Define to 1 if] NAME [decoder is enabled.])
156 AC_MSG_ERROR([unknown filter: $arg])
161 # LZMA2 requires that LZMA1 is enabled.
162 test "x$enable_encoder_lzma2" = xyes && enable_encoder_lzma1=yes
163 test "x$enable_decoder_lzma2" = xyes && enable_decoder_lzma1=yes
165 AC_MSG_RESULT([$enable_decoders])
168 if test "x$enable_encoder_lzma2$enable_encoder_lzma1" = xyesno \
169 || test "x$enable_decoder_lzma2$enable_decoder_lzma1" = xyesno; then
170 AC_MSG_ERROR([LZMA2 requires that LZMA1 is also enabled.])
173 m4_foreach([NAME], [SUPPORTED_FILTERS],
174 [AM_CONDITIONAL(COND_FILTER_[]m4_toupper(NAME), test "x$enable_filter_[]NAME" = xyes)
175 AM_CONDITIONAL(COND_ENCODER_[]m4_toupper(NAME), test "x$enable_encoder_[]NAME" = xyes)
176 AM_CONDITIONAL(COND_DECODER_[]m4_toupper(NAME), test "x$enable_decoder_[]NAME" = xyes)
179 # The so called "simple filters" share common code.
180 enable_filter_simple=no
181 enable_encoder_simple=no
182 enable_decoder_simple=no
183 m4_foreach([NAME], [SIMPLE_FILTERS],
184 [test "x$enable_filter_[]NAME" = xyes && enable_filter_simple=yes
185 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_simple=yes
186 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_simple=yes
188 AM_CONDITIONAL(COND_FILTER_SIMPLE, test "x$enable_filter_simple" = xyes)
189 AM_CONDITIONAL(COND_ENCODER_SIMPLE, test "x$enable_encoder_simple" = xyes)
190 AM_CONDITIONAL(COND_DECODER_SIMPLE, test "x$enable_decoder_simple" = xyes)
192 # LZ-based filters share common code.
196 m4_foreach([NAME], [LZ_FILTERS],
197 [test "x$enable_filter_[]NAME" = xyes && enable_filter_lz=yes
198 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_lz=yes
199 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_lz=yes
201 AM_CONDITIONAL(COND_FILTER_LZ, test "x$enable_filter_lz" = xyes)
202 AM_CONDITIONAL(COND_ENCODER_LZ, test "x$enable_encoder_lz" = xyes)
203 AM_CONDITIONAL(COND_DECODER_LZ, test "x$enable_decoder_lz" = xyes)
210 m4_define([SUPPORTED_MATCH_FINDERS], [hc3,hc4,bt2,bt3,bt4])
212 m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS],
213 [enable_match_finder_[]NAME=no
216 AC_MSG_CHECKING([which match finders to build])
217 AC_ARG_ENABLE([match-finders], AC_HELP_STRING([--enable-match-finders=LIST],
218 [Comma-separated list of match finders to build. Default=all.
219 At least one match finder is required for encoding with
220 the LZMA1 and LZMA2 filters. Available match finders:]
221 m4_translit(m4_defn([SUPPORTED_MATCH_FINDERS]), [,], [ ])), [],
222 [enable_match_finders=SUPPORTED_MATCH_FINDERS])
223 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
224 if test "x$enable_encoder" = xyes && test "x$enable_encoder_lz" = xyes ; then
225 for arg in $enable_match_finders
227 case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
229 enable_match_finder_[]NAME=yes
230 AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
231 [Define to 1 to enable] NAME [match finder.])
235 AC_MSG_ERROR([unknown match finder: $arg])
239 AC_MSG_RESULT([$enable_match_finders])
241 AC_MSG_RESULT([(none because not building any LZ-based encoder)])
249 m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
251 m4_foreach([NAME], [SUPPORTED_FILTERS],
252 [enable_check_[]NAME=no
255 AC_MSG_CHECKING([which integrity checks to build])
256 AC_ARG_ENABLE([checks], AC_HELP_STRING([--enable-checks=LIST],
257 [Comma-separated list of integrity checks to build.
258 Default=all. Available integrity checks:]
259 m4_translit(m4_defn([SUPPORTED_CHECKS]), [,], [ ])),
260 [], [enable_checks=SUPPORTED_CHECKS])
261 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
262 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
263 AC_MSG_RESULT([(none)])
265 for arg in $enable_checks
267 case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
269 enable_check_[]NAME=yes
270 AC_DEFINE(HAVE_CHECK_[]m4_toupper(NAME), [1],
271 [Define to 1 if] NAME
272 [integrity check is enabled.])
276 AC_MSG_ERROR([unknown integrity check: $arg])
280 AC_MSG_RESULT([$enable_checks])
282 if test "x$enable_checks_crc32" = xno ; then
283 AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
286 m4_foreach([NAME], [SUPPORTED_CHECKS],
287 [AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
291 ###########################
292 # Assembler optimizations #
293 ###########################
295 AC_MSG_CHECKING([if assembler optimizations should be used])
296 AC_ARG_ENABLE([assembler], AC_HELP_STRING([--disable-assembler],
297 [Do not use assembler optimizations even if such exist
298 for the architecture.]),
299 [], [enable_assembler=yes])
300 if test "x$enable_assembler" = xyes; then
302 i?86) enable_assembler=x86 ;;
303 x86_64) enable_assembler=x86_64 ;;
304 *) enable_assembler=no ;;
307 case $enable_assembler in
309 AC_DEFINE([HAVE_ASM_X86], [1],
310 [Define to 1 if using x86 assembler optimizations.])
313 AC_DEFINE([HAVE_ASM_X86_64], [1],
314 [Define to 1 if using x86_64 assembler optimizations.])
320 AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', \`x86', or \`x86_64'.])
323 AC_MSG_RESULT([$enable_assembler])
324 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
325 AM_CONDITIONAL(COND_ASM_X86_64, test "x$enable_assembler" = xx86_64)
328 ################################
329 # Fast unaligned memory access #
330 ################################
332 AC_MSG_CHECKING([if unaligned memory access should be used])
333 AC_ARG_ENABLE([unaligned-access], AC_HELP_STRING([--enable-unaligned-access],
334 [Enable if the system supports *fast* unaligned memory access
335 with 16-bit and 32-bit integers. By default, this is enabled
336 only on x86, x86_64, and big endian PowerPC.]),
337 [], [enable_unaligned_access=auto])
338 if test "x$enable_unaligned_access" = xauto ; then
340 i?86|x86_64|powerpc|powerpc64)
341 enable_unaligned_access=yes
344 enable_unaligned_access=no
348 if test "x$enable_unaligned_access" = xyes ; then
349 AC_DEFINE([HAVE_FAST_UNALIGNED_ACCESS], [1], [Define to 1 if
350 the system supports fast unaligned memory access.])
357 #####################
358 # Size optimization #
359 #####################
361 AC_MSG_CHECKING([if small size is preferred over speed])
362 AC_ARG_ENABLE([small], AC_HELP_STRING([--enable-small],
363 [Make liblzma smaller and a little slower.
364 This is disabled by default to optimize for speed.]),
365 [], [enable_small=no])
366 if test "x$enable_small" = xyes; then
367 AC_DEFINE([HAVE_SMALL], [1], [Define to 1 if optimizing for size.])
368 elif test "x$enable_small" != xno; then
370 AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
372 AC_MSG_RESULT([$enable_small])
373 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
380 AC_MSG_CHECKING([if threading support is wanted])
381 AC_ARG_ENABLE([threads], AC_HELP_STRING([--disable-threads],
382 [Disable threading support.
383 This makes some things thread-unsafe.]),
384 [], [enable_threads=yes])
385 if test "x$enable_threads" != xyes && test "x$enable_threads" != xno; then
387 AC_MSG_ERROR([--enable-threads accepts only \`yes' or \`no'])
389 AC_MSG_RESULT([$enable_threads])
390 # We use the actual result a little later.
393 ############################################
394 # xz/xzdec/lzmadec linkage against liblzma #
395 ############################################
397 # Link the command line tool statically against liblzma unless using
398 # --enable-dynamic. Using static liblzma gives a little bit faster executable
399 # on x86, because no register is wasted for PIC. We also have one dependency
400 # less, which allows users to more freely copy the xz binary to other boxes.
401 # However, I wouldn't be surprised if distro maintainers still prefer dynamic
402 # linking, so let's make it easy for them.
404 AC_MSG_CHECKING([how command line tools should be linked against liblzma])
405 AC_ARG_ENABLE([dynamic], [AC_HELP_STRING([--enable-dynamic],
406 [Link command line tools dynamically against liblzma.
407 The default is to use static liblzma if it was
409 [], [enable_dynamic=no])
410 case $enable_dynamic in
414 AC_MSG_RESULT([dynamically])
417 STATIC_CPPFLAGS="-DLZMA_API_STATIC"
418 STATIC_LDFLAGS="-static"
419 AC_MSG_RESULT([statically])
423 AC_MSG_ERROR([--enable-dynamic accepts only \`yes' or \`no'])
426 AC_SUBST([STATIC_CPPFLAGS])
427 AC_SUBST([STATIC_LDFLAGS])
430 ###############################################################################
431 # Checks for programs.
432 ###############################################################################
435 echo "Initializing Automake:"
437 AM_INIT_AUTOMAKE([1.10 foreign tar-v7 filename-length-max=99])
441 if test x$ac_cv_prog_cc_c99 = xno ; then
442 AC_MSG_ERROR([No C99 compiler was found.])
447 AC_USE_SYSTEM_EXTENSIONS
449 if test "x$enable_threads" = xyes; then
451 echo "Threading support:"
453 LIBS="$LIBS $PTHREAD_LIBS"
454 AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
459 echo "Initializing Libtool:"
465 ###############################################################################
466 # Checks for libraries.
467 ###############################################################################
470 echo "Initializing gettext:"
471 AM_GNU_GETTEXT_VERSION([0.16.1])
472 AM_GNU_GETTEXT([external])
474 ###############################################################################
475 # Checks for header files.
476 ###############################################################################
479 echo "System headers and functions:"
481 # There is currently no workarounds in this package if some of
482 # these headers are missing.
483 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
485 [AC_MSG_ERROR([Required header file(s) are missing.])])
487 # If any of these headers are missing, things should still work correctly:
488 AC_CHECK_HEADERS([sys/param.h sys/sysctl.h byteswap.h],
490 #ifdef HAVE_SYS_PARAM_H
491 # include <sys/param.h>
495 # Even if we have byteswap.h, we may lack the specific macros/functions.
496 if test x$ac_cv_header_byteswap_h = xyes ; then
497 m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
498 AC_MSG_CHECKING([if FUNC is available])
499 AC_LINK_IFELSE([AC_LANG_SOURCE([
500 #include <byteswap.h>
508 AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
509 [Define to 1 if] FUNC [is available.])
511 ], [AC_MSG_RESULT([no])])
517 ###############################################################################
518 # Checks for typedefs, structures, and compiler characteristics.
519 ###############################################################################
521 dnl We don't need these as long as we need a C99 compiler anyway.
535 AC_CHECK_SIZEOF([size_t])
537 # The command line tool can copy high resolution timestamps if such
538 # information is availabe in struct stat. Otherwise one second accuracy
541 struct stat.st_atim.tv_nsec,
542 struct stat.st_atimespec.tv_nsec,
543 struct stat.st_atimensec,
544 struct stat.st_uatime,
545 struct stat.st_atim.st__tim.tv_nsec])
551 ###############################################################################
552 # Checks for library functions.
553 ###############################################################################
555 # Gnulib replacements as needed
558 # Find the best function to set timestamps.
559 AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
565 ###############################################################################
566 # If using GCC, set some additional AM_CFLAGS:
567 ###############################################################################
571 if test "x$GCC" = xyes ; then
573 echo "GCC extensions:"
575 if test -n "$CFLAG_VISIBILITY" ; then
576 AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
579 # -Wno-uninitialized is needed with -Werror with SHA256 code
580 # to omit a bogus warning.
581 AC_MSG_CHECKING([if $CC accepts -Wno-uninitialized])
583 CFLAGS="$CFLAGS -Wno-uninitialized"
584 AC_COMPILE_IFELSE([void foo(void) { }], [Wno_uninitialized=yes])
586 AC_MSG_RESULT([$Wno_uninitialized])
588 # Enable as much warnings as possible. These commented warnings won't
589 # work for this package though:
590 # * -Wunreachable-code breaks several assert(0) cases, which are
591 # backed up with "return LZMA_PROG_ERROR".
592 # * -Wcast-qual would break various things where we need a non-const
593 # pointer although we don't modify anything through it.
594 # * -Wcast-align breaks optimized CRC32 and CRC64 implementation
595 # on some architectures (not on x86), where this warning is bogus,
596 # because we take care of correct alignment.
597 # * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
598 # don't seem so useful here; at least the last one gives some
599 # warnings which are not bugs.
605 -Wmissing-include-dirs \
611 -Wbad-function-cast \
615 -Wstrict-prototypes \
616 -Wold-style-definition \
617 -Wmissing-prototypes \
618 -Wmissing-declarations \
622 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
624 CFLAGS="$CFLAGS $NEW_FLAG"
625 AC_COMPILE_IFELSE([void foo(void) { }], [
626 AM_CFLAGS="$AM_CFLAGS $NEW_FLAG"
634 AC_ARG_ENABLE([werror],
635 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
636 compilation on all compiler warnings.]),
637 [], [enable_werror=no])
638 if test "x$enable_werror" = "xyes"; then
639 AM_CFLAGS="$AM_CFLAGS -Werror"
643 AM_CONDITIONAL([COND_WNO_UNINITIALIZED], test "x$Wno_uninitialized" = "xyes")
646 ###############################################################################
647 # Create the makefiles and config.h
648 ###############################################################################
652 # Don't build the lib directory at all if we don't need any replacement
654 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
656 # Add default AM_CFLAGS.
657 AC_SUBST([AM_CFLAGS])
665 src/liblzma/liblzma.pc
667 src/liblzma/api/Makefile
668 src/liblzma/common/Makefile
669 src/liblzma/check/Makefile
670 src/liblzma/rangecoder/Makefile
671 src/liblzma/lz/Makefile
672 src/liblzma/lzma/Makefile
673 src/liblzma/subblock/Makefile
674 src/liblzma/delta/Makefile
675 src/liblzma/simple/Makefile