Skip to content

Commit

Permalink
Merge pull request #231 from pipping/master
Browse files Browse the repository at this point in the history
Use pkg-config if available
  • Loading branch information
stewid committed Apr 20, 2016
2 parents 33a064d + 2a8cb7d commit 9f249a7
Show file tree
Hide file tree
Showing 2 changed files with 226 additions and 0 deletions.
218 changes: 218 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,11 @@ LIBICONV
EGREP
GREP
CPP
libssl_LIBS
libssl_CFLAGS
PKG_CONFIG_LIBDIR
PKG_CONFIG_PATH
PKG_CONFIG
BREW
OBJEXT
EXEEXT
Expand Down Expand Up @@ -713,6 +718,11 @@ CFLAGS
LDFLAGS
LIBS
CPPFLAGS
PKG_CONFIG
PKG_CONFIG_PATH
PKG_CONFIG_LIBDIR
libssl_CFLAGS
libssl_LIBS
CPP'


Expand Down Expand Up @@ -1358,6 +1368,14 @@ Some influential environment variables:
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
PKG_CONFIG path to pkg-config utility
PKG_CONFIG_PATH
directories to add to pkg-config's search path
PKG_CONFIG_LIBDIR
path overriding pkg-config's built-in search path
libssl_CFLAGS
C compiler flags for libssl, overriding pkg-config
libssl_LIBS linker flags for libssl, overriding pkg-config
CPP C preprocessor
Use these variables to override the choices made by `configure' or to help
Expand Down Expand Up @@ -3445,6 +3463,206 @@ fi
# Check for SSL
have_ssl=no








if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PKG_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $PKG_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS

;;
esac
fi
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
if test -n "$PKG_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
$as_echo "$PKG_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_path_PKG_CONFIG"; then
ac_pt_PKG_CONFIG=$PKG_CONFIG
# Extract the first word of "pkg-config", so it can be a program name with args.
set dummy pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $ac_pt_PKG_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS

;;
esac
fi
ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
if test -n "$ac_pt_PKG_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
$as_echo "$ac_pt_PKG_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

if test "x$ac_pt_PKG_CONFIG" = x; then
PKG_CONFIG=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
PKG_CONFIG=$ac_pt_PKG_CONFIG
fi
else
PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
fi

fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=0.9.0
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
PKG_CONFIG=""
fi
fi
if test x != "x${PKG_CONFIG}"; then :

pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libssl" >&5
$as_echo_n "checking for libssl... " >&6; }

if test -n "$libssl_CFLAGS"; then
pkg_cv_libssl_CFLAGS="$libssl_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libssl\""; } >&5
($PKG_CONFIG --exists --print-errors "libssl") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_libssl_CFLAGS=`$PKG_CONFIG --cflags "libssl" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$libssl_LIBS"; then
pkg_cv_libssl_LIBS="$libssl_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libssl\""; } >&5
($PKG_CONFIG --exists --print-errors "libssl") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_libssl_LIBS=`$PKG_CONFIG --libs "libssl" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi



if test $pkg_failed = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }

if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
libssl_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libssl" 2>&1`
else
libssl_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libssl" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$libssl_PKG_ERRORS" >&5

{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"pkg-config failed to find libssl.\"" >&5
$as_echo "$as_me: WARNING: \"pkg-config failed to find libssl.\"" >&2;}
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"pkg-config failed to find libssl.\"" >&5
$as_echo "$as_me: WARNING: \"pkg-config failed to find libssl.\"" >&2;}
else
libssl_CFLAGS=$pkg_cv_libssl_CFLAGS
libssl_LIBS=$pkg_cv_libssl_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
CPPFLAGS="${libssl_CFLAGS} ${CPPFLAGS}"
LIBS="${libssl_LIBS} ${LIBS}"
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"pkg-config not found. Proceeding without it\"" >&5
$as_echo "$as_me: WARNING: \"pkg-config not found. Proceeding without it\"" >&2;}
fi

# Check for optional libssl include path
if test -n "$libssl_include_path" ; then
CPPFLAGS="-I${libssl_include_path} ${CPPFLAGS}"
Expand Down
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ fi
# Check for SSL
have_ssl=no

PKG_PROG_PKG_CONFIG
AS_IF([test x != "x${PKG_CONFIG}"],
[PKG_CHECK_MODULES([libssl], [libssl],
[CPPFLAGS="${libssl_CFLAGS} ${CPPFLAGS}"
LIBS="${libssl_LIBS} ${LIBS}"],
[AC_MSG_WARN("pkg-config failed to find libssl.")])],
[AC_MSG_WARN("pkg-config not found. Proceeding without it")])

# Check for optional libssl include path
if test [ -n "$libssl_include_path" ] ; then
CPPFLAGS="-I${libssl_include_path} ${CPPFLAGS}"
Expand Down

0 comments on commit 9f249a7

Please sign in to comment.