]> icculus.org git repositories - icculus/xz.git/blob - configure.ac
Added autoconf check to detect if we can use arithmetic
[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 # [LZMA] instead of [LZMA utils] since I prefer to have lzma-version.tar.gz
28 # instead of lzma-utils-version.tar.gz.
29 AC_INIT([LZMA], [4.42.3alpha], [lasse.collin@tukaani.org])
30
31 AC_CONFIG_SRCDIR([src/liblzma/common/common.h])
32 AC_CONFIG_HEADER([config.h])
33
34 echo
35 echo "LZMA Utils $PACKAGE_VERSION"
36
37 echo
38 echo "System type:"
39 # This is needed to know if assembler optimizations can be used.
40 AC_CANONICAL_HOST
41
42 echo
43 echo "Configure options:"
44
45 # Enable/disable debugging code:
46 AC_MSG_CHECKING([if debugging code should be compiled])
47 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging code.]),
48         [], enable_debug=no)
49 if test "x$enable_debug" = xyes; then
50         AC_MSG_RESULT([yes])
51 else
52         AC_DEFINE(NDEBUG, 1, [Define to disable debugging code.])
53         AC_MSG_RESULT([no])
54 fi
55
56 # Enable/disable the encoder components:
57 AC_MSG_CHECKING([if encoder components should be built])
58 AC_ARG_ENABLE(encoder, AC_HELP_STRING([--disable-encoder],
59                 [Do not build the encoder components.]),
60         [], enable_encoder=yes)
61 if test "x$enable_encoder" = xyes; then
62         AC_DEFINE([HAVE_ENCODER], 1,
63                 [Define to 1 if encoder components are enabled.])
64         AC_MSG_RESULT([yes])
65 else
66         AC_MSG_RESULT([no])
67 fi
68 AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoder" = xyes)
69
70 # Enable/disable the decoder components:
71 AC_MSG_CHECKING([if decoder components should be built])
72 AC_ARG_ENABLE(decoder, AC_HELP_STRING([--disable-decoder],
73                 [Do not build the decoder components.]),
74         [], enable_decoder=yes)
75 if test "x$enable_decoder" = xyes; then
76         AC_DEFINE([HAVE_DECODER], 1,
77                 [Define to 1 if decoder components are enabled.])
78         AC_MSG_RESULT([yes])
79 else
80         AC_MSG_RESULT([no])
81         if test "x$enable_encoder" = xno; then
82                 AC_MSG_ERROR([Do not disable both encoder and decoder.])
83         fi
84 fi
85 AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoder" = xyes)
86
87 # Filters
88 AC_MSG_CHECKING([which filters to build])
89 AC_ARG_ENABLE(filters, AC_HELP_STRING([--enable-filters=],
90                 [Comma-separated list of filters to build. Default=all.
91                 Filters used in encoding are needed also in decoding.
92                 Available filters: copy subblock x86 powerpc ia64
93                 arm armthumb sparc delta lzma]),
94                 [], [enable_filters=copy,subblock,x86,powerpc,ia64,arm,armthumb,sparc,delta,lzma])
95 enable_filters=`echo "$enable_filters" | sed 's/,/ /g'`
96 enable_filters_copy=no
97 enable_filters_subblock=no
98 enable_filters_x86=no
99 enable_filters_powerpc=no
100 enable_filters_ia64=no
101 enable_filters_arm=no
102 enable_filters_armthumb=no
103 enable_filters_sparc=no
104 enable_filters_delta=no
105 enable_filters_lzma=no
106 enable_simple_filters=no
107 if test "x$enable_filters" = xno || test "x$enable_filters" = x; then
108         AC_MSG_RESULT([])
109         AC_MSG_ERROR([Please enable at least one filter.])
110 else
111         for arg in $enable_filters
112         do
113                 case $arg in
114                         copy)
115                                 enable_filters_copy=yes
116                                 AC_DEFINE([HAVE_FILTER_COPY], 1,
117                                         [Define to 1 if support for the
118                                         Copy filter is enabled.])
119                                 ;;
120                         subblock)
121                                 enable_filters_subblock=yes
122                                 AC_DEFINE([HAVE_FILTER_SUBBLOCK], 1,
123                                         [Define to 1 if support for the
124                                         Subblock filter is enabled.])
125                                 ;;
126                         x86)
127                                 enable_filters_x86=yes
128                                 enable_simple_filters=yes
129                                 AC_DEFINE([HAVE_FILTER_X86], 1,
130                                         [Define to 1 if support for the
131                                         x86 (BCJ) filter is enabled.])
132                                 ;;
133                         powerpc)
134                                 enable_filters_powerpc=yes
135                                 enable_simple_filters=yes
136                                 AC_DEFINE([HAVE_FILTER_POWERPC], 1,
137                                         [Define to 1 if support for the
138                                         PowerPC filter is enabled.])
139                                 ;;
140                         ia64)
141                                 enable_filters_ia64=yes
142                                 enable_simple_filters=yes
143                                 AC_DEFINE([HAVE_FILTER_IA64], 1,
144                                         [Define to 1 if support for the
145                                         IA64 filter is enabled.])
146                                 ;;
147                         arm)
148                                 enable_filters_arm=yes
149                                 enable_simple_filters=yes
150                                 AC_DEFINE([HAVE_FILTER_ARM], 1,
151                                         [Define to 1 if support for the
152                                         ARM filter is enabled.])
153                                 ;;
154                         armthumb)
155                                 enable_filters_armthumb=yes
156                                 enable_simple_filters=yes
157                                 AC_DEFINE([HAVE_FILTER_ARMTHUMB], 1,
158                                         [Define to 1 if support for the
159                                         ARMThumb filter is enabled.])
160                                 ;;
161                         sparc)
162                                 enable_filters_sparc=yes
163                                 enable_simple_filters=yes
164                                 AC_DEFINE([HAVE_FILTER_SPARC], 1,
165                                         [Define to 1 if support for the
166                                         SPARC filter is enabled.])
167                                 ;;
168                         delta)
169                                 enable_filters_delta=yes
170                                 AC_DEFINE([HAVE_FILTER_DELTA], 1,
171                                         [Define to 1 if support for the
172                                         Delta filter is enabled.])
173                                 ;;
174                         lzma)
175                                 enable_filters_lzma=yes
176                                 AC_DEFINE([HAVE_FILTER_LZMA], 1,
177                                         [Define to 1 if support for the
178                                         LZMA filter is enabled.])
179                                 ;;
180                         *)
181                                 AC_MSG_RESULT([])
182                                 AC_MSG_ERROR([unknown filter: $arg])
183                                 ;;
184                 esac
185         done
186         AC_MSG_RESULT([$enable_filters])
187 fi
188 if test "x$enable_simple_filters" = xyes ; then
189         AC_DEFINE([HAVE_FILTER_SIMPLE], 1, [Define to 1 if support for any
190                 of the so called simple filters is enabled.])
191 fi
192 AM_CONDITIONAL(COND_FILTER_COPY, test "x$enable_filters_copy" = xyes)
193 AM_CONDITIONAL(COND_FILTER_SUBBLOCK, test "x$enable_filters_subblock" = xyes)
194 AM_CONDITIONAL(COND_FILTER_X86, test "x$enable_filters_x86" = xyes)
195 AM_CONDITIONAL(COND_FILTER_POWERPC, test "x$enable_filters_powerpc" = xyes)
196 AM_CONDITIONAL(COND_FILTER_IA64, test "x$enable_filters_ia64" = xyes)
197 AM_CONDITIONAL(COND_FILTER_ARM, test "x$enable_filters_arm" = xyes)
198 AM_CONDITIONAL(COND_FILTER_ARMTHUMB, test "x$enable_filters_armthumb" = xyes)
199 AM_CONDITIONAL(COND_FILTER_SPARC, test "x$enable_filters_sparc" = xyes)
200 AM_CONDITIONAL(COND_FILTER_DELTA, test "x$enable_filters_delta" = xyes)
201 AM_CONDITIONAL(COND_FILTER_LZMA, test "x$enable_filters_lzma" = xyes)
202 AM_CONDITIONAL(COND_MAIN_SIMPLE, test "x$enable_simple_filters" = xyes)
203
204 # Which match finders should be enabled:
205 AC_MSG_CHECKING([which match finders to build])
206 AC_ARG_ENABLE(match-finders, AC_HELP_STRING([--enable-match-finders=],
207                 [Comma-separated list of match finders to build. Default=all.
208                 At least one match finder is required for encoding with
209                 the LZMA filter.
210                 Available match finders: hc3 hc4 bt2 bt3 bt4]), [],
211         [enable_match_finders=hc3,hc4,bt2,bt3,bt4])
212 enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
213 enable_match_finders_hc3=no
214 enable_match_finders_hc4=no
215 enable_match_finders_bt2=no
216 enable_match_finders_bt3=no
217 enable_match_finders_bt4=no
218 if test "x$enable_encoder" = xyes && test "x$enable_filters_lzma" = xyes ; then
219         for arg in $enable_match_finders
220                 do
221                 case $arg in
222                         hc3) enable_match_finders_hc3=yes ;;
223                         hc4) enable_match_finders_hc4=yes ;;
224                         bt2) enable_match_finders_bt2=yes ;;
225                         bt3) enable_match_finders_bt3=yes ;;
226                         bt4) enable_match_finders_bt4=yes ;;
227                         *)
228                                 AC_MSG_RESULT([])
229                                 AC_MSG_ERROR([unknown match finder: $arg])
230                                 ;;
231                 esac
232         done
233         AC_MSG_RESULT([$enable_match_finders])
234 else
235         AC_MSG_RESULT([(none because not building the LZMA encoder)])
236 fi
237 AM_CONDITIONAL(COND_MF_HC3, test "x$enable_match_finders_hc3" = xyes)
238 AM_CONDITIONAL(COND_MF_HC4, test "x$enable_match_finders_hc4" = xyes)
239 AM_CONDITIONAL(COND_MF_BT2, test "x$enable_match_finders_bt2" = xyes)
240 AM_CONDITIONAL(COND_MF_BT3, test "x$enable_match_finders_bt3" = xyes)
241 AM_CONDITIONAL(COND_MF_BT4, test "x$enable_match_finders_bt4" = xyes)
242
243 # Which integrity checks to build
244 AC_MSG_CHECKING([which integrity checks to build])
245 AC_ARG_ENABLE(checks, AC_HELP_STRING([--enable-checks=],
246                 [Comma-separated list of integrity checks to build.
247                 Default=all. Available integrity checks: crc32 crc64 sha256]),
248                 [], [enable_checks=crc32,crc64,sha256])
249 enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
250 enable_checks_crc32=no
251 enable_checks_crc64=no
252 enable_checks_sha256=no
253 if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
254         AC_MSG_RESULT([(none)])
255 else
256         for arg in $enable_checks
257         do
258                 case $arg in
259                         crc32)
260                                 enable_checks_crc32=yes
261                                 AC_DEFINE([HAVE_CHECK_CRC32], 1,
262                                         [Define to 1 if CRC32 support
263                                         is enabled.])
264                                 ;;
265                         crc64)
266                                 enable_checks_crc64=yes
267                                 AC_DEFINE([HAVE_CHECK_CRC64], 1,
268                                         [Define to 1 if CRC64 support
269                                         is enabled.])
270                                 ;;
271                         sha256)
272                                 enable_checks_sha256=yes
273                                 AC_DEFINE([HAVE_CHECK_SHA256], 1,
274                                         [Define to 1 if SHA256 support
275                                         is enabled.])
276                                 ;;
277                         *)
278                                 AC_MSG_RESULT([])
279                                 AC_MSG_ERROR([unknown integrity check: $arg])
280                                 ;;
281                 esac
282         done
283         AC_MSG_RESULT([$enable_checks])
284 fi
285 if test "x$enable_checks_crc32" = xno ; then
286         AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
287 fi
288 AM_CONDITIONAL(COND_CHECK_CRC32, test "x$enable_checks_crc32" = xyes)
289 AM_CONDITIONAL(COND_CHECK_CRC64, test "x$enable_checks_crc64" = xyes)
290 AM_CONDITIONAL(COND_CHECK_SHA256, test "x$enable_checks_sha256" = xyes)
291
292 # Assembler optimizations
293 AC_MSG_CHECKING([if assembler optimizations should be used])
294 AC_ARG_ENABLE(assembler, AC_HELP_STRING([--disable-assembler],
295                 [Do not use assembler optimizations even if such exist
296                 for the architecture.]),
297                 [], [enable_assembler=yes])
298 if test "x$enable_assembler" = xyes; then
299         case $host_cpu in
300                 i?86)   enable_assembler=x86 ;;
301                 x86_64) enable_assembler=x86_64 ;;
302                 *)      enable_assembler=no ;;
303         esac
304         # Darwin has different ABI than GNU+Linux and Solaris,
305         # and the assembler code doesn't assemble.
306         case $host_os in
307                 darwin*) enable_assembler=no ;;
308                 *)       ;;
309         esac
310 fi
311 case $enable_assembler in
312         x86)
313                 AC_DEFINE([HAVE_ASM_X86], 1,
314                         [Define to 1 if using x86 assembler optimizations.])
315                 ;;
316         x86_64)
317                 AC_DEFINE([HAVE_ASM_X86_64], 1,
318                         [Define to 1 if using x86_64 assembler optimizations.])
319                 ;;
320         no)
321                 ;;
322         *)
323                 AC_MSG_RESULT([])
324                 AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', or \`x86'.])
325                 ;;
326 esac
327 AC_MSG_RESULT([$enable_assembler])
328 AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
329
330 # Size optimization
331 AC_MSG_CHECKING([if small size is preferred over speed])
332 AC_ARG_ENABLE(small, AC_HELP_STRING([--enable-small],
333                 [Omit precomputed tables to make liblzma a few kilobytes
334                 smaller. This will increase startup time of applications
335                 slightly, because the tables need to be computed first.]),
336                 [], [enable_small=no])
337 if test "x$enable_small" = xyes; then
338         AC_DEFINE([HAVE_SMALL], 1, [Define to 1 if optimizing for size.])
339 elif test "x$enable_small" != xno; then
340         AC_MSG_RESULT([])
341         AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
342 fi
343 AC_MSG_RESULT([$enable_small])
344 AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
345
346 ###############################################################################
347 # Checks for programs.
348 ###############################################################################
349
350 echo
351 echo "Initializing Automake:"
352
353 # There's no C++ or Fortran in LZMA Utils:
354 CXX=no
355 F77=no
356
357 AM_INIT_AUTOMAKE
358 AC_PROG_LN_S
359 AM_PROG_CC_C_O
360 AM_PROG_AS
361 AC_USE_SYSTEM_EXTENSIONS
362
363 echo
364 echo "Threading support:"
365 ACX_PTHREAD
366 CC="$PTHREAD_CC"
367
368 echo
369 echo "Initializing Libtool:"
370 AC_PROG_LIBTOOL
371
372
373 ###############################################################################
374 # Checks for libraries.
375 ###############################################################################
376
377 echo
378 echo "Initializing gettext:"
379 AM_GNU_GETTEXT_VERSION([0.16.1])
380 AM_GNU_GETTEXT([external])
381
382 ###############################################################################
383 # Checks for header files.
384 ###############################################################################
385
386 echo
387 echo "System headers and functions:"
388
389 # There is currently no workarounds in this package if some of
390 # these headers are missing.
391 AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
392         [],
393         [AC_MSG_ERROR([Required header file(s) are missing.])])
394
395 # If any of these headers are missing, things should still work correctly:
396 AC_CHECK_HEADERS([assert.h errno.h byteswap.h sys/param.h sys/sysctl.h],
397         [], [], [
398 #ifdef HAVE_SYS_PARAM_H
399 #       include <sys/param.h>
400 #endif
401 ])
402
403
404 ###############################################################################
405 # Checks for typedefs, structures, and compiler characteristics.
406 ###############################################################################
407
408 AC_C_INLINE
409 AC_C_RESTRICT
410 AX_C_ARITHMETIC_RSHIFT
411
412 AC_HEADER_STDBOOL
413
414 AC_TYPE_UINT8_T
415 AC_TYPE_INT32_T
416 AC_TYPE_UINT32_T
417 AC_TYPE_INT64_T
418 AC_TYPE_UINT64_T
419 AC_TYPE_UINTPTR_T
420
421 AC_CHECK_SIZEOF([unsigned long])
422 AC_CHECK_SIZEOF([size_t])
423
424 # The command line tool can copy high resolution timestamps if such
425 # information is availabe in struct stat. Otherwise one second accuracy
426 # is used. Most systems seem to have st_xtim but BSDs have st_xtimespec.
427 AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec, struct stat.st_mtim.tv_nsec,
428         struct stat.st_atimespec.tv_nsec, struct stat.st_mtimespec.tv_nsec])
429
430 # It is very unlikely that you want to build liblzma without
431 # large file support.
432 AC_SYS_LARGEFILE
433
434 # At the moment, the only endian-dependent part should be the integrity checks.
435 AC_C_BIGENDIAN
436
437
438 ###############################################################################
439 # Checks for library functions.
440 ###############################################################################
441
442 # Gnulib replacements as needed
443 gl_GETOPT
444
445 # Functions that are not mandatory i.e. we have alternatives for them
446 # or we can just drop some functionality:
447 AC_CHECK_FUNCS([memcpy memmove memset futimes futimesat])
448
449 # Check how to find out the amount of physical memory in the system. The
450 # lzma command line tool uses this to automatically limits its memory usage.
451 # - sysconf() gives all the needed info on GNU+Linux and Solaris.
452 # - BSDs use sysctl().
453 AC_MSG_CHECKING([how to detect the amount of physical memory])
454 AC_COMPILE_IFELSE([
455 #include <unistd.h>
456 int
457 main()
458 {
459         long i;
460         i = sysconf(_SC_PAGESIZE);
461         i = sysconf(_SC_PHYS_PAGES);
462         return 0;
463 }
464 ], [
465         AC_DEFINE([HAVE_PHYSMEM_SYSCONF], 1,
466                 [Define to 1 if the amount of physical memory can be detected
467                 with sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES).])
468         AC_MSG_RESULT([sysconf])
469 ], [
470 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
471 #include <sys/types.h>
472 #ifdef HAVE_SYS_PARAM_H
473 #       include <sys/param.h>
474 #endif
475 #include <sys/sysctl.h>
476 int
477 main()
478 {
479         int name[2] = { CTL_HW, HW_PHYSMEM };
480         unsigned long mem;
481         size_t mem_ptr_size = sizeof(mem);
482         sysctl(name, 2, &mem, &mem_ptr_size, NULL, NULL);
483         return 0;
484 }
485 ]])], [
486         AC_DEFINE([HAVE_PHYSMEM_SYSCTL], 1,
487                 [Define to 1 if the amount of physical memory can be detected
488                 with sysctl().])
489         AC_MSG_RESULT([sysctl])
490 ], [
491         AC_MSG_RESULT([unknown])
492 ])])
493
494 # Check how to find out the number of available CPU cores in the system.
495 # sysconf(_SC_NPROCESSORS_ONLN) works on most systems, except that BSDs
496 # use sysctl().
497 AC_MSG_CHECKING([how to detect the number of available CPU cores])
498 AC_COMPILE_IFELSE([
499 #include <unistd.h>
500 int
501 main()
502 {
503         long i;
504         i = sysconf(_SC_NPROCESSORS_ONLN);
505         return 0;
506 }
507 ], [
508         AC_DEFINE([HAVE_NCPU_SYSCONF], 1,
509                 [Define to 1 if the number of available CPU cores can be
510                 detected with sysconf(_SC_NPROCESSORS_ONLN).])
511         AC_MSG_RESULT([sysconf])
512 ], [
513 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
514 #include <sys/types.h>
515 #ifdef HAVE_SYS_PARAM_H
516 #       include <sys/param.h>
517 #endif
518 #include <sys/sysctl.h>
519 int
520 main()
521 {
522         int name[2] = { CTL_HW, HW_NCPU };
523         int cpus;
524         size_t cpus_size = sizeof(cpus);
525         sysctl(name, 2, &cpus, &cpus_size, NULL, NULL);
526         return 0;
527 }
528 ]])], [
529         AC_DEFINE([HAVE_NCPU_SYSCTL], 1,
530                 [Define to 1 if the number of available CPU cores can be
531                 detected with sysctl().])
532         AC_MSG_RESULT([sysctl])
533 ], [
534         AC_MSG_RESULT([unknown])
535 ])])
536
537
538 ###############################################################################
539 # If using GCC, set some additional CFLAGS:
540 ###############################################################################
541
542 Wno_uninitialized=no
543
544 if test "x$GCC" = xyes ; then
545         echo
546         echo "GCC extensions:"
547         gl_VISIBILITY
548         if test -n "$CFLAG_VISIBILITY" ; then
549                 CFLAGS="$CFLAG_VISIBILITY $CFLAGS"
550         fi
551
552         # -Wno-uninitialized is needed with -Werror with SHA256 code
553         # to omit a bogus warning.
554         AC_MSG_CHECKING([if $CC accepts -Wno-uninitialized])
555         OLD_CFLAGS="$CFLAGS"
556         CFLAGS="$CFLAGS -Wno-uninitialized"
557         AC_COMPILE_IFELSE([void foo(void) { }], [Wno_uninitialized=yes])
558         CFLAGS="$OLD_CFLAGS"
559         AC_MSG_RESULT([$Wno_uninitialized])
560
561         # Enable as much warnings as possible. These commented warnings won't
562         # work for LZMA Utils though:
563         #   * -Wunreachable-code breaks several assert(0) cases, which are
564         #     backed up with "return LZMA_PROG_ERROR".
565         #   * -Wcast-qual would break various things where we need a non-const
566         #     pointer although we don't modify anything through it.
567         #   * -Wcast-align breaks optimized CRC32 and CRC64 implementation
568         #     on some architectures (not on x86), where this warning is bogus,
569         #     because we take care of correct alignment.
570         #   * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
571         #     don't seem so useful here; at least the last one gives some
572         #     warnings which are not bugs.
573         #
574         # The flags are in reverse order below so they end up in "beautiful"
575         # order on the actual command line.
576         for NEW_FLAG in \
577                         -Wredundant-decls \
578                         -Wmissing-noreturn \
579                         -Wmissing-declarations \
580                         -Wmissing-prototypes \
581                         -Wold-style-definition \
582                         -Wstrict-prototypes \
583                         -Waggregate-return \
584                         -Wwrite-strings \
585                         -Wbad-function-cast \
586                         -Wpointer-arith \
587                         -Wshadow \
588                         -Wfloat-equal \
589                         -Wstrict-aliasing=2 \
590                         -Winit-self \
591                         -Wformat=2 \
592                         -Wextra \
593                         -Wall \
594                         -pedantic \
595                         -std=c99
596         do
597                 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
598                 OLD_CFLAGS="$CFLAGS"
599                 CFLAGS="$NEW_FLAG $CFLAGS"
600                 AC_COMPILE_IFELSE([void foo(void) { }], [
601                         AC_MSG_RESULT([yes])
602                 ], [
603                         CFLAGS="$OLD_CFLAGS"
604                         AC_MSG_RESULT([no])
605                 ])
606         done
607
608         AC_ARG_ENABLE([werror],
609                 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
610                         compilation on all compiler warnings.]),
611                 [], [enable_werror=no])
612         if test "x$enable_werror" = "xyes"; then
613                 CFLAGS="-Werror $CFLAGS"
614         fi
615 fi
616
617 AM_CONDITIONAL([COND_WNO_UNINITIALIZED], test "x$Wno_uninitialized" = "xyes")
618
619
620 ###############################################################################
621 # Create the makefiles and config.h
622 ###############################################################################
623
624 echo
625
626 # Don't build the lib directory at all if we don't need any replacement
627 # functions.
628 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
629
630 AC_CONFIG_FILES([
631         Doxyfile
632         Makefile
633         po/Makefile.in
634         lib/Makefile
635         src/Makefile
636         src/liblzma/lzma.pc
637         src/liblzma/Makefile
638         src/liblzma/api/Makefile
639         src/liblzma/common/Makefile
640         src/liblzma/check/Makefile
641         src/liblzma/lz/Makefile
642         src/liblzma/lzma/Makefile
643         src/liblzma/simple/Makefile
644         src/liblzma/subblock/Makefile
645         src/liblzma/rangecoder/Makefile
646         src/lzma/Makefile
647         src/lzmadec/Makefile
648         src/scripts/Makefile
649         tests/Makefile
650         debug/Makefile
651 ])
652
653 AC_OUTPUT