Make it easy to choose if command line tools should be

linked statically or dynamically against liblzma. The
default is still to use static liblzma, but it can now
be changed by passing --enable-dynamic to configure.
Thanks to Mike Frysinger for the original patch.

Fixed a few minor bugs in configure.ac.
This commit is contained in:
Lasse Collin 2009-02-07 21:17:07 +02:00
parent 3f86532407
commit 880c330938
3 changed files with 45 additions and 7 deletions

View File

@ -387,11 +387,50 @@ AC_ARG_ENABLE([threads], AC_HELP_STRING([--disable-threads],
This makes some things thread-unsafe.]), This makes some things thread-unsafe.]),
[], [enable_threads=yes]) [], [enable_threads=yes])
if test "x$enable_threads" != xyes && test "x$enable_threads" != xno; then if test "x$enable_threads" != xyes && test "x$enable_threads" != xno; then
AC_MSG_RESULT([])
AC_MSG_ERROR([--enable-threads accepts only \`yes' or \`no']) AC_MSG_ERROR([--enable-threads accepts only \`yes' or \`no'])
fi fi
AC_MSG_RESULT([$enable_threads])
# We use the actual result a little later. # We use the actual result a little later.
############################################
# xz/xzdec/lzmadec linkage against liblzma #
############################################
# Link the command line tool statically against liblzma unless using
# --enable-dynamic. Using static liblzma gives a little bit faster executable
# on x86, because no register is wasted for PIC. We also have one dependency
# less, which allows users to more freely copy the xz binary to other boxes.
# However, I wouldn't be surprised if distro maintainers still prefer dynamic
# linking, so let's make it easy for them.
AC_MSG_CHECKING([how command line tools should be linked against liblzma])
AC_ARG_ENABLE([dynamic], [AC_HELP_STRING([--enable-dynamic],
[Link command line tools dynamically against liblzma.
The default is to use static liblzma if it was
built.])],
[], [enable_dynamic=no])
case $enable_dynamic in
yes)
STATIC_CPPFLAGS=
STATIC_LDFLAGS=
AC_MSG_RESULT([dynamically])
;;
no)
STATIC_CPPFLAGS="-DLZMA_API_STATIC"
STATIC_LDFLAGS="-static"
AC_MSG_RESULT([statically])
;;
*)
AC_MSG_RESULT([])
AC_MSG_ERROR([--enable-dynamic accepts only \`yes' or \`no'])
;;
esac
AC_SUBST([STATIC_CPPFLAGS])
AC_SUBST([STATIC_LDFLAGS])
############################################################################### ###############################################################################
# Checks for programs. # Checks for programs.
############################################################################### ###############################################################################

View File

@ -42,12 +42,10 @@ xz_CPPFLAGS = \
-I@top_srcdir@/src/common \ -I@top_srcdir@/src/common \
-I@top_srcdir@/src/liblzma/api \ -I@top_srcdir@/src/liblzma/api \
-I@top_builddir@/lib \ -I@top_builddir@/lib \
-I@top_srcdir@/lib -I@top_srcdir@/lib \
@STATIC_CPPFLAGS@
## Always link the command line tool statically against liblzma. It is xz_LDFLAGS = @STATIC_LDFLAGS@
## faster on x86, because no need for PIC. We also have one dependency less,
## which allows users to more freely copy the xz binary to other boxes.
xz_LDFLAGS = -static
xz_LDADD = \ xz_LDADD = \
@top_builddir@/src/liblzma/liblzma.la \ @top_builddir@/src/liblzma/liblzma.la \
@LTLIBINTL@ @LTLIBINTL@

View File

@ -18,8 +18,9 @@ xzdec_SOURCES = xzdec.c
xzdec_CPPFLAGS = \ xzdec_CPPFLAGS = \
-I@top_srcdir@/src/common \ -I@top_srcdir@/src/common \
-I@top_srcdir@/src/liblzma/api \ -I@top_srcdir@/src/liblzma/api \
-I@top_builddir@/lib -I@top_builddir@/lib \
xzdec_LDFLAGS = -static @STATIC_CPPFLAGS@
xzdec_LDFLAGS = @STATIC_LDFLAGS@
xzdec_LDADD = \ xzdec_LDADD = \
@top_builddir@/src/liblzma/liblzma.la \ @top_builddir@/src/liblzma/liblzma.la \
@LTLIBINTL@ @LTLIBINTL@