From c5d951846d6b803909cbd7cfeac643f5feb42911 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 30 Mar 2012 14:26:35 -0400 Subject: buildsys: use pkg-config for openssl detection Signed-off-by: Dave Reisner --- lib/libalpm/Makefile.am | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am index 61dcb877..8d1be908 100644 --- a/lib/libalpm/Makefile.am +++ b/lib/libalpm/Makefile.am @@ -64,6 +64,13 @@ libalpm_la_SOURCES += \ endif libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO) @LIBCURL@ -libalpm_la_LIBADD = $(LTLIBINTL) + +libalpm_la_CFLAGS = \ + $(AM_CFLAGS) \ + $(LIBSSL_CFLAGS) + +libalpm_la_LIBADD = \ + $(LTLIBINTL) \ + $(LIBSSL_LIBS) # vim:set ts=2 sw=2 noet: -- cgit v1.2.3-70-g09d2 From 059c572ca5c0f3ac9d90c53f0c0bdc8e4fb0336f Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 30 Mar 2012 14:30:08 -0400 Subject: buildsys: use pkg-config for libarchive detection This also introduces a versioned dependency of >=2.8.0. Signed-off-by: Dave Reisner --- configure.ac | 6 +++--- lib/libalpm/Makefile.am | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/configure.ac b/configure.ac index 2fa7634c..1f265cb5 100644 --- a/configure.ac +++ b/configure.ac @@ -153,8 +153,8 @@ AC_CHECK_LIB([m], [fabs], , AC_MSG_ERROR([libm is needed to compile pacman!])) # Check for libarchive -AC_CHECK_LIB([archive], [archive_read_data], , - AC_MSG_ERROR([libarchive is needed to compile pacman!])) +PKG_CHECK_MODULES(LIBARCHIVE, [libarchive >= 2.8.0], , + AC_MSG_ERROR([*** libarchive >= 2.8.0 is needed to compile pacman!])) # Check for OpenSSL have_openssl=no @@ -412,7 +412,7 @@ ${PACKAGE_NAME}: preprocessor flags : ${CPPFLAGS} compiler flags : ${CFLAGS} defines : ${DEFS} - library flags : ${LIBS} ${LIBSSL_LIBS} + library flags : ${LIBS} ${LIBSSL_LIBS} ${LIBARCHIVE_LIBS} linker flags : ${LDFLAGS} Architecture : ${CARCH} diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am index 8d1be908..3773f2df 100644 --- a/lib/libalpm/Makefile.am +++ b/lib/libalpm/Makefile.am @@ -67,10 +67,12 @@ libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO) @LIBCURL@ libalpm_la_CFLAGS = \ $(AM_CFLAGS) \ + $(LIBARCHIVE_CFLAGS) \ $(LIBSSL_CFLAGS) libalpm_la_LIBADD = \ $(LTLIBINTL) \ + $(LIBARCHIVE_LIBS) \ $(LIBSSL_LIBS) # vim:set ts=2 sw=2 noet: -- cgit v1.2.3-70-g09d2 From b2226ed11bca158ab32199b5899802a78a42f5aa Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 30 Mar 2012 14:37:06 -0400 Subject: buildsys: use pkg-config for libcurl detection Signed-off-by: Dave Reisner --- configure.ac | 21 +++- lib/libalpm/Makefile.am | 4 +- m4/libcurl.m4 | 250 ------------------------------------------------ 3 files changed, 20 insertions(+), 255 deletions(-) delete mode 100644 m4/libcurl.m4 (limited to 'lib') diff --git a/configure.ac b/configure.ac index 1f265cb5..ddcf535d 100644 --- a/configure.ac +++ b/configure.ac @@ -105,8 +105,10 @@ AC_ARG_WITH(gpgme, AS_HELP_STRING([--with-gpgme], [use GPGME for PGP signature verification]), [], [with_gpgme=check]) -# Check for useable libcurl -LIBCURL_CHECK_CONFIG([yes], [7.19.4], [with_libcurl=yes], [with_libcurl=no]) +# Help line for using libcurl +AC_ARG_WITH(curl, + AS_HELP_STRING([--with-libcurl], [use libcurl for the internal downloader]), + [], [with_curl=check]) # Help line for documentation AC_ARG_ENABLE(doc, @@ -167,6 +169,17 @@ if test "x$with_openssl" != "xno"; then fi AM_CONDITIONAL(HAVE_LIBSSL, [test "$have_openssl" = "yes"]) +# Check for libcurl +have_libcurl=no +if test "x$with_libcurl" != "xno"; then + PKG_CHECK_MODULES(LIBCURL, [libcurl >= 7.19.4], + [AC_DEFINE(HAVE_LIBCURL, 1, [Define if libcurl is available]) have_libcurl=yes], have_libcurl=no) + if test "x$have_libcurl" = xno -a "x$with_libcurl" = xyes; then + AC_MSG_ERROR([*** libcurl >= 7.19.4 is required for internal downloader support]) + fi +fi +AM_CONDITIONAL(HAVE_LIBCURL, [test "$have_libcurl" = "yes"]) + # Check for gpgme AC_MSG_CHECKING(whether to link with libgpgme) AS_IF([test "x$with_gpgme" != "xno"], @@ -412,7 +425,7 @@ ${PACKAGE_NAME}: preprocessor flags : ${CPPFLAGS} compiler flags : ${CFLAGS} defines : ${DEFS} - library flags : ${LIBS} ${LIBSSL_LIBS} ${LIBARCHIVE_LIBS} + library flags : ${LIBS} ${LIBSSL_LIBS} ${LIBARCHIVE_LIBS} ${LIBCURL_LIBS} linker flags : ${LDFLAGS} Architecture : ${CARCH} @@ -432,7 +445,7 @@ ${PACKAGE_NAME}: build script name : ${BUILDSCRIPT} Compilation options: - Use libcurl : ${with_libcurl} + Use libcurl : ${have_libcurl} Use GPGME : ${with_gpgme} Use OpenSSL : ${have_openssl} Run make in doc/ dir : ${wantdoc} ${asciidoc} diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am index 3773f2df..c34079c7 100644 --- a/lib/libalpm/Makefile.am +++ b/lib/libalpm/Makefile.am @@ -63,16 +63,18 @@ libalpm_la_SOURCES += \ base64.h base64.c endif -libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO) @LIBCURL@ +libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO) libalpm_la_CFLAGS = \ $(AM_CFLAGS) \ $(LIBARCHIVE_CFLAGS) \ + $(LIBCURL_CFLAGS) \ $(LIBSSL_CFLAGS) libalpm_la_LIBADD = \ $(LTLIBINTL) \ $(LIBARCHIVE_LIBS) \ + $(LIBCURL_LIBS) \ $(LIBSSL_LIBS) # vim:set ts=2 sw=2 noet: diff --git a/m4/libcurl.m4 b/m4/libcurl.m4 deleted file mode 100644 index 01a0575c..00000000 --- a/m4/libcurl.m4 +++ /dev/null @@ -1,250 +0,0 @@ -# LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION], -# [ACTION-IF-YES], [ACTION-IF-NO]) -# ---------------------------------------------------------- -# David Shaw May-09-2006 -# -# Checks for libcurl. DEFAULT-ACTION is the string yes or no to -# specify whether to default to --with-libcurl or --without-libcurl. -# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the -# minimum version of libcurl to accept. Pass the version as a regular -# version number like 7.10.1. If not supplied, any version is -# accepted. ACTION-IF-YES is a list of shell commands to run if -# libcurl was successfully found and passed the various tests. -# ACTION-IF-NO is a list of shell commands that are run otherwise. -# Note that using --without-libcurl does run ACTION-IF-NO. -# -# This macro #defines HAVE_LIBCURL if a working libcurl setup is -# found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary -# values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are -# the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy -# where yyy are the various protocols supported by libcurl. Both xxx -# and yyy are capitalized. See the list of AH_TEMPLATEs at the top of -# the macro for the complete list of possible defines. Shell -# variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also -# defined to 'yes' for those features and protocols that were found. -# Note that xxx and yyy keep the same capitalization as in the -# curl-config list (e.g. it's "HTTP" and not "http"). -# -# Users may override the detected values by doing something like: -# LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure -# -# For the sake of sanity, this macro assumes that any libcurl that is -# found is after version 7.7.2, the first version that included the -# curl-config script. Note that it is very important for people -# packaging binary versions of libcurl to include this script! -# Without curl-config, we can only guess what protocols are available, -# or use curl_version_info to figure it out at runtime. - -AC_DEFUN([LIBCURL_CHECK_CONFIG], -[ - AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL]) - AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4]) - AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6]) - AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz]) - AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS]) - AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN]) - AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI]) - AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM]) - - AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP]) - AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS]) - AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP]) - AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS]) - AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE]) - AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET]) - AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP]) - AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT]) - AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP]) - AH_TEMPLATE([LIBCURL_PROTOCOL_RTSP],[Defined if libcurl supports RTSP]) - AH_TEMPLATE([LIBCURL_PROTOCOL_POP3],[Defined if libcurl supports POP3]) - AH_TEMPLATE([LIBCURL_PROTOCOL_IMAP],[Defined if libcurl supports IMAP]) - AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP]) - - AC_ARG_WITH(libcurl, - AC_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]), - [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])]) - - if test "$_libcurl_with" != "no" ; then - - AC_PROG_AWK - - _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'" - - _libcurl_try_link=yes - - if test -d "$_libcurl_with" ; then - LIBCURL_CPPFLAGS="-I$withval/include" - _libcurl_ldflags="-L$withval/lib" - AC_PATH_PROG([_libcurl_config],[curl-config],[], - ["$withval/bin"]) - else - AC_PATH_PROG([_libcurl_config],[curl-config],[],[$PATH]) - fi - - if test x$_libcurl_config != "x" ; then - AC_CACHE_CHECK([for the version of libcurl], - [libcurl_cv_lib_curl_version], - [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`]) - - _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse` - _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse` - - if test $_libcurl_wanted -gt 0 ; then - AC_CACHE_CHECK([for libcurl >= version $2], - [libcurl_cv_lib_version_ok], - [ - if test $_libcurl_version -ge $_libcurl_wanted ; then - libcurl_cv_lib_version_ok=yes - else - libcurl_cv_lib_version_ok=no - fi - ]) - fi - - if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then - if test x"$LIBCURL_CPPFLAGS" = "x" ; then - LIBCURL_CPPFLAGS=`$_libcurl_config --cflags` - fi - if test x"$LIBCURL" = "x" ; then - LIBCURL=`$_libcurl_config --libs` - - # This is so silly, but Apple actually has a bug in their - # curl-config script. Fixed in Tiger, but there are still - # lots of Panther installs around. - case "${host}" in - powerpc-apple-darwin7*) - LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'` - ;; - esac - fi - - # All curl-config scripts support --feature - _libcurl_features=`$_libcurl_config --feature` - - # Is it modern enough to have --protocols? (7.12.4) - if test $_libcurl_version -ge 461828 ; then - _libcurl_protocols=`$_libcurl_config --protocols` - fi - else - _libcurl_try_link=no - fi - - unset _libcurl_wanted - fi - - if test $_libcurl_try_link = yes ; then - - # we didn't find curl-config, so let's see if the user-supplied - # link line (or failing that, "-lcurl") is enough. - LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"} - - AC_CACHE_CHECK([whether libcurl is usable], - [libcurl_cv_lib_curl_usable], - [ - _libcurl_save_cppflags=$CPPFLAGS - CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS" - _libcurl_save_libs=$LIBS - LIBS="$LIBCURL $LIBS" - - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ],[ -/* Try and use a few common options to force a failure if we are - missing symbols or can't link. */ -int x; -curl_easy_setopt(NULL,CURLOPT_URL,NULL); -x=CURL_ERROR_SIZE; -x=CURLOPT_WRITEFUNCTION; -x=CURLOPT_FILE; -x=CURLOPT_ERRORBUFFER; -x=CURLOPT_STDERR; -x=CURLOPT_VERBOSE; -])],libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no) - - CPPFLAGS=$_libcurl_save_cppflags - LIBS=$_libcurl_save_libs - unset _libcurl_save_cppflags - unset _libcurl_save_libs - ]) - - if test $libcurl_cv_lib_curl_usable = yes ; then - - # Does curl_free() exist in this version of libcurl? - # If not, fake it with free() - - _libcurl_save_cppflags=$CPPFLAGS - CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS" - _libcurl_save_libs=$LIBS - LIBS="$LIBS $LIBCURL" - - AC_CHECK_FUNC(curl_free,, - AC_DEFINE(curl_free,free, - [Define curl_free() as free() if our version of curl lacks curl_free.])) - - CPPFLAGS=$_libcurl_save_cppflags - LIBS=$_libcurl_save_libs - unset _libcurl_save_cppflags - unset _libcurl_save_libs - - AC_DEFINE(HAVE_LIBCURL,1, - [Define to 1 if you have a functional curl library.]) - AC_SUBST(LIBCURL_CPPFLAGS) - AC_SUBST(LIBCURL) - - for _libcurl_feature in $_libcurl_features ; do - AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1]) - eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes - done - - if test "x$_libcurl_protocols" = "x" ; then - - # We don't have --protocols, so just assume that all - # protocols are available - _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP" - - if test x$libcurl_feature_SSL = xyes ; then - _libcurl_protocols="$_libcurl_protocols HTTPS" - - # FTPS wasn't standards-compliant until version - # 7.11.0 (0x070b00 == 461568) - if test $_libcurl_version -ge 461568; then - _libcurl_protocols="$_libcurl_protocols FTPS" - fi - fi - - # RTSP, IMAP, POP3 and SMTP were added in - # 7.20.0 (0x071400 == 463872) - if test $_libcurl_version -ge 463872; then - _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP" - fi - fi - - for _libcurl_protocol in $_libcurl_protocols ; do - AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1]) - eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes - done - else - unset LIBCURL - unset LIBCURL_CPPFLAGS - fi - fi - - unset _libcurl_try_link - unset _libcurl_version_parse - unset _libcurl_config - unset _libcurl_feature - unset _libcurl_features - unset _libcurl_protocol - unset _libcurl_protocols - unset _libcurl_version - unset _libcurl_ldflags - fi - - if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then - # This is the IF-NO path - ifelse([$4],,:,[$4]) - else - # This is the IF-YES path - ifelse([$3],,:,[$3]) - fi - - unset _libcurl_with -])dnl -- cgit v1.2.3-70-g09d2 From cb5b66367ddf4af05953a9486bddaaf105fb4f38 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 30 Mar 2012 23:08:31 -0400 Subject: buildsys: cleanup gpgme compile time check - handle gpgme libs and cflags separately rather than appending to CFLAGS and LDFLAGS - be consistent in AC_LINK_IFELSE check for gpgme 1.3.0 (though this is irrelephant since we don't actually run) - be consistent with usage of "have" and "with" variables (this actually ends up reducing SLOC) - when voluntary detection fails, unset GPGME_CFLAGS and GPGME_LIBS - when requested support fails the version check, complain about the min version. Signed-off-by: Dave Reisner --- configure.ac | 41 +++++++++++++++++++++-------------------- lib/libalpm/Makefile.am | 2 ++ 2 files changed, 23 insertions(+), 20 deletions(-) (limited to 'lib') diff --git a/configure.ac b/configure.ac index ddcf535d..ac25a9d6 100644 --- a/configure.ac +++ b/configure.ac @@ -186,11 +186,9 @@ AS_IF([test "x$with_gpgme" != "xno"], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) -require_gpgme=no +have_gpgme=no AS_IF([test "x$with_gpgme" != "xno"], - [AS_IF([test "x$with_gpgme" = "xyes"], - [require_gpgme=yes]) - AM_PATH_GPGME([1.3.0], + [AM_PATH_GPGME([1.3.0], [LIBS_save="$LIBS" CPPFLAGS_save="$CPPFLAGS" CFLAGS_save="$CFLAGS" @@ -203,23 +201,26 @@ AS_IF([test "x$with_gpgme" != "xno"], AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include ]], - [[const char *ver; -ver = gpgme_check_version("1.2.4");]])], + [[return gpgme_check_version("1.3.0");]])], [AC_MSG_RESULT([yes]) - with_gpgme=yes + have_gpgme=yes AC_DEFINE([HAVE_LIBGPGME], [1], [Define if gpgme should be used to provide GPG signature support.])], [AC_MSG_RESULT([no]) - with_gpgme=no - LIBS="$LIBS_save" - CPPFLAGS="$CPPFLAGS_save" - CFLAGS="$CFLAGS_save"])], - [with_gpgme=no])]) -AS_IF([test "x$with_gpgme" != "xyes"], - [AS_IF([test "x$require_gpgme" = "xyes"], - [AC_MSG_FAILURE([--with-gpgme was given, but gpgme was not found])]) - with_gpgme=no]) - -AM_CONDITIONAL([HAVE_LIBGPGME], [test "x$with_gpgme" = "xyes"]) + have_gpgme=no + unset GPGME_LIBS + unset GPGME_CFLAGS] + AS_IF([test "x$with_gpgme" = "xyes"], + [AC_MSG_FAILURE([*** gpgme >= 1.3.0 is needed for GPG signature support])]) + )], + [with_gpgme=no])] + [LIBS="$LIBS_save" + CPPFLAGS="$CPPFLAGS_save" + CFLAGS="$CFLAGS_save" + unset CPPFLAGS_save + unset CFLAGS_save]) +AS_IF([test "x$have_gpgme" = xno -a "x$with_gpgme" = xyes], + [AC_MSG_FAILURE([--with-gpgme was given, but gpgme was not found])]) +AM_CONDITIONAL([HAVE_LIBGPGME], [test "x$have_gpgme" = "xyes"]) # Checks for header files. AC_CHECK_HEADERS([fcntl.h float.h glob.h libintl.h limits.h locale.h \ @@ -425,7 +426,7 @@ ${PACKAGE_NAME}: preprocessor flags : ${CPPFLAGS} compiler flags : ${CFLAGS} defines : ${DEFS} - library flags : ${LIBS} ${LIBSSL_LIBS} ${LIBARCHIVE_LIBS} ${LIBCURL_LIBS} + library flags : ${LIBS} ${LIBSSL_LIBS} ${LIBARCHIVE_LIBS} ${LIBCURL_LIBS} ${GPGME_LIBS} linker flags : ${LDFLAGS} Architecture : ${CARCH} @@ -446,7 +447,7 @@ ${PACKAGE_NAME}: Compilation options: Use libcurl : ${have_libcurl} - Use GPGME : ${with_gpgme} + Use GPGME : ${have_gpgme} Use OpenSSL : ${have_openssl} Run make in doc/ dir : ${wantdoc} ${asciidoc} Doxygen support : ${usedoxygen} diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am index c34079c7..31de62e3 100644 --- a/lib/libalpm/Makefile.am +++ b/lib/libalpm/Makefile.am @@ -67,12 +67,14 @@ libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO) libalpm_la_CFLAGS = \ $(AM_CFLAGS) \ + $(GPGME_CFLAGS) \ $(LIBARCHIVE_CFLAGS) \ $(LIBCURL_CFLAGS) \ $(LIBSSL_CFLAGS) libalpm_la_LIBADD = \ $(LTLIBINTL) \ + $(GPGME_LIBS) \ $(LIBARCHIVE_LIBS) \ $(LIBCURL_LIBS) \ $(LIBSSL_LIBS) -- cgit v1.2.3-70-g09d2 From 793eff37047dbceedaf3443311bc826566685181 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 30 Mar 2012 23:26:32 -0400 Subject: buildsys: define warning CFLAGS in separate var Continue the trend of not touching the environment CFLAGS, ensuring that the user always has the final say. Signed-off-by: Dave Reisner --- configure.ac | 6 +++--- lib/libalpm/Makefile.am | 2 +- src/pacman/Makefile.am | 2 +- src/util/Makefile.am | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/configure.ac b/configure.ac index 13dddc61..3c6df0db 100644 --- a/configure.ac +++ b/configure.ac @@ -350,10 +350,10 @@ if test "x$debug" = "xyes" ; then GCC_STACK_PROTECT_LIB GCC_STACK_PROTECT_CC GCC_FORTIFY_SOURCE_CC - CFLAGS="$CFLAGS -g -Wall -Werror" + WARNING_CFLAGS="-g -Wall -Werror" else AC_MSG_RESULT(no) - CFLAGS="$CFLAGS -Wall" + WARNING_CFLAGS="-Wall" fi # Enable or disable use of git version in pacman version string @@ -424,7 +424,7 @@ ${PACKAGE_NAME}: compiler : ${CC} preprocessor flags : ${CPPFLAGS} - compiler flags : ${CFLAGS} + compiler flags : ${WARNING_CFLAGS} ${CFLAGS} defines : ${DEFS} library flags : ${LIBS} ${LIBSSL_LIBS} ${LIBARCHIVE_LIBS} ${LIBCURL_LIBS} ${GPGME_LIBS} linker flags : ${LDFLAGS} diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am index 31de62e3..0781d5d8 100644 --- a/lib/libalpm/Makefile.am +++ b/lib/libalpm/Makefile.am @@ -10,7 +10,7 @@ DEFS = -DLOCALEDIR=\"@localedir@\" @DEFS@ AM_CPPFLAGS = \ -imacros $(top_builddir)/config.h -AM_CFLAGS = -pedantic -D_GNU_SOURCE +AM_CFLAGS = -pedantic -D_GNU_SOURCE $(WARNING_CFLAGS) if ENABLE_VISIBILITY_CC if DARWIN diff --git a/src/pacman/Makefile.am b/src/pacman/Makefile.am index 9a92fd6b..c8ce9773 100644 --- a/src/pacman/Makefile.am +++ b/src/pacman/Makefile.am @@ -21,7 +21,7 @@ AM_CPPFLAGS = \ -imacros $(top_builddir)/config.h \ -I$(top_srcdir)/lib/libalpm -AM_CFLAGS = -pedantic -D_GNU_SOURCE +AM_CFLAGS = -pedantic -D_GNU_SOURCE $(WARNING_CFLAGS) if USE_GIT_VERSION GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 --dirty | sed s/^v//') diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 1465407c..463abf7f 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -17,7 +17,7 @@ AM_CPPFLAGS = \ -imacros $(top_builddir)/config.h \ -I$(top_srcdir)/lib/libalpm -AM_CFLAGS = -pedantic -D_GNU_SOURCE +AM_CFLAGS = -pedantic -D_GNU_SOURCE $(WARNING_CFLAGS) cleanupdelta_SOURCES = cleanupdelta.c cleanupdelta_LDADD = $(top_builddir)/lib/libalpm/.libs/libalpm.la -- cgit v1.2.3-70-g09d2 From a8a1b093eb23450244418232c9e30c4be035fc0b Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 7 Apr 2012 13:01:13 -0500 Subject: Various tweaks to support building with excessive GCC warning flags This fixes a bunch of small issues in order to enable a clean successful build with a crazy number of GCC warning flags. A lot of these changes are covered by -Wshadow, -Wformat-security, and -Wstrict-overflow=5. Signed-off-by: Dan McGee --- lib/libalpm/deps.c | 10 ++++++---- lib/libalpm/trans.c | 7 +++++-- lib/libalpm/util.c | 17 ++++++++++------- lib/libalpm/util.h | 2 +- src/pacman/conf.c | 6 +++--- src/pacman/pacman.c | 9 +++++---- src/pacman/sync.c | 4 ++-- src/pacman/util.c | 2 +- 8 files changed, 33 insertions(+), 24 deletions(-) (limited to 'lib') diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 6069f5e6..98519bd0 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -158,15 +158,17 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle, else if(nextchild->state == -1) { alpm_pkg_t *vertexpkg = vertex->data; alpm_pkg_t *childpkg = nextchild->data; - const char *message; _alpm_log(handle, ALPM_LOG_WARNING, _("dependency cycle detected:\n")); if(reverse) { - message =_("%s will be removed after its %s dependency\n"); + _alpm_log(handle, ALPM_LOG_WARNING, + _("%s will be removed after its %s dependency\n"), + vertexpkg->name, childpkg->name); } else { - message =_("%s will be installed before its %s dependency\n"); + _alpm_log(handle, ALPM_LOG_WARNING, + _("%s will be installed before its %s dependency\n"), + vertexpkg->name, childpkg->name); } - _alpm_log(handle, ALPM_LOG_WARNING, message, vertexpkg->name, childpkg->name); } } if(!found) { diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 4309c07e..08f70dd7 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -276,8 +276,8 @@ static int grep(const char *fn, const char *needle) int _alpm_runscriptlet(alpm_handle_t *handle, const char *filepath, const char *script, const char *ver, const char *oldver, int is_archive) { - char cmdline[PATH_MAX]; - char *argv[] = { SCRIPTLET_SHELL, "-c", cmdline, NULL }; + char arg0[64], arg1[3], cmdline[PATH_MAX]; + char *argv[] = { arg0, arg1, cmdline, NULL }; char *tmpdir, *scriptfn = NULL, *scriptpath; int retval = 0; size_t len; @@ -293,6 +293,9 @@ int _alpm_runscriptlet(alpm_handle_t *handle, const char *filepath, return 0; } + strcpy(arg0, SCRIPTLET_SHELL); + strcpy(arg1, "-c"); + /* create a directory in $root/tmp/ for copying/extracting the scriptlet */ len = strlen(handle->root) + strlen("tmp/alpm_XXXXXX") + 1; MALLOC(tmpdir, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 22e9e359..a392c773 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -621,7 +621,9 @@ int _alpm_ldconfig(alpm_handle_t *handle) if(access(line, F_OK) == 0) { snprintf(line, PATH_MAX, "%ssbin/ldconfig", handle->root); if(access(line, X_OK) == 0) { - char *argv[] = { "ldconfig", NULL }; + char arg0[32]; + char *argv[] = { arg0, NULL }; + strcpy(arg0, "ldconfig"); return _alpm_run_chroot(handle, "/sbin/ldconfig", argv); } } @@ -676,7 +678,8 @@ const char *_alpm_filecache_setup(alpm_handle_t *handle) { struct stat buf; alpm_list_t *i; - char *cachedir, *tmpdir; + char *cachedir; + const char *tmpdir; /* Loop through the cache dirs until we find a usable directory */ for(i = handle->cachedirs; i; i = i->next) { @@ -995,13 +998,13 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b) } if(needed > b->line_size) { /* need to realloc + copy data to fit total length */ - char *new; - CALLOC(new, needed, sizeof(char), b->ret = -ENOMEM; goto cleanup); - memcpy(new, b->line, b->line_size); + char *new_line; + CALLOC(new_line, needed, sizeof(char), b->ret = -ENOMEM; goto cleanup); + memcpy(new_line, b->line, b->line_size); b->line_size = needed; - b->line_offset = new + (b->line_offset - b->line); + b->line_offset = new_line + (b->line_offset - b->line); free(b->line); - b->line = new; + b->line = new_line; } } diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index e6747827..e35e35b9 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -87,7 +87,7 @@ #endif #define OPEN(fd, path, flags) do { fd = open(path, flags | O_BINARY); } while(fd == -1 && errno == EINTR) -#define CLOSE(fd) do { int ret; do { ret = close(fd); } while(ret == -1 && errno == EINTR); } while(0) +#define CLOSE(fd) do { int _ret; do { _ret = close(fd); } while(_ret == -1 && errno == EINTR); } while(0) /** * Used as a buffer/state holder for _alpm_archive_fgets(). diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 4c3d063b..2632d18f 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -202,14 +202,14 @@ static int download_with_xfercommand(const char *url, const char *localpath, cleanup: /* restore the old cwd if we have it */ if(cwdfd >= 0) { - int ret; + int close_ret; if(fchdir(cwdfd) != 0) { pm_printf(ALPM_LOG_ERROR, _("could not restore working directory (%s)\n"), strerror(errno)); } do { - ret = close(cwdfd); - } while(ret == -1 && errno == EINTR); + close_ret = close(cwdfd); + } while(close_ret == -1 && errno == EINTR); } if(ret == -1) { diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 1e6797c9..73d5be94 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -808,12 +808,13 @@ int main(int argc, char *argv[]) /* we support reading targets from stdin if a cmdline parameter is '-' */ if(!isatty(fileno(stdin)) && alpm_list_find_str(pm_targets, "-")) { - size_t current_size = PATH_MAX, i = 0; + size_t current_size = PATH_MAX; char *line = malloc(current_size); /* remove the '-' from the list */ pm_targets = alpm_list_remove_str(pm_targets, "-", NULL); + i = 0; while((line[i] = (char)fgetc(stdin)) != EOF) { if(isspace((unsigned char)line[i])) { /* avoid adding zero length arg when multiple spaces separate args */ @@ -885,13 +886,13 @@ int main(int argc, char *argv[]) #endif if(config->verbose > 0) { - alpm_list_t *i; + alpm_list_t *j; printf("Root : %s\n", alpm_option_get_root(config->handle)); printf("Conf File : %s\n", config->configfile); printf("DB Path : %s\n", alpm_option_get_dbpath(config->handle)); printf("Cache Dirs: "); - for(i = alpm_option_get_cachedirs(config->handle); i; i = alpm_list_next(i)) { - printf("%s ", (const char *)i->data); + for(j = alpm_option_get_cachedirs(config->handle); j; j = alpm_list_next(j)) { + printf("%s ", (const char *)j->data); } printf("\n"); printf("Lock File : %s\n", alpm_option_get_lockfile(config->handle)); diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 5165dca1..9c17f45f 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -307,12 +307,12 @@ static int sync_cleancache(int level) static int sync_synctree(int level, alpm_list_t *syncs) { alpm_list_t *i; - int success = 0, ret; + unsigned int success = 0; for(i = syncs; i; i = alpm_list_next(i)) { alpm_db_t *db = i->data; - ret = alpm_db_update((level < 2 ? 0 : 1), db); + int ret = alpm_db_update((level < 2 ? 0 : 1), db); if(ret < 0) { pm_printf(ALPM_LOG_ERROR, _("failed to update %s (%s)\n"), alpm_db_get_name(db), alpm_strerror(alpm_errno(config->handle))); diff --git a/src/pacman/util.c b/src/pacman/util.c index f2ab163b..be8fc308 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -258,7 +258,7 @@ void indentprint(const char *str, unsigned short indent, unsigned short cols) { wchar_t *wcstr; const wchar_t *p; - int len, cidx; + size_t len, cidx; if(!str) { return; -- cgit v1.2.3-70-g09d2