Currently there are two problems with the detection of
source-highlight via pkg-config in GDB's configure script:
1. The LDFLAGS variable is used to pass the 'pkg-config --libs' output
to AC_LINK_IFELSE, which results in the "-L/some/path
-lsource-highlight" preceding the conftest.cpp, which can result in a
failure to find symbols referenced in conftest.cpp, if the linker is
using --as-needed by default.
2. The CFLAGS variable is used to pass the 'pkg-config --cflags'
output to AC_LINK_IFELSE. However, as the current language is C++,
AC_LINK_IFELSE will actuall use CXXFLAGS, not CFLAGS, so any flags
returned from pkg-config will not be seen.
This patch fixes both of these mistakes, allowing GDB to correctly
configure and build using source-highlight installed into a custom
prefix, e.g. ~/opt/gdb-git (because the system version of
source-highlight is too old).
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
- save_CFLAGS="$CFLAGS"
- save_LDFLAGS="$LDFLAGS"
- CFLAGS="$CFLAGS $srchigh_pkg_cflags"
- LDFLAGS="$LDFLAGS $srchigh_pkg_libs"
+ save_CXXFLAGS="$CXXFLAGS"
+ save_LIBS="$LIBS"
+ CXXFLAGS="$CXXFLAGS $srchigh_pkg_cflags"
+ LIBS="$LIBS $srchigh_pkg_libs"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <srchilite/sourcehighlight.h>
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- CFLAGS="$save_CFLAGS"
- LDFLAGS="$save_LDFLAGS"
+ CXXFLAGS="$save_CXXFLAGS"
+ LIBS="$save_LIBS"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
# This situation can occur for instance when using a source highlight
# library compiled with g++ 7.5.0 while building gdb with g++ 4.8.5.
AC_LANG_PUSH(C++)
- save_CFLAGS="$CFLAGS"
- save_LDFLAGS="$LDFLAGS"
- CFLAGS="$CFLAGS $srchigh_pkg_cflags"
- LDFLAGS="$LDFLAGS $srchigh_pkg_libs"
+ save_CXXFLAGS="$CXXFLAGS"
+ save_LIBS="$LIBS"
+ CXXFLAGS="$CXXFLAGS $srchigh_pkg_cflags"
+ LIBS="$LIBS $srchigh_pkg_libs"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include <srchilite/sourcehighlight.h>],
[have_usable_source_highlight=yes],
[have_usable_source_highlight=no]
)
- CFLAGS="$save_CFLAGS"
- LDFLAGS="$save_LDFLAGS"
+ CXXFLAGS="$save_CXXFLAGS"
+ LIBS="$save_LIBS"
AC_LANG_POP(C++)
if test "${have_usable_source_highlight}" = "yes"; then