Detect and document dependency on -ldl on Linux, -lc on BSD for dlopen
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 21 Feb 2012 16:25:14 +0000 (11:25 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 21 Feb 2012 16:25:14 +0000 (11:25 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
15 files changed:
README
configure.ac
doc/examples/easy-ust/Makefile
doc/examples/gen-tp/Makefile
liblttng-ust-fork/Makefile.am
liblttng-ust-libc-wrapper/Makefile.am
tests/demo/Makefile.am
tests/demo/README
tests/dlopen/Makefile.am
tests/hello-static-lib/Makefile.am
tests/hello.cxx/Makefile.am
tests/hello/Makefile.am
tests/hello/Makefile.example [deleted file]
tests/hello/Makefile.example.bsd [new file with mode: 0644]
tests/hello/Makefile.example.linux [new file with mode: 0644]

diff --git a/README b/README
index e2b52aa026f74a3ff598c774bc034baefe01c5aa..78ed56f68067bbdefef3bfb771110eb439377590 100644 (file)
--- a/README
+++ b/README
@@ -67,7 +67,7 @@ USAGE:
       "TRACEPOINT_DEFINE" and include the tracepoint provider.
     - Use "-I." for the compilation unit containing the tracepoint
       provider include (e.g. tp.c).
-    - Link application with "-ldl".
+    - Link application with "-ldl" on Linux, with "-lc" on BSD.
     - If building the provider directly into the application,
       link the application with "-llttng-ust".
     - If building a static library for the provider, link the static
@@ -75,7 +75,7 @@ USAGE:
     - Include the tracepoint provider header into all C files using
       the provider.
     - Example:
-        tests/hello/  hello.c tp.c ust_tests_hello.h Makefile.example
+        tests/hello/  hello.c tp.c ust_tests_hello.h Makefile.example.*
 
   2) Compile the Tracepoint Provider separately from the application,
      using dynamic linking:
@@ -87,7 +87,7 @@ USAGE:
       files that use the provider.
     - Compile the tracepoint provider with "-I.".
     - Link the tracepoint provider with "-llttng-ust".
-    - Link application with "-ldl".
+    - Link application with "-ldl" on Linux, "-lc" on BSD.
     - Set a LD_PRELOAD environment to preload the tracepoint provider
       shared object before starting the application when tracing is
       needed.
index 00da3e8c6ac78bd3985a0a2846141347c8466ffe..8b79f9a9566b3809eced77d07ac392a1ab5b35c6 100644 (file)
@@ -42,7 +42,23 @@ AC_PROG_MAKE_SET
 LT_INIT
 
 ## Checks for libraries.
-AC_CHECK_LIB([dl], [dlopen])
+AC_CHECK_LIB([dl], [dlopen],
+[
+       have_libdl=yes
+],
+[
+       #libdl not found, check for dlopen in libc.
+       AC_CHECK_LIB([c], [dlopen],
+       [
+               have_libc_dl=yes
+       ],
+       [
+               AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
+       ])
+])
+AM_CONDITIONAL([LTTNG_UST_BUILD_WITH_LIBDL], [test "x$have_libdl" = "xyes"])
+AM_CONDITIONAL([LTTNG_UST_BUILD_WITH_LIBC_DL], [test "x$have_libc_dl" = "xyes"])
+
 AC_CHECK_LIB([pthread], [pthread_create])
 
 # Check for libuuid
@@ -59,7 +75,7 @@ AC_CHECK_LIB([uuid], [uuid_generate],
                have_libc_uuid=yes
        ],
        [
-               AC_MSG_ERROR([Cannot find libuuid uuid_generate nor libc uuid_create. Use [LDFLAGS]=-Ldir to specify its location.])
+               AC_MSG_ERROR([Cannot find libuuid uuid_generate nor libc uuid_create. Use [LDFLAGS]=-Ldir to specify their location.])
        ])
 ]
 )
