configure: Add a check for the -Wl,--as-needed flag.

This fits with our general build philosophy of checking at configure
time for desired support, (rather than putting platform-specific
conditionals into our Makefiles).
This commit is contained in:
Carl Worth 2010-10-30 13:20:33 -07:00
parent e94db26c5c
commit 6b9a717c26
2 changed files with 15 additions and 4 deletions

View file

@ -31,11 +31,9 @@ GPG_FILE=$(SHA1_FILE).asc
# Smash together user's values with our extra values # Smash together user's values with our extra values
FINAL_CFLAGS = -DNOTMUCH_VERSION=$(VERSION) $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags) FINAL_CFLAGS = -DNOTMUCH_VERSION=$(VERSION) $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags) FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
FINAL_NOTMUCH_LDFLAGS = $(LDFLAGS) -Llib -lnotmuch $(GMIME_LDFLAGS) $(TALLOC_LDFLAGS) FINAL_NOTMUCH_LDFLAGS = $(LDFLAGS) -Llib -lnotmuch $(GMIME_LDFLAGS) $(TALLOC_LDFLAGS) $(AS_NEEDED_LDFLAGS)
FINAL_NOTMUCH_LINKER = CC FINAL_NOTMUCH_LINKER = CC
ifeq ($(LINKER_RESOLVES_LIBRARY_DEPENDENCIES),1) ifneq ($(LINKER_RESOLVES_LIBRARY_DEPENDENCIES),1)
FINAL_NOTMUCH_LDFLAGS += -Wl,--as-needed
else
FINAL_NOTMUCH_LDFLAGS += $(CONFIGURE_LDFLAGS) FINAL_NOTMUCH_LDFLAGS += $(CONFIGURE_LDFLAGS)
FINAL_NOTMUCH_LINKER = CXX FINAL_NOTMUCH_LINKER = CXX
endif endif

13
configure vendored
View file

@ -402,6 +402,16 @@ else
rpath_ldflags="" rpath_ldflags=""
fi fi
printf "Checking for -Wl,--as-needed... "
if ${CC} -Wl,--as-needed -o minimal minimal.c >/dev/null 2>&1
then
printf "Yes.\n"
as_needed_ldflags="-Wl,--as-needed"
else
printf "No (nothing to worry about).\n"
as_needed_ldflags=""
fi
WARN_CXXFLAGS="" WARN_CXXFLAGS=""
printf "Checking for available C++ compiler warning flags... " printf "Checking for available C++ compiler warning flags... "
for flag in -Wall -Wextra -Wwrite-strings -Wswitch-enum; do for flag in -Wall -Wextra -Wwrite-strings -Wswitch-enum; do
@ -535,6 +545,9 @@ TALLOC_LDFLAGS = ${talloc_ldflags}
# Flags needed to have linker set rpath attribute # Flags needed to have linker set rpath attribute
RPATH_LDFLAGS = ${rpath_ldflags} RPATH_LDFLAGS = ${rpath_ldflags}
# Flags needed to have linker link only to necessary libraries
AS_NEEDED_LDFLAGS = ${as_needed_ldflags}
# Whether valgrind header files are available # Whether valgrind header files are available
HAVE_VALGRIND = ${have_valgrind} HAVE_VALGRIND = ${have_valgrind}