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