File: gccxml_find_flags

package info (click to toggle)
gccxml 0.9.0%2Bcvs20080525-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 78,840 kB
  • ctags: 72,674
  • sloc: ansic: 749,255; cpp: 33,564; asm: 26,833; sh: 5,161; makefile: 4,695; lex: 589; awk: 566; perl: 334; yacc: 271; pascal: 86; python: 18
file content (93 lines) | stat: -rwxr-xr-x 2,888 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
#=============================================================================
#
#  Program:   GCC-XML
#  Module:    $RCSfile: gccxml_find_flags,v $
#  Language:  C++
#  Date:      $Date: 2007-11-28 19:52:06 $
#  Version:   $Revision: 1.3 $
#
#  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
#  See Copyright.txt for details.
#
#     This software is distributed WITHOUT ANY WARRANTY; without even 
#     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
#     PURPOSE.  See the above copyright notices for more information.
#
#=============================================================================

# Find the compiler executable name.
if test "x$1" = "x" ; then
  if test "x$GCCXML_COMPILER" = "x"; then
    if test "x${CXX}" != "x" ; then
      GCCXML_COMPILER="${CXX}"
    else
      echo "Need to specify compiler name or set GCCXML_COMPILER or CXX."
      exit 1
    fi
  fi
  if test "x$GCCXML_CXXFLAGS" = "x"; then
    if test "x${CXXFLAGS}" != "x" ; then
      GCCXML_CXXFLAGS="${CXXFLAGS}"
    fi
  fi
else 
  GCCXML_COMPILER="$1"
  shift
  GCCXML_CXXFLAGS="$@"
fi

# Use the compiler's preprocessor to identify the compiler.
GCCXML_PID="$$"
cat > "/tmp/gccxml_identify_compiler$GCCXML_PID.cc" <<!
#if defined(__GNUC__)
GCCXML_SUPPORT="GCC"
#elif defined(__sgi) && defined(_COMPILER_VERSION)
GCCXML_SUPPORT="MIPSpro"
#elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 700)
GCCXML_SUPPORT="Intel"
#elif defined(__SUNPRO_CC)
GCCXML_SUPPORT="Sun"
#else
GCCXML_SUPPORT=""
#endif
!

# Run the compiler's preprocessor on the above code to identify it.
# (workaround for CC whitespace:)
if (${GCCXML_COMPILER} ${GCCXML_CXXFLAGS} \
                         -E "/tmp/gccxml_identify_compiler$GCCXML_PID.cc" \
			 | sed -e 's/[ ^]//g' \
                          > "/tmp/gccxml_identify_compiler$GCCXML_PID.pp";
      rm -f "/tmp/gccxml_identify_compiler$GCCXML_PID.cc"
) ; then : ; else
  echo "Error running \"${GCCXML_COMPILER} -E\""
  exit 1
fi

# Source the result to get the settings found.
. "/tmp/gccxml_identify_compiler$GCCXML_PID.pp"
rm -f "/tmp/gccxml_identify_compiler$GCCXML_PID.pp"

# Check if a supported compiler was identified.
if test "x$GCCXML_SUPPORT" = "x" ; then
  echo "Compiler \"${GCCXML_COMPILER}\" is not supported by GCC-XML."
  exit 1
fi

# The support directories are located near this script.
SELFPATH=`cd "\`echo $0 | sed -n '/\//{s/\/[^\/]*$//;p;}'\`";pwd`

# Find the compiler-specific support directory.
if test -d "${SELFPATH}/${GCCXML_SUPPORT}" ; then
  GCCXML_SUPPORT_DIR="${SELFPATH}/${GCCXML_SUPPORT}"
else
  echo "Cannot find GCC_XML compiler support directory ${GCCXML_SUPPORT}."
  exit 1
fi

# Run the compiler-specific flag finding script.
GCCXML_FLAGS=`"${GCCXML_SUPPORT_DIR}/find_flags" ${GCCXML_COMPILER} ${GCCXML_CXXFLAGS}`

# Display the output.
echo ${GCCXML_FLAGS}