File: 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 (105 lines) | stat: -rwxr-xr-x 3,664 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
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
#=============================================================================
#
#  Program:   GCC-XML
#  Module:    $RCSfile: find_flags,v $
#  Language:  C++
#  Date:      $Date: 2008-03-19 21:14:33 $
#  Version:   $Revision: 1.21 $
#
#  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 GCC executable name.
if test "x$1" = "x" ; then
  if test "x${CXX}" = "x" ; then
    CXX=gcc
  fi
else 
  CXX="$1"
  shift
  CXXFLAGS="$@"
fi

# Find the macro definition options.
MACROS=`echo "" | ${CXX} -x c++ -E -dM ${CXXFLAGS} - 2>/dev/null |
  sed -n '
/^#define / {s/#define \([A-Za-z_][A-Za-z0-9_()]*\) \(.*\)/-D\1='\''\2'\''/;p;}
' |
  awk '
BEGIN { first=1 }
/./ { if(first) { printf("%s", $0); first=0 } else { printf(" %s", $0) } }
'`

# Find the include path options.
INCLUDES=`
  echo "" | ${CXX} -v -x c++ -E ${CXXFLAGS} - 2>&1 |
  awk '/^[^ \/].*$/ { if (f) { printf("\n"); exit } }
       /^[ ]*\/[^ ]*$/ { if (f) { printf("-I%s ",$0) } }
       /\#include <\.\.\..*$/   {f=1} ' - |
  sed 's/^-I /-I/;s/ -I / -I/g'
`

# The support headers are located where this script is.
SELFPATH=`echo $0 | sed -n '/\//{s/\/find_flags//;p;}'`
if test "x$SELFPATH" = "x" ; then SELFPATH="." ; fi
SELFPATH=`cd "$SELFPATH" ; pwd`

# Determine the major version number.
MAJOR_VERSION=`
echo "__GNUC__" | ${CXX} -v -x c++ -E ${CXXFLAGS} - 2>/dev/null |
  sed -n '/^[0-9]/{s/[^0-9]//g;p;}'`

MINOR_VERSION=`
echo "__GNUC_MINOR__" | ${CXX} -v -x c++ -E ${CXXFLAGS} - 2>/dev/null |
  sed -n '/^[0-9]/{s/[^0-9]//g;p;}'`

# hack to handle bad gcc 4.0 on RedHat
if [ "$MAJOR_VERSION" = 4 ]; then
  if echo "$INCLUDES" | grep "c++/3\.4" > /dev/null 2>&1; then
    MAJOR_VERSION=3
    MINOR_VERSION=4
  fi
fi

# For GCC versions before 3, some special options are needed.
if [ "$MAJOR_VERSION" -lt 3 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/2.95\" $INCLUDES"
  if [ "$MINOR_VERSION" = 96 ]; then
    INCLUDES="-iwrapper\"$SELFPATH/2.96\" $INCLUDES"
  fi
elif [ "$MAJOR_VERSION" = 4 -a "$MINOR_VERSION" -ge 3 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/4.3\" $INCLUDES"
  SPECIAL="-include \"gccxml_builtins.h\""
elif [ "$MAJOR_VERSION" = 4 -a "$MINOR_VERSION" -ge 2 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/4.2\" $INCLUDES"
  SPECIAL="-include \"gccxml_builtins.h\""
elif [ "$MAJOR_VERSION" = 4 -a "$MINOR_VERSION" -ge 1 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/4.1\" $INCLUDES"
  SPECIAL="-include \"gccxml_builtins.h\""
elif [ "$MAJOR_VERSION" = 4 -a "$MINOR_VERSION" -ge 0 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/4.0\" $INCLUDES"
  SPECIAL="-include \"gccxml_builtins.h\""
elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" -ge 4 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/3.4\" $INCLUDES"
  SPECIAL="-include \"gccxml_builtins.h\""
elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" = 3 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/3.3\" $INCLUDES"
  SPECIAL="-include \"gccxml_builtins.h\""
elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" = 2 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/3.2\" $INCLUDES"
elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" = 1 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/3.1\" $INCLUDES"
elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" = 0 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/3.0\" $INCLUDES"
fi

# Format and print out the options.
OPTIONS="$MACROS $INCLUDES $SPECIAL"
echo $OPTIONS