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