Message ID | 1416844898-12631-3-git-send-email-anders.roxell@linaro.org |
---|---|
State | Superseded |
Headers | show |
On Mon, Nov 24, 2014 at 6:01 PM, Anders Roxell <anders.roxell@linaro.org> wrote: > Always check OpenSSL dependency > > Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > --- > configure.ac | 34 +++++++++++++++++++++++++--------- > 1 file changed, 25 insertions(+), 9 deletions(-) > > diff --git a/configure.ac b/configure.ac > index 3752f3d..acd0060 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -126,21 +126,37 @@ if test -z "$DOXYGEN"; > fi > > ########################################################################## > -# Check for openssl availability > +# Set optional OpenSSL path > ########################################################################## > - > AC_ARG_WITH([openssl-path], > AC_HELP_STRING([--with-openssl-path=DIR Path to openssl libs and headers], > [(or in the default path if not specified).]), > -[OPENSSL_PATH=$withval > -AM_CFLAGS="$AM_CFLAGS -I$OPENSSL_PATH/include" > -AM_LDFLAGS="$AM_LDFLAGS -L$OPENSSL_PATH/lib -lcrypto" > -],[ > + [OPENSSL_PATH=$withval > + AM_CFLAGS="$AM_CFLAGS -I$OPENSSL_PATH/include" > + AM_LDFLAGS="$AM_LDFLAGS -L$OPENSSL_PATH/lib" > + ],[AC_MSG_RESULT([no])]) > + > +########################################################################## > +# Save and set temporary compilation flags > +########################################################################## > +OLD_LDFLAGS=$LDFLAGS > +OLD_CFLAGS=$CFLAGS > +LDFLAGS="$AM_LDFLAGS $LDFLAGS" > +CFLAGS="$AM_CFLAGS $CFLAGS" Can you describe your setup in which not setting these temporary CFLAGS and LDFLAGS does not work? Or simply what's the rationale of doing this? > + > +########################################################################## > +# Check for OpenSSL availability > +########################################################################## > AC_CHECK_LIB([crypto], [EVP_EncryptInit], [], > - [AC_MSG_FAILURE([can't find openssl crypto lib])]) > + [AC_MSG_FAILURE([OpenSSL libraries required])]) > AC_CHECK_HEADERS([openssl/des.h openssl/rand.h openssl/hmac.h openssl/evp.h], [], > - [AC_MSG_FAILURE([can't find openssl crypto headers])]) > - ]) > + [AC_MSG_ERROR([OpenSSL headers required])]) > + > +########################################################################## > +# Restore old saved variables > +########################################################################## > +LDFLAGS=$OLD_LDFLAGS > +CFLAGS=$OLD_CFLAGS > > ########################################################################## > # Default warning setup > -- > 2.1.0 > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp
On 2014-11-25 14:34, Ciprian Barbu wrote: > On Mon, Nov 24, 2014 at 6:01 PM, Anders Roxell <anders.roxell@linaro.org> wrote: > > Always check OpenSSL dependency > > > > Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > > --- > > configure.ac | 34 +++++++++++++++++++++++++--------- > > 1 file changed, 25 insertions(+), 9 deletions(-) > > > > diff --git a/configure.ac b/configure.ac > > index 3752f3d..acd0060 100644 > > --- a/configure.ac > > +++ b/configure.ac > > @@ -126,21 +126,37 @@ if test -z "$DOXYGEN"; > > fi > > > > ########################################################################## > > -# Check for openssl availability > > +# Set optional OpenSSL path > > ########################################################################## > > - > > AC_ARG_WITH([openssl-path], > > AC_HELP_STRING([--with-openssl-path=DIR Path to openssl libs and headers], > > [(or in the default path if not specified).]), > > -[OPENSSL_PATH=$withval > > -AM_CFLAGS="$AM_CFLAGS -I$OPENSSL_PATH/include" > > -AM_LDFLAGS="$AM_LDFLAGS -L$OPENSSL_PATH/lib -lcrypto" > > -],[ > > + [OPENSSL_PATH=$withval > > + AM_CFLAGS="$AM_CFLAGS -I$OPENSSL_PATH/include" > > + AM_LDFLAGS="$AM_LDFLAGS -L$OPENSSL_PATH/lib" > > + ],[AC_MSG_RESULT([no])]) > > + > > +########################################################################## > > +# Save and set temporary compilation flags > > +########################################################################## > > +OLD_LDFLAGS=$LDFLAGS > > +OLD_CFLAGS=$CFLAGS > > +LDFLAGS="$AM_LDFLAGS $LDFLAGS" > > +CFLAGS="$AM_CFLAGS $CFLAGS" > > Can you describe your setup in which not setting these temporary > CFLAGS and LDFLAGS does not work? Or simply what's the rationale of > doing this? When using "--with-openssl-path" above, we set some custom paths that needs to be available when running the AC_CHECK_LIB macro below. Because AC_CHECK_LIB uses an internal compilation check to see if the library is available, and these internal compilation checks doesn't use AM_*FLAGS, we need to temporarily copy the paths that we set above into the "normal" *FLAGS variables for the compilation check to succeed. After the AC_CHECK_LIB macro is run, we reset the *FLAGS variables that we messed with to not clobber what the user passed in when running configure. Unfortunately autoconf doesn't have an automatic way to handle this, thus the convoluted temporary setting of variables. > > + > > +########################################################################## > > +# Check for OpenSSL availability > > +########################################################################## > > AC_CHECK_LIB([crypto], [EVP_EncryptInit], [], > > - [AC_MSG_FAILURE([can't find openssl crypto lib])]) > > + [AC_MSG_FAILURE([OpenSSL libraries required])]) > > AC_CHECK_HEADERS([openssl/des.h openssl/rand.h openssl/hmac.h openssl/evp.h], [], > > - [AC_MSG_FAILURE([can't find openssl crypto headers])]) > > - ]) > > + [AC_MSG_ERROR([OpenSSL headers required])]) > > + > > +########################################################################## > > +# Restore old saved variables > > +########################################################################## > > +LDFLAGS=$OLD_LDFLAGS > > +CFLAGS=$OLD_CFLAGS ^ Here the variables are reset to the original values. Patch v2 will be sent out soon... Cheers, Anders
diff --git a/configure.ac b/configure.ac index 3752f3d..acd0060 100644 --- a/configure.ac +++ b/configure.ac @@ -126,21 +126,37 @@ if test -z "$DOXYGEN"; fi ########################################################################## -# Check for openssl availability +# Set optional OpenSSL path ########################################################################## - AC_ARG_WITH([openssl-path], AC_HELP_STRING([--with-openssl-path=DIR Path to openssl libs and headers], [(or in the default path if not specified).]), -[OPENSSL_PATH=$withval -AM_CFLAGS="$AM_CFLAGS -I$OPENSSL_PATH/include" -AM_LDFLAGS="$AM_LDFLAGS -L$OPENSSL_PATH/lib -lcrypto" -],[ + [OPENSSL_PATH=$withval + AM_CFLAGS="$AM_CFLAGS -I$OPENSSL_PATH/include" + AM_LDFLAGS="$AM_LDFLAGS -L$OPENSSL_PATH/lib" + ],[AC_MSG_RESULT([no])]) + +########################################################################## +# Save and set temporary compilation flags +########################################################################## +OLD_LDFLAGS=$LDFLAGS +OLD_CFLAGS=$CFLAGS +LDFLAGS="$AM_LDFLAGS $LDFLAGS" +CFLAGS="$AM_CFLAGS $CFLAGS" + +########################################################################## +# Check for OpenSSL availability +########################################################################## AC_CHECK_LIB([crypto], [EVP_EncryptInit], [], - [AC_MSG_FAILURE([can't find openssl crypto lib])]) + [AC_MSG_FAILURE([OpenSSL libraries required])]) AC_CHECK_HEADERS([openssl/des.h openssl/rand.h openssl/hmac.h openssl/evp.h], [], - [AC_MSG_FAILURE([can't find openssl crypto headers])]) - ]) + [AC_MSG_ERROR([OpenSSL headers required])]) + +########################################################################## +# Restore old saved variables +########################################################################## +LDFLAGS=$OLD_LDFLAGS +CFLAGS=$OLD_CFLAGS ########################################################################## # Default warning setup
Always check OpenSSL dependency Signed-off-by: Anders Roxell <anders.roxell@linaro.org> --- configure.ac | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)