Emese Revfy | 6b90bd4 | 2016-05-24 00:09:38 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | srctree=$(dirname "$0") |
| 3 | gccplugins_dir=$($3 -print-file-name=plugin) |
| 4 | plugincc=$($1 -E -x c++ - -o /dev/null -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <<EOF |
| 5 | #include "gcc-common.h" |
| 6 | #if BUILDING_GCC_VERSION >= 4008 || defined(ENABLE_BUILD_WITH_CXX) |
| 7 | #warning $2 CXX |
| 8 | #else |
| 9 | #warning $1 CC |
| 10 | #endif |
| 11 | EOF |
| 12 | ) |
| 13 | |
| 14 | if [ $? -ne 0 ] |
| 15 | then |
| 16 | exit 1 |
| 17 | fi |
| 18 | |
| 19 | case "$plugincc" in |
| 20 | *"$1 CC"*) |
| 21 | echo "$1" |
| 22 | exit 0 |
| 23 | ;; |
| 24 | |
| 25 | *"$2 CXX"*) |
| 26 | # the c++ compiler needs another test, see below |
| 27 | ;; |
| 28 | |
| 29 | *) |
| 30 | exit 1 |
| 31 | ;; |
| 32 | esac |
| 33 | |
| 34 | # we need a c++ compiler that supports the designated initializer GNU extension |
| 35 | plugincc=$($2 -c -x c++ -std=gnu++98 - -fsyntax-only -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <<EOF |
| 36 | #include "gcc-common.h" |
| 37 | class test { |
| 38 | public: |
| 39 | int test; |
| 40 | } test = { |
| 41 | .test = 1 |
| 42 | }; |
| 43 | EOF |
| 44 | ) |
| 45 | |
| 46 | if [ $? -eq 0 ] |
| 47 | then |
| 48 | echo "$2" |
| 49 | exit 0 |
| 50 | fi |
| 51 | exit 1 |