1From 38c361e6860bfaefbefeccae621e698c301879f2 Mon Sep 17 00:00:00 2001 2From: Ross Burton <ross.burton@intel.com> 3Date: Tue, 23 Jan 2018 00:54:13 +0000 4Subject: [PATCH] gettext: beat library detection into shape 5 6For reasons which I just can't fathom gnulib doesn't use the expected tools to 7find libraries but badly reinvents the wheel. This will trivially lead to host 8contamination (explicit searches of /usr/lib) or incorrect RPATHs (bad 9canonicalisation resulting in relative paths). 10 11Simply delete all the crazy, and replace with a single call to pkg-config. 12 13Upstream-Status: Inappropriate [upstream still refuse to consider pkg-config] 14Signed-off-by: Ross Burton <ross.burton@intel.com> 15 16--- 17 gettext-tools/gnulib-m4/libxml.m4 | 105 +---------------- 18 libtextstyle/gnulib-local/m4/libglib.m4 | 106 +++--------------- 19 libtextstyle/gnulib-m4/libglib.m4 | 106 +++--------------- 20 3 files changed, 79 insertions(+), 470 deletions(-) 21 22diff --git a/gettext-tools/gnulib-m4/libxml.m4 b/gettext-tools/gnulib-m4/libxml.m4 23index 0340490..0355388 100644 24--- a/gettext-tools/gnulib-m4/libxml.m4 25+++ b/gettext-tools/gnulib-m4/libxml.m4 26@@ -13,6 +13,7 @@ dnl gl_LIBXML(FORCE-INCLUDED) 27 dnl forces the use of the included or an external libxml. 28 AC_DEFUN([gl_LIBXML], 29 [ 30+ AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 31 AC_REQUIRE([AM_ICONV_LINK]) 32 33 ifelse([$1], , [ 34@@ -30,106 +31,10 @@ AC_DEFUN([gl_LIBXML], 35 INCXML= 36 ifelse([$1], [yes], , [ 37 if test "$gl_cv_libxml_use_included" != yes; then 38- dnl Figure out whether we can use a preinstalled libxml2, or have to use 39- dnl the included one. 40- AC_CACHE_VAL([gl_cv_libxml], [ 41- gl_cv_libxml=no 42- gl_cv_LIBXML= 43- gl_cv_LTLIBXML= 44- gl_cv_INCXML= 45- gl_save_LIBS="$LIBS" 46- LIBS="$LIBS $LIBICONV" 47- dnl Search for libxml2 and define LIBXML2, LTLIBXML2 and INCXML2 48- dnl accordingly. 49- dnl Don't use xml2-config nor pkg-config, since it doesn't work when 50- dnl cross-compiling or when the C compiler in use is different from the 51- dnl one that built the library. 52- dnl Use a test program that tries to invoke xmlFree. On Cygwin 1.7.x, 53- dnl libxml2 is built in such a way that uses of xmlFree work fine with 54- dnl -Wl,--enable-auto-import but lead to a link error with 55- dnl -Wl,--disable-auto-import. 56- AC_LIB_LINKFLAGS_BODY([xml2]) 57- LIBS="$gl_save_LIBS $LIBXML2 $LIBICONV" 58- AC_LINK_IFELSE( 59- [AC_LANG_PROGRAM( 60- [[#include <libxml/xmlversion.h> 61- #include <libxml/xmlmemory.h> 62- #include <libxml/xpath.h> 63- ]], 64- [[xmlCheckVersion (0); 65- xmlFree ((void *) 0); 66- xmlXPathSetContextNode ((void *)0, (void *)0); 67- ]])], 68- [gl_cv_libxml=yes 69- gl_cv_LIBXML="$LIBXML2 $LIBICONV" 70- gl_cv_LTLIBXML="$LTLIBXML2 $LTLIBICONV" 71- ]) 72- if test "$gl_cv_libxml" != yes; then 73- gl_save_CPPFLAGS="$CPPFLAGS" 74- CPPFLAGS="$CPPFLAGS $INCXML2" 75- AC_LINK_IFELSE( 76- [AC_LANG_PROGRAM( 77- [[#include <libxml/xmlversion.h> 78- #include <libxml/xmlmemory.h> 79- #include <libxml/xpath.h> 80- ]], 81- [[xmlCheckVersion (0); 82- xmlFree ((void *) 0); 83- xmlXPathSetContextNode ((void *)0, (void *)0); 84- ]])], 85- [gl_cv_libxml=yes 86- gl_cv_LIBXML="$LIBXML2 $LIBICONV" 87- gl_cv_LTLIBXML="$LTLIBXML2 $LTLIBICONV" 88- gl_cv_INCXML="$INCXML2" 89- ]) 90- if test "$gl_cv_libxml" != yes; then 91- dnl Often the include files are installed in /usr/include/libxml2. 92- dnl In libxml2-2.5, <libxml/xmlversion.h> is self-contained. 93- dnl In libxml2-2.6, it includes <libxml/xmlexports.h> which is 94- dnl self-contained. 95- libxml2_include_dir= 96- AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <libxml2/libxml/xmlexports.h>]])], 97- [gl_ABSOLUTE_HEADER([libxml2/libxml/xmlexports.h]) 98- libxml2_include_dir=`echo "$gl_cv_absolute_libxml2_libxml_xmlexports_h" | sed -e 's,.libxml.xmlexports\.h$,,'` 99- ]) 100- if test -z "$libxml2_include_dir"; then 101- AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <libxml2/libxml/xmlversion.h>]])], 102- [gl_ABSOLUTE_HEADER([libxml2/libxml/xmlversion.h]) 103- libxml2_include_dir=`echo "$gl_cv_absolute_libxml2_libxml_xmlversion_h" | sed -e 's,.libxml.xmlversion\.h$,,'` 104- ]) 105- fi 106- if test -n "$libxml2_include_dir" && test -d "$libxml2_include_dir"; then 107- CPPFLAGS="$gl_save_CPPFLAGS -I$libxml2_include_dir" 108- AC_LINK_IFELSE( 109- [AC_LANG_PROGRAM( 110- [[#include <libxml/xmlversion.h> 111- #include <libxml/xmlmemory.h> 112- #include <libxml/xpath.h> 113- ]], 114- [[xmlCheckVersion (0); 115- xmlFree ((void *) 0); 116- xmlXPathSetContextNode ((void *)0, (void *)0); 117- ]])], 118- [gl_cv_libxml=yes 119- gl_cv_LIBXML="$LIBXML2 $LIBICONV" 120- gl_cv_LTLIBXML="$LTLIBXML2 $LTLIBICONV" 121- gl_cv_INCXML="-I$libxml2_include_dir" 122- ]) 123- fi 124- fi 125- CPPFLAGS="$gl_save_CPPFLAGS" 126- fi 127- LIBS="$gl_save_LIBS" 128- ]) 129- AC_MSG_CHECKING([for libxml]) 130- AC_MSG_RESULT([$gl_cv_libxml]) 131- if test $gl_cv_libxml = yes; then 132- LIBXML="$gl_cv_LIBXML" 133- LTLIBXML="$gl_cv_LTLIBXML" 134- INCXML="$gl_cv_INCXML" 135- else 136- gl_cv_libxml_use_included=yes 137- fi 138+ PKG_CHECK_MODULES([XML], [libxml-2.0]) 139+ LIBXML=$XML_LIBS 140+ LTLIBXML=$XML_LIBS 141+ INCXML=$XML_CFLAGS 142 fi 143 ]) 144 AC_SUBST([LIBXML]) 145diff --git a/libtextstyle/gnulib-local/m4/libglib.m4 b/libtextstyle/gnulib-local/m4/libglib.m4 146index 7ee5029..bb1e5e4 100644 147--- a/libtextstyle/gnulib-local/m4/libglib.m4 148+++ b/libtextstyle/gnulib-local/m4/libglib.m4 149@@ -6,106 +6,26 @@ dnl with or without modifications, as long as this notice is preserved. 150 151 dnl From Bruno Haible. 152 153-dnl gl_LIBGLIB 154-dnl gives the user the option to decide whether to use the included or 155-dnl an external libglib. 156-dnl gl_LIBGLIB(FORCE-INCLUDED) 157-dnl forces the use of the included or an external libglib. 158 AC_DEFUN([gl_LIBGLIB], 159 [ 160- ifelse([$1], , [ 161- AC_MSG_CHECKING([whether included glib is requested]) 162- AC_ARG_WITH([included-glib], 163- [ --with-included-glib use the glib2 included here], 164- [gl_cv_libglib_force_included=$withval], 165- [gl_cv_libglib_force_included=no]) 166- AC_MSG_RESULT([$gl_cv_libglib_force_included]) 167- ], [gl_cv_libglib_force_included=$1]) 168+ AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 169+ AC_MSG_CHECKING([whether included glib is requested]) 170+ AC_ARG_WITH([included-glib], 171+ [ --with-included-glib use the glib2 included here], 172+ [gl_cv_libglib_force_included=$withval], 173+ [gl_cv_libglib_force_included=no]) 174+ AC_MSG_RESULT([$gl_cv_libglib_force_included]) 175 176 gl_cv_libglib_use_included="$gl_cv_libglib_force_included" 177 LIBGLIB= 178 LTLIBGLIB= 179 INCGLIB= 180- ifelse([$1], [yes], , [ 181- if test "$gl_cv_libglib_use_included" != yes; then 182- dnl Figure out whether we can use a preinstalled libglib-2.0, or have to use 183- dnl the included one. 184- AC_CACHE_VAL([gl_cv_libglib], [ 185- gl_cv_libglib=no 186- gl_cv_LIBGLIB= 187- gl_cv_LTLIBGLIB= 188- gl_cv_INCGLIB= 189- gl_save_LIBS="$LIBS" 190- dnl Search for libglib2 and define LIBGLIB_2_0, LTLIBGLIB_2_0 and 191- dnl INCGLIB_2_0 accordingly. 192- dnl Don't use glib-config nor pkg-config, since it doesn't work when 193- dnl cross-compiling or when the C compiler in use is different from the 194- dnl one that built the library. 195- AC_LIB_LINKFLAGS_BODY([glib-2.0]) 196- LIBS="$gl_save_LIBS $LIBGLIB_2_0" 197- AC_LINK_IFELSE( 198- [AC_LANG_PROGRAM( 199- [[#include <glib.h> 200- #ifndef G_BEGIN_DECLS 201- error this glib.h includes a glibconfig.h from a glib version 1.x 202- #endif 203- ]], 204- [[g_string_new ("foo");]])], 205- [gl_cv_libglib=yes 206- gl_cv_LIBGLIB="$LIBGLIB_2_0" 207- gl_cv_LTLIBGLIB="$LTLIBGLIB_2_0" 208- ]) 209- if test "$gl_cv_libglib" != yes; then 210- gl_save_CPPFLAGS="$CPPFLAGS" 211- CPPFLAGS="$CPPFLAGS $INCGLIB_2_0" 212- AC_LINK_IFELSE( 213- [AC_LANG_PROGRAM( 214- [[#include <glib.h> 215- #ifndef G_BEGIN_DECLS 216- error this glib.h includes a glibconfig.h from a glib version 1.x 217- #endif 218- ]], 219- [[g_string_new ("foo");]])], 220- [gl_cv_libglib=yes 221- gl_cv_LIBGLIB="$LIBGLIB_2_0" 222- gl_cv_LTLIBGLIB="$LTLIBGLIB_2_0" 223- gl_cv_INCGLIB="$INCGLIB_2_0" 224- ]) 225- if test "$gl_cv_libglib" != yes; then 226- dnl Often the include files are installed in /usr/include/glib-2.0 227- dnl and /usr/lib/glib-2.0/include. 228- if test -n "$LIBGLIB_2_0_PREFIX"; then 229- CPPFLAGS="$gl_save_CPPFLAGS -I$LIBGLIB_2_0_PREFIX/include/glib-2.0 -I$LIBGLIB_2_0_PREFIX/$acl_libdirstem/glib-2.0/include" 230- AC_LINK_IFELSE( 231- [AC_LANG_PROGRAM( 232- [[#include <glib.h> 233- #ifndef G_BEGIN_DECLS 234- error this glib.h includes a glibconfig.h from a glib version 1.x 235- #endif 236- ]], 237- [[g_string_new ("foo");]])], 238- [gl_cv_libglib=yes 239- gl_cv_LIBGLIB="$LIBGLIB_2_0" 240- gl_cv_LTLIBGLIB="$LTLIBGLIB_2_0" 241- gl_cv_INCGLIB="-I$LIBGLIB_2_0_PREFIX/include/glib-2.0 -I$LIBGLIB_2_0_PREFIX/$acl_libdirstem/glib-2.0/include" 242- ]) 243- fi 244- fi 245- CPPFLAGS="$gl_save_CPPFLAGS" 246- fi 247- LIBS="$gl_save_LIBS" 248- ]) 249- AC_MSG_CHECKING([for glib]) 250- AC_MSG_RESULT([$gl_cv_libglib]) 251- if test $gl_cv_libglib = yes; then 252- LIBGLIB="$gl_cv_LIBGLIB" 253- LTLIBGLIB="$gl_cv_LTLIBGLIB" 254- INCGLIB="$gl_cv_INCGLIB" 255- else 256- gl_cv_libglib_use_included=yes 257- fi 258- fi 259- ]) 260+ if test "$gl_cv_libglib_use_included" != yes; then 261+ PKG_CHECK_MODULES([GLIB], [glib-2.0]) 262+ LIBGLIB="$GLIB_LIBS" 263+ LTLIBGLIB="$GLIB_LIBS" 264+ INCGLIB="$GLIB_CFLAGS" 265+ fi 266 AC_SUBST([LIBGLIB]) 267 AC_SUBST([LTLIBGLIB]) 268 AC_SUBST([INCGLIB]) 269diff --git a/libtextstyle/gnulib-m4/libglib.m4 b/libtextstyle/gnulib-m4/libglib.m4 270index 7ee5029..bb1e5e4 100644 271--- a/libtextstyle/gnulib-m4/libglib.m4 272+++ b/libtextstyle/gnulib-m4/libglib.m4 273@@ -6,106 +6,26 @@ dnl with or without modifications, as long as this notice is preserved. 274 275 dnl From Bruno Haible. 276 277-dnl gl_LIBGLIB 278-dnl gives the user the option to decide whether to use the included or 279-dnl an external libglib. 280-dnl gl_LIBGLIB(FORCE-INCLUDED) 281-dnl forces the use of the included or an external libglib. 282 AC_DEFUN([gl_LIBGLIB], 283 [ 284- ifelse([$1], , [ 285- AC_MSG_CHECKING([whether included glib is requested]) 286- AC_ARG_WITH([included-glib], 287- [ --with-included-glib use the glib2 included here], 288- [gl_cv_libglib_force_included=$withval], 289- [gl_cv_libglib_force_included=no]) 290- AC_MSG_RESULT([$gl_cv_libglib_force_included]) 291- ], [gl_cv_libglib_force_included=$1]) 292+ AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 293+ AC_MSG_CHECKING([whether included glib is requested]) 294+ AC_ARG_WITH([included-glib], 295+ [ --with-included-glib use the glib2 included here], 296+ [gl_cv_libglib_force_included=$withval], 297+ [gl_cv_libglib_force_included=no]) 298+ AC_MSG_RESULT([$gl_cv_libglib_force_included]) 299 300 gl_cv_libglib_use_included="$gl_cv_libglib_force_included" 301 LIBGLIB= 302 LTLIBGLIB= 303 INCGLIB= 304- ifelse([$1], [yes], , [ 305- if test "$gl_cv_libglib_use_included" != yes; then 306- dnl Figure out whether we can use a preinstalled libglib-2.0, or have to use 307- dnl the included one. 308- AC_CACHE_VAL([gl_cv_libglib], [ 309- gl_cv_libglib=no 310- gl_cv_LIBGLIB= 311- gl_cv_LTLIBGLIB= 312- gl_cv_INCGLIB= 313- gl_save_LIBS="$LIBS" 314- dnl Search for libglib2 and define LIBGLIB_2_0, LTLIBGLIB_2_0 and 315- dnl INCGLIB_2_0 accordingly. 316- dnl Don't use glib-config nor pkg-config, since it doesn't work when 317- dnl cross-compiling or when the C compiler in use is different from the 318- dnl one that built the library. 319- AC_LIB_LINKFLAGS_BODY([glib-2.0]) 320- LIBS="$gl_save_LIBS $LIBGLIB_2_0" 321- AC_LINK_IFELSE( 322- [AC_LANG_PROGRAM( 323- [[#include <glib.h> 324- #ifndef G_BEGIN_DECLS 325- error this glib.h includes a glibconfig.h from a glib version 1.x 326- #endif 327- ]], 328- [[g_string_new ("foo");]])], 329- [gl_cv_libglib=yes 330- gl_cv_LIBGLIB="$LIBGLIB_2_0" 331- gl_cv_LTLIBGLIB="$LTLIBGLIB_2_0" 332- ]) 333- if test "$gl_cv_libglib" != yes; then 334- gl_save_CPPFLAGS="$CPPFLAGS" 335- CPPFLAGS="$CPPFLAGS $INCGLIB_2_0" 336- AC_LINK_IFELSE( 337- [AC_LANG_PROGRAM( 338- [[#include <glib.h> 339- #ifndef G_BEGIN_DECLS 340- error this glib.h includes a glibconfig.h from a glib version 1.x 341- #endif 342- ]], 343- [[g_string_new ("foo");]])], 344- [gl_cv_libglib=yes 345- gl_cv_LIBGLIB="$LIBGLIB_2_0" 346- gl_cv_LTLIBGLIB="$LTLIBGLIB_2_0" 347- gl_cv_INCGLIB="$INCGLIB_2_0" 348- ]) 349- if test "$gl_cv_libglib" != yes; then 350- dnl Often the include files are installed in /usr/include/glib-2.0 351- dnl and /usr/lib/glib-2.0/include. 352- if test -n "$LIBGLIB_2_0_PREFIX"; then 353- CPPFLAGS="$gl_save_CPPFLAGS -I$LIBGLIB_2_0_PREFIX/include/glib-2.0 -I$LIBGLIB_2_0_PREFIX/$acl_libdirstem/glib-2.0/include" 354- AC_LINK_IFELSE( 355- [AC_LANG_PROGRAM( 356- [[#include <glib.h> 357- #ifndef G_BEGIN_DECLS 358- error this glib.h includes a glibconfig.h from a glib version 1.x 359- #endif 360- ]], 361- [[g_string_new ("foo");]])], 362- [gl_cv_libglib=yes 363- gl_cv_LIBGLIB="$LIBGLIB_2_0" 364- gl_cv_LTLIBGLIB="$LTLIBGLIB_2_0" 365- gl_cv_INCGLIB="-I$LIBGLIB_2_0_PREFIX/include/glib-2.0 -I$LIBGLIB_2_0_PREFIX/$acl_libdirstem/glib-2.0/include" 366- ]) 367- fi 368- fi 369- CPPFLAGS="$gl_save_CPPFLAGS" 370- fi 371- LIBS="$gl_save_LIBS" 372- ]) 373- AC_MSG_CHECKING([for glib]) 374- AC_MSG_RESULT([$gl_cv_libglib]) 375- if test $gl_cv_libglib = yes; then 376- LIBGLIB="$gl_cv_LIBGLIB" 377- LTLIBGLIB="$gl_cv_LTLIBGLIB" 378- INCGLIB="$gl_cv_INCGLIB" 379- else 380- gl_cv_libglib_use_included=yes 381- fi 382- fi 383- ]) 384+ if test "$gl_cv_libglib_use_included" != yes; then 385+ PKG_CHECK_MODULES([GLIB], [glib-2.0]) 386+ LIBGLIB="$GLIB_LIBS" 387+ LTLIBGLIB="$GLIB_LIBS" 388+ INCGLIB="$GLIB_CFLAGS" 389+ fi 390 AC_SUBST([LIBGLIB]) 391 AC_SUBST([LTLIBGLIB]) 392 AC_SUBST([INCGLIB]) 393