[dconf] portability: only link to -ldl if needed



commit c8603e6d3673f06f84dc2b0ff0f96ede4ad881a8
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun Dec 8 12:58:49 2013 -0500

    portability: only link to -ldl if needed
    
    We use -ldl in some of our testcases to mock out some system calls via
    interposing, using dlsym() to chain up.
    
    Make sure we only use this if we really need to.  Many systems have
    dlsym() in the C library and no -ldl.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720072

 configure.ac      |    2 ++
 tests/Makefile.am |    5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 87356b6..f99e903 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,6 +18,8 @@ fi
 
 # Check for programs
 AC_PROG_CC
+AC_CHECK_LIB(c, dlsym, LIBDL="", [AC_CHECK_LIB(dl, dlsym, LIBDL="-ldl")])
+AC_SUBST(LIBDL)
 AM_PROG_VALAC([0.17.0])
 AC_PROG_RANLIB
 AC_ARG_ENABLE(man,
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fc77755..adc8519 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -29,7 +29,7 @@ shm_CFLAGS = $(glib_CFLAGS)
 shm_LDADD = \
        ../shm/libdconf-shm.a                   \
        $(glib_LIBS)                            \
-       -ldl
+       $(LIBDL)
 shm_SOURCES = \
        shm.c                                   \
        tmpdir.h                                \
@@ -79,7 +79,8 @@ engine_LDADD = \
        ../common/libdconf-common.a             \
        libdconf-mock.a                         \
        $(glib_LIBS)                            \
-       -ldl -lm
+       $(LIBDL)                                \
+       -lm
 engine_SOURCES = engine.c
 EXTRA_DIST += \
        profile/broken-profile                  \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]