Use a variable to select the dlopen lib in Makefiles
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 20 Dec 2018 20:22:39 +0000 (15:22 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 21 Dec 2018 21:05:43 +0000 (16:05 -0500)
Instead of multiple conditionnals, it makes for cleaner and more
readable Makefiles.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
15 files changed:
configure.ac
liblttng-ust-cyg-profile/Makefile.am
liblttng-ust-dl/Makefile.am
liblttng-ust-fd/Makefile.am
liblttng-ust-fork/Makefile.am
liblttng-ust-libc-wrapper/Makefile.am
liblttng-ust/Makefile.am
tests/benchmark/Makefile.am
tests/ctf-types/Makefile.am
tests/hello-many/Makefile.am
tests/hello.cxx/Makefile.am
tests/hello/Makefile.am
tests/same_line_tracepoint/Makefile.am
tests/test-app-ctx/Makefile.am
tests/ust-variant/Makefile.am

index 5f27f99980d850edd0c065fc879558b7c1b03233..f2be286875916beb224ec50a41e990aa161a5f22 100644 (file)
@@ -207,17 +207,18 @@ AH_TEMPLATE([LTTNG_UST_HAVE_PERF_EVENT], [Perf event integration via perf_event.
 
 # Checks for libraries.
 AC_CHECK_LIB([dl], [dlopen], [
-       have_libdl=yes
        libdl_name=dl
+       DL_LIBS="-ldl"
 ], [
        #libdl not found, check for dlopen in libc.
        AC_CHECK_LIB([c], [dlopen], [
-               have_libc_dl=yes
                libdl_name=c
+               DL_LIBS="-lc"
        ], [
                AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
        ])
 ])
+AC_SUBST(DL_LIBS)
 
 # Check if libdl has dlmopen support.
 AH_TEMPLATE([HAVE_DLMOPEN], ["Define to 1 if dlmopen is available."])
@@ -225,9 +226,6 @@ AC_CHECK_LIB([$libdl_name], [dlmopen],
        [AC_DEFINE([HAVE_DLMOPEN], [1])]
 )
 
-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])
 AC_CHECK_LIB([pthread], [pthread_setname_np],
        AC_DEFINE([HAVE_PTHREAD_SETNAME_NP], [1], [Define to 1 if pthread_setname_np is available.]),
index 3130282d2fd383cf8c326404cd1e2dc1e4b994bc..0ed2cd9cae6169f8646368d2b6b6b12128fad540 100644 (file)
@@ -7,25 +7,20 @@ lib_LTLIBRARIES = liblttng-ust-cyg-profile.la \
 liblttng_ust_cyg_profile_la_SOURCES = \
        lttng-ust-cyg-profile.c \
        lttng-ust-cyg-profile.h
+
 liblttng_ust_cyg_profile_la_LIBADD = \
        -L$(top_builddir)/liblttng-ust/.libs \
-       -llttng-ust
+       -llttng-ust \
+       $(DL_LIBS)
 
 liblttng_ust_cyg_profile_fast_la_SOURCES = \
        lttng-ust-cyg-profile-fast.c \
        lttng-ust-cyg-profile-fast.h
+
 liblttng_ust_cyg_profile_fast_la_LIBADD = \
        -L$(top_builddir)/liblttng-ust/.libs \
-       -llttng-ust
-
-if LTTNG_UST_BUILD_WITH_LIBDL
-liblttng_ust_cyg_profile_la_LIBADD += -ldl
-liblttng_ust_cyg_profile_fast_la_LIBADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-liblttng_ust_cyg_profile_la_LIBADD += -lc
-liblttng_ust_cyg_profile_fast_la_LIBADD += -lc
-endif
+       -llttng-ust \
+       $(DL_LIBS)
 
 noinst_SCRIPTS = run run-fast
 EXTRA_DIST = run run-fast
index c0168f395bf9e4a093339d3e61a703e397e39f39..1f6d166a013ae4230f9cb22405fa0d0f899f9df9 100644 (file)
@@ -6,14 +6,9 @@ liblttng_ust_dl_la_SOURCES = \
        lttng-ust-dl.c \
        ust_dl.c \
        ust_dl.h
-liblttng_ust_dl_la_LIBADD = \
-       $(top_builddir)/liblttng-ust/liblttng-ust.la
 
-if LTTNG_UST_BUILD_WITH_LIBDL
-liblttng_ust_dl_la_LIBADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-liblttng_ust_dl_la_LIBADD += -lc
-endif
+liblttng_ust_dl_la_LIBADD = \
+       $(top_builddir)/liblttng-ust/liblttng-ust.la \
+       $(DL_LIBS)
 
 liblttng_ust_dl_la_CFLAGS = -DUST_COMPONENT=liblttng-ust-dl $(AM_CFLAGS)
index f7706634a99161dab22389de8e28940ebbb72569..57122ec7a65d64b424bf563946b026dd5c3e5206 100644 (file)
@@ -4,14 +4,9 @@ AM_CFLAGS += -fno-strict-aliasing
 lib_LTLIBRARIES = liblttng-ust-fd.la
 liblttng_ust_fd_la_SOURCES = \
        lttng-ust-fd.c
-liblttng_ust_fd_la_LIBADD = \
-       $(top_builddir)/liblttng-ust/liblttng-ust.la
 
-if LTTNG_UST_BUILD_WITH_LIBDL
-liblttng_ust_fd_la_LIBADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-liblttng_ust_fd_la_LIBADD += -lc
-endif
+liblttng_ust_fd_la_LIBADD = \
+       $(top_builddir)/liblttng-ust/liblttng-ust.la \
+       $(DL_LIBS)
 
 liblttng_ust_fd_la_CFLAGS = -DUST_COMPONENT=liblttng-ust-fd $(AM_CFLAGS)
index 2f0976d4da05c5b956a608aa63e91cae1be5118b..d05f5b933ecd440356b9b3105847f651339b8de5 100644 (file)
@@ -4,13 +4,7 @@ AM_CFLAGS += -fno-strict-aliasing
 lib_LTLIBRARIES = liblttng-ust-fork.la
 liblttng_ust_fork_la_SOURCES = ustfork.c
 liblttng_ust_fork_la_LIBADD = \
-       $(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
+       $(top_builddir)/liblttng-ust/liblttng-ust.la \
+       $(DL_LIBS)
 
 liblttng_ust_fork_la_CFLAGS = -DUST_COMPONENT=liblttng-ust-fork $(AM_CFLAGS)
index e73b4d88ad52c9a8f634c6ae316e953937f12e2c..e510a11a2c319c0e01493d431977b74ef45f75fd 100644 (file)
@@ -3,28 +3,24 @@ AM_CFLAGS += -fno-strict-aliasing
 
 lib_LTLIBRARIES = liblttng-ust-libc-wrapper.la \
   liblttng-ust-pthread-wrapper.la
+
 liblttng_ust_libc_wrapper_la_SOURCES = \
        lttng-ust-malloc.c \
        ust_libc.h
+
 liblttng_ust_libc_wrapper_la_LIBADD = \
        -L$(top_builddir)/liblttng-ust/.libs \
-       -llttng-ust
+       -llttng-ust \
+       $(DL_LIBS)
 
 liblttng_ust_pthread_wrapper_la_SOURCES = \
        lttng-ust-pthread.c \
        ust_pthread.h
+
 liblttng_ust_pthread_wrapper_la_LIBADD = \
        -L$(top_builddir)/liblttng-ust/.libs \
-       -llttng-ust
-
-if LTTNG_UST_BUILD_WITH_LIBDL
-liblttng_ust_libc_wrapper_la_LIBADD += -ldl
-liblttng_ust_pthread_wrapper_la_LIBADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-liblttng_ust_libc_wrapper_la_LIBADD += -lc
-liblttng_ust_pthread_wrapper_la_LIBADD += -lc
-endif
+       -llttng-ust \
+       $(DL_LIBS)
 
 noinst_SCRIPTS = run
 EXTRA_DIST = run
index 57df3aedc9b3f04ad57c6530994e9a61609f2e57..ea4c8f612ee4c947e71c1472052731e235e3b448 100644 (file)
@@ -12,20 +12,16 @@ liblttng_ust_tracepoint_la_SOURCES = \
        lttng-tracer-core.h \
        jhash.h \
        error.h
+
 liblttng_ust_tracepoint_la_LIBADD = \
        -lurcu-bp \
        -lpthread \
-       $(top_builddir)/snprintf/libustsnprintf.la
+       $(top_builddir)/snprintf/libustsnprintf.la \
+       $(DL_LIBS)
+
 liblttng_ust_tracepoint_la_LDFLAGS = -no-undefined -version-info $(LTTNG_UST_LIBRARY_VERSION)
 liblttng_ust_tracepoint_la_CFLAGS = -DUST_COMPONENT="liblttng_ust_tracepoint" $(AM_CFLAGS)
 
-if LTTNG_UST_BUILD_WITH_LIBDL
-liblttng_ust_tracepoint_la_LIBADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-liblttng_ust_tracepoint_la_LIBADD += -lc
-endif
-
 liblttng_ust_runtime_la_SOURCES = \
        lttng-ust-comm.c \
        lttng-ust-abi.c \
@@ -106,13 +102,7 @@ liblttng_ust_la_LIBADD = \
        $(top_builddir)/snprintf/libustsnprintf.la \
        $(top_builddir)/liblttng-ust-comm/liblttng-ust-comm.la \
        liblttng-ust-tracepoint.la \
-       liblttng-ust-runtime.la liblttng-ust-support.la
-
-if LTTNG_UST_BUILD_WITH_LIBDL
-liblttng_ust_la_LIBADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-liblttng_ust_la_LIBADD += -lc
-endif
+       liblttng-ust-runtime.la liblttng-ust-support.la \
+       $(DL_LIBS)
 
 liblttng_ust_la_CFLAGS = -DUST_COMPONENT="liblttng_ust" $(AM_CFLAGS)
index 4ea420c61fe1f1a831a521b6e9b8a9493c865bf1..ef9635c0da9b567aa9617f9afd5109dd5e9257ce 100644 (file)
@@ -2,20 +2,12 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers
 
 noinst_PROGRAMS = bench1 bench2
 bench1_SOURCES = bench.c tp.c ust_tests_benchmark.h
-bench1_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
+bench1_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+
 bench2_SOURCES = bench.c tp.c ust_tests_benchmark.h
-bench2_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
+bench2_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
 bench2_CFLAGS = -DTRACING $(AM_CFLAGS)
 
 dist_noinst_SCRIPTS = test_benchmark ptime
 
 extra_DIST = README
-
-if LTTNG_UST_BUILD_WITH_LIBDL
-bench1_LDADD += -ldl
-bench2_LDADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-bench1_LDADD += -lc
-bench2_LDADD += -lc
-endif
index a9b40b6ac25a8cee36de141c4cf206c423aaac54..42d803f2a409ce6cb3fc7c63ce7703c9e0e2b7b4 100644 (file)
@@ -2,12 +2,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers
 
 noinst_PROGRAMS = ctf-types
 ctf_types_SOURCES = ctf-types.c tp.c ust_tests_ctf_types.h
-ctf_types_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
+ctf_types_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
 ctf_types_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
-
-if LTTNG_UST_BUILD_WITH_LIBDL
-ctf_types_LDADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-ctf_types_LDADD += -lc
-endif
index 338b7986cfa09b8f4cf7af0083519f7eb9d96d5f..ee64822551a3f83e98c71484d4df05e0a077f769 100644 (file)
@@ -2,12 +2,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers
 
 noinst_PROGRAMS = hello-many
 hello_many_SOURCES = hello-many.c tp.c ust_tests_hello_many.h
-hello_many_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
+hello_many_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
 hello_many_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
-
-if LTTNG_UST_BUILD_WITH_LIBDL
-hello_many_LDADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-hello_many_LDADD += -lc
-endif
index f8a8f46df813afb8c07a45f9d7123af1f1ef7b11..4b0fb2344fc5107ab8584aa43ed8b2f8edac61fd 100644 (file)
@@ -2,11 +2,4 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers
 
 noinst_PROGRAMS = hello
 hello_SOURCES = hello.cpp tp-cpp.cpp 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
+hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
index cb4d46266646fd57fd79a2806c4bc755e1593ffa..d5e42d331eb41d4b62677a74cc04f3dbfb71a624 100644 (file)
@@ -2,12 +2,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers
 
 noinst_PROGRAMS = hello
 hello_SOURCES = hello.c tp.c ust_tests_hello.h
-hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
+hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
 hello_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
-
-if LTTNG_UST_BUILD_WITH_LIBDL
-hello_LDADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-hello_LDADD += -lc
-endif
index 5cb4f36b1c3d53869845169d9a828422dd1a9b29..ae1f773d74dfdefb61fc181d5e201def7615c292 100644 (file)
@@ -2,11 +2,4 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers
 
 noinst_PROGRAMS = same_line_tracepoint
 same_line_tracepoint_SOURCES = same_line_tracepoint.c ust_tests_sameline.h
-same_line_tracepoint_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
-
-if LTTNG_UST_BUILD_WITH_LIBDL
-same_line_tracepoint_LDADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-same_line_tracepoint_LDADD += -lc
-endif
+same_line_tracepoint_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
index cb4d46266646fd57fd79a2806c4bc755e1593ffa..d5e42d331eb41d4b62677a74cc04f3dbfb71a624 100644 (file)
@@ -2,12 +2,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers
 
 noinst_PROGRAMS = hello
 hello_SOURCES = hello.c tp.c ust_tests_hello.h
-hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
+hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
 hello_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
-
-if LTTNG_UST_BUILD_WITH_LIBDL
-hello_LDADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-hello_LDADD += -lc
-endif
index 5d741bdfdb2dd76730d5d190f22beafaa2269275..28e62009718a3f17d76008a96fb3001e7d63d01a 100644 (file)
@@ -2,12 +2,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers
 
 noinst_PROGRAMS = ust-variant
 ust_variant_SOURCES = ust-variant.c
-ust_variant_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
+ust_variant_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
 ust_variant_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
-
-if LTTNG_UST_BUILD_WITH_LIBDL
-ust_variant_LDADD += -ldl
-endif
-if LTTNG_UST_BUILD_WITH_LIBC_DL
-ust_variant_LDADD += -lc
-endif
This page took 0.032118 seconds and 4 git commands to generate.