aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2012-12-03 22:40:26 +0100
committerYang Tse <yangsita@gmail.com>2012-12-03 22:41:18 +0100
commit068f7ae2645844ce76b73702bd275f2073f3919c (patch)
treee058bde364ccad867e1c413d0a101023c28a2455
parent68d2830ee9df50961e481e81c1baaa290c33f03e (diff)
build: prevent global LIBS from influencing src and lib build targets
Currently, LIBS is already used through other macros.
-rw-r--r--acinclude.m45
-rw-r--r--configure.ac265
-rw-r--r--curl-config.in6
-rw-r--r--lib/Makefile.am3
-rw-r--r--libcurl.pc.in4
-rw-r--r--src/Makefile.am10
6 files changed, 153 insertions, 140 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 4921bd210..6596be710 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -130,7 +130,7 @@ int main (void)
]])
],[
tst_lib_xnet_required="yes"
- LIBS="$LIBS -lxnet"
+ LIBS="-lxnet $LIBS"
])
AC_MSG_RESULT([$tst_lib_xnet_required])
])
@@ -2103,7 +2103,6 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
#
curl_cv_save_LIBS="$LIBS"
curl_cv_gclk_LIBS="unknown"
- curl_cv_save_CURL_LIBS="$CURL_LIBS"
#
for x_xlibs in '' '-lrt' '-lposix4' ; do
if test "$curl_cv_gclk_LIBS" = "unknown"; then
@@ -2155,7 +2154,6 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
else
LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
fi
- CURL_LIBS="$CURL_LIBS $curl_cv_gclk_LIBS"
AC_MSG_RESULT([$curl_cv_gclk_LIBS])
ac_cv_func_clock_gettime="yes"
;;
@@ -2197,7 +2195,6 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
ac_cv_func_clock_gettime="no"
LIBS="$curl_cv_save_LIBS"
- CURL_LIBS="$curl_cv_save_CURL_LIBS"
])
fi
#
diff --git a/configure.ac b/configure.ac
index d9f9783f0..0ad654790 100644
--- a/configure.ac
+++ b/configure.ac
@@ -168,9 +168,10 @@ curl_verbose_msg="enabled (--disable-verbose)"
init_ssl_msg=${curl_ssl_msg}
dnl
-dnl Save anything in $LIBS for later
+dnl Save some initial values the user might have provided
dnl
-ALL_LIBS=$LIBS
+INITIAL_LDFLAGS=$LDFLAGS
+INITIAL_LIBS=$LIBS
dnl
dnl Detect the canonical host and target build environment
@@ -682,6 +683,20 @@ dnl **********************************************************************
dnl Checks for libraries.
dnl **********************************************************************
+AC_MSG_CHECKING([whether to use libgcc])
+AC_ARG_ENABLE(libgcc,
+AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
+[ case "$enableval" in
+ yes)
+ LIBS="-lgcc $LIBS"
+ AC_MSG_RESULT(yes)
+ ;;
+ *) AC_MSG_RESULT(no)
+ ;;
+ esac ],
+ AC_MSG_RESULT(no)
+)
+
CURL_CHECK_LIB_XNET
dnl gethostbyname without lib or in the nsl lib?
@@ -690,7 +705,7 @@ AC_CHECK_FUNC(gethostbyname,
],
[ AC_CHECK_LIB(nsl, gethostbyname,
[HAVE_GETHOSTBYNAME="1"
- LIBS="$LIBS -lnsl"
+ LIBS="-lnsl $LIBS"
])
])
@@ -699,7 +714,7 @@ then
dnl gethostbyname in the socket lib?
AC_CHECK_LIB(socket, gethostbyname,
[HAVE_GETHOSTBYNAME="1"
- LIBS="$LIBS -lsocket"
+ LIBS="-lsocket $LIBS"
])
fi
@@ -710,7 +725,7 @@ then
[HAVE_GETHOSTBYNAME="1"
CPPFLAGS="-I/dev/env/WATT_ROOT/inc"
LDFLAGS="-L/dev/env/WATT_ROOT/lib"
- LIBS="$LIBS -lwatt"
+ LIBS="-lwatt $LIBS"
])
fi
@@ -754,7 +769,7 @@ then
fi
if test ! -z "$winsock_LIB"; then
my_ac_save_LIBS=$LIBS
- LIBS="$LIBS $winsock_LIB"
+ LIBS="$winsock_LIB $LIBS"
AC_MSG_CHECKING([for gethostbyname in $winsock_LIB])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
@@ -829,7 +844,7 @@ then
dnl gethostbyname in the network lib - for Haiku OS
AC_CHECK_LIB(network, gethostbyname,
[HAVE_GETHOSTBYNAME="1"
- LIBS="$LIBS -lnetwork"
+ LIBS="-lnetwork $LIBS"
])
fi
@@ -838,7 +853,7 @@ then
dnl gethostbyname in the net lib - for BeOS
AC_CHECK_LIB(net, gethostbyname,
[HAVE_GETHOSTBYNAME="1"
- LIBS="$LIBS -lnet"
+ LIBS="-lnet $LIBS"
])
fi
@@ -877,19 +892,101 @@ dnl **********************************************************************
CURL_NETWORK_AND_TIME_LIBS=$LIBS
dnl **********************************************************************
-AC_MSG_CHECKING([whether to use libgcc])
-AC_ARG_ENABLE(libgcc,
-AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
-[ case "$enableval" in
- yes)
- ALL_LIBS="$ALL_LIBS -lgcc"
- AC_MSG_RESULT(yes)
- ;;
- *) AC_MSG_RESULT(no)
- ;;
- esac ],
- AC_MSG_RESULT(no)
-)
+dnl Check for the presence of ZLIB libraries and headers
+dnl **********************************************************************
+
+dnl Check for & handle argument to --with-zlib.
+
+clean_CPPFLAGS=$CPPFLAGS
+clean_LDFLAGS=$LDFLAGS
+clean_LIBS=$LIBS
+ZLIB_LIBS=""
+AC_ARG_WITH(zlib,
+AC_HELP_STRING([--with-zlib=PATH],[search for zlib in PATH])
+AC_HELP_STRING([--without-zlib],[disable use of zlib]),
+ [OPT_ZLIB="$withval"])
+
+if test "$OPT_ZLIB" = "no" ; then
+ AC_MSG_WARN([zlib disabled])
+else
+ if test "$OPT_ZLIB" = "yes" ; then
+ OPT_ZLIB=""
+ fi
+
+ if test -z "$OPT_ZLIB" ; then
+ dnl check for the lib first without setting any new path, since many
+ dnl people have it in the default path
+
+ AC_CHECK_LIB(z, inflateEnd,
+ dnl libz found, set the variable
+ [HAVE_LIBZ="1"
+ LIBS="-lz $LIBS"],
+ dnl if no lib found, try /usr/local
+ [OPT_ZLIB="/usr/local"])
+
+ fi
+
+ dnl Add a nonempty path to the compiler flags
+ if test -n "$OPT_ZLIB"; then
+ CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
+ LDFLAGS="$LDFLAGS -L$OPT_ZLIB/lib$libsuff"
+ fi
+
+ AC_CHECK_HEADER(zlib.h,
+ [
+ dnl zlib.h was found
+ HAVE_ZLIB_H="1"
+ dnl if the lib wasn't found already, try again with the new paths
+ if test "$HAVE_LIBZ" != "1"; then
+ AC_CHECK_LIB(z, gzread,
+ [
+ dnl the lib was found!
+ HAVE_LIBZ="1"
+ LIBS="-lz $LIBS"
+ ],
+ [ CPPFLAGS=$clean_CPPFLAGS
+ LDFLAGS=$clean_LDFLAGS])
+ fi
+ ],
+ [
+ dnl zlib.h was not found, restore the flags
+ CPPFLAGS=$clean_CPPFLAGS
+ LDFLAGS=$clean_LDFLAGS]
+ )
+
+ if test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" != "1"
+ then
+ AC_MSG_WARN([configure found only the libz lib, not the header file!])
+ HAVE_LIBZ=""
+ CPPFLAGS=$clean_CPPFLAGS
+ LDFLAGS=$clean_LDFLAGS
+ LIBS=$clean_LIBS
+ elif test "$HAVE_LIBZ" != "1" && test "$HAVE_ZLIB_H" = "1"
+ then
+ AC_MSG_WARN([configure found only the libz header file, not the lib!])
+ CPPFLAGS=$clean_CPPFLAGS
+ LDFLAGS=$clean_LDFLAGS
+ LIBS=$clean_LIBS
+ elif test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" = "1"
+ then
+ dnl both header and lib were found!
+ AC_SUBST(HAVE_LIBZ)
+ AC_DEFINE(HAVE_ZLIB_H, 1, [if you have the zlib.h header file])
+ AC_DEFINE(HAVE_LIBZ, 1, [if zlib is available])
+
+ ZLIB_LIBS="-lz"
+ LIBS="-lz $clean_LIBS"
+
+ dnl replace 'HAVE_LIBZ' in the automake makefile.ams
+ AMFIXLIB="1"
+ AC_MSG_NOTICE([found both libz and libz.h header])
+ curl_zlib_msg="enabled"
+ fi
+fi
+
+dnl set variable for use in automakefile(s)
+AM_CONDITIONAL(HAVE_LIBZ, test x"$AMFIXLIB" = x1)
+AC_SUBST(ZLIB_LIBS)
dnl **********************************************************************
dnl Check for LDAP
@@ -1315,29 +1412,29 @@ if test x"$want_gss" = xyes; then
if test -n "$gnu_gss"; then
curl_gss_msg="enabled (GNU GSS)"
LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
- LIBS="$LIBS -lgss"
+ LIBS="-lgss $LIBS"
elif test -z "$GSSAPI_LIB_DIR"; then
case $host in
*-*-darwin*)
- LIBS="$LIBS -lgssapi_krb5 -lresolv"
+ LIBS="-lgssapi_krb5 -lresolv $LIBS"
;;
*)
if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
dnl krb5-config doesn't have --libs-only-L or similar, put everything
dnl into LIBS
gss_libs=`$GSSAPI_ROOT/bin/krb5-config --libs gssapi`
- LIBS="$LIBS $gss_libs"
+ LIBS="$gss_libs $LIBS"
elif test "$GSSAPI_ROOT" != "yes"; then
LDFLAGS="$LDFLAGS -L$GSSAPI_ROOT/lib$libsuff"
- LIBS="$LIBS -lgssapi"
+ LIBS="-lgssapi $LIBS"
else
- LIBS="$LIBS -lgssapi"
+ LIBS="-lgssapi $LIBS"
fi
;;
esac
else
LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
- LIBS="$LIBS -lgssapi"
+ LIBS="-lgssapi $LIBS"
fi
else
CPPFLAGS="$save_CPPFLAGS"
@@ -1484,7 +1581,7 @@ if test "$curl_ssl_msg" = "$init_ssl_msg" && test X"$OPT_SSL" != Xno; then
dnl the argument to --with-ssl we don't know what
dnl additional libs may be necessary. Hope that we
dnl don't need any.
- LIBS="$LIBS $SSL_LIBS"
+ LIBS="$SSL_LIBS $LIBS"
fi
fi
@@ -1536,7 +1633,7 @@ if test "$curl_ssl_msg" = "$init_ssl_msg" && test X"$OPT_SSL" != Xno; then
dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
OLIBS=$LIBS
- LIBS="$LIBS -lRSAglue -lrsaref"
+ LIBS="-lRSAglue -lrsaref $LIBS"
AC_CHECK_LIB(ssl, SSL_connect)
if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
dnl still no SSL_connect
@@ -1652,92 +1749,6 @@ if test "$curl_ssl_msg" = "$init_ssl_msg" && test X"$OPT_SSL" != Xno; then
fi
dnl **********************************************************************
-dnl Check for the presence of ZLIB libraries and headers
-dnl **********************************************************************
-
-dnl Check for & handle argument to --with-zlib.
-
-_cppflags=$CPPFLAGS
-_ldflags=$LDFLAGS
-AC_ARG_WITH(zlib,
-AC_HELP_STRING([--with-zlib=PATH],[search for zlib in PATH])
-AC_HELP_STRING([--without-zlib],[disable use of zlib]),
- [OPT_ZLIB="$withval"])
-
-if test "$OPT_ZLIB" = "no" ; then
- AC_MSG_WARN([zlib disabled])
-else
- if test "$OPT_ZLIB" = "yes" ; then
- OPT_ZLIB=""
- fi
-
- if test -z "$OPT_ZLIB" ; then
- dnl check for the lib first without setting any new path, since many
- dnl people have it in the default path
-
- AC_CHECK_LIB(z, inflateEnd,
- dnl libz found, set the variable
- [HAVE_LIBZ="1"],
- dnl if no lib found, try /usr/local
- [OPT_ZLIB="/usr/local"])
-
- fi
-
- dnl Add a nonempty path to the compiler flags
- if test -n "$OPT_ZLIB"; then
- CPPFLAGS="$CPPFLAGS -I$OPT_ZLIB/include"
- LDFLAGS="$LDFLAGS -L$OPT_ZLIB/lib$libsuff"
- fi
-
- AC_CHECK_HEADER(zlib.h,
- [
- dnl zlib.h was found
- HAVE_ZLIB_H="1"
- dnl if the lib wasn't found already, try again with the new paths
- if test "$HAVE_LIBZ" != "1"; then
- AC_CHECK_LIB(z, gzread,
- [
- dnl the lib was found!
- HAVE_LIBZ="1"
- ],
- [ CPPFLAGS=$_cppflags
- LDFLAGS=$_ldflags])
- fi
- ],
- [
- dnl zlib.h was not found, restore the flags
- CPPFLAGS=$_cppflags
- LDFLAGS=$_ldflags]
- )
-
- if test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" != "1"
- then
- AC_MSG_WARN([configure found only the libz lib, not the header file!])
- HAVE_LIBZ=""
- elif test "$HAVE_LIBZ" != "1" && test "$HAVE_ZLIB_H" = "1"
- then
- AC_MSG_WARN([configure found only the libz header file, not the lib!])
- elif test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" = "1"
- then
- dnl both header and lib were found!
- AC_SUBST(HAVE_LIBZ)
- AC_DEFINE(HAVE_ZLIB_H, 1, [if you have the zlib.h header file])
- AC_DEFINE(HAVE_LIBZ, 1, [if zlib is available])
-
- CURL_LIBS="$CURL_LIBS -lz"
- LIBS="$LIBS -lz"
-
- dnl replace 'HAVE_LIBZ' in the automake makefile.ams
- AMFIXLIB="1"
- AC_MSG_NOTICE([found both libz and libz.h header])
- curl_zlib_msg="enabled"
- fi
-fi
-
-dnl set variable for use in automakefile(s)
-AM_CONDITIONAL(HAVE_LIBZ, test x"$AMFIXLIB" = x1)
-
-dnl **********************************************************************
dnl Check for the random seed preferences
dnl **********************************************************************
@@ -1853,7 +1864,7 @@ if test "$curl_ssl_msg" = "$init_ssl_msg"; then
CLEANCPPFLAGS="$CPPFLAGS"
CLEADLDFLAGS="$LDFLAGS"
- LIBS="$LIBS $addlib"
+ LIBS="$addlib $LIBS"
LDFLAGS="$LDFLAGS $addld"
if test "$addcflags" != "-I/usr/include"; then
CPPFLAGS="$CPPFLAGS $addcflags"
@@ -1918,9 +1929,9 @@ if test "$GNUTLS_ENABLED" = "1"; then
if test "$USE_GNUTLS_NETTLE" = "1"; then
AC_DEFINE(USE_GNUTLS_NETTLE, 1, [if GnuTLS uses nettle as crypto backend])
AC_SUBST(USE_GNUTLS_NETTLE, [1])
- LIBS="$LIBS -lnettle"
+ LIBS="-lnettle $LIBS"
else
- LIBS="$LIBS -lgcrypt"
+ LIBS="-lgcrypt $LIBS"
fi
fi
@@ -1999,8 +2010,7 @@ if test "$curl_ssl_msg" = "$init_ssl_msg"; then
if test "x$USE_POLARSSL" = "xyes"; then
AC_MSG_NOTICE([detected PolarSSL])
- CURL_LIBS="$CURL_LIBS -lpolarssl"
- LIBS="$LIBS -lpolarssl"
+ LIBS="-lpolarssl $LIBS"
if test -n "$polarssllib"; then
dnl when shared libs were found in a path that the run-time
@@ -2083,8 +2093,7 @@ if test "$curl_ssl_msg" = "$init_ssl_msg"; then
if test "x$USE_CYASSL" = "xyes"; then
AC_MSG_NOTICE([detected CyaSSL])
- CURL_LIBS="$CURL_LIBS -lcyassl -lm"
- LIBS="$LIBS -lcyassl -lm"
+ LIBS="-lcyassl -lm $LIBS"
if test -n "$cyassllib"; then
dnl when shared libs were found in a path that the run-time
@@ -2156,7 +2165,7 @@ if test "$curl_ssl_msg" = "$init_ssl_msg"; then
CLEANLIBS="$LIBS"
CLEANCPPFLAGS="$CPPFLAGS"
- LIBS="$LIBS $addlib"
+ LIBS="$addlib $LIBS"
if test "$addcflags" != "-I/usr/include"; then
CPPFLAGS="$CPPFLAGS $addcflags"
fi
@@ -2410,7 +2419,7 @@ if test X"$OPT_LIBSSH2" != Xno; then
LDFLAGS="$LDFLAGS $LD_SSH2"
CPPFLAGS="$CPPFLAGS $CPP_SSH2"
- LIBS="$LIBS $LIB_SSH2"
+ LIBS="$LIB_SSH2 $LIBS"
AC_CHECK_LIB(ssh2, libssh2_channel_open_ex)
@@ -2506,7 +2515,7 @@ if test X"$OPT_LIBRTMP" != Xno; then
LDFLAGS="$LDFLAGS $LD_RTMP"
CPPFLAGS="$CPPFLAGS $CPP_RTMP"
- LIBS="$LIBS $LIB_RTMP"
+ LIBS="$LIB_RTMP $LIBS"
AC_CHECK_LIB(rtmp, RTMP_Init,
[
@@ -3329,16 +3338,13 @@ fi
dnl
dnl All the library dependencies put into $LIB apply to libcurl only.
-dnl Those in $CURL_LIBS apply to the curl command-line client only.
-dnl Those in $ALL_LIBS apply to all targets, including test targets.
dnl
LIBCURL_LIBS=$LIBS
AC_SUBST(LIBCURL_LIBS)
-AC_SUBST(CURL_LIBS)
AC_SUBST(CURL_NETWORK_LIBS)
AC_SUBST(CURL_NETWORK_AND_TIME_LIBS)
-LIBS=$ALL_LIBS dnl LIBS is a magic variable that's used for every link
+dnl LIBS is a magic variable that's used for every link
dnl BLANK_AT_MAKETIME might be used in some of our Makefile.am files to
dnl blank LIBS variable used in generated makefile at makefile processing
@@ -3478,7 +3484,6 @@ squeeze DEFS
squeeze LDFLAGS
squeeze LIBS
-squeeze CURL_LIBS
squeeze LIBCURL_LIBS
squeeze CURL_NETWORK_LIBS
squeeze CURL_NETWORK_AND_TIME_LIBS
diff --git a/curl-config.in b/curl-config.in
index 731761c3d..a719aec4b 100644
--- a/curl-config.in
+++ b/curl-config.in
@@ -148,14 +148,14 @@ while test $# -gt 0; do
CURLLIBDIR=""
fi
if test "X@REQUIRE_LIB_DEPS@" = "Xyes"; then
- echo ${CURLLIBDIR}-lcurl @LIBCURL_LIBS@ @LIBS@
+ echo ${CURLLIBDIR}-lcurl @LIBCURL_LIBS@
else
- echo ${CURLLIBDIR}-lcurl @LIBS@
+ echo ${CURLLIBDIR}-lcurl
fi
;;
--static-libs)
- echo @libdir@/libcurl.@libext@ @LDFLAGS@ @LIBCURL_LIBS@ @LIBS@
+ echo @libdir@/libcurl.@libext@ @LDFLAGS@ @LIBCURL_LIBS@
;;
--configure)
diff --git a/lib/Makefile.am b/lib/Makefile.am
index acfa5a61a..c8a88cd13 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -132,6 +132,9 @@ if VERSIONED_SYMBOLS
VERSIONED_SYMBOLS = -Wl,--version-script=libcurl.vers
endif
+# Prevent global LIBS from influencing lib build targets
+LIBS = $(BLANK_AT_MAKETIME)
+
libcurl_la_LDFLAGS = $(UNDEF) $(VERSIONINFO) $(MIMPURE) $(VERSIONED_SYMBOLS) $(LIBCURL_LIBS)
if DOING_CURL_SYMBOL_HIDING
diff --git a/libcurl.pc.in b/libcurl.pc.in
index 6e878c549..fdfaec916 100644
--- a/libcurl.pc.in
+++ b/libcurl.pc.in
@@ -34,6 +34,6 @@ Name: libcurl
URL: http://curl.haxx.se/
Description: Library to transfer files with ftp, http, etc.
Version: @CURLVERSION@
-Libs: -L${libdir} -lcurl @LIBS@
-Libs.private: @LIBCURL_LIBS@ @LIBS@
+Libs: -L${libdir} -lcurl
+Libs.private: @LIBCURL_LIBS@
Cflags: -I${includedir} @CPPFLAG_CURL_STATICLIB@
diff --git a/src/Makefile.am b/src/Makefile.am
index b53127d27..7839904d5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,7 +54,15 @@ include Makefile.inc
# This might hold -Werror
CFLAGS += @CURL_CFLAG_EXTRAS@ @LIBMETALINK_CFLAGS@
-curl_LDADD = $(top_builddir)/lib/libcurl.la @CURL_LIBS@ @LIBMETALINK_LIBS@
+# Prevent global LIBS from influencing src build targets
+LIBS = $(BLANK_AT_MAKETIME)
+
+if USE_EXPLICIT_LIB_DEPS
+curl_LDADD = $(top_builddir)/lib/libcurl.la @LIBMETALINK_LIBS@ @LIBCURL_LIBS@
+else
+curl_LDADD = $(top_builddir)/lib/libcurl.la @LIBMETALINK_LIBS@ @ZLIB_LIBS@ @CURL_NETWORK_AND_TIME_LIBS@
+endif
+
curl_LDFLAGS = @LIBMETALINK_LDFLAGS@
curl_DEPENDENCIES = $(top_builddir)/lib/libcurl.la
BUILT_SOURCES = hugehelp.c