index 597071b58621f9e2c5bbc033a5d130dec4b588e5..3d043df428f51f02e1c9c05cfbb8be082f0b8924 100644 (file)
@@ -16,7 +16,8 @@
 # the "html" target helps for documentation (req. code2html)
 
 CC = gcc
-LIBS = -ldl -llttng-ust
+LIBS = -ldl -llttng-ust                # On Linux
+#LIBS = -lc -llttng-ust                # On BSD
 CFLAGS = -I.
 
 all: sample
index b29eed4cf707821d8d695274d7387f2a72399150..518f017498b279814aa992c10d03133cc2b6fb45 100644 (file)
@@ -16,7 +16,9 @@
 # provider probe.
 
 CC = gcc
-LIBS = -ldl -llttng-ust
+
+LIBS = -ldl -llttng-ust                #On Linux
+#LIBS = -lc -llttng-ust                #On BSD
 
 all: sample
 
index e0e42a3f4d707f3e01500e2296f0a25b973327f3..49466f6481d6a39a0b3c1623956c2d1f2e1907ec 100644 (file)
@@ -4,6 +4,13 @@ AM_CFLAGS = -fno-strict-aliasing
 lib_LTLIBRARIES = liblttng-ust-fork.la
 liblttng_ust_fork_la_SOURCES = ustfork.c
 liblttng_ust_fork_la_LIBADD = \
-       -ldl \
        $(top_builddir)/liblttng-ust/liblttng-ust.la
+
+if LTTNG_UST_BUILD_WITH_LIBDL
+liblttng_ust_fork_la_LIBADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+liblttng_ust_fork_la_LIBADD += -lc
+endif
+
 libustfork_CFLAGS = -DUST_COMPONENT=liblttng-ust-fork -fno-strict-aliasing
index 6220f76c6c64ec2d6d239f87ee0f4270f08d9c68..5b3f7f0da586872bce4f7e04ee9fa664072f9dba 100644 (file)
@@ -5,9 +5,16 @@ lib_LTLIBRARIES = liblttng-ust-libc-wrapper.la
 liblttng_ust_libc_wrapper_la_SOURCES = \
        lttng-ust-malloc.c \
        ust_libc.h
-liblttng_ust_libc_wrapper_la_LIBADD = -ldl \
+liblttng_ust_libc_wrapper_la_LIBADD = \
        -L$(top_builddir)/liblttng-ust/.libs \
        -llttng-ust
 
+if LTTNG_UST_BUILD_WITH_LIBDL
+liblttng_ust_libc_wrapper_la_LIBADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+liblttng_ust_libc_wrapper_la_LIBADD += -lc
+endif
+
 noinst_SCRIPTS = run
 EXTRA_DIST = run
index 4afeaad79529bc4fad86eb377a70bdec5c0a04b7..4e113edc87705e0c9654d68b5b589df5e493533e 100644 (file)
@@ -37,5 +37,11 @@ liblttng_ust_provider_ust_tests_demo3_la_LDFLAGS = \
 
 noinst_PROGRAMS = demo
 demo_SOURCES = demo.c ust_tests_demo.h
-# The demo program only depends on libdl.
-demo_LDFLAGS = -ldl
+# The demo program only depends on libdl/libc for dlopen().
+if LTTNG_UST_BUILD_WITH_LIBDL
+demo_LDADD = -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+demo_LDADD = -lc
+endif
+
index cc51b67c763ef6a06e0c4db0e5f1d67b7c781ffe..03ee4ee1ea7e2c6dabf1c9b22e88fa5b2fbf717c 100644 (file)
@@ -4,7 +4,8 @@ demo-trace shell script preloads the provider shared objects before
 executing the demo. Executing "demo" without the shell wrapper will not
 provide any tracing support. This ensures the demo binary can be
 distributed on distros without depending on having liblttng-ust.so in
-place. Note: the "demo" program must be compiled with "-ldl".
+place. Note: the "demo" program must be compiled with "-ldl" on Linux,
+with "-lc" on BSD.
 
 The simplest command to trace the demo program are:
 lttng create
