From 9942f51dc2bc2e35e34c473ae34b57ad3fbafb2e Mon Sep 17 00:00:00 2001 From: Alexander Afanasyev Date: Wed, 3 Aug 2011 15:40:30 -0700 Subject: [PATCH] Modifying autoconf files CCNx and OpenSSL are required and if they are not present, then ./configure will abort with error --- configure.ac | 4 +-- m4/ax_ccnx.m4 | 72 +++++++++++++++++++++++++++++---------------------- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/configure.ac b/configure.ac index ddfee8a..372652b 100644 --- a/configure.ac +++ b/configure.ac @@ -13,10 +13,10 @@ AC_PROG_CC # Checks for libraries. # CCNx Library -AX_CCNX([0.4.0]) +AX_CCNX([0.4.0],[],[AC_MSG_ERROR([Required CCNx library not found])]) # OpenSSL -AX_CHECK_OPENSSL +AX_CHECK_OPENSSL([],[AC_MSG_ERROR([Required OpenSSL libraries not found])]) # Checks for header files. # AC_CHECK_HEADERS([netdb.h netinet/in.h stdlib.h string.h sys/time.h unistd.h]) diff --git a/m4/ax_ccnx.m4 b/m4/ax_ccnx.m4 index bc19e72..fe1124d 100644 --- a/m4/ax_ccnx.m4 +++ b/m4/ax_ccnx.m4 @@ -12,9 +12,7 @@ # # AC_SUBST(CCNX_CFLAGS) / AC_SUBST(CCNX_LDFLAGS) / AC_SUBST(CCNX_LIBS) # -# And sets: -# -# HAVE_CCNX +# And calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately # # LICENSE # Copyright (c) 2011 Alexander Afanasyev @@ -26,26 +24,26 @@ AC_DEFUN([AX_CCNX], [ -AC_ARG_WITH([ccnx], - [AS_HELP_STRING([--with-ccnx@<:@=ARG@:>@], - [use CCNx library from a standard location (ARG=yes), - from the specified location (ARG=), - or disable it (ARG=no) - @<:@ARG=yes@:>@ ])], + AC_ARG_WITH([ccnx], + [AS_HELP_STRING([--with-ccnx=DIR], + [root directory for CCNx library])], [ - if test "$withval" = "no"; then - want_ccnx="no" - elif test "$withval" = "yes"; then - want_ccnx="yes" - ac_ccnx_path="" - else - want_ccnx="yes" - ac_ccnx_path="$withval" - fi + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([Invalid --with-ccnx value]) + ;; + *) + basedirs="$withval" + indir="in $withval" + ;; + esac ], - [want_ccnx="yes"]) - -if test "x$want_ccnx" = "xyes"; then + [ + basedirs="/usr /usr/local /opt /opt/local" + indir="" + ] + ) + ccnx_lib_version_req=ifelse([$1], ,0.4.0,$1) ccnx_lib_version_req_major=`expr $ccnx_lib_version_req : '\([[0-9]]*\)'` ccnx_lib_version_req_minor=`expr $ccnx_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` @@ -55,10 +53,10 @@ if test "x$want_ccnx" = "xyes"; then fi WANT_CCNX_VERSION=`expr $ccnx_lib_version_req_major \* 100000 \+ $ccnx_lib_version_req_minor \* 1000 \+ $ccnx_lib_version_req_sub_minor` - AC_MSG_CHECKING(for CCNx library with API version >= $ccnx_lib_version_req) + AC_MSG_CHECKING(for CCNx library with API version >= $ccnx_lib_version_req $indir) succeeded=no + found=false - basedirs="/usr /usr/local /opt /opt/local" libsubdirs="lib64 lib" for ccnx_base_tmp in $basedirs ; do @@ -68,13 +66,24 @@ if test "x$want_ccnx" = "xyes"; then done CCNX_LDFLAGS="-L$ccnx_base_tmp/$libsubdir" CCNX_CFLAGS="-I$ccnx_base_tmp/include" + CCNX_LIBS="-lccn" + found=true break; fi done - AC_REQUIRE([AC_PROG_CC]) - AC_LANG_PUSH([C]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + if ! $found; then + AC_MSG_RESULT([no]) + else + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + save_CFLAGS="$CFLAGS" + LDFLAGS="$LDFLAGS $CCNX_LDFLAGS" + LIBS="$CCNX_LIBS $LIBS" + CFLAGS="$CCNX_CFLAGS $CFLAGS" + + AC_REQUIRE([AC_PROG_CC]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ @%:@include ]], [[ #if CCN_API_VERSION >= $WANT_CCNX_VERSION @@ -83,12 +92,15 @@ if test "x$want_ccnx" = "xyes"; then # error CCNx API version is too old #endif ]])],[ - AC_MSG_RESULT(yes) - CCNX_LIBS="-lccn" + AC_MSG_RESULT([yes]) succeeded=yes ],[ ]) - AC_LANG_POP([C]) + + CFLAGS="$save_CFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + fi if test "$succeeded" != "yes" ; then # execute ACTION-IF-NOT-FOUND (if present): @@ -97,11 +109,9 @@ if test "x$want_ccnx" = "xyes"; then AC_SUBST(CCNX_CFLAGS) AC_SUBST(CCNX_LDFLAGS) AC_SUBST(CCNX_LIBS) - AC_DEFINE(HAVE_CCNX,,[define if the CCNx library is available]) # execute ACTION-IF-FOUND (if present): ifelse([$2], , :, [$2]) fi -fi ])