configure.ac: use pkg-config for libelf
authorJonathan Gray <jsg@jsg.id.au>
Wed, 9 Dec 2015 05:55:01 +0000 (16:55 +1100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 17 Dec 2015 09:37:24 +0000 (09:37 +0000)
Use PKG_CHECK_MODULES to get the flags to link libelf

v2: keep AC_CHECK_LIB as a fallback for elfutils provided
libelf that doesn't install a pkg-config file.

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
configure.ac
src/gallium/drivers/radeon/Makefile.am
src/gallium/targets/opencl/Makefile.am

index b6680d04fd1fcfe99c393d9bd22e9498a02f9210..7a3c7cd2fafc98ad59232dd91aa205e034013481 100644 (file)
@@ -1712,7 +1712,15 @@ AC_ARG_WITH([clang-libdir],
    [CLANG_LIBDIR=''])
 
 PKG_CHECK_EXISTS([libclc], [have_libclc=yes], [have_libclc=no])
-AC_CHECK_LIB([elf], [elf_memory], [have_libelf=yes;ELF_LIB=-lelf])
+PKG_CHECK_MODULES([LIBELF], [libelf], [have_libelf=yes], [have_libelf=no])
+
+if test "x$have_libelf" = xno; then
+   LIBELF_LIBS=''
+   LIBELF_CFLAGS=''
+   AC_CHECK_LIB([elf], [elf_memory], [have_libelf=yes;LIBELF_LIBS=-lelf], [have_libelf=no])
+   AC_SUBST([LIBELF_LIBS])
+   AC_SUBST([LIBELF_CFLAGS])
+fi
 
 if test "x$enable_opencl" = xyes; then
     if test -z "$with_gallium_drivers"; then
@@ -2299,8 +2307,6 @@ if test "x$USE_VC4_SIMULATOR" = xyes -a "x$HAVE_GALLIUM_ILO" = xyes; then
     AC_MSG_ERROR([VC4 simulator on x86 replaces i965 driver build, so ilo must be disabled.])
 fi
 
-AC_SUBST([ELF_LIB])
-
 AM_CONDITIONAL(HAVE_LIBDRM, test "x$have_libdrm" = xyes)
 AM_CONDITIONAL(HAVE_X11_DRIVER, test "x$enable_xlib_glx" = xyes)
 AM_CONDITIONAL(HAVE_OSMESA, test "x$enable_osmesa" = xyes)
index 13d8976de9577a3b8615450d6b2b8682a766fafd..a6fc145cb5c48c58730eab44b9c7af8dad16b6d5 100644 (file)
@@ -16,7 +16,8 @@ libradeon_la_SOURCES = \
 if NEED_RADEON_LLVM
 
 AM_CFLAGS += \
-       $(LLVM_CFLAGS)
+       $(LLVM_CFLAGS) \
+       $(LIBELF_CFLAGS)
 
 libradeon_la_SOURCES += \
        $(LLVM_C_FILES)
@@ -24,7 +25,7 @@ libradeon_la_SOURCES += \
 libradeon_la_LIBADD = \
        $(CLOCK_LIB) \
        $(LLVM_LIBS) \
-       $(ELF_LIB)
+       $(LIBELF_LIBS)
 
 libradeon_la_LDFLAGS = \
        $(LLVM_LDFLAGS)
index 08f95e8074c471e2ec953eab10b68310de270639..f3ba1e32d1bd1802df56d80166075ba1a1b115f2 100644 (file)
@@ -2,6 +2,9 @@ include $(top_srcdir)/src/gallium/Automake.inc
 
 lib_LTLIBRARIES = lib@OPENCL_LIBNAME@.la
 
+AM_CPPFLAGS = \
+        $(LIBELF_CFLAGS)
+
 lib@OPENCL_LIBNAME@_la_LDFLAGS = \
        $(LLVM_LDFLAGS) \
        -no-undefined \
@@ -19,7 +22,7 @@ lib@OPENCL_LIBNAME@_la_LIBADD = \
        $(top_builddir)/src/gallium/state_trackers/clover/libclover.la \
        $(top_builddir)/src/gallium/auxiliary/libgallium.la \
        $(top_builddir)/src/util/libmesautil.la \
-       $(ELF_LIB) \
+       $(LIBELF_LIBS) \
        $(DLOPEN_LIBS) \
        -lclangCodeGen \
        -lclangFrontendTool \