File: find_flags

package info (click to toggle)
gccxml 0.7.0%2Bcvs20060311-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 45,240 kB
  • ctags: 59,007
  • sloc: ansic: 589,435; asm: 19,610; cpp: 12,681; sh: 4,326; yacc: 3,727; makefile: 3,074; perl: 318; lex: 307; awk: 117; pascal: 78; sed: 20
file content (96 lines) | stat: -rwxr-xr-x 3,238 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
#!/bin/sh
#=============================================================================
#
#  Program:   GCC-XML
#  Module:    $RCSfile: find_flags,v $
#  Language:  C++
#  Date:      $Date: 2005/09/21 18:02:10 $
#  Version:   $Revision: 1.17 $
#
#  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 0 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/4.0\" $INCLUDES"
  SPECIAL="-include \"$SELFPATH/4.0/gccxml_builtins.h\""
elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" -ge 4 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/3.4\" $INCLUDES"
  SPECIAL="-include \"$SELFPATH/3.4/gccxml_builtins.h\""
elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" = 3 ]; then
  INCLUDES="-iwrapper\"$SELFPATH/3.3\" $INCLUDES"
  SPECIAL="-include \"$SELFPATH/3.3/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