index 89fd9dbfc57b993a16d700654b4cd429cbb76247..de05346c710b37251d2861946f169d8c4d4b6d79 100644 (file)
@@ -6,7 +6,14 @@ libdummy_la_SOURCES = libdummy.c
 libdummy_la_LIBADD = $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
 libdummy_la_LDFLAGS = -rpath /nowhere
 dlopen_SOURCES = dlopen.c
-dlopen_LDADD = -ldl $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
+dlopen_LDADD = $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
+
+if LTTNG_UST_BUILD_WITH_LIBDL
+dlopen_LDADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+dlopen_LDADD += -lc
+endif
 
 noinst_SCRIPTS = run
 EXTRA_DIST = run
index 0eff080cdd2bb4746299b9fd90a1d9a6bf203ce0..6633489424a388db1f375e5aefa3e14f8746f66e 100644 (file)
@@ -8,7 +8,14 @@ liblttng_ust_provider_ust_test_hello_la_LIBADD = \
 
 noinst_PROGRAMS = hello
 hello_SOURCES = hello.c
-hello_LDADD = -ldl liblttng-ust-provider-ust-test-hello.la
+hello_LDADD = liblttng-ust-provider-ust-test-hello.la
+
+if LTTNG_UST_BUILD_WITH_LIBDL
+hello_LDADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+hello_LDADD += -lc
+endif
 
 noinst_SCRIPTS = run
 EXTRA_DIST = run
index 3e84796a731b4ecf965e57bae6d0f0f967190e99..f56f431c70f9800c74ffa37b2d63dfd4a88e9f32 100644 (file)
@@ -4,5 +4,12 @@ noinst_PROGRAMS = hello
 hello_SOURCES = hello.cpp tp.c ust_tests_hello.h
 hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
 
+if LTTNG_UST_BUILD_WITH_LIBDL
+hello_LDADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+hello_LDADD += -lc
+endif
+
 noinst_SCRIPTS = run
 EXTRA_DIST = run
index d866b6da6a1a9851c4061badeadef113243c9e4e..847e64d907200685a2f3a8c41560bf19f835bbce 100644 (file)
@@ -4,5 +4,12 @@ noinst_PROGRAMS = hello
 hello_SOURCES = hello.c tp.c ust_tests_hello.h
 hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
 
+if LTTNG_UST_BUILD_WITH_LIBDL
+hello_LDADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+hello_LDADD += -lc
+endif
+
 noinst_SCRIPTS = run
 EXTRA_DIST = run
diff --git a/tests/hello/Makefile.example b/tests/hello/Makefile.example
deleted file mode 100644 (file)
index c983f4c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Example makefile for build outside of the LTTng-UST tree.
-
-hello:
-       ${CC} -O2 -I. -o hello -ldl -llttng-ust hello.c tp.c
-
-.PHONY: clean
-clean:
-       rm -f hello
diff --git a/tests/hello/Makefile.example.bsd b/tests/hello/Makefile.example.bsd
new file mode 100644 (file)
index 0000000..607171c
--- /dev/null
@@ -0,0 +1,8 @@
+# Example makefile for build outside of the LTTng-UST tree.
+
+hello:
+       ${CC} -O2 -I. -o hello -lc -llttng-ust hello.c tp.c
+
+.PHONY: clean
+clean:
+       rm -f hello
diff --git a/tests/hello/Makefile.example.linux b/tests/hello/Makefile.example.linux
new file mode 100644 (file)
index 0000000..c983f4c
--- /dev/null
@@ -0,0 +1,8 @@
+# Example makefile for build outside of the LTTng-UST tree.
+
+hello:
+       ${CC} -O2 -I. -o hello -ldl -llttng-ust hello.c tp.c
+
+.PHONY: clean
+clean:
+       rm -f hello
This page took 0.031162 seconds and 4 git commands to generate.