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])
26 PACKAGE_HOMEPAGE=http://tukaani.org/xz/
27 AC_DEFINE_UNQUOTED([PACKAGE_HOMEPAGE], ["$PACKAGE_HOMEPAGE"],
28 [Define to the URL of the home page of this package.])
29 AC_SUBST([PACKAGE_HOMEPAGE])
32 echo "$PACKAGE_STRING"
36 # This is needed to know if assembler optimizations can be used.
39 # We do some special things on Windows (32-bit or 64-bit) builds.
41 mingw* | cygwin*) is_w32=yes ;;
44 AM_CONDITIONAL([COND_W32], [test "$is_w32" = yes])
48 echo "Configure options:"
56 AC_MSG_CHECKING([if debugging code should be compiled])
57 AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable debugging code.]),
59 if test "x$enable_debug" = xyes; then
62 AC_DEFINE([NDEBUG], [1], [Define to 1 to disable debugging code.])
71 m4_define([SUPPORTED_FILTERS], [lzma1,lzma2,subblock,delta,x86,powerpc,ia64,arm,armthumb,sparc])dnl
72 m4_define([SIMPLE_FILTERS], [x86,powerpc,ia64,arm,armthumb,sparc])
73 m4_define([LZ_FILTERS], [lzma1,lzma2])
75 m4_foreach([NAME], [SUPPORTED_FILTERS],
76 [enable_filter_[]NAME=no
77 enable_encoder_[]NAME=no
78 enable_decoder_[]NAME=no
81 AC_MSG_CHECKING([which encoders to build])
82 AC_ARG_ENABLE([encoders], AC_HELP_STRING([--enable-encoders=LIST],
83 [Comma-separated list of encoders to build. Default=all.
85 m4_translit(m4_defn([SUPPORTED_FILTERS]), [,], [ ])),
86 [], [enable_encoders=SUPPORTED_FILTERS])
87 enable_encoders=`echo "$enable_encoders" | sed 's/,subblock//; s/,/ /g'`
88 if test "x$enable_encoders" = xno || test "x$enable_encoders" = x; then
89 AC_MSG_RESULT([(none)])
91 AC_DEFINE([HAVE_ENCODER], [1],
92 [Define to 1 if encoder components are enabled.])
93 for arg in $enable_encoders
95 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
97 enable_filter_[]NAME=yes
98 enable_encoder_[]NAME=yes
99 AC_DEFINE(HAVE_ENCODER_[]m4_toupper(NAME), [1],
100 [Define to 1 if] NAME [encoder is enabled.])
104 AC_MSG_ERROR([unknown filter: $arg])
108 AC_MSG_RESULT([$enable_encoders])
111 AC_MSG_CHECKING([which decoders to build])
112 AC_ARG_ENABLE([decoders], AC_HELP_STRING([--enable-decoders=LIST],
113 [Comma-separated list of decoders to build. Default=all.
114 Available decoders are the same as available encoders.]),
115 [], [enable_decoders=SUPPORTED_FILTERS])
116 enable_decoders=`echo "$enable_decoders" | sed 's/,subblock//; s/,/ /g'`
117 if test "x$enable_decoders" = xno || test "x$enable_decoders" = x; then
118 AC_MSG_RESULT([(none)])
120 AC_DEFINE([HAVE_DECODER], [1],
121 [Define to 1 if decoder components are enabled.])
122 for arg in $enable_decoders
124 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
126 enable_filter_[]NAME=yes
127 enable_decoder_[]NAME=yes
128 AC_DEFINE(HAVE_DECODER_[]m4_toupper(NAME), [1],
129 [Define to 1 if] NAME [decoder is enabled.])
133 AC_MSG_ERROR([unknown filter: $arg])
138 # LZMA2 requires that LZMA1 is enabled.
139 test "x$enable_encoder_lzma2" = xyes && enable_encoder_lzma1=yes
140 test "x$enable_decoder_lzma2" = xyes && enable_decoder_lzma1=yes
142 AC_MSG_RESULT([$enable_decoders])
145 if test "x$enable_encoder_lzma2$enable_encoder_lzma1" = xyesno \
146 || test "x$enable_decoder_lzma2$enable_decoder_lzma1" = xyesno; then
147 AC_MSG_ERROR([LZMA2 requires that LZMA1 is also enabled.])
150 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoders" != xno && test "x$enable_encoders" != x)
151 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoders" != xno && test "x$enable_decoders" != x)
153 m4_foreach([NAME], [SUPPORTED_FILTERS],
154 [AM_CONDITIONAL(COND_FILTER_[]m4_toupper(NAME), test "x$enable_filter_[]NAME" = xyes)
155 AM_CONDITIONAL(COND_ENCODER_[]m4_toupper(NAME), test "x$enable_encoder_[]NAME" = xyes)
156 AM_CONDITIONAL(COND_DECODER_[]m4_toupper(NAME), test "x$enable_decoder_[]NAME" = xyes)
159 # The so called "simple filters" share common code.
160 enable_filter_simple=no
161 enable_encoder_simple=no
162 enable_decoder_simple=no
163 m4_foreach([NAME], [SIMPLE_FILTERS],
164 [test "x$enable_filter_[]NAME" = xyes && enable_filter_simple=yes
165 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_simple=yes
166 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_simple=yes
168 AM_CONDITIONAL(COND_FILTER_SIMPLE, test "x$enable_filter_simple" = xyes)
169 AM_CONDITIONAL(COND_ENCODER_SIMPLE, test "x$enable_encoder_simple" = xyes)
170 AM_CONDITIONAL(COND_DECODER_SIMPLE, test "x$enable_decoder_simple" = xyes)
172 # LZ-based filters share common code.
176 m4_foreach([NAME], [LZ_FILTERS],
177 [test "x$enable_filter_[]NAME" = xyes && enable_filter_lz=yes
178 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_lz=yes
179 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_lz=yes
181 AM_CONDITIONAL(COND_FILTER_LZ, test "x$enable_filter_lz" = xyes)
182 AM_CONDITIONAL(COND_ENCODER_LZ, test "x$enable_encoder_lz" = xyes)
183 AM_CONDITIONAL(COND_DECODER_LZ, test "x$enable_decoder_lz" = xyes)
190 m4_define([SUPPORTED_MATCH_FINDERS], [hc3,hc4,bt2,bt3,bt4])
192 m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS],
193 [enable_match_finder_[]NAME=no
196 AC_MSG_CHECKING([which match finders to build])
197 AC_ARG_ENABLE([match-finders], AC_HELP_STRING([--enable-match-finders=LIST],
198 [Comma-separated list of match finders to build. Default=all.
199 At least one match finder is required for encoding with
200 the LZMA1 and LZMA2 filters. Available match finders:]
201 m4_translit(m4_defn([SUPPORTED_MATCH_FINDERS]), [,], [ ])), [],
202 [enable_match_finders=SUPPORTED_MATCH_FINDERS])
203 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
204 if test "x$enable_encoder_lz" = xyes ; then
205 for arg in $enable_match_finders
207 case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
209 enable_match_finder_[]NAME=yes
210 AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
211 [Define to 1 to enable] NAME [match finder.])
215 AC_MSG_ERROR([unknown match finder: $arg])
219 AC_MSG_RESULT([$enable_match_finders])
221 AC_MSG_RESULT([(none because not building any LZ-based encoder)])
229 m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
231 m4_foreach([NAME], [SUPPORTED_FILTERS],
232 [enable_check_[]NAME=no
235 AC_MSG_CHECKING([which integrity checks to build])
236 AC_ARG_ENABLE([checks], AC_HELP_STRING([--enable-checks=LIST],
237 [Comma-separated list of integrity checks to build.
238 Default=all. Available integrity checks:]
239 m4_translit(m4_defn([SUPPORTED_CHECKS]), [,], [ ])),
240 [], [enable_checks=SUPPORTED_CHECKS])
241 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
242 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
243 AC_MSG_RESULT([(none)])
245 for arg in $enable_checks
247 case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
249 enable_check_[]NAME=yes
250 AC_DEFINE(HAVE_CHECK_[]m4_toupper(NAME), [1],
251 [Define to 1 if] NAME
252 [integrity check is enabled.])
256 AC_MSG_ERROR([unknown integrity check: $arg])
260 AC_MSG_RESULT([$enable_checks])
262 if test "x$enable_checks_crc32" = xno ; then
263 AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
266 m4_foreach([NAME], [SUPPORTED_CHECKS],
267 [AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
271 ###########################
272 # Assembler optimizations #
273 ###########################
275 AC_MSG_CHECKING([if assembler optimizations should be used])
276 AC_ARG_ENABLE([assembler], AC_HELP_STRING([--disable-assembler],
277 [Do not use assembler optimizations even if such exist
278 for the architecture.]),
279 [], [enable_assembler=yes])
280 if test "x$enable_assembler" = xyes; then
282 i?86) enable_assembler=x86 ;;
283 x86_64) enable_assembler=x86_64 ;;
284 *) enable_assembler=no ;;
287 case $enable_assembler in
289 AC_DEFINE([HAVE_ASM_X86], [1],
290 [Define to 1 if using x86 assembler optimizations.])
293 AC_DEFINE([HAVE_ASM_X86_64], [1],
294 [Define to 1 if using x86_64 assembler optimizations.])
300 AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', \`x86', or \`x86_64'.])
303 AC_MSG_RESULT([$enable_assembler])
304 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
305 AM_CONDITIONAL(COND_ASM_X86_64, test "x$enable_assembler" = xx86_64)
308 ################################
309 # Fast unaligned memory access #
310 ################################
312 AC_MSG_CHECKING([if unaligned memory access should be used])
313 AC_ARG_ENABLE([unaligned-access], AC_HELP_STRING([--enable-unaligned-access],
314 [Enable if the system supports *fast* unaligned memory access
315 with 16-bit and 32-bit integers. By default, this is enabled
316 only on x86, x86_64, and big endian PowerPC.]),
317 [], [enable_unaligned_access=auto])
318 if test "x$enable_unaligned_access" = xauto ; then
320 i?86|x86_64|powerpc|powerpc64)
321 enable_unaligned_access=yes
324 enable_unaligned_access=no
328 if test "x$enable_unaligned_access" = xyes ; then
329 AC_DEFINE([HAVE_FAST_UNALIGNED_ACCESS], [1], [Define to 1 if
330 the system supports fast unaligned memory access.])
337 #####################
338 # Size optimization #
339 #####################
341 AC_MSG_CHECKING([if small size is preferred over speed])
342 AC_ARG_ENABLE([small], AC_HELP_STRING([--enable-small],
343 [Make liblzma smaller and a little slower.
344 This is disabled by default to optimize for speed.]),
345 [], [enable_small=no])
346 if test "x$enable_small" = xyes; then
347 AC_DEFINE([HAVE_SMALL], [1], [Define to 1 if optimizing for size.])
348 elif test "x$enable_small" != xno; then
350 AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
352 AC_MSG_RESULT([$enable_small])
353 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
360 AC_MSG_CHECKING([if threading support is wanted])
361 AC_ARG_ENABLE([threads], AC_HELP_STRING([--disable-threads],
362 [Disable threading support.
363 This makes some things thread-unsafe.]),
364 [], [enable_threads=yes])
365 if test "x$enable_threads" != xyes && test "x$enable_threads" != xno; then
367 AC_MSG_ERROR([--enable-threads accepts only \`yes' or \`no'])
369 AC_MSG_RESULT([$enable_threads])
370 # We use the actual result a little later.
373 ############################################
374 # xz/xzdec/lzmadec linkage against liblzma #
375 ############################################
377 # Link the command line tool statically against liblzma unless using
378 # --enable-dynamic. Using static liblzma gives a little bit faster executable
379 # on x86, because no register is wasted for PIC. We also have one dependency
380 # less, which allows users to more freely copy the xz binary to other boxes.
381 # However, I wouldn't be surprised if distro maintainers still prefer dynamic
382 # linking, so let's make it easy for them.
384 AC_MSG_CHECKING([how command line tools should be linked against liblzma])
385 AC_ARG_ENABLE([dynamic], [AC_HELP_STRING([--enable-dynamic],
386 [Link command line tools dynamically against liblzma.
387 The default is to use static liblzma if it was
389 [], [enable_dynamic=no])
390 case $enable_dynamic in
394 AC_MSG_RESULT([dynamically])
397 STATIC_CPPFLAGS="-DLZMA_API_STATIC"
398 STATIC_LDFLAGS="-static"
399 AC_MSG_RESULT([statically])
403 AC_MSG_ERROR([--enable-dynamic accepts only \`yes' or \`no'])
406 AC_SUBST([STATIC_CPPFLAGS])
407 AC_SUBST([STATIC_LDFLAGS])
410 ###############################################################################
411 # Checks for programs.
412 ###############################################################################
415 echo "Initializing Automake:"
417 AM_INIT_AUTOMAKE([1.10 foreign tar-v7 filename-length-max=99])
421 if test x$ac_cv_prog_cc_c99 = xno ; then
422 AC_MSG_ERROR([No C99 compiler was found.])
427 AC_USE_SYSTEM_EXTENSIONS
429 if test "x$enable_threads" = xyes; then
431 echo "Threading support:"
433 LIBS="$LIBS $PTHREAD_LIBS"
434 AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
439 echo "Initializing Libtool:"
446 dnl Some day we can drop support for libtool 1.5.x. Then the above five
447 dnl lines can be replaced with these:
448 dnl LT_INIT([win32-dll])
449 dnl LT_LANG([Windows Resource])
451 # This is a bit wrong since it is possible to request that only some libs
452 # are built as shared. Using that feature isn't so common though, and this
453 # breaks only on Windows (at least for now) if the user enables only some
455 AM_CONDITIONAL([COND_SHARED], [test "x$enable_shared" != xno])
458 ###############################################################################
459 # Checks for libraries.
460 ###############################################################################
463 echo "Initializing gettext:"
464 AM_GNU_GETTEXT_VERSION([0.16.1])
465 AM_GNU_GETTEXT([external])
467 ###############################################################################
468 # Checks for header files.
469 ###############################################################################
472 echo "System headers and functions:"
474 # There is currently no workarounds in this package if some of
475 # these headers are missing.
476 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
478 [AC_MSG_ERROR([Required header file(s) are missing.])])
480 # If any of these headers are missing, things should still work correctly:
481 AC_CHECK_HEADERS([sys/param.h sys/sysctl.h byteswap.h],
483 #ifdef HAVE_SYS_PARAM_H
484 # include <sys/param.h>
488 # Even if we have byteswap.h, we may lack the specific macros/functions.
489 if test x$ac_cv_header_byteswap_h = xyes ; then
490 m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
491 AC_MSG_CHECKING([if FUNC is available])
492 AC_LINK_IFELSE([AC_LANG_SOURCE([
493 #include <byteswap.h>
501 AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
502 [Define to 1 if] FUNC [is available.])
504 ], [AC_MSG_RESULT([no])])
510 ###############################################################################
511 # Checks for typedefs, structures, and compiler characteristics.
512 ###############################################################################
514 dnl We don't need these as long as we need a C99 compiler anyway.
528 AC_CHECK_SIZEOF([size_t])
530 # The command line tool can copy high resolution timestamps if such
531 # information is availabe in struct stat. Otherwise one second accuracy
534 struct stat.st_atim.tv_nsec,
535 struct stat.st_atimespec.tv_nsec,
536 struct stat.st_atimensec,
537 struct stat.st_uatime,
538 struct stat.st_atim.st__tim.tv_nsec])
544 ###############################################################################
545 # Checks for library functions.
546 ###############################################################################
548 # Gnulib replacements as needed
551 # Find the best function to set timestamps.
552 AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
558 ###############################################################################
559 # If using GCC, set some additional AM_CFLAGS:
560 ###############################################################################
562 if test "$GCC" = yes ; then
564 echo "GCC extensions:"
567 # Always do the visibility check but don't set AM_CFLAGS on Windows.
568 # This way things get set properly even on Windows.
570 if test -n "$CFLAG_VISIBILITY" && test "$is_w32" = no; then
571 AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
574 if test "$GCC" = yes ; then
575 # Enable as much warnings as possible. These commented warnings won't
576 # work for this package though:
577 # * -Wunreachable-code breaks several assert(0) cases, which are
578 # backed up with "return LZMA_PROG_ERROR".
579 # * -Wcast-qual would break various things where we need a non-const
580 # pointer although we don't modify anything through it.
581 # * -Wcast-align breaks optimized CRC32 and CRC64 implementation
582 # on some architectures (not on x86), where this warning is bogus,
583 # because we take care of correct alignment.
584 # * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
585 # don't seem so useful here; at least the last one gives some
586 # warnings which are not bugs.
592 -Wmissing-include-dirs \
598 -Wbad-function-cast \
602 -Wstrict-prototypes \
603 -Wold-style-definition \
604 -Wmissing-prototypes \
605 -Wmissing-declarations \
609 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
611 CFLAGS="$CFLAGS $NEW_FLAG"
612 AC_COMPILE_IFELSE([void foo(void) { }], [
613 AM_CFLAGS="$AM_CFLAGS $NEW_FLAG"
621 AC_ARG_ENABLE([werror],
622 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
623 compilation on all compiler warnings.]),
624 [], [enable_werror=no])
625 if test "x$enable_werror" = "xyes"; then
626 AM_CFLAGS="$AM_CFLAGS -Werror"
631 ###############################################################################
632 # Create the makefiles and config.h
633 ###############################################################################
637 # Don't build the lib directory at all if we don't need any replacement
639 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
641 # Add default AM_CFLAGS.
642 AC_SUBST([AM_CFLAGS])
650 src/liblzma/liblzma.pc
652 src/liblzma/api/Makefile