From c1213feac306f2452e43003fb6d38048175cbbdf Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 13 Feb 2017 20:47:45 +0100 Subject: [PATCH] build system: try detecting pugixml via pkg-config with fallback Implements #1891. --- NEWS.md | 4 ++++ Rakefile | 2 +- ac/pugixml.m4 | 26 +++++++++++++++++++------- build-config.in | 2 ++ rake.d/target.rb | 1 + 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index ed9dbfd31..768bab13c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -67,6 +67,10 @@ In order to facilitate finding the new requirements new options have been added to confiure: "--with-xsltproc=prog", "--with-docbook-xsl=dir", "--with-po4a=prog" and "--with-po4a-translate=prog. +* pugixml detection will be attempted via "pkg-config" first. If that fails, + "configure" will fall back to the previous method of trying just to compile + and link a test program with the standard include and library locations. + Implements #1891. # Version 9.8.0 "Kuglblids" 2017-01-22 diff --git a/Rakefile b/Rakefile index 9d5122e2e..d641a2ebe 100644 --- a/Rakefile +++ b/Rakefile @@ -126,7 +126,7 @@ def setup_globals cflags_common += " -fsanitize=undefined" if c?(:UBSAN) cflags_common += " -fsanitize=address -fno-omit-frame-pointer" if c?(:ADDRSAN) cflags_common += " -Ilib/libebml -Ilib/libmatroska" if c?(:EBML_MATROSKA_INTERNAL) - cflags_common += " #{c(:MATROSKA_CFLAGS)} #{c(:EBML_CFLAGS)} #{c(:EXTRA_CFLAGS)} #{c(:DEBUG_CFLAGS)} #{c(:PROFILING_CFLAGS)} #{c(:USER_CPPFLAGS)}" + cflags_common += " #{c(:MATROSKA_CFLAGS)} #{c(:EBML_CFLAGS)} #{c(:PUGIXML_CFLAGS)} #{c(:EXTRA_CFLAGS)} #{c(:DEBUG_CFLAGS)} #{c(:PROFILING_CFLAGS)} #{c(:USER_CPPFLAGS)}" cflags_common += " -mno-ms-bitfields -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 " if c?(:MINGW) cflags_common += " -march=i686" if c?(:MINGW) && /i686/.match(c(:host)) cflags_common += " -fPIC " if c?(:USE_QT) && !c?(:MINGW) diff --git a/ac/pugixml.m4 b/ac/pugixml.m4 index 0c8f82375..08501e888 100644 --- a/ac/pugixml.m4 +++ b/ac/pugixml.m4 @@ -2,17 +2,29 @@ dnl dnl Check for pugixml dnl -AC_LANG_PUSH(C++) +PKG_CHECK_EXISTS([pugixml],[pugixml_found=yes],[pugixml_found=no]) -AC_CHECK_HEADERS([pugixml.hpp]) - -if test x"$ac_cv_header_pugixml_hpp" = xyes; then - AC_CHECK_LIB([pugixml], [main]) +if test x"$pugixml_found" = xyes; then + PKG_CHECK_MODULES([PUGIXML],[pugixml],[pugixml_found=yes],[pugixml_found=no]) fi -AC_LANG_POP +if test x"$pugixml_found" = xno; then + AC_LANG_PUSH(C++) -if test x"$ac_cv_header_pugixml_hpp" = xyes -a x"$ac_cv_lib_pugixml_main" = xyes ; then + AC_CHECK_HEADERS([pugixml.hpp]) + + if test x"$ac_cv_header_pugixml_hpp" = xyes; then + AC_CHECK_LIB([pugixml], [main]) + fi + + AC_LANG_POP + + if test x"$ac_cv_header_pugixml_hpp" = xyes -a x"$ac_cv_lib_pugixml_main" = xyes ; then + pugixml_found=yes + fi +fi + +if test $pugixml_found = yes; then AC_MSG_NOTICE([Using the system version of the pugixml library]) PUGIXML_INTERNAL=no else diff --git a/build-config.in b/build-config.in index 6e7a4c286..801968b1a 100644 --- a/build-config.in +++ b/build-config.in @@ -107,7 +107,9 @@ PO4A_TRANSLATE_FLAGS = @PO4A_TRANSLATE_FLAGS@ PO4A_WORKS = @PO4A_WORKS@ PROFILING_CFLAGS = @PROFILING_CFLAGS@ PROFILING_LIBS = @PROFILING_LIBS@ +PUGIXML_CFLAGS = @PUGIXML_CFLAGS@ PUGIXML_INTERNAL = @PUGIXML_INTERNAL@ +PUGIXML_LIBS = @PUGIXML_LIBS@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ QUNUSED_ARGUMENTS = @QUNUSED_ARGUMENTS@ diff --git a/rake.d/target.rb b/rake.d/target.rb index f672a6232..c65926527 100644 --- a/rake.d/target.rb +++ b/rake.d/target.rb @@ -131,6 +131,7 @@ class Target when :boost_regex then c(:BOOST_REGEX_LIB) when :boost_filesystem then c(:BOOST_FILESYSTEM_LIB) when :boost_system then c(:BOOST_SYSTEM_LIB) + when :pugixml then c(:PUGIXML_LIBS) when :qt then c(:QT_LIBS) when :static then c(:LINK_STATICALLY) when :mpegparser then [ '-Lsrc/mpegparser', '-lmpegparser' ]