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 m4_define([SUPPORTED_FILTERS], [lzma1,lzma2,subblock,delta,x86,powerpc,ia64,arm,armthumb,sparc])dnl
60 m4_define([SIMPLE_FILTERS], [x86,powerpc,ia64,arm,armthumb,sparc])
61 m4_define([LZ_FILTERS], [lzma1,lzma2])
63 m4_foreach([NAME], [SUPPORTED_FILTERS],
64 [enable_filter_[]NAME=no
65 enable_encoder_[]NAME=no
66 enable_decoder_[]NAME=no
69 AC_MSG_CHECKING([which encoders to build])
70 AC_ARG_ENABLE([encoders], AC_HELP_STRING([--enable-encoders=LIST],
71 [Comma-separated list of encoders to build. Default=all.
73 m4_translit(m4_defn([SUPPORTED_FILTERS]), [,], [ ])),
74 [], [enable_encoders=SUPPORTED_FILTERS])
75 enable_encoders=`echo "$enable_encoders" | sed 's/,subblock//; s/,/ /g'`
76 if test "x$enable_encoders" = xno || test "x$enable_encoders" = x; then
77 AC_MSG_RESULT([(none)])
79 AC_DEFINE([HAVE_ENCODER], [1],
80 [Define to 1 if encoder components are enabled.])
81 for arg in $enable_encoders
83 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
85 enable_filter_[]NAME=yes
86 enable_encoder_[]NAME=yes
87 AC_DEFINE(HAVE_ENCODER_[]m4_toupper(NAME), [1],
88 [Define to 1 if] NAME [encoder is enabled.])
92 AC_MSG_ERROR([unknown filter: $arg])
96 AC_MSG_RESULT([$enable_encoders])
99 AC_MSG_CHECKING([which decoders to build])
100 AC_ARG_ENABLE([decoders], AC_HELP_STRING([--enable-decoders=LIST],
101 [Comma-separated list of decoders to build. Default=all.
102 Available decoders are the same as available encoders.]),
103 [], [enable_decoders=SUPPORTED_FILTERS])
104 enable_decoders=`echo "$enable_decoders" | sed 's/,subblock//; s/,/ /g'`
105 if test "x$enable_decoders" = xno || test "x$enable_decoders" = x; then
106 AC_MSG_RESULT([(none)])
108 AC_DEFINE([HAVE_DECODER], [1],
109 [Define to 1 if decoder components are enabled.])
110 for arg in $enable_decoders
112 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
114 enable_filter_[]NAME=yes
115 enable_decoder_[]NAME=yes
116 AC_DEFINE(HAVE_DECODER_[]m4_toupper(NAME), [1],
117 [Define to 1 if] NAME [decoder is enabled.])
121 AC_MSG_ERROR([unknown filter: $arg])
126 # LZMA2 requires that LZMA1 is enabled.
127 test "x$enable_encoder_lzma2" = xyes && enable_encoder_lzma1=yes
128 test "x$enable_decoder_lzma2" = xyes && enable_decoder_lzma1=yes
130 AC_MSG_RESULT([$enable_decoders])
133 if test "x$enable_encoder_lzma2$enable_encoder_lzma1" = xyesno \
134 || test "x$enable_decoder_lzma2$enable_decoder_lzma1" = xyesno; then
135 AC_MSG_ERROR([LZMA2 requires that LZMA1 is also enabled.])
138 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoders" != xno && test "x$enable_encoders" != x)
139 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoders" != xno && test "x$enable_decoders" != x)
141 m4_foreach([NAME], [SUPPORTED_FILTERS],
142 [AM_CONDITIONAL(COND_FILTER_[]m4_toupper(NAME), test "x$enable_filter_[]NAME" = xyes)
143 AM_CONDITIONAL(COND_ENCODER_[]m4_toupper(NAME), test "x$enable_encoder_[]NAME" = xyes)
144 AM_CONDITIONAL(COND_DECODER_[]m4_toupper(NAME), test "x$enable_decoder_[]NAME" = xyes)
147 # The so called "simple filters" share common code.
148 enable_filter_simple=no
149 enable_encoder_simple=no
150 enable_decoder_simple=no
151 m4_foreach([NAME], [SIMPLE_FILTERS],
152 [test "x$enable_filter_[]NAME" = xyes && enable_filter_simple=yes
153 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_simple=yes
154 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_simple=yes
156 AM_CONDITIONAL(COND_FILTER_SIMPLE, test "x$enable_filter_simple" = xyes)
157 AM_CONDITIONAL(COND_ENCODER_SIMPLE, test "x$enable_encoder_simple" = xyes)
158 AM_CONDITIONAL(COND_DECODER_SIMPLE, test "x$enable_decoder_simple" = xyes)
160 # LZ-based filters share common code.
164 m4_foreach([NAME], [LZ_FILTERS],
165 [test "x$enable_filter_[]NAME" = xyes && enable_filter_lz=yes
166 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_lz=yes
167 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_lz=yes
169 AM_CONDITIONAL(COND_FILTER_LZ, test "x$enable_filter_lz" = xyes)
170 AM_CONDITIONAL(COND_ENCODER_LZ, test "x$enable_encoder_lz" = xyes)
171 AM_CONDITIONAL(COND_DECODER_LZ, test "x$enable_decoder_lz" = xyes)
178 m4_define([SUPPORTED_MATCH_FINDERS], [hc3,hc4,bt2,bt3,bt4])
180 m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS],
181 [enable_match_finder_[]NAME=no
184 AC_MSG_CHECKING([which match finders to build])
185 AC_ARG_ENABLE([match-finders], AC_HELP_STRING([--enable-match-finders=LIST],
186 [Comma-separated list of match finders to build. Default=all.
187 At least one match finder is required for encoding with
188 the LZMA1 and LZMA2 filters. Available match finders:]
189 m4_translit(m4_defn([SUPPORTED_MATCH_FINDERS]), [,], [ ])), [],
190 [enable_match_finders=SUPPORTED_MATCH_FINDERS])
191 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
192 if test "x$enable_encoder_lz" = xyes ; then
193 for arg in $enable_match_finders
195 case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
197 enable_match_finder_[]NAME=yes
198 AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
199 [Define to 1 to enable] NAME [match finder.])
203 AC_MSG_ERROR([unknown match finder: $arg])
207 AC_MSG_RESULT([$enable_match_finders])
209 AC_MSG_RESULT([(none because not building any LZ-based encoder)])
217 m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
219 m4_foreach([NAME], [SUPPORTED_FILTERS],
220 [enable_check_[]NAME=no
223 AC_MSG_CHECKING([which integrity checks to build])
224 AC_ARG_ENABLE([checks], AC_HELP_STRING([--enable-checks=LIST],
225 [Comma-separated list of integrity checks to build.
226 Default=all. Available integrity checks:]
227 m4_translit(m4_defn([SUPPORTED_CHECKS]), [,], [ ])),
228 [], [enable_checks=SUPPORTED_CHECKS])
229 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
230 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
231 AC_MSG_RESULT([(none)])
233 for arg in $enable_checks
235 case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
237 enable_check_[]NAME=yes
238 AC_DEFINE(HAVE_CHECK_[]m4_toupper(NAME), [1],
239 [Define to 1 if] NAME
240 [integrity check is enabled.])
244 AC_MSG_ERROR([unknown integrity check: $arg])
248 AC_MSG_RESULT([$enable_checks])
250 if test "x$enable_checks_crc32" = xno ; then
251 AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
254 m4_foreach([NAME], [SUPPORTED_CHECKS],
255 [AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
259 ###########################
260 # Assembler optimizations #
261 ###########################
263 AC_MSG_CHECKING([if assembler optimizations should be used])
264 AC_ARG_ENABLE([assembler], AC_HELP_STRING([--disable-assembler],
265 [Do not use assembler optimizations even if such exist
266 for the architecture.]),
267 [], [enable_assembler=yes])
268 if test "x$enable_assembler" = xyes; then
270 i?86) enable_assembler=x86 ;;
271 x86_64) enable_assembler=x86_64 ;;
272 *) enable_assembler=no ;;
275 case $enable_assembler in
277 AC_DEFINE([HAVE_ASM_X86], [1],
278 [Define to 1 if using x86 assembler optimizations.])
281 AC_DEFINE([HAVE_ASM_X86_64], [1],
282 [Define to 1 if using x86_64 assembler optimizations.])
288 AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', \`x86', or \`x86_64'.])
291 AC_MSG_RESULT([$enable_assembler])
292 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
293 AM_CONDITIONAL(COND_ASM_X86_64, test "x$enable_assembler" = xx86_64)
296 ################################
297 # Fast unaligned memory access #
298 ################################
300 AC_MSG_CHECKING([if unaligned memory access should be used])
301 AC_ARG_ENABLE([unaligned-access], AC_HELP_STRING([--enable-unaligned-access],
302 [Enable if the system supports *fast* unaligned memory access
303 with 16-bit and 32-bit integers. By default, this is enabled
304 only on x86, x86_64, and big endian PowerPC.]),
305 [], [enable_unaligned_access=auto])
306 if test "x$enable_unaligned_access" = xauto ; then
308 i?86|x86_64|powerpc|powerpc64)
309 enable_unaligned_access=yes
312 enable_unaligned_access=no
316 if test "x$enable_unaligned_access" = xyes ; then
317 AC_DEFINE([HAVE_FAST_UNALIGNED_ACCESS], [1], [Define to 1 if
318 the system supports fast unaligned memory access.])
325 #####################
326 # Size optimization #
327 #####################
329 AC_MSG_CHECKING([if small size is preferred over speed])
330 AC_ARG_ENABLE([small], AC_HELP_STRING([--enable-small],
331 [Make liblzma smaller and a little slower.
332 This is disabled by default to optimize for speed.]),
333 [], [enable_small=no])
334 if test "x$enable_small" = xyes; then
335 AC_DEFINE([HAVE_SMALL], [1], [Define to 1 if optimizing for size.])
336 elif test "x$enable_small" != xno; then
338 AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
340 AC_MSG_RESULT([$enable_small])
341 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
348 AC_MSG_CHECKING([if threading support is wanted])
349 AC_ARG_ENABLE([threads], AC_HELP_STRING([--disable-threads],
350 [Disable threading support.
351 This makes some things thread-unsafe.]),
352 [], [enable_threads=yes])
353 if test "x$enable_threads" != xyes && test "x$enable_threads" != xno; then
355 AC_MSG_ERROR([--enable-threads accepts only \`yes' or \`no'])
357 AC_MSG_RESULT([$enable_threads])
358 # We use the actual result a little later.
361 ############################################
362 # xz/xzdec/lzmadec linkage against liblzma #
363 ############################################
365 # Link the command line tool statically against liblzma unless using
366 # --enable-dynamic. Using static liblzma gives a little bit faster executable
367 # on x86, because no register is wasted for PIC. We also have one dependency
368 # less, which allows users to more freely copy the xz binary to other boxes.
369 # However, I wouldn't be surprised if distro maintainers still prefer dynamic
370 # linking, so let's make it easy for them.
372 AC_MSG_CHECKING([how command line tools should be linked against liblzma])
373 AC_ARG_ENABLE([dynamic], [AC_HELP_STRING([--enable-dynamic],
374 [Link command line tools dynamically against liblzma.
375 The default is to use static liblzma if it was
377 [], [enable_dynamic=no])
378 case $enable_dynamic in
382 AC_MSG_RESULT([dynamically])
385 STATIC_CPPFLAGS="-DLZMA_API_STATIC"
386 STATIC_LDFLAGS="-static"
387 AC_MSG_RESULT([statically])
391 AC_MSG_ERROR([--enable-dynamic accepts only \`yes' or \`no'])
394 AC_SUBST([STATIC_CPPFLAGS])
395 AC_SUBST([STATIC_LDFLAGS])
398 ###############################################################################
399 # Checks for programs.
400 ###############################################################################
403 echo "Initializing Automake:"
405 AM_INIT_AUTOMAKE([1.10 foreign tar-v7 filename-length-max=99])
409 if test x$ac_cv_prog_cc_c99 = xno ; then
410 AC_MSG_ERROR([No C99 compiler was found.])
415 AC_USE_SYSTEM_EXTENSIONS
417 if test "x$enable_threads" = xyes; then
419 echo "Threading support:"
421 LIBS="$LIBS $PTHREAD_LIBS"
422 AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
427 echo "Initializing Libtool:"
433 ###############################################################################
434 # Checks for libraries.
435 ###############################################################################
438 echo "Initializing gettext:"
439 AM_GNU_GETTEXT_VERSION([0.16.1])
440 AM_GNU_GETTEXT([external])
442 ###############################################################################
443 # Checks for header files.
444 ###############################################################################
447 echo "System headers and functions:"
449 # There is currently no workarounds in this package if some of
450 # these headers are missing.
451 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
453 [AC_MSG_ERROR([Required header file(s) are missing.])])
455 # If any of these headers are missing, things should still work correctly:
456 AC_CHECK_HEADERS([sys/param.h sys/sysctl.h byteswap.h],
458 #ifdef HAVE_SYS_PARAM_H
459 # include <sys/param.h>
463 # Even if we have byteswap.h, we may lack the specific macros/functions.
464 if test x$ac_cv_header_byteswap_h = xyes ; then
465 m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
466 AC_MSG_CHECKING([if FUNC is available])
467 AC_LINK_IFELSE([AC_LANG_SOURCE([
468 #include <byteswap.h>
476 AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
477 [Define to 1 if] FUNC [is available.])
479 ], [AC_MSG_RESULT([no])])
485 ###############################################################################
486 # Checks for typedefs, structures, and compiler characteristics.
487 ###############################################################################
489 dnl We don't need these as long as we need a C99 compiler anyway.
503 AC_CHECK_SIZEOF([size_t])
505 # The command line tool can copy high resolution timestamps if such
506 # information is availabe in struct stat. Otherwise one second accuracy
509 struct stat.st_atim.tv_nsec,
510 struct stat.st_atimespec.tv_nsec,
511 struct stat.st_atimensec,
512 struct stat.st_uatime,
513 struct stat.st_atim.st__tim.tv_nsec])
519 ###############################################################################
520 # Checks for library functions.
521 ###############################################################################
523 # Gnulib replacements as needed
526 # Find the best function to set timestamps.
527 AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
533 ###############################################################################
534 # If using GCC, set some additional AM_CFLAGS:
535 ###############################################################################
537 if test "x$GCC" = xyes ; then
539 echo "GCC extensions:"
541 if test -n "$CFLAG_VISIBILITY" ; then
542 AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
545 # Enable as much warnings as possible. These commented warnings won't
546 # work for this package though:
547 # * -Wunreachable-code breaks several assert(0) cases, which are
548 # backed up with "return LZMA_PROG_ERROR".
549 # * -Wcast-qual would break various things where we need a non-const
550 # pointer although we don't modify anything through it.
551 # * -Wcast-align breaks optimized CRC32 and CRC64 implementation
552 # on some architectures (not on x86), where this warning is bogus,
553 # because we take care of correct alignment.
554 # * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
555 # don't seem so useful here; at least the last one gives some
556 # warnings which are not bugs.
562 -Wmissing-include-dirs \
568 -Wbad-function-cast \
572 -Wstrict-prototypes \
573 -Wold-style-definition \
574 -Wmissing-prototypes \
575 -Wmissing-declarations \
579 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
581 CFLAGS="$CFLAGS $NEW_FLAG"
582 AC_COMPILE_IFELSE([void foo(void) { }], [
583 AM_CFLAGS="$AM_CFLAGS $NEW_FLAG"
591 AC_ARG_ENABLE([werror],
592 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
593 compilation on all compiler warnings.]),
594 [], [enable_werror=no])
595 if test "x$enable_werror" = "xyes"; then
596 AM_CFLAGS="$AM_CFLAGS -Werror"
601 ###############################################################################
602 # Create the makefiles and config.h
603 ###############################################################################
607 # Don't build the lib directory at all if we don't need any replacement
609 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
611 # Add default AM_CFLAGS.
612 AC_SUBST([AM_CFLAGS])
620 src/liblzma/liblzma.pc
622 src/liblzma/api/Makefile
623 src/liblzma/common/Makefile
624 src/liblzma/check/Makefile
625 src/liblzma/rangecoder/Makefile
626 src/liblzma/lz/Makefile
627 src/liblzma/lzma/Makefile
628 src/liblzma/subblock/Makefile
629 src/liblzma/delta/Makefile
630 src/liblzma/simple/Makefile