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