Skip to content

Commit

Permalink
configure.ac: Fix AC_ARG_ENABLE/AC_ARG_WITH macros
Browse files Browse the repository at this point in the history
Multiple tests in configure.ac are flawed:

[--snip--]
    AC_ARG_ENABLE([pthreads],
            [AS_HELP_STRING([--disable-pthreads],
                            [Disable support for pthreads])],
            [pthreads_on=1],
            [pthreads_on=0])
[--snip--]

The third argument is "action-if-given" and the fourth argument
is "action-if-not-given" [0]. Which means that, whether you pass
--enable-pthreads or --disable-pthreads, the third argument will be
executed, that is "pthreads_on=1". And if you pass neither, the fourth
argument will be executed, i.e. "pthreads_on=0".

We want `--enable-pthreads` and `--disable-pthreads` flags to do their job.
The right way to do that will be to eliminate "action-if-given" and replace
the user-defined `FEATURE_on=0|1` shell variables with the `enable_FEATURE`
and `with_PACKAGE` shell variables provided by Autotools.

[0] https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/autoconf.html#Package-Options

Signed-off-by: Aleksandr Makarov <[email protected]>
  • Loading branch information
Aleksandr Makarov committed Jul 17, 2020
1 parent 0f8de87 commit af537b3
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ AM_CONDITIONAL([JAVA_HOME_SET], [test ! -z "$JAVA_HOME"])
AC_ARG_ENABLE([client-only],
[AS_HELP_STRING([--enable-client-only],
[Enable the building of only the client mode of libEST])],
[clientonly_on=1],
[clientonly_on=0])
AM_CONDITIONAL([ENABLE_CLIENT_ONLY], [test x$clientonly_on = x1])
[],
[enable_client_only="no"])
AM_CONDITIONAL([ENABLE_CLIENT_ONLY], [test "$enable_client_only" = "yes"])
AM_COND_IF([ENABLE_CLIENT_ONLY],
AC_MSG_RESULT([Client only build enabled])
AC_DEFINE([ENABLE_CLIENT_ONLY]),
Expand All @@ -54,9 +54,9 @@ AM_COND_IF([ENABLE_CLIENT_ONLY],
AC_ARG_ENABLE([brski],
[AS_HELP_STRING([--enable-brski],
[Enable support for brski bootstrap functionality])],
[brski_on=1],
[brski_on=0])
AM_CONDITIONAL([ENABLE_BRSKI], [test x$brski_on = x1])
[],
[enable_brski="no"])
AM_CONDITIONAL([ENABLE_BRSKI], [test "$enable_brski" = "yes"])
AM_COND_IF([ENABLE_BRSKI],
AC_MSG_RESULT([BRSKI support enabled])
AC_DEFINE([ENABLE_BRSKI]),
Expand All @@ -65,9 +65,9 @@ AM_COND_IF([ENABLE_BRSKI],
AC_ARG_ENABLE([pthreads],
[AS_HELP_STRING([--disable-pthreads],
[Disable support for pthreads])],
[pthreads_on=1],
[pthreads_on=0])
AM_CONDITIONAL([DISABLE_PTHREAD], [test x$pthreads_on = x1])
[],
[enable_pthreads="yes"])
AM_CONDITIONAL([DISABLE_PTHREAD], [test "$enable_pthreads" = "no"])
AM_COND_IF([DISABLE_PTHREAD],
AC_MSG_RESULT([pthread support disabled])
AC_DEFINE([DISABLE_PTHREADS]),
Expand All @@ -88,13 +88,13 @@ AM_COND_IF([ENABLE_EXAMPLES], AC_MSG_RESULT([yes]), AC_MSG_RESULT([no]))
AC_ARG_WITH([ssl-dir],
[AS_HELP_STRING([--with-ssl-dir],
[location of OpenSSL install folder, defaults to /usr/local/ssl])],
[ssldir="$withval"],
[ssldir="/usr/local/ssl"])
AC_SUBST([SSL_CFLAGS], "$ssldir/include")
AC_SUBST([SSL_LDFLAGS], "$ssldir/lib")
[],
[with_ssl_dir="/usr/local/ssl"])
AC_SUBST([SSL_CFLAGS], "$with_ssl_dir/include")
AC_SUBST([SSL_LDFLAGS], "$with_ssl_dir/lib")

CFLAGS="$CFLAGS -Wall -I$ssldir/include"
LDFLAGS="$LDFLAGS -L$ssldir/lib"
CFLAGS="$CFLAGS -Wall -I$with_ssl_dir/include"
LDFLAGS="$LDFLAGS -L$with_ssl_dir/lib"
if test "$is_freebsd" = "1" ; then
AC_CHECK_LIB([crypto], [EVP_EncryptInit], [],
[AC_MSG_FAILURE([can't find openssl crypto lib])]
Expand All @@ -120,13 +120,13 @@ AC_CHECK_LIB([crypto], [EVP_CIPHER_CTX_reset], [],
AC_ARG_WITH([libcurl-dir],
[AS_HELP_STRING([--with-libcurl-dir],
[enable support for client proxy using libcurl])],
[libcurldir="$withval"],
[with_libcurldir=no])
[],
[with_libcurl_dir=no])

AS_IF(
[test "x$with_libcurldir" != xno],
[[CFLAGS="$CFLAGS -I$libcurldir/include"]
[LDFLAGS="$LDFLAGS -L$libcurldir/lib -lcurl"]
[test "$with_libcurl_dir" != "no"],
[[CFLAGS="$CFLAGS -I$with_libcurl_dir/include"]
[LDFLAGS="$LDFLAGS -L$with_libcurl_dir/lib -lcurl"]
AC_CHECK_LIB(
[curl],
[curl_easy_init],
Expand All @@ -143,17 +143,17 @@ AC_ARG_WITH([libcurl-dir],
AC_ARG_WITH([uriparser-dir],
[AS_HELP_STRING([--with-uriparser-dir],
[enable support for path segments using uriparser])],
[uriparserdir="$withval"],
[with_uriparserdir=no])
[],
[with_uriparser_dir=no])

dnl CFLAGS="$CFLAGS -Wall -I$uriparserdir/include"
dnl CPPFLAGS="$CPPFLAGS -I$uriparser/include"
dnl LDFLAGS="$LDFLAGS -L$uriparserdir/lib -luriparser"

AS_IF(
[test "x$with_uriparserdir" != xno],
[[CFLAGS="$CFLAGS -I$uriparserdir/include"]
[LDFLAGS="$LDFLAGS -L$uriparserdir/lib -luriparser"]
[test "$with_uriparser_dir" != "no"],
[[CFLAGS="$CFLAGS -I$with_uriparser_dir/include"]
[LDFLAGS="$LDFLAGS -L$with_uriparser_dir/lib -luriparser"]
AC_CHECK_LIB(
[uriparser],
[uriParseUriA],
Expand All @@ -170,13 +170,13 @@ AC_ARG_WITH([uriparser-dir],
AC_ARG_WITH([libcoap-dir],
[AS_HELP_STRING([--with-libcoap-dir],
[enable support for ESToCoAP using libcoap library])],
[libcoapdir="$withval"],
[with_libcoapdir=no])
[],
[with_libcoap_dir=no])

AS_IF(
[test "x$with_libcoapdir" != xno],
[[CFLAGS="$CFLAGS -I$libcoapdir/include"]
[LDFLAGS="$LDFLAGS -L$libcoapdir/lib -lcoap-2-openssl"]
[test "$with_libcoap_dir" != "no"],
[[CFLAGS="$CFLAGS -I$with_libcoap_dir/include"]
[LDFLAGS="$LDFLAGS -L$with_libcoap_dir/lib -lcoap-2-openssl"]
AC_CHECK_LIB(
[coap-2-openssl],
[coap_startup],
Expand Down

0 comments on commit af537b3

Please sign in to comment.