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