aboutsummaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-03-19 15:02:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-03-19 15:02:31 +0200
commita2dee162af41c80827ff60d87c08ea981b55b31b (patch)
treec76f73c8b6652c5de54e36c3256570f408dd053b /m4
parent29020cbfef6e3f797f7f76564d0f9b2663263f7b (diff)
Add support for installing plugin into default GCC plugin directory
Diffstat (limited to 'm4')
-rw-r--r--m4/gcc-plugin.m4125
1 files changed, 113 insertions, 12 deletions
diff --git a/m4/gcc-plugin.m4 b/m4/gcc-plugin.m4
index 27453a2..27ce15d 100644
--- a/m4/gcc-plugin.m4
+++ b/m4/gcc-plugin.m4
@@ -5,23 +5,124 @@ dnl
dnl GCC_PLUGIN
dnl
AC_DEFUN([GCC_PLUGIN], [
-gcc_plugin_support=no
+static_plugin=$enable_static
-if test x"$GXX" != xyes; then
- AC_MSG_ERROR([$CXX is not a GNU C++ compiler])
+AC_ARG_WITH(
+ [gcc-plugin-dir],
+ [AC_HELP_STRING([--with-gcc-plugin-dir=DIR], [install ODB plugin into the GCC plugin directory])],
+ [gcc_plugin_dir=$withval],
+ [gcc_plugin_dir=test])
+
+if test x"$static_plugin" = xyes; then
+ gcc_plugin_dir=no
+else
+ if test x"$cross_compiling" = xyes; then
+ AC_MSG_CHECKING([whether to install into default GCC plugin dir])
+ case $gcc_plugin_dir in
+ yes)
+ AC_MSG_ERROR([GCC plugin directory must be specified explicitly when cross-compiling])
+ ;;
+ test)
+ # We cannot detect the plugin directory since there is no way to
+ # run host GCC. So assume no.
+ #
+ gcc_plugin_dir=no
+ ;;
+ no)
+ ;;
+ *)
+ # Add the include/ subdirectory of the plugin dir to CPPFLAGS since
+ # the plugin headers are normally installed there.
+ #
+ CPPFLAGS="$CPPFLAGS -I$gcc_plugin_dir/include"
+ ;;
+ esac
+ else
+ if test x"$GXX" != xyes; then
+ AC_MSG_ERROR([$CXX is not a GNU C++ compiler])
+ fi
+
+ AC_MSG_CHECKING([whether $CXX supports plugins])
+ dir=`$CXX -print-file-name=plugin 2>/dev/null`
+
+ if test x"$dir" = xplugin; then
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([$CXX does not support plugins; reconfigure GCC with --enable-plugin])
+ else
+ AC_MSG_RESULT([yes])
+ fi
+
+ CPPFLAGS="$CPPFLAGS -I$dir/include"
+
+ AC_MSG_CHECKING([whether to install ODB plugin into default GCC plugin directory])
+ case $gcc_plugin_dir in
+ yes)
+ gcc_plugin_dir=$dir
+ ;;
+ test)
+ # Only install into the GCC plugin dir if both GCC and ODB are
+ # installed into the same prefix. Testing whether $libdir or
+ # $libexecdir is a prefix of the GCC plugin dir is a good
+ # approximation.
+ #
+
+ # Get the expanded values for libdir and libexecdir.
+ #
+ if test x$exec_prefix = xNONE; then
+ if test x$prefix = xNONE; then
+ e_exec_prefix=$ac_default_prefix
+ else
+ e_exec_prefix=$prefix
+ fi
+ else
+ e_exec_prefix=$exec_prefix
+ fi
+
+ e_libdir=`echo "$libdir" | sed "s?^\\\${exec_prefix}?$e_exec_prefix?"`
+ e_libexecdir=`echo "$libexecdir" | sed "s?^\\\${exec_prefix}?$e_exec_prefix?"`
+
+ # See if either one of them is a prefix of the plugin dir.
+ #
+ ld_suffix=`echo "$dir" | sed "s?^$e_libdir/*??"`
+ led_suffix=`echo "$dir" | sed "s?^$e_libexecdir/*??"`
+
+ if test x$ld_suffix != x$dir -o x$led_suffix != x$dir; then
+ gcc_plugin_dir=$dir
+ else
+ gcc_plugin_dir=no
+ fi
+ ;;
+ *)
+ ;;
+ esac
+ fi
+
+ if test x"$gcc_plugin_dir" != xno; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
fi
-AC_MSG_CHECKING([whether $CXX supports plugins])
+AC_MSG_CHECKING([for GCC plugin headers])
-gcc_plugin_base=`$CXX -print-file-name=plugin 2>/dev/null`
+CXX_LIBTOOL_LINK_IFELSE([
+AC_LANG_SOURCE([
+#include <bversion.h>
-if test x"$gcc_plugin_base" = xplugin; then
- AC_MSG_RESULT([no])
- AC_MSG_ERROR([$CXX does not support plugins; reconfigure GCC with --enable-plugin or install plugin headers])
-else
+#ifndef BUILDING_GCC_MAJOR
+# error no BUILDING_GCC_MAJOR in bversion.h
+#endif
+
+int main () {}
+])],
+[gcc_plugin_headers=yes],
+[gcc_plugin_headers=no])
+
+if test x"$gcc_plugin_headers" = xyes; then
AC_MSG_RESULT([yes])
- gcc_plugin_support=yes
+else
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([GCC plugin headers not found; consider installing GCC plugin development package])
fi
-
-CPPFLAGS="$CPPFLAGS -I$gcc_plugin_base/include"
])dnl