aboutsummaryrefslogtreecommitdiff
path: root/helper/m4
diff options
context:
space:
mode:
authorJere Leppänen <jere.leppanen@nokia.com>2021-02-18 15:07:24 +0200
committerPetri Savolainen <petri.savolainen@nokia.com>2021-02-23 11:01:07 +0200
commitb1b10b702674378905a9cca643f7d404a3ca15db (patch)
treeff5f885831cc12635525fa8c2228ee1c51b7b3c9 /helper/m4
parent84b6587531ea50a9de473587af52cdf39f7e9dd9 (diff)
configure: add with-libcli-path option
Allow user to specify the location of libcli headers and libraries, in case libcli is installed outside the normal search paths. Also, move all the libcli related logic to a separate libcli.m4 file. Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com> Reviewed-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'helper/m4')
-rw-r--r--helper/m4/configure.m420
-rw-r--r--helper/m4/libcli.m443
2 files changed, 48 insertions, 15 deletions
diff --git a/helper/m4/configure.m4 b/helper/m4/configure.m4
index e67ca019e..36629c81e 100644
--- a/helper/m4/configure.m4
+++ b/helper/m4/configure.m4
@@ -1,4 +1,9 @@
##########################################################################
+# Include m4 files
+##########################################################################
+m4_include([helper/m4/libcli.m4])
+
+##########################################################################
# Enable/disable test-helper
##########################################################################
AC_ARG_ENABLE([test-helper],
@@ -42,20 +47,5 @@ AS_IF([test "x$enable_helper_debug_print" != "xno"], [ODPH_DEBUG_PRINT=1],
AC_DEFINE_UNQUOTED([ODPH_DEBUG_PRINT], [$ODPH_DEBUG_PRINT],
[Define to 1 to display helper debug information])
-#########################################################################
-# If libcli is available, enable CLI helper
-#########################################################################
-helper_cli=no
-AC_CHECK_HEADER(libcli.h,
- [AC_CHECK_LIB(cli, cli_init, [helper_cli=yes], [], [-lcrypt])],
- [])
-
-LIBCLI_LIBS=""
-AS_IF([test "x$helper_cli" != "xno"],
- [AC_DEFINE_UNQUOTED([ODPH_CLI], [1], [Define to 1 to enable CLI helper])
- LIBCLI_LIBS="-lcli -lcrypt"])
-
-AC_SUBST([LIBCLI_LIBS])
-
AC_CONFIG_FILES([helper/libodphelper.pc
helper/test/Makefile])
diff --git a/helper/m4/libcli.m4 b/helper/m4/libcli.m4
new file mode 100644
index 000000000..6748cbb41
--- /dev/null
+++ b/helper/m4/libcli.m4
@@ -0,0 +1,43 @@
+##########################################################################
+# Set optional libcli path
+##########################################################################
+AC_ARG_WITH([libcli-path],
+ [AS_HELP_STRING([--with-libcli-path=DIR],
+ [path to libcli libs and headers [default=system]])],
+ [libcli_path_given=yes
+ LIBCLI_CPPFLAGS="-I$withval/include"
+ LIBCLI_LIBS="-L$withval/lib"
+ LIBCLI_RPATH="-R$withval/lib"],
+ [])
+
+##########################################################################
+# Save and set temporary compilation flags
+##########################################################################
+OLD_CPPFLAGS=$CPPFLAGS
+OLD_LIBS=$LIBS
+CPPFLAGS="$LIBCLI_CPPFLAGS $CPPFLAGS"
+LIBS="$LIBCLI_LIBS $LIBS"
+
+#########################################################################
+# If libcli is available, enable CLI helper
+#########################################################################
+helper_cli=no
+AC_CHECK_HEADER(libcli.h,
+ [AC_CHECK_LIB(cli, cli_init, [helper_cli=yes], [], [-lcrypt])],
+ [AS_IF([test "x$libcli_path_given" = "xyes"],
+ [AC_MSG_ERROR([libcli not found at the specified path (--with-libcli-path)])])])
+
+AS_IF([test "x$helper_cli" != "xno"],
+ [AC_DEFINE_UNQUOTED([ODPH_CLI], [1], [Define to 1 to enable CLI helper])
+ LIBCLI_LIBS="$LIBCLI_RPATH $LIBCLI_LIBS -lcli -lcrypt"],
+ [LIBCLI_CPPFLAGS=""
+ LIBCLI_LIBS=""])
+
+##########################################################################
+# Restore old saved variables
+##########################################################################
+LIBS=$OLD_LIBS
+CPPFLAGS=$OLD_CPPFLAGS
+
+AC_SUBST([LIBCLI_CPPFLAGS])
+AC_SUBST([LIBCLI_LIBS])