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