]> icculus.org git repositories - icculus/xz.git/blob - configure.ac
Updated the totally outdated TODO file.
[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 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])
30
31 echo
32 echo "$PACKAGE_STRING"
33
34 echo
35 echo "System type:"
36 # This is needed to know if assembler optimizations can be used.
37 AC_CANONICAL_HOST
38
39 # We do some special things on Windows (32-bit or 64-bit) builds.
40 case $host_os in
41         mingw* | cygwin*) is_w32=yes ;;
42         *)                is_w32=no ;;
43 esac
44 AM_CONDITIONAL([COND_W32], [test "$is_w32" = yes])
45
46
47 echo
48 echo "Configure options:"
49 AM_CFLAGS=
50
51
52 #############
53 # Debugging #
54 #############
55
56 AC_MSG_CHECKING([if debugging code should be compiled])
57 AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Enable debugging code.]),
58         [], enable_debug=no)
59 if test "x$enable_debug" = xyes; then
60         AC_MSG_RESULT([yes])
61 else
62         AC_DEFINE([NDEBUG], [1], [Define to 1 to disable debugging code.])
63         AC_MSG_RESULT([no])
64 fi
65
66
67 ###########
68 # Filters #
69 ###########
70
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])
74
75 m4_foreach([NAME], [SUPPORTED_FILTERS],
76 [enable_filter_[]NAME=no
77 enable_encoder_[]NAME=no
78 enable_decoder_[]NAME=no
79 ])dnl
80
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.
84                 Available encoders:]
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)])
90 else
91         AC_DEFINE([HAVE_ENCODER], [1],
92                 [Define to 1 if encoder components are enabled.])
93         for arg in $enable_encoders
94         do
95                 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
96                         NAME)
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.])
101                                 ;;])
102                         *)
103                                 AC_MSG_RESULT([])
104                                 AC_MSG_ERROR([unknown filter: $arg])
105                                 ;;
106                 esac
107         done
108         AC_MSG_RESULT([$enable_encoders])
109 fi
110
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)])
119 else
120         AC_DEFINE([HAVE_DECODER], [1],
121                 [Define to 1 if decoder components are enabled.])
122         for arg in $enable_decoders
123         do
124                 case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
125                         NAME)
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.])
130                                 ;;])
131                         *)
132                                 AC_MSG_RESULT([])
133                                 AC_MSG_ERROR([unknown filter: $arg])
134                                 ;;
135                 esac
136         done
137
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
141
142         AC_MSG_RESULT([$enable_decoders])
143 fi
144
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.])
148 fi
149
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)
152
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)
157 ])dnl
158
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
167 ])dnl
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)
171
172 # LZ-based filters share common code.
173 enable_filter_lz=no
174 enable_encoder_lz=no
175 enable_decoder_lz=no
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
180 ])dnl
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)
184
185
186 #################
187 # Match finders #
188 #################
189
190 m4_define([SUPPORTED_MATCH_FINDERS], [hc3,hc4,bt2,bt3,bt4])
191
192 m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS],
193 [enable_match_finder_[]NAME=no
194 ])
195
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
206                 do
207                 case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
208                         NAME)
209                                 enable_match_finder_[]NAME=yes
210                                 AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
211                                 [Define to 1 to enable] NAME [match finder.])
212                                 ;;])
213                         *)
214                                 AC_MSG_RESULT([])
215                                 AC_MSG_ERROR([unknown match finder: $arg])
216                                 ;;
217                 esac
218         done
219         AC_MSG_RESULT([$enable_match_finders])
220 else
221         AC_MSG_RESULT([(none because not building any LZ-based encoder)])
222 fi
223
224
225 ####################
226 # Integrity checks #
227 ####################
228
229 m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
230
231 m4_foreach([NAME], [SUPPORTED_FILTERS],
232 [enable_check_[]NAME=no
233 ])dnl
234
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)])
244 else
245         for arg in $enable_checks
246         do
247                 case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
248                         NAME)
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.])
253                                 ;;])
254                         *)
255                                 AC_MSG_RESULT([])
256                                 AC_MSG_ERROR([unknown integrity check: $arg])
257                                 ;;
258                 esac
259         done
260         AC_MSG_RESULT([$enable_checks])
261 fi
262 if test "x$enable_checks_crc32" = xno ; then
263         AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
264 fi
265
266 m4_foreach([NAME], [SUPPORTED_CHECKS],
267 [AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
268 ])dnl
269
270
271 ###########################
272 # Assembler optimizations #
273 ###########################
274
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
281         case $host_cpu in
282                 i?86)   enable_assembler=x86 ;;
283                 x86_64) enable_assembler=x86_64 ;;
284                 *)      enable_assembler=no ;;
285         esac
286 fi
287 case $enable_assembler in
288         x86)
289                 AC_DEFINE([HAVE_ASM_X86], [1],
290                         [Define to 1 if using x86 assembler optimizations.])
291                 ;;
292         x86_64)
293                 AC_DEFINE([HAVE_ASM_X86_64], [1],
294                         [Define to 1 if using x86_64 assembler optimizations.])
295                 ;;
296         no)
297                 ;;
298         *)
299                 AC_MSG_RESULT([])
300                 AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', \`x86', or \`x86_64'.])
301                 ;;
302 esac
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)
306
307
308 ################################
309 # Fast unaligned memory access #
310 ################################
311
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
319         case $host_cpu in
320                 i?86|x86_64|powerpc|powerpc64)
321                         enable_unaligned_access=yes
322                         ;;
323                 *)
324                         enable_unaligned_access=no
325                         ;;
326         esac
327 fi
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.])
331         AC_MSG_RESULT([yes])
332 else
333         AC_MSG_RESULT([no])
334 fi
335
336
337 #####################
338 # Size optimization #
339 #####################
340
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
349         AC_MSG_RESULT([])
350         AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
351 fi
352 AC_MSG_RESULT([$enable_small])
353 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
354
355
356 #############
357 # Threading #
358 #############
359
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
366         AC_MSG_RESULT([])
367         AC_MSG_ERROR([--enable-threads accepts only \`yes' or \`no'])
368 fi
369 AC_MSG_RESULT([$enable_threads])
370 # We use the actual result a little later.
371
372
373 ############################################
374 # xz/xzdec/lzmadec linkage against liblzma #
375 ############################################
376
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.
383
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
388                         built.])],
389                 [], [enable_dynamic=no])
390 case $enable_dynamic in
391         yes)
392                 STATIC_CPPFLAGS=
393                 STATIC_LDFLAGS=
394                 AC_MSG_RESULT([dynamically])
395                 ;;
396         no)
397                 STATIC_CPPFLAGS="-DLZMA_API_STATIC"
398                 STATIC_LDFLAGS="-static"
399                 AC_MSG_RESULT([statically])
400                 ;;
401         *)
402                 AC_MSG_RESULT([])
403                 AC_MSG_ERROR([--enable-dynamic accepts only \`yes' or \`no'])
404                 ;;
405 esac
406 AC_SUBST([STATIC_CPPFLAGS])
407 AC_SUBST([STATIC_LDFLAGS])
408
409
410 ###############################################################################
411 # Checks for programs.
412 ###############################################################################
413
414 echo
415 gl_POSIX_SHELL
416 if test -z "$POSIX_SHELL" ; then
417         AC_MSG_ERROR([No POSIX conforming shell (sh) was found.])
418 fi
419
420 echo
421 echo "Initializing Automake:"
422
423 AM_INIT_AUTOMAKE([1.10 foreign tar-v7 filename-length-max=99])
424 AC_PROG_LN_S
425
426 AC_PROG_CC_C99
427 if test x$ac_cv_prog_cc_c99 = xno ; then
428         AC_MSG_ERROR([No C99 compiler was found.])
429 fi
430
431 AM_PROG_CC_C_O
432 AM_PROG_AS
433 AC_USE_SYSTEM_EXTENSIONS
434
435 if test "x$enable_threads" = xyes; then
436         echo
437         echo "Threading support:"
438         ACX_PTHREAD
439         LIBS="$LIBS $PTHREAD_LIBS"
440         AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"
441         CC="$PTHREAD_CC"
442 fi
443
444 echo
445 echo "Initializing Libtool:"
446 CXX=no
447 F77=no
448 AC_LIBTOOL_WIN32_DLL
449 AC_PROG_LIBTOOL
450 AC_LIBTOOL_RC
451
452 dnl Some day we can drop support for libtool 1.5.x. Then the above five
453 dnl lines can be replaced with these:
454 dnl LT_INIT([win32-dll])
455 dnl LT_LANG([Windows Resource])
456
457 # This is a bit wrong since it is possible to request that only some libs
458 # are built as shared. Using that feature isn't so common though, and this
459 # breaks only on Windows (at least for now) if the user enables only some
460 # libs as shared.
461 AM_CONDITIONAL([COND_SHARED], [test "x$enable_shared" != xno])
462
463
464 ###############################################################################
465 # Checks for libraries.
466 ###############################################################################
467
468 echo
469 echo "Initializing gettext:"
470 AM_GNU_GETTEXT_VERSION([0.16.1])
471 AM_GNU_GETTEXT([external])
472
473 ###############################################################################
474 # Checks for header files.
475 ###############################################################################
476
477 echo
478 echo "System headers and functions:"
479
480 # There is currently no workarounds in this package if some of
481 # these headers are missing.
482 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
483         [],
484         [AC_MSG_ERROR([Required header file(s) are missing.])])
485
486 # If any of these headers are missing, things should still work correctly:
487 AC_CHECK_HEADERS([sys/param.h sys/sysctl.h byteswap.h],
488         [], [], [
489 #ifdef HAVE_SYS_PARAM_H
490 #       include <sys/param.h>
491 #endif
492 ])
493
494 # Even if we have byteswap.h, we may lack the specific macros/functions.
495 if test x$ac_cv_header_byteswap_h = xyes ; then
496         m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
497                 AC_MSG_CHECKING([if FUNC is available])
498                 AC_LINK_IFELSE([AC_LANG_SOURCE([
499 #include <byteswap.h>
500 int
501 main(void)
502 {
503         FUNC[](42);
504         return 0;
505 }
506                 ])], [
507                         AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
508                                         [Define to 1 if] FUNC [is available.])
509                         AC_MSG_RESULT([yes])
510                 ], [AC_MSG_RESULT([no])])
511
512         ])dnl
513 fi
514
515
516 ###############################################################################
517 # Checks for typedefs, structures, and compiler characteristics.
518 ###############################################################################
519
520 dnl We don't need these as long as we need a C99 compiler anyway.
521 dnl AC_C_INLINE
522 dnl AC_C_RESTRICT
523
524 AC_HEADER_STDBOOL
525
526 AC_TYPE_UINT8_T
527 AC_TYPE_UINT16_T
528 AC_TYPE_INT32_T
529 AC_TYPE_UINT32_T
530 AC_TYPE_INT64_T
531 AC_TYPE_UINT64_T
532 AC_TYPE_UINTPTR_T
533
534 AC_CHECK_SIZEOF([size_t])
535
536 # The command line tool can copy high resolution timestamps if such
537 # information is availabe in struct stat. Otherwise one second accuracy
538 # is used.
539 AC_CHECK_MEMBERS([
540         struct stat.st_atim.tv_nsec,
541         struct stat.st_atimespec.tv_nsec,
542         struct stat.st_atimensec,
543         struct stat.st_uatime,
544         struct stat.st_atim.st__tim.tv_nsec])
545
546 AC_SYS_LARGEFILE
547 AC_C_BIGENDIAN
548
549
550 ###############################################################################
551 # Checks for library functions.
552 ###############################################################################
553
554 # Gnulib replacements as needed
555 gl_GETOPT
556
557 # Find the best function to set timestamps.
558 AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
559
560 lc_PHYSMEM
561 lc_CPUCORES
562
563
564 ###############################################################################
565 # If using GCC, set some additional AM_CFLAGS:
566 ###############################################################################
567
568 if test "$GCC" = yes ; then
569         echo
570         echo "GCC extensions:"
571 fi
572
573 # Always do the visibility check but don't set AM_CFLAGS on Windows.
574 # This way things get set properly even on Windows.
575 gl_VISIBILITY
576 if test -n "$CFLAG_VISIBILITY" && test "$is_w32" = no; then
577         AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
578 fi
579
580 if test "$GCC" = yes ; then
581         # Enable as much warnings as possible. These commented warnings won't
582         # work for this package though:
583         #   * -Wunreachable-code breaks several assert(0) cases, which are
584         #     backed up with "return LZMA_PROG_ERROR".
585         #   * -Wcast-qual would break various things where we need a non-const
586         #     pointer although we don't modify anything through it.
587         #   * -Wcast-align breaks optimized CRC32 and CRC64 implementation
588         #     on some architectures (not on x86), where this warning is bogus,
589         #     because we take care of correct alignment.
590         #   * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
591         #     don't seem so useful here; at least the last one gives some
592         #     warnings which are not bugs.
593         for NEW_FLAG in \
594                         -Wall \
595                         -Wextra \
596                         -Wformat=2 \
597                         -Winit-self \
598                         -Wmissing-include-dirs \
599                         -Wstrict-aliasing \
600                         -Wfloat-equal \
601                         -Wundef \
602                         -Wshadow \
603                         -Wpointer-arith \
604                         -Wbad-function-cast \
605                         -Wwrite-strings \
606                         -Wlogical-op \
607                         -Waggregate-return \
608                         -Wstrict-prototypes \
609                         -Wold-style-definition \
610                         -Wmissing-prototypes \
611                         -Wmissing-declarations \
612                         -Wmissing-noreturn \
613                         -Wredundant-decls
614         do
615                 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
616                 OLD_CFLAGS="$CFLAGS"
617                 CFLAGS="$CFLAGS $NEW_FLAG"
618                 AC_COMPILE_IFELSE([void foo(void) { }], [
619                         AM_CFLAGS="$AM_CFLAGS $NEW_FLAG"
620                         AC_MSG_RESULT([yes])
621                 ], [
622                         AC_MSG_RESULT([no])
623                 ])
624                 CFLAGS="$OLD_CFLAGS"
625         done
626
627         AC_ARG_ENABLE([werror],
628                 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
629                         compilation on all compiler warnings.]),
630                 [], [enable_werror=no])
631         if test "x$enable_werror" = "xyes"; then
632                 AM_CFLAGS="$AM_CFLAGS -Werror"
633         fi
634 fi
635
636
637 ###############################################################################
638 # Create the makefiles and config.h
639 ###############################################################################
640
641 echo
642
643 # Don't build the lib directory at all if we don't need any replacement
644 # functions.
645 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
646
647 # Add default AM_CFLAGS.
648 AC_SUBST([AM_CFLAGS])
649
650 # This is needed for src/scripts.
651 xz=`echo xz | sed "$program_transform_name"`
652 AC_SUBST([xz])
653
654 AC_CONFIG_FILES([
655         Doxyfile
656         Makefile
657         po/Makefile.in
658         lib/Makefile
659         src/Makefile
660         src/liblzma/liblzma.pc
661         src/liblzma/Makefile
662         src/liblzma/api/Makefile
663         src/xz/Makefile
664         src/xzdec/Makefile
665         src/scripts/Makefile
666         src/scripts/xzdiff
667         src/scripts/xzgrep
668         src/scripts/xzmore
669         src/scripts/xzless
670         tests/Makefile
671         debug/Makefile
672 ])
673
674 AC_OUTPUT