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.
34 # We do some special things on Windows (32-bit or 64-bit) builds.
36 mingw* | cygwin*) is_w32=yes ;;
39 AM_CONDITIONAL([COND_W32], [test "$is_w32" = yes])
43 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 m4_define([SUPPORTED_FILTERS], [lzma1,lzma2,subblock,delta,x86,powerpc,ia64,arm,armthumb,sparc])dnl
67 m4_define([SIMPLE_FILTERS], [x86,powerpc,ia64,arm,armthumb,sparc])
68 m4_define([LZ_FILTERS], [lzma1,lzma2])
70 m4_foreach([NAME], [SUPPORTED_FILTERS],
71 [enable_filter_[]NAME=no
72 enable_encoder_[]NAME=no
73 enable_decoder_[]NAME=no
76 AC_MSG_CHECKING([which encoders to build])
77 AC_ARG_ENABLE([encoders], AC_HELP_STRING([--enable-encoders=LIST],
78 [Comma-separated list of encoders to build. Default=all.
80 m4_translit(m4_defn([SUPPORTED_FILTERS]), [,], [ ])),
81 [], [enable_encoders=SUPPORTED_FILTERS])
82 enable_encoders=`echo "$enable_encoders" | sed 's/,subblock//; s/,/ /g'`
83 if test "x$enable_encoders" = xno || test "x$enable_encoders" = x; then
84 AC_MSG_RESULT([(none)])
86 AC_DEFINE([HAVE_ENCODER], [1],
87 [Define to 1 if encoder components are enabled.])
88 for arg in $enable_encoders
90 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
92 enable_filter_[]NAME=yes
93 enable_encoder_[]NAME=yes
94 AC_DEFINE(HAVE_ENCODER_[]m4_toupper(NAME), [1],
95 [Define to 1 if] NAME [encoder is enabled.])
99 AC_MSG_ERROR([unknown filter: $arg])
103 AC_MSG_RESULT([$enable_encoders])
106 AC_MSG_CHECKING([which decoders to build])
107 AC_ARG_ENABLE([decoders], AC_HELP_STRING([--enable-decoders=LIST],
108 [Comma-separated list of decoders to build. Default=all.
109 Available decoders are the same as available encoders.]),
110 [], [enable_decoders=SUPPORTED_FILTERS])
111 enable_decoders=`echo "$enable_decoders" | sed 's/,subblock//; s/,/ /g'`
112 if test "x$enable_decoders" = xno || test "x$enable_decoders" = x; then
113 AC_MSG_RESULT([(none)])
115 AC_DEFINE([HAVE_DECODER], [1],
116 [Define to 1 if decoder components are enabled.])
117 for arg in $enable_decoders
119 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
121 enable_filter_[]NAME=yes
122 enable_decoder_[]NAME=yes
123 AC_DEFINE(HAVE_DECODER_[]m4_toupper(NAME), [1],
124 [Define to 1 if] NAME [decoder is enabled.])
128 AC_MSG_ERROR([unknown filter: $arg])
133 # LZMA2 requires that LZMA1 is enabled.
134 test "x$enable_encoder_lzma2" = xyes && enable_encoder_lzma1=yes
135 test "x$enable_decoder_lzma2" = xyes && enable_decoder_lzma1=yes
137 AC_MSG_RESULT([$enable_decoders])
140 if test "x$enable_encoder_lzma2$enable_encoder_lzma1" = xyesno \
141 || test "x$enable_decoder_lzma2$enable_decoder_lzma1" = xyesno; then
142 AC_MSG_ERROR([LZMA2 requires that LZMA1 is also enabled.])
145 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoders" != xno && test "x$enable_encoders" != x)
146 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoders" != xno && test "x$enable_decoders" != x)
148 m4_foreach([NAME], [SUPPORTED_FILTERS],
149 [AM_CONDITIONAL(COND_FILTER_[]m4_toupper(NAME), test "x$enable_filter_[]NAME" = xyes)
150 AM_CONDITIONAL(COND_ENCODER_[]m4_toupper(NAME), test "x$enable_encoder_[]NAME" = xyes)
151 AM_CONDITIONAL(COND_DECODER_[]m4_toupper(NAME), test "x$enable_decoder_[]NAME" = xyes)
154 # The so called "simple filters" share common code.
155 enable_filter_simple=no
156 enable_encoder_simple=no
157 enable_decoder_simple=no
158 m4_foreach([NAME], [SIMPLE_FILTERS],
159 [test "x$enable_filter_[]NAME" = xyes && enable_filter_simple=yes
160 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_simple=yes
161 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_simple=yes
163 AM_CONDITIONAL(COND_FILTER_SIMPLE, test "x$enable_filter_simple" = xyes)
164 AM_CONDITIONAL(COND_ENCODER_SIMPLE, test "x$enable_encoder_simple" = xyes)
165 AM_CONDITIONAL(COND_DECODER_SIMPLE, test "x$enable_decoder_simple" = xyes)
167 # LZ-based filters share common code.
171 m4_foreach([NAME], [LZ_FILTERS],
172 [test "x$enable_filter_[]NAME" = xyes && enable_filter_lz=yes
173 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_lz=yes
174 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_lz=yes
176 AM_CONDITIONAL(COND_FILTER_LZ, test "x$enable_filter_lz" = xyes)
177 AM_CONDITIONAL(COND_ENCODER_LZ, test "x$enable_encoder_lz" = xyes)
178 AM_CONDITIONAL(COND_DECODER_LZ, test "x$enable_decoder_lz" = xyes)
185 m4_define([SUPPORTED_MATCH_FINDERS], [hc3,hc4,bt2,bt3,bt4])
187 m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS],
188 [enable_match_finder_[]NAME=no
191 AC_MSG_CHECKING([which match finders to build])
192 AC_ARG_ENABLE([match-finders], AC_HELP_STRING([--enable-match-finders=LIST],
193 [Comma-separated list of match finders to build. Default=all.
194 At least one match finder is required for encoding with
195 the LZMA1 and LZMA2 filters. Available match finders:]
196 m4_translit(m4_defn([SUPPORTED_MATCH_FINDERS]), [,], [ ])), [],
197 [enable_match_finders=SUPPORTED_MATCH_FINDERS])
198 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
199 if test "x$enable_encoder_lz" = xyes ; then
200 for arg in $enable_match_finders
202 case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
204 enable_match_finder_[]NAME=yes
205 AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
206 [Define to 1 to enable] NAME [match finder.])
210 AC_MSG_ERROR([unknown match finder: $arg])
214 AC_MSG_RESULT([$enable_match_finders])
216 AC_MSG_RESULT([(none because not building any LZ-based encoder)])
224 m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
226 m4_foreach([NAME], [SUPPORTED_FILTERS],
227 [enable_check_[]NAME=no
230 AC_MSG_CHECKING([which integrity checks to build])
231 AC_ARG_ENABLE([checks], AC_HELP_STRING([--enable-checks=LIST],
232 [Comma-separated list of integrity checks to build.
233 Default=all. Available integrity checks:]
234 m4_translit(m4_defn([SUPPORTED_CHECKS]), [,], [ ])),
235 [], [enable_checks=SUPPORTED_CHECKS])
236 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
237 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
238 AC_MSG_RESULT([(none)])
240 for arg in $enable_checks
242 case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
244 enable_check_[]NAME=yes
245 AC_DEFINE(HAVE_CHECK_[]m4_toupper(NAME), [1],
246 [Define to 1 if] NAME
247 [integrity check is enabled.])
251 AC_MSG_ERROR([unknown integrity check: $arg])
255 AC_MSG_RESULT([$enable_checks])
257 if test "x$enable_checks_crc32" = xno ; then
258 AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
261 m4_foreach([NAME], [SUPPORTED_CHECKS],
262 [AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
266 ###########################
267 # Assembler optimizations #
268 ###########################
270 AC_MSG_CHECKING([if assembler optimizations should be used])
271 AC_ARG_ENABLE([assembler], AC_HELP_STRING([--disable-assembler],
272 [Do not use assembler optimizations even if such exist
273 for the architecture.]),
274 [], [enable_assembler=yes])
275 if test "x$enable_assembler" = xyes; then
277 i?86) enable_assembler=x86 ;;
278 x86_64) enable_assembler=x86_64 ;;
279 *) enable_assembler=no ;;
282 case $enable_assembler in
284 AC_DEFINE([HAVE_ASM_X86], [1],
285 [Define to 1 if using x86 assembler optimizations.])
288 AC_DEFINE([HAVE_ASM_X86_64], [1],
289 [Define to 1 if using x86_64 assembler optimizations.])
295 AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', \`x86', or \`x86_64'.])
298 AC_MSG_RESULT([$enable_assembler])
299 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
300 AM_CONDITIONAL(COND_ASM_X86_64, test "x$enable_assembler" = xx86_64)
303 ################################
304 # Fast unaligned memory access #
305 ################################
307 AC_MSG_CHECKING([if unaligned memory access should be used])
308 AC_ARG_ENABLE([unaligned-access], AC_HELP_STRING([--enable-unaligned-access],
309 [Enable if the system supports *fast* unaligned memory access
310 with 16-bit and 32-bit integers. By default, this is enabled
311 only on x86, x86_64, and big endian PowerPC.]),
312 [], [enable_unaligned_access=auto])
313 if test "x$enable_unaligned_access" = xauto ; then
315 i?86|x86_64|powerpc|powerpc64)
316 enable_unaligned_access=yes
319 enable_unaligned_access=no
323 if test "x$enable_unaligned_access" = xyes ; then
324 AC_DEFINE([HAVE_FAST_UNALIGNED_ACCESS], [1], [Define to 1 if
325 the system supports fast unaligned memory access.])
332 #####################
333 # Size optimization #
334 #####################
336 AC_MSG_CHECKING([if small size is preferred over speed])
337 AC_ARG_ENABLE([small], AC_HELP_STRING([--enable-small],
338 [Make liblzma smaller and a little slower.
339 This is disabled by default to optimize for speed.]),
340 [], [enable_small=no])
341 if test "x$enable_small" = xyes; then
342 AC_DEFINE([HAVE_SMALL], [1], [Define to 1 if optimizing for size.])
343 elif test "x$enable_small" != xno; then
345 AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
347 AC_MSG_RESULT([$enable_small])
348 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
355 AC_MSG_CHECKING([if threading support is wanted])
356 AC_ARG_ENABLE([threads], AC_HELP_STRING([--disable-threads],
357 [Disable threading support.
358 This makes some things thread-unsafe.]),
359 [], [enable_threads=yes])
360 if test "x$enable_threads" != xyes && test "x$enable_threads" != xno; then
362 AC_MSG_ERROR([--enable-threads accepts only \`yes' or \`no'])
364 AC_MSG_RESULT([$enable_threads])
365 # We use the actual result a little later.
368 ############################################
369 # xz/xzdec/lzmadec linkage against liblzma #
370 ############################################
372 # Link the command line tool statically against liblzma unless using
373 # --enable-dynamic. Using static liblzma gives a little bit faster executable
374 # on x86, because no register is wasted for PIC. We also have one dependency
375 # less, which allows users to more freely copy the xz binary to other boxes.
376 # However, I wouldn't be surprised if distro maintainers still prefer dynamic
377 # linking, so let's make it easy for them.
379 AC_MSG_CHECKING([how command line tools should be linked against liblzma])
380 AC_ARG_ENABLE([dynamic], [AC_HELP_STRING([--enable-dynamic],
381 [Link command line tools dynamically against liblzma.
382 The default is to use static liblzma if it was
384 [], [enable_dynamic=no])
385 case $enable_dynamic in
389 AC_MSG_RESULT([dynamically])
392 STATIC_CPPFLAGS="-DLZMA_API_STATIC"
393 STATIC_LDFLAGS="-static"
394 AC_MSG_RESULT([statically])
398 AC_MSG_ERROR([--enable-dynamic accepts only \`yes' or \`no'])
401 AC_SUBST([STATIC_CPPFLAGS])
402 AC_SUBST([STATIC_LDFLAGS])
405 ###############################################################################
406 # Checks for programs.
407 ###############################################################################
410 echo "Initializing Automake:"
412 AM_INIT_AUTOMAKE([1.10 foreign tar-v7 filename-length-max=99])
416 if test x$ac_cv_prog_cc_c99 = xno ; then
417 AC_MSG_ERROR([No C99 compiler was found.])
422 AC_USE_SYSTEM_EXTENSIONS
424 if test "x$enable_threads" = xyes; then
426 echo "Threading support:"
428 LIBS="$LIBS $PTHREAD_LIBS"
429 AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
434 echo "Initializing Libtool:"
441 dnl Some day we can drop support for libtool 1.5.x. Then the above five
442 dnl lines can be replaced with these:
443 dnl LT_INIT([win32-dll])
444 dnl LT_LANG([Windows Resource])
446 # This is a bit wrong since it is possible to request that only some libs
447 # are built as shared. Using that feature isn't so common though, and this
448 # breaks only on Windows (at least for now) if the user enables only some
450 AM_CONDITIONAL([COND_SHARED], [test "x$enable_shared" != xno])
453 ###############################################################################
454 # Checks for libraries.
455 ###############################################################################
458 echo "Initializing gettext:"
459 AM_GNU_GETTEXT_VERSION([0.16.1])
460 AM_GNU_GETTEXT([external])
462 ###############################################################################
463 # Checks for header files.
464 ###############################################################################
467 echo "System headers and functions:"
469 # There is currently no workarounds in this package if some of
470 # these headers are missing.
471 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
473 [AC_MSG_ERROR([Required header file(s) are missing.])])
475 # If any of these headers are missing, things should still work correctly:
476 AC_CHECK_HEADERS([sys/param.h sys/sysctl.h byteswap.h],
478 #ifdef HAVE_SYS_PARAM_H
479 # include <sys/param.h>
483 # Even if we have byteswap.h, we may lack the specific macros/functions.
484 if test x$ac_cv_header_byteswap_h = xyes ; then
485 m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
486 AC_MSG_CHECKING([if FUNC is available])
487 AC_LINK_IFELSE([AC_LANG_SOURCE([
488 #include <byteswap.h>
496 AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
497 [Define to 1 if] FUNC [is available.])
499 ], [AC_MSG_RESULT([no])])
505 ###############################################################################
506 # Checks for typedefs, structures, and compiler characteristics.
507 ###############################################################################
509 dnl We don't need these as long as we need a C99 compiler anyway.
523 AC_CHECK_SIZEOF([size_t])
525 # The command line tool can copy high resolution timestamps if such
526 # information is availabe in struct stat. Otherwise one second accuracy
529 struct stat.st_atim.tv_nsec,
530 struct stat.st_atimespec.tv_nsec,
531 struct stat.st_atimensec,
532 struct stat.st_uatime,
533 struct stat.st_atim.st__tim.tv_nsec])
539 ###############################################################################
540 # Checks for library functions.
541 ###############################################################################
543 # Gnulib replacements as needed
546 # Find the best function to set timestamps.
547 AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
553 ###############################################################################
554 # If using GCC, set some additional AM_CFLAGS:
555 ###############################################################################
557 if test "$GCC" = yes ; then
559 echo "GCC extensions:"
562 # Always do the visibility check but don't set AM_CFLAGS on Windows.
563 # This way things get set properly even on Windows.
565 if test -n "$CFLAG_VISIBILITY" && test "$is_w32" = no; then
566 AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
569 if test "$GCC" = yes ; then
570 # Enable as much warnings as possible. These commented warnings won't
571 # work for this package though:
572 # * -Wunreachable-code breaks several assert(0) cases, which are
573 # backed up with "return LZMA_PROG_ERROR".
574 # * -Wcast-qual would break various things where we need a non-const
575 # pointer although we don't modify anything through it.
576 # * -Wcast-align breaks optimized CRC32 and CRC64 implementation
577 # on some architectures (not on x86), where this warning is bogus,
578 # because we take care of correct alignment.
579 # * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
580 # don't seem so useful here; at least the last one gives some
581 # warnings which are not bugs.
587 -Wmissing-include-dirs \
593 -Wbad-function-cast \
597 -Wstrict-prototypes \
598 -Wold-style-definition \
599 -Wmissing-prototypes \
600 -Wmissing-declarations \
604 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
606 CFLAGS="$CFLAGS $NEW_FLAG"
607 AC_COMPILE_IFELSE([void foo(void) { }], [
608 AM_CFLAGS="$AM_CFLAGS $NEW_FLAG"
616 AC_ARG_ENABLE([werror],
617 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
618 compilation on all compiler warnings.]),
619 [], [enable_werror=no])
620 if test "x$enable_werror" = "xyes"; then
621 AM_CFLAGS="$AM_CFLAGS -Werror"
626 ###############################################################################
627 # Create the makefiles and config.h
628 ###############################################################################
632 # Don't build the lib directory at all if we don't need any replacement
634 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
636 # Add default AM_CFLAGS.
637 AC_SUBST([AM_CFLAGS])
645 src/liblzma/liblzma.pc
647 src/liblzma/api/Makefile