Back to home page

LXR

 
 

    


0001 #!/bin/sh
0002 srctree=$(dirname "$0")
0003 
0004 SHOW_ERROR=
0005 if [ "$1" = "--show-error" ] ; then
0006         SHOW_ERROR=1
0007         shift || true
0008 fi
0009 
0010 gccplugins_dir=$($3 -print-file-name=plugin)
0011 plugincc=$($1 -E -x c++ - -o /dev/null -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <<EOF
0012 #include "gcc-common.h"
0013 #if BUILDING_GCC_VERSION >= 4008 || defined(ENABLE_BUILD_WITH_CXX)
0014 #warning $2 CXX
0015 #else
0016 #warning $1 CC
0017 #endif
0018 EOF
0019 )
0020 
0021 if [ $? -ne 0 ]
0022 then
0023         if [ -n "$SHOW_ERROR" ] ; then
0024                 echo "${plugincc}" >&2
0025         fi
0026         exit 1
0027 fi
0028 
0029 case "$plugincc" in
0030         *"$1 CC"*)
0031                 echo "$1"
0032                 exit 0
0033                 ;;
0034 
0035         *"$2 CXX"*)
0036                 # the c++ compiler needs another test, see below
0037                 ;;
0038 
0039         *)
0040                 exit 1
0041                 ;;
0042 esac
0043 
0044 # we need a c++ compiler that supports the designated initializer GNU extension
0045 plugincc=$($2 -c -x c++ -std=gnu++98 - -fsyntax-only -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <<EOF
0046 #include "gcc-common.h"
0047 class test {
0048 public:
0049         int test;
0050 } test = {
0051         .test = 1
0052 };
0053 EOF
0054 )
0055 
0056 if [ $? -eq 0 ]
0057 then
0058         echo "$2"
0059         exit 0
0060 fi
0061 
0062 if [ -n "$SHOW_ERROR" ] ; then
0063         echo "${plugincc}" >&2
0064 fi
0065 exit 1