]> icculus.org git repositories - icculus/xz.git/blob - configure.ac
Added AC_CONFIG_MACRO_DIR to configure.ac.
[icculus/xz.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 ###############################################################################
5 #
6 #   Copyright (C) 2007 Lasse Collin
7 #
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.
12 #
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.
17 #
18 ###############################################################################
19
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.
24
25 AC_PREREQ([2.61])
26
27 AC_INIT([XZ Utils], m4_esyscmd([/bin/sh version.sh]),
28         [lasse.collin@tukaani.org], [xz])
29 AC_CONFIG_SRCDIR([src/liblzma/common/common.h])
30 AC_CONFIG_HEADER([config.h])
31 AC_CONFIG_MACRO_DIR([m4])
32
33 echo
34 echo "$PACKAGE_STRING"
35
36 echo
37 echo "System type:"
38 # This is needed to know if assembler optimizations can be used.
39 AC_CANONICAL_HOST
40
41
42 echo
43 echo "Configure options:"
44 AM_CFLAGS=
45
46
47 #############
48 # Debugging #
49 #############
50
51 AC_MSG_CHECKING([if debugging code should be compiled])
52 AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable debugging code.]),
53         [], enable_debug=no)
54 if test "x$enable_debug" = xyes; then
55         AC_MSG_RESULT([yes])
56 else
57         AC_DEFINE([NDEBUG], [1], [Define to 1 to disable debugging code.])
58         AC_MSG_RESULT([no])
59 fi
60
61
62 ###########
63 # Encoder #
64 ###########
65
66 AC_MSG_CHECKING([if encoder components should be built])
67 AC_ARG_ENABLE([encoder], AC_HELP_STRING([--disable-encoder],
68                 [Do not build the encoder components.]),
69         [], enable_encoder=yes)
70 if test "x$enable_encoder" = xyes; then
71         AC_DEFINE([HAVE_ENCODER], [1],
72                 [Define to 1 if encoder components are enabled.])
73         AC_MSG_RESULT([yes])
74 else
75         AC_MSG_RESULT([no])
76 fi
77 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoder" = xyes)
78
79
80 ###########
81 # Decoder #
82 ###########
83
84 AC_MSG_CHECKING([if decoder components should be built])
85 AC_ARG_ENABLE([decoder], AC_HELP_STRING([--disable-decoder],
86                 [Do not build the decoder components.]),
87         [], enable_decoder=yes)
88 if test "x$enable_decoder" = xyes; then
89         AC_DEFINE([HAVE_DECODER], [1],
90                 [Define to 1 if decoder components are enabled.])
91         AC_MSG_RESULT([yes])
92 else
93         AC_MSG_RESULT([no])
94         if test "x$enable_encoder" = xno; then
95                 AC_MSG_ERROR([Do not disable both encoder and decoder.])
96         fi
97 fi
98 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoder" = xyes)
99
100
101 ###########
102 # Filters #
103 ###########
104
105 m4_define([SUPPORTED_FILTERS], [lzma1,lzma2,subblock,delta,x86,powerpc,ia64,arm,armthumb,sparc])dnl
106 m4_define([SIMPLE_FILTERS], [x86,powerpc,ia64,arm,armthumb,sparc])
107 m4_define([LZ_FILTERS], [lzma1,lzma2])
108
109 m4_foreach([NAME], [SUPPORTED_FILTERS],
110 [enable_filter_[]NAME=no
111 enable_encoder_[]NAME=no
112 enable_decoder_[]NAME=no
113 ])dnl
114
115 AC_MSG_CHECKING([which encoders to build])
116 AC_ARG_ENABLE([encoders], AC_HELP_STRING([--enable-encoders=LIST],
117                 [Comma-separated list of encoders to build. Default=all.
118                 Available encoders:]
119                         m4_translit(m4_defn([SUPPORTED_FILTERS]), [,], [ ])),
120         [], [enable_encoders=SUPPORTED_FILTERS])
121 enable_encoders=`echo "$enable_encoders" | sed 's/,subblock//; s/,/ /g'`
122 if test "x$enable_encoders" = xno || test "x$enable_encoders" = x; then
123         AC_MSG_RESULT([(none)])
124 else
125         for arg in $enable_encoders
126         do
127                 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
128                         NAME)
129                                 enable_filter_[]NAME=yes
130                                 enable_encoder_[]NAME=yes
131                                 AC_DEFINE(HAVE_ENCODER_[]m4_toupper(NAME), [1],
132                                 [Define to 1 if] NAME [encoder is enabled.])
133                                 ;;])
134                         *)
135                                 AC_MSG_RESULT([])
136                                 AC_MSG_ERROR([unknown filter: $arg])
137                                 ;;
138                 esac
139         done
140         AC_MSG_RESULT([$enable_encoders])
141 fi
142
143 AC_MSG_CHECKING([which decoders to build])
144 AC_ARG_ENABLE([decoders], AC_HELP_STRING([--enable-decoders=LIST],
145                 [Comma-separated list of decoders to build. Default=all.
146                 Available decoders are the same as available encoders.]),
147         [], [enable_decoders=SUPPORTED_FILTERS])
148 enable_decoders=`echo "$enable_decoders" | sed 's/,subblock//; s/,/ /g'`
149 if test "x$enable_decoders" = xno || test "x$enable_decoders" = x; then
150         AC_MSG_RESULT([(none)])
151 else
152         for arg in $enable_decoders
153         do
154                 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
155                         NAME)
156                                 enable_filter_[]NAME=yes
157                                 enable_decoder_[]NAME=yes
158                                 AC_DEFINE(HAVE_DECODER_[]m4_toupper(NAME), [1],
159                                 [Define to 1 if] NAME [decoder is enabled.])
160                                 ;;])
161                         *)
162                                 AC_MSG_RESULT([])
163                                 AC_MSG_ERROR([unknown filter: $arg])
164                                 ;;
165                 esac
166         done
167
168         # LZMA2 requires that LZMA1 is enabled.
169         test "x$enable_encoder_lzma2" = xyes && enable_encoder_lzma1=yes
170         test "x$enable_decoder_lzma2" = xyes && enable_decoder_lzma1=yes
171
172         AC_MSG_RESULT([$enable_decoders])
173 fi
174
175 if test "x$enable_encoder_lzma2$enable_encoder_lzma1" = xyesno \
176                 || test "x$enable_decoder_lzma2$enable_decoder_lzma1" = xyesno; then
177         AC_MSG_ERROR([LZMA2 requires that LZMA1 is also enabled.])
178 fi
179
180 m4_foreach([NAME], [SUPPORTED_FILTERS],
181 [AM_CONDITIONAL(COND_FILTER_[]m4_toupper(NAME), test "x$enable_filter_[]NAME" = xyes)
182 AM_CONDITIONAL(COND_ENCODER_[]m4_toupper(NAME), test "x$enable_encoder_[]NAME" = xyes)
183 AM_CONDITIONAL(COND_DECODER_[]m4_toupper(NAME), test "x$enable_decoder_[]NAME" = xyes)
184 ])dnl
185
186 # The so called "simple filters" share common code.
187 enable_filter_simple=no
188 enable_encoder_simple=no
189 enable_decoder_simple=no
190 m4_foreach([NAME], [SIMPLE_FILTERS],
191 [test "x$enable_filter_[]NAME" = xyes && enable_filter_simple=yes
192 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_simple=yes
193 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_simple=yes
194 ])dnl
195 AM_CONDITIONAL(COND_FILTER_SIMPLE, test "x$enable_filter_simple" = xyes)
196 AM_CONDITIONAL(COND_ENCODER_SIMPLE, test "x$enable_encoder_simple" = xyes)
197 AM_CONDITIONAL(COND_DECODER_SIMPLE, test "x$enable_decoder_simple" = xyes)
198
199 # LZ-based filters share common code.
200 enable_filter_lz=no
201 enable_encoder_lz=no
202 enable_decoder_lz=no
203 m4_foreach([NAME], [LZ_FILTERS],
204 [test "x$enable_filter_[]NAME" = xyes && enable_filter_lz=yes
205 test "x$enable_encoder_[]NAME" = xyes && enable_encoder_lz=yes
206 test "x$enable_decoder_[]NAME" = xyes && enable_decoder_lz=yes
207 ])dnl
208 AM_CONDITIONAL(COND_FILTER_LZ, test "x$enable_filter_lz" = xyes)
209 AM_CONDITIONAL(COND_ENCODER_LZ, test "x$enable_encoder_lz" = xyes)
210 AM_CONDITIONAL(COND_DECODER_LZ, test "x$enable_decoder_lz" = xyes)
211
212
213 #################
214 # Match finders #
215 #################
216
217 m4_define([SUPPORTED_MATCH_FINDERS], [hc3,hc4,bt2,bt3,bt4])
218
219 m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS],
220 [enable_match_finder_[]NAME=no
221 ])
222
223 AC_MSG_CHECKING([which match finders to build])
224 AC_ARG_ENABLE([match-finders], AC_HELP_STRING([--enable-match-finders=LIST],
225                 [Comma-separated list of match finders to build. Default=all.
226                 At least one match finder is required for encoding with
227                 the LZMA1 and LZMA2 filters. Available match finders:]
228                 m4_translit(m4_defn([SUPPORTED_MATCH_FINDERS]), [,], [ ])), [],
229         [enable_match_finders=SUPPORTED_MATCH_FINDERS])
230 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
231 if test "x$enable_encoder" = xyes && test "x$enable_encoder_lz" = xyes ; then
232         for arg in $enable_match_finders
233                 do
234                 case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
235                         NAME)
236                                 enable_match_finder_[]NAME=yes
237                                 AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
238                                 [Define to 1 to enable] NAME [match finder.])
239                                 ;;])
240                         *)
241                                 AC_MSG_RESULT([])
242                                 AC_MSG_ERROR([unknown match finder: $arg])
243                                 ;;
244                 esac
245         done
246         AC_MSG_RESULT([$enable_match_finders])
247 else
248         AC_MSG_RESULT([(none because not building any LZ-based encoder)])
249 fi
250
251
252 ####################
253 # Integrity checks #
254 ####################
255
256 m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
257
258 m4_foreach([NAME], [SUPPORTED_FILTERS],
259 [enable_check_[]NAME=no
260 ])dnl
261
262 AC_MSG_CHECKING([which integrity checks to build])
263 AC_ARG_ENABLE([checks], AC_HELP_STRING([--enable-checks=LIST],
264                 [Comma-separated list of integrity checks to build.
265                 Default=all. Available integrity checks:]
266                 m4_translit(m4_defn([SUPPORTED_CHECKS]), [,], [ ])),
267         [], [enable_checks=SUPPORTED_CHECKS])
268 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
269 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
270         AC_MSG_RESULT([(none)])
271 else
272         for arg in $enable_checks
273         do
274                 case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
275                         NAME)
276                                 enable_check_[]NAME=yes
277                                 AC_DEFINE(HAVE_CHECK_[]m4_toupper(NAME), [1],
278                                 [Define to 1 if] NAME
279                                 [integrity check is enabled.])
280                                 ;;])
281                         *)
282                                 AC_MSG_RESULT([])
283                                 AC_MSG_ERROR([unknown integrity check: $arg])
284                                 ;;
285                 esac
286         done
287         AC_MSG_RESULT([$enable_checks])
288 fi
289 if test "x$enable_checks_crc32" = xno ; then
290         AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
291 fi
292
293 m4_foreach([NAME], [SUPPORTED_CHECKS],
294 [AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
295 ])dnl
296
297
298 ###########################
299 # Assembler optimizations #
300 ###########################
301
302 AC_MSG_CHECKING([if assembler optimizations should be used])
303 AC_ARG_ENABLE([assembler], AC_HELP_STRING([--disable-assembler],
304                 [Do not use assembler optimizations even if such exist
305                 for the architecture.]),
306         [], [enable_assembler=yes])
307 if test "x$enable_assembler" = xyes; then
308         case $host_cpu in
309                 i?86)   enable_assembler=x86 ;;
310                 x86_64) enable_assembler=x86_64 ;;
311                 *)      enable_assembler=no ;;
312         esac
313 fi
314 case $enable_assembler in
315         x86)
316                 AC_DEFINE([HAVE_ASM_X86], [1],
317                         [Define to 1 if using x86 assembler optimizations.])
318                 ;;
319         x86_64)
320                 AC_DEFINE([HAVE_ASM_X86_64], [1],
321                         [Define to 1 if using x86_64 assembler optimizations.])
322                 ;;
323         no)
324                 ;;
325         *)
326                 AC_MSG_RESULT([])
327                 AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', \`x86', or \`x86_64'.])
328                 ;;
329 esac
330 AC_MSG_RESULT([$enable_assembler])
331 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
332 AM_CONDITIONAL(COND_ASM_X86_64, test "x$enable_assembler" = xx86_64)
333
334
335 ################################
336 # Fast unaligned memory access #
337 ################################
338
339 AC_MSG_CHECKING([if unaligned memory access should be used])
340 AC_ARG_ENABLE([unaligned-access], AC_HELP_STRING([--enable-unaligned-access],
341                 [Enable if the system supports *fast* unaligned memory access
342                 with 16-bit and 32-bit integers. By default, this is enabled
343                 only on x86, x86_64, and big endian PowerPC.]),
344         [], [enable_unaligned_access=auto])
345 if test "x$enable_unaligned_access" = xauto ; then
346         case $host_cpu in
347                 i?86|x86_64|powerpc|powerpc64)
348                         enable_unaligned_access=yes
349                         ;;
350                 *)
351                         enable_unaligned_access=no
352                         ;;
353         esac
354 fi
355 if test "x$enable_unaligned_access" = xyes ; then
356         AC_DEFINE([HAVE_FAST_UNALIGNED_ACCESS], [1], [Define to 1 if
357                 the system supports fast unaligned memory access.])
358         AC_MSG_RESULT([yes])
359 else
360         AC_MSG_RESULT([no])
361 fi
362
363
364 #####################
365 # Size optimization #
366 #####################
367
368 AC_MSG_CHECKING([if small size is preferred over speed])
369 AC_ARG_ENABLE([small], AC_HELP_STRING([--enable-small],
370                 [Make liblzma smaller and a little slower.
371                 This is disabled by default to optimize for speed.]),
372         [], [enable_small=no])
373 if test "x$enable_small" = xyes; then
374         AC_DEFINE([HAVE_SMALL], [1], [Define to 1 if optimizing for size.])
375 elif test "x$enable_small" != xno; then
376         AC_MSG_RESULT([])
377         AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
378 fi
379 AC_MSG_RESULT([$enable_small])
380 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
381
382
383 #############
384 # Threading #
385 #############
386
387 AC_MSG_CHECKING([if threading support is wanted])
388 AC_ARG_ENABLE([threads], AC_HELP_STRING([--disable-threads],
389                 [Disable threading support.
390                 This makes some things thread-unsafe.]),
391         [], [enable_threads=yes])
392 if test "x$enable_threads" != xyes && test "x$enable_threads" != xno; then
393         AC_MSG_RESULT([])
394         AC_MSG_ERROR([--enable-threads accepts only \`yes' or \`no'])
395 fi
396 AC_MSG_RESULT([$enable_threads])
397 # We use the actual result a little later.
398
399
400 ############################################
401 # xz/xzdec/lzmadec linkage against liblzma #
402 ############################################
403
404 # Link the command line tool statically against liblzma unless using
405 # --enable-dynamic. Using static liblzma gives a little bit faster executable
406 # on x86, because no register is wasted for PIC. We also have one dependency
407 # less, which allows users to more freely copy the xz binary to other boxes.
408 # However, I wouldn't be surprised if distro maintainers still prefer dynamic
409 # linking, so let's make it easy for them.
410
411 AC_MSG_CHECKING([how command line tools should be linked against liblzma])
412 AC_ARG_ENABLE([dynamic], [AC_HELP_STRING([--enable-dynamic],
413                         [Link command line tools dynamically against liblzma.
414                         The default is to use static liblzma if it was
415                         built.])],
416                 [], [enable_dynamic=no])
417 case $enable_dynamic in
418         yes)
419                 STATIC_CPPFLAGS=
420                 STATIC_LDFLAGS=
421                 AC_MSG_RESULT([dynamically])
422                 ;;
423         no)
424                 STATIC_CPPFLAGS="-DLZMA_API_STATIC"
425                 STATIC_LDFLAGS="-static"
426                 AC_MSG_RESULT([statically])
427                 ;;
428         *)
429                 AC_MSG_RESULT([])
430                 AC_MSG_ERROR([--enable-dynamic accepts only \`yes' or \`no'])
431                 ;;
432 esac
433 AC_SUBST([STATIC_CPPFLAGS])
434 AC_SUBST([STATIC_LDFLAGS])
435
436
437 ###############################################################################
438 # Checks for programs.
439 ###############################################################################
440
441 echo
442 echo "Initializing Automake:"
443
444 AM_INIT_AUTOMAKE([1.10 foreign tar-v7 filename-length-max=99])
445 AC_PROG_LN_S
446
447 AC_PROG_CC_C99
448 if test x$ac_cv_prog_cc_c99 = xno ; then
449         AC_MSG_ERROR([No C99 compiler was found.])
450 fi
451
452 AM_PROG_CC_C_O
453 AM_PROG_AS
454 AC_USE_SYSTEM_EXTENSIONS
455
456 if test "x$enable_threads" = xyes; then
457         echo
458         echo "Threading support:"
459         ACX_PTHREAD
460         LIBS="$LIBS $PTHREAD_LIBS"
461         AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
462         CC="$PTHREAD_CC"
463 fi
464
465 echo
466 echo "Initializing Libtool:"
467 CXX=no
468 F77=no
469 AC_PROG_LIBTOOL
470
471
472 ###############################################################################
473 # Checks for libraries.
474 ###############################################################################
475
476 echo
477 echo "Initializing gettext:"
478 AM_GNU_GETTEXT_VERSION([0.16.1])
479 AM_GNU_GETTEXT([external])
480
481 ###############################################################################
482 # Checks for header files.
483 ###############################################################################
484
485 echo
486 echo "System headers and functions:"
487
488 # There is currently no workarounds in this package if some of
489 # these headers are missing.
490 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
491         [],
492         [AC_MSG_ERROR([Required header file(s) are missing.])])
493
494 # If any of these headers are missing, things should still work correctly:
495 AC_CHECK_HEADERS([sys/param.h sys/sysctl.h byteswap.h],
496         [], [], [
497 #ifdef HAVE_SYS_PARAM_H
498 #       include <sys/param.h>
499 #endif
500 ])
501
502 # Even if we have byteswap.h, we may lack the specific macros/functions.
503 if test x$ac_cv_header_byteswap_h = xyes ; then
504         m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
505                 AC_MSG_CHECKING([if FUNC is available])
506                 AC_LINK_IFELSE([AC_LANG_SOURCE([
507 #include <byteswap.h>
508 int
509 main(void)
510 {
511         FUNC[](42);
512         return 0;
513 }
514                 ])], [
515                         AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
516                                         [Define to 1 if] FUNC [is available.])
517                         AC_MSG_RESULT([yes])
518                 ], [AC_MSG_RESULT([no])])
519
520         ])dnl
521 fi
522
523
524 ###############################################################################
525 # Checks for typedefs, structures, and compiler characteristics.
526 ###############################################################################
527
528 dnl We don't need these as long as we need a C99 compiler anyway.
529 dnl AC_C_INLINE
530 dnl AC_C_RESTRICT
531
532 AC_HEADER_STDBOOL
533
534 AC_TYPE_UINT8_T
535 AC_TYPE_UINT16_T
536 AC_TYPE_INT32_T
537 AC_TYPE_UINT32_T
538 AC_TYPE_INT64_T
539 AC_TYPE_UINT64_T
540 AC_TYPE_UINTPTR_T
541
542 AC_CHECK_SIZEOF([size_t])
543
544 # The command line tool can copy high resolution timestamps if such
545 # information is availabe in struct stat. Otherwise one second accuracy
546 # is used.
547 AC_CHECK_MEMBERS([
548         struct stat.st_atim.tv_nsec,
549         struct stat.st_atimespec.tv_nsec,
550         struct stat.st_atimensec,
551         struct stat.st_uatime,
552         struct stat.st_atim.st__tim.tv_nsec])
553
554 AC_SYS_LARGEFILE
555 AC_C_BIGENDIAN
556
557
558 ###############################################################################
559 # Checks for library functions.
560 ###############################################################################
561
562 # Gnulib replacements as needed
563 gl_GETOPT
564
565 # Find the best function to set timestamps.
566 AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
567
568 lc_PHYSMEM
569 lc_CPUCORES
570
571
572 ###############################################################################
573 # If using GCC, set some additional AM_CFLAGS:
574 ###############################################################################
575
576 Wno_uninitialized=no
577
578 if test "x$GCC" = xyes ; then
579         echo
580         echo "GCC extensions:"
581         gl_VISIBILITY
582         if test -n "$CFLAG_VISIBILITY" ; then
583                 AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
584         fi
585
586         # -Wno-uninitialized is needed with -Werror with SHA256 code
587         # to omit a bogus warning.
588         AC_MSG_CHECKING([if $CC accepts -Wno-uninitialized])
589         OLD_CFLAGS="$CFLAGS"
590         CFLAGS="$CFLAGS -Wno-uninitialized"
591         AC_COMPILE_IFELSE([void foo(void) { }], [Wno_uninitialized=yes])
592         CFLAGS="$OLD_CFLAGS"
593         AC_MSG_RESULT([$Wno_uninitialized])
594
595         # Enable as much warnings as possible. These commented warnings won't
596         # work for this package though:
597         #   * -Wunreachable-code breaks several assert(0) cases, which are
598         #     backed up with "return LZMA_PROG_ERROR".
599         #   * -Wcast-qual would break various things where we need a non-const
600         #     pointer although we don't modify anything through it.
601         #   * -Wcast-align breaks optimized CRC32 and CRC64 implementation
602         #     on some architectures (not on x86), where this warning is bogus,
603         #     because we take care of correct alignment.
604         #   * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
605         #     don't seem so useful here; at least the last one gives some
606         #     warnings which are not bugs.
607         for NEW_FLAG in \
608                         -Wall \
609                         -Wextra \
610                         -Wformat=2 \
611                         -Winit-self \
612                         -Wmissing-include-dirs \
613                         -Wstrict-aliasing \
614                         -Wfloat-equal \
615                         -Wundef \
616                         -Wshadow \
617                         -Wpointer-arith \
618                         -Wbad-function-cast \
619                         -Wwrite-strings \
620                         -Wlogical-op \
621                         -Waggregate-return \
622                         -Wstrict-prototypes \
623                         -Wold-style-definition \
624                         -Wmissing-prototypes \
625                         -Wmissing-declarations \
626                         -Wmissing-noreturn \
627                         -Wredundant-decls
628         do
629                 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
630                 OLD_CFLAGS="$CFLAGS"
631                 CFLAGS="$CFLAGS $NEW_FLAG"
632                 AC_COMPILE_IFELSE([void foo(void) { }], [
633                         AM_CFLAGS="$AM_CFLAGS $NEW_FLAG"
634                         AC_MSG_RESULT([yes])
635                 ], [
636                         AC_MSG_RESULT([no])
637                 ])
638                 CFLAGS="$OLD_CFLAGS"
639         done
640
641         AC_ARG_ENABLE([werror],
642                 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
643                         compilation on all compiler warnings.]),
644                 [], [enable_werror=no])
645         if test "x$enable_werror" = "xyes"; then
646                 AM_CFLAGS="$AM_CFLAGS -Werror"
647         fi
648 fi
649
650 AM_CONDITIONAL([COND_WNO_UNINITIALIZED], test "x$Wno_uninitialized" = "xyes")
651
652
653 ###############################################################################
654 # Create the makefiles and config.h
655 ###############################################################################
656
657 echo
658
659 # Don't build the lib directory at all if we don't need any replacement
660 # functions.
661 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
662
663 # Add default AM_CFLAGS.
664 AC_SUBST([AM_CFLAGS])
665
666 AC_CONFIG_FILES([
667         Doxyfile
668         Makefile
669         po/Makefile.in
670         lib/Makefile
671         src/Makefile
672         src/liblzma/liblzma.pc
673         src/liblzma/Makefile
674         src/liblzma/api/Makefile
675         src/liblzma/common/Makefile
676         src/liblzma/check/Makefile
677         src/liblzma/rangecoder/Makefile
678         src/liblzma/lz/Makefile
679         src/liblzma/lzma/Makefile
680         src/liblzma/subblock/Makefile
681         src/liblzma/delta/Makefile
682         src/liblzma/simple/Makefile
683         src/xz/Makefile
684         src/xzdec/Makefile
685         src/scripts/Makefile
686         tests/Makefile
687         debug/Makefile
688 ])
689
690 AC_OUTPUT