]> icculus.org git repositories - icculus/xz.git/blob - configure.ac
Make the memusage functions of LZMA1 and LZMA2 encoders
[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 1 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([sys/param.h sys/sysctl.h byteswap.h],
444         [], [], [
445 #ifdef HAVE_SYS_PARAM_H
446 #       include <sys/param.h>
447 #endif
448 ])
449
450 # Even if we have byteswap.h, we may lack the specific macros/functions.
451 if test x$ac_cv_header_byteswap_h = xyes ; then
452         m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
453                 AC_MSG_CHECKING([if FUNC is available])
454                 AC_LINK_IFELSE([AC_LANG_SOURCE([
455 #include <byteswap.h>
456 int
457 main(void)
458 {
459         FUNC[](42);
460         return 0;
461 }
462                 ])], [
463                         AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
464                                         [Define to 1 if] FUNC [is available.])
465                         AC_MSG_RESULT([yes])
466                 ], [AC_MSG_RESULT([no])])
467
468         ])dnl
469 fi
470
471
472 ###############################################################################
473 # Checks for typedefs, structures, and compiler characteristics.
474 ###############################################################################
475
476 dnl We don't need these as long as we need a C99 compiler anyway.
477 dnl AC_C_INLINE
478 dnl AC_C_RESTRICT
479
480 AC_HEADER_STDBOOL
481
482 AC_TYPE_UINT8_T
483 AC_TYPE_UINT16_T
484 AC_TYPE_INT32_T
485 AC_TYPE_UINT32_T
486 AC_TYPE_INT64_T
487 AC_TYPE_UINT64_T
488 AC_TYPE_UINTPTR_T
489
490 AC_CHECK_SIZEOF([size_t])
491
492 # The command line tool can copy high resolution timestamps if such
493 # information is availabe in struct stat. Otherwise one second accuracy
494 # is used.
495 AC_CHECK_MEMBERS([
496         struct stat.st_atim.tv_nsec,
497         struct stat.st_atimespec.tv_nsec,
498         struct stat.st_atimensec,
499         struct stat.st_uatime,
500         struct stat.st_atim.st__tim.tv_nsec])
501
502 AC_SYS_LARGEFILE
503 AC_C_BIGENDIAN
504
505
506 ###############################################################################
507 # Checks for library functions.
508 ###############################################################################
509
510 # Gnulib replacements as needed
511 gl_GETOPT
512
513 # Find the best function to set timestamps.
514 AC_CHECK_FUNCS([futimens futimes futimesat utimes utime], [break])
515
516 # Check how to find out the amount of physical memory in the system. The
517 # lzma command line tool uses this to automatically limits its memory usage.
518 # - sysconf() gives all the needed info on GNU+Linux and Solaris.
519 # - BSDs use sysctl().
520 AC_MSG_CHECKING([how to detect the amount of physical memory])
521 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
522 #include <unistd.h>
523 int
524 main()
525 {
526         long i;
527         i = sysconf(_SC_PAGESIZE);
528         i = sysconf(_SC_PHYS_PAGES);
529         return 0;
530 }
531 ]])], [
532         AC_DEFINE([HAVE_PHYSMEM_SYSCONF], 1,
533                 [Define to 1 if the amount of physical memory can be detected
534                 with sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES).])
535         AC_MSG_RESULT([sysconf])
536 ], [
537 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
538 #include <sys/types.h>
539 #ifdef HAVE_SYS_PARAM_H
540 #       include <sys/param.h>
541 #endif
542 #include <sys/sysctl.h>
543 int
544 main()
545 {
546         int name[2] = { CTL_HW, HW_PHYSMEM };
547         unsigned long mem;
548         size_t mem_ptr_size = sizeof(mem);
549         sysctl(name, 2, &mem, &mem_ptr_size, NULL, NULL);
550         return 0;
551 }
552 ]])], [
553         AC_DEFINE([HAVE_PHYSMEM_SYSCTL], 1,
554                 [Define to 1 if the amount of physical memory can be detected
555                 with sysctl().])
556         AC_MSG_RESULT([sysctl])
557 ], [
558         AC_MSG_RESULT([unknown])
559 ])])
560
561 # Check how to find out the number of available CPU cores in the system.
562 # sysconf(_SC_NPROCESSORS_ONLN) works on most systems, except that BSDs
563 # use sysctl().
564 AC_MSG_CHECKING([how to detect the number of available CPU cores])
565 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
566 #include <unistd.h>
567 int
568 main()
569 {
570         long i;
571         i = sysconf(_SC_NPROCESSORS_ONLN);
572         return 0;
573 }
574 ]])], [
575         AC_DEFINE([HAVE_NCPU_SYSCONF], 1,
576                 [Define to 1 if the number of available CPU cores can be
577                 detected with sysconf(_SC_NPROCESSORS_ONLN).])
578         AC_MSG_RESULT([sysconf])
579 ], [
580 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
581 #include <sys/types.h>
582 #ifdef HAVE_SYS_PARAM_H
583 #       include <sys/param.h>
584 #endif
585 #include <sys/sysctl.h>
586 int
587 main()
588 {
589         int name[2] = { CTL_HW, HW_NCPU };
590         int cpus;
591         size_t cpus_size = sizeof(cpus);
592         sysctl(name, 2, &cpus, &cpus_size, NULL, NULL);
593         return 0;
594 }
595 ]])], [
596         AC_DEFINE([HAVE_NCPU_SYSCTL], 1,
597                 [Define to 1 if the number of available CPU cores can be
598                 detected with sysctl().])
599         AC_MSG_RESULT([sysctl])
600 ], [
601         AC_MSG_RESULT([unknown])
602 ])])
603
604
605 ###############################################################################
606 # If using GCC, set some additional CFLAGS:
607 ###############################################################################
608
609 Wno_uninitialized=no
610
611 if test "x$GCC" = xyes ; then
612         echo
613         echo "GCC extensions:"
614         gl_VISIBILITY
615         if test -n "$CFLAG_VISIBILITY" ; then
616                 CFLAGS="$CFLAG_VISIBILITY $CFLAGS"
617         fi
618
619         # -Wno-uninitialized is needed with -Werror with SHA256 code
620         # to omit a bogus warning.
621         AC_MSG_CHECKING([if $CC accepts -Wno-uninitialized])
622         OLD_CFLAGS="$CFLAGS"
623         CFLAGS="$CFLAGS -Wno-uninitialized"
624         AC_COMPILE_IFELSE([void foo(void) { }], [Wno_uninitialized=yes])
625         CFLAGS="$OLD_CFLAGS"
626         AC_MSG_RESULT([$Wno_uninitialized])
627
628         # Enable as much warnings as possible. These commented warnings won't
629         # work for LZMA Utils though:
630         #   * -Wunreachable-code breaks several assert(0) cases, which are
631         #     backed up with "return LZMA_PROG_ERROR".
632         #   * -Wcast-qual would break various things where we need a non-const
633         #     pointer although we don't modify anything through it.
634         #   * -Wcast-align breaks optimized CRC32 and CRC64 implementation
635         #     on some architectures (not on x86), where this warning is bogus,
636         #     because we take care of correct alignment.
637         #   * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
638         #     don't seem so useful here; at least the last one gives some
639         #     warnings which are not bugs.
640         #
641         # The flags are in reverse order below so they end up in "beautiful"
642         # order on the actual command line.
643         for NEW_FLAG in \
644                         -Wredundant-decls \
645                         -Wmissing-noreturn \
646                         -Wmissing-declarations \
647                         -Wmissing-prototypes \
648                         -Wold-style-definition \
649                         -Wstrict-prototypes \
650                         -Waggregate-return \
651                         -Wwrite-strings \
652                         -Wbad-function-cast \
653                         -Wpointer-arith \
654                         -Wshadow \
655                         -Wfloat-equal \
656                         -Wstrict-aliasing=2 \
657                         -Winit-self \
658                         -Wformat=2 \
659                         -Wextra \
660                         -Wall \
661                         -pedantic
662         do
663                 AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
664                 OLD_CFLAGS="$CFLAGS"
665                 CFLAGS="$NEW_FLAG $CFLAGS"
666                 AC_COMPILE_IFELSE([void foo(void) { }], [
667                         AC_MSG_RESULT([yes])
668                 ], [
669                         CFLAGS="$OLD_CFLAGS"
670                         AC_MSG_RESULT([no])
671                 ])
672         done
673
674         AC_ARG_ENABLE([werror],
675                 AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
676                         compilation on all compiler warnings.]),
677                 [], [enable_werror=no])
678         if test "x$enable_werror" = "xyes"; then
679                 CFLAGS="-Werror $CFLAGS"
680         fi
681 fi
682
683 AM_CONDITIONAL([COND_WNO_UNINITIALIZED], test "x$Wno_uninitialized" = "xyes")
684
685
686 ###############################################################################
687 # Create the makefiles and config.h
688 ###############################################################################
689
690 echo
691
692 # Don't build the lib directory at all if we don't need any replacement
693 # functions.
694 AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
695
696 AC_CONFIG_FILES([
697         Doxyfile
698         Makefile
699         po/Makefile.in
700         lib/Makefile
701         src/Makefile
702         src/liblzma/lzma.pc
703         src/liblzma/Makefile
704         src/liblzma/api/Makefile
705         src/liblzma/common/Makefile
706         src/liblzma/check/Makefile
707         src/liblzma/rangecoder/Makefile
708         src/liblzma/lz/Makefile
709         src/liblzma/lzma/Makefile
710         src/liblzma/subblock/Makefile
711         src/liblzma/delta/Makefile
712         src/liblzma/simple/Makefile
713         src/xz/Makefile
714         src/xzdec/Makefile
715         src/scripts/Makefile
716         tests/Makefile
717         debug/Makefile
718 ])
719
720 AC_OUTPUT