Skip to content

Commit af537b3

Browse files
author
Aleksandr Makarov
committed
configure.ac: Fix AC_ARG_ENABLE/AC_ARG_WITH macros
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]>
1 parent 0f8de87 commit af537b3

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

configure.ac

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ AM_CONDITIONAL([JAVA_HOME_SET], [test ! -z "$JAVA_HOME"])
4343
AC_ARG_ENABLE([client-only],
4444
[AS_HELP_STRING([--enable-client-only],
4545
[Enable the building of only the client mode of libEST])],
46-
[clientonly_on=1],
47-
[clientonly_on=0])
48-
AM_CONDITIONAL([ENABLE_CLIENT_ONLY], [test x$clientonly_on = x1])
46+
[],
47+
[enable_client_only="no"])
48+
AM_CONDITIONAL([ENABLE_CLIENT_ONLY], [test "$enable_client_only" = "yes"])
4949
AM_COND_IF([ENABLE_CLIENT_ONLY],
5050
AC_MSG_RESULT([Client only build enabled])
5151
AC_DEFINE([ENABLE_CLIENT_ONLY]),
@@ -54,9 +54,9 @@ AM_COND_IF([ENABLE_CLIENT_ONLY],
5454
AC_ARG_ENABLE([brski],
5555
[AS_HELP_STRING([--enable-brski],
5656
[Enable support for brski bootstrap functionality])],
57-
[brski_on=1],
58-
[brski_on=0])
59-
AM_CONDITIONAL([ENABLE_BRSKI], [test x$brski_on = x1])
57+
[],
58+
[enable_brski="no"])
59+
AM_CONDITIONAL([ENABLE_BRSKI], [test "$enable_brski" = "yes"])
6060
AM_COND_IF([ENABLE_BRSKI],
6161
AC_MSG_RESULT([BRSKI support enabled])
6262
AC_DEFINE([ENABLE_BRSKI]),
@@ -65,9 +65,9 @@ AM_COND_IF([ENABLE_BRSKI],
6565
AC_ARG_ENABLE([pthreads],
6666
[AS_HELP_STRING([--disable-pthreads],
6767
[Disable support for pthreads])],
68-
[pthreads_on=1],
69-
[pthreads_on=0])
70-
AM_CONDITIONAL([DISABLE_PTHREAD], [test x$pthreads_on = x1])
68+
[],
69+
[enable_pthreads="yes"])
70+
AM_CONDITIONAL([DISABLE_PTHREAD], [test "$enable_pthreads" = "no"])
7171
AM_COND_IF([DISABLE_PTHREAD],
7272
AC_MSG_RESULT([pthread support disabled])
7373
AC_DEFINE([DISABLE_PTHREADS]),
@@ -88,13 +88,13 @@ AM_COND_IF([ENABLE_EXAMPLES], AC_MSG_RESULT([yes]), AC_MSG_RESULT([no]))
8888
AC_ARG_WITH([ssl-dir],
8989
[AS_HELP_STRING([--with-ssl-dir],
9090
[location of OpenSSL install folder, defaults to /usr/local/ssl])],
91-
[ssldir="$withval"],
92-
[ssldir="/usr/local/ssl"])
93-
AC_SUBST([SSL_CFLAGS], "$ssldir/include")
94-
AC_SUBST([SSL_LDFLAGS], "$ssldir/lib")
91+
[],
92+
[with_ssl_dir="/usr/local/ssl"])
93+
AC_SUBST([SSL_CFLAGS], "$with_ssl_dir/include")
94+
AC_SUBST([SSL_LDFLAGS], "$with_ssl_dir/lib")
9595

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

126126
AS_IF(
127-
[test "x$with_libcurldir" != xno],
128-
[[CFLAGS="$CFLAGS -I$libcurldir/include"]
129-
[LDFLAGS="$LDFLAGS -L$libcurldir/lib -lcurl"]
127+
[test "$with_libcurl_dir" != "no"],
128+
[[CFLAGS="$CFLAGS -I$with_libcurl_dir/include"]
129+
[LDFLAGS="$LDFLAGS -L$with_libcurl_dir/lib -lcurl"]
130130
AC_CHECK_LIB(
131131
[curl],
132132
[curl_easy_init],
@@ -143,17 +143,17 @@ AC_ARG_WITH([libcurl-dir],
143143
AC_ARG_WITH([uriparser-dir],
144144
[AS_HELP_STRING([--with-uriparser-dir],
145145
[enable support for path segments using uriparser])],
146-
[uriparserdir="$withval"],
147-
[with_uriparserdir=no])
146+
[],
147+
[with_uriparser_dir=no])
148148

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

153153
AS_IF(
154-
[test "x$with_uriparserdir" != xno],
155-
[[CFLAGS="$CFLAGS -I$uriparserdir/include"]
156-
[LDFLAGS="$LDFLAGS -L$uriparserdir/lib -luriparser"]
154+
[test "$with_uriparser_dir" != "no"],
155+
[[CFLAGS="$CFLAGS -I$with_uriparser_dir/include"]
156+
[LDFLAGS="$LDFLAGS -L$with_uriparser_dir/lib -luriparser"]
157157
AC_CHECK_LIB(
158158
[uriparser],
159159
[uriParseUriA],
@@ -170,13 +170,13 @@ AC_ARG_WITH([uriparser-dir],
170170
AC_ARG_WITH([libcoap-dir],
171171
[AS_HELP_STRING([--with-libcoap-dir],
172172
[enable support for ESToCoAP using libcoap library])],
173-
[libcoapdir="$withval"],
174-
[with_libcoapdir=no])
173+
[],
174+
[with_libcoap_dir=no])
175175

176176
AS_IF(
177-
[test "x$with_libcoapdir" != xno],
178-
[[CFLAGS="$CFLAGS -I$libcoapdir/include"]
179-
[LDFLAGS="$LDFLAGS -L$libcoapdir/lib -lcoap-2-openssl"]
177+
[test "$with_libcoap_dir" != "no"],
178+
[[CFLAGS="$CFLAGS -I$with_libcoap_dir/include"]
179+
[LDFLAGS="$LDFLAGS -L$with_libcoap_dir/lib -lcoap-2-openssl"]
180180
AC_CHECK_LIB(
181181
[coap-2-openssl],
182182
[coap_startup],

0 commit comments

Comments
 (0)