summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-05-12 10:47:19 (GMT)
committerThomas Haller <thaller@redhat.com>2017-05-12 10:57:34 (GMT)
commitc881a27fbda7233405d91d70ec517386e2d85304 (patch)
treec27889c980c773b261e01378606752e27d549a96 /src
parent144c6c5e6a31cbcfad9e55256a2b1e20b238b24a (diff)
downloadlibnl-c881a27fbda7233405d91d70ec517386e2d85304.zip
libnl-c881a27fbda7233405d91d70ec517386e2d85304.tar.gz
libnl-c881a27fbda7233405d91d70ec517386e2d85304.tar.bz2
build: allow building cli without dynamic librarires support
Commit 3cb28534d34392ceec4adead0cfa97039796ccb7 enables building of cli always as part of `make check`. As cli previously always included <dlfcn.h>, this broke tests for building with toolchains that don't support dynamic library loading. Add a configure check and disable dlopen() based on whether <dlfcn.h> is available. Signed-off-by: Thomas Haller <thaller@redhat.com> https://github.com/thom311/libnl/pull/141
Diffstat (limited to 'src')
-rw-r--r--src/lib/utils.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/lib/utils.c b/src/lib/utils.c
index feb1d4e..6e288b6 100644
--- a/src/lib/utils.c
+++ b/src/lib/utils.c
@@ -24,6 +24,12 @@
#include <netlink/cli/utils.h>
#include <locale.h>
+#include "lib/defs.h"
+
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
/**
* Parse a text based 32 bit unsigned integer argument
* @arg arg Integer in text form.
@@ -220,14 +226,23 @@ struct nl_cache *nl_cli_alloc_cache_flags(struct nl_sock *sock,
void nl_cli_load_module(const char *prefix, const char *name)
{
char path[FILENAME_MAX+1];
- void *handle;
snprintf(path, sizeof(path), "%s/%s/%s.so",
PKGLIBDIR, prefix, name);
- if (!(handle = dlopen(path, RTLD_NOW)))
- nl_cli_fatal(ENOENT, "Unable to load module \"%s\": %s\n",
- path, dlerror());
+#ifdef HAVE_DLFCN_H
+ {
+ void *handle;
+
+ if (!(handle = dlopen(path, RTLD_NOW))) {
+ nl_cli_fatal(ENOENT, "Unable to load module \"%s\": %s\n",
+ path, dlerror());
+ }
+ }
+#else
+ nl_cli_fatal(ENOTSUP, "Unable to load module \"%s\": built without dynamic libraries support\n",
+ path);
+#endif
}
/** @} */