OSDN Git Service

c0ae1e5f22f07169e39ddae3db5b9bd19f581e5b
[pf3gnuchains/gcc-fork.git] / gcc / fixinc / genfixes
1 #! /bin/sh
2
3 # Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
4 # This file is part of GNU CC.
5
6 # GNU CC is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
10
11 # GNU CC is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with GNU CC; see the file COPYING.  If not, write to
18 # the Free Software Foundation, 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
20
21 SHELL=/bin/sh
22 export SHELL
23 if [ $# -eq 0 ] ; then
24   not_done=false
25 else
26   not_done=true
27 fi
28
29 while $not_done
30 do
31   case "$1" in
32   -D )
33     shift
34     if [ $# -eq 0 ] ; then
35       not_done=false
36     else
37       AG="$AG -D$1"
38       shift
39     fi
40     ;;
41
42   -D* )
43     AG="$AG $1"
44     shift
45     ;;
46
47   '-?' )
48     echo "USAGE: gendefs [ -D<def-name> ... ] [ <output-name> ]"
49     echo "WHERE: '<def-name>' specifies a #define test name from inclhack.def"
50     echo "  and  '<output-name>' is one of:"
51     echo "       fixincl.x machine.h"
52     echo "The default is to produce the first three outputs."
53     exit 0
54     ;;
55
56   * )
57     not_done=false
58     ;;
59   esac
60 done
61
62 if [ $# -eq 0 ] ; then
63   set -- fixincl.x
64 fi
65
66 AG="autogen $AG"
67 set -e
68
69 case "$1" in
70 fixincl.x | */fixincl.x )
71   if (${AG} --help > /dev/null 2>&1)
72   then
73     echo AutoGen-ing fixincl.x
74     $AG inclhack.def
75   else
76     echo "AutoGen does not appear to be correctly installed."
77     echo "Please download and install:"
78     echo "   ftp://gcc.gnu.org/pub/gcc/infrastructure/autogen.tar.gz"
79     touch fixincl.x
80   fi
81   ;;
82
83 machname.h | */machname.h )
84   # This script extracts from the specs file all the predefined macros
85   # that are not in the C89 reserved namespace (the reserved namespace
86   # is all identifiers beginnning with two underscores or one underscore
87   # followed by a capital letter).  The specs file is on standard input.
88   # A #define for a regular expression to find any of those macros in a
89   # header file is written to standard output.
90
91   # Note dependency on ASCII. \040 = space, \011 = tab, \012 = newline.
92   # tr ' ' '\n' is, alas, not portable.
93
94   tr -s '\040\011' '\012\012' < ../specs |
95     sed -n 's/^.*-D\([a-zA-Z_][a-zA-Z0-9_]*\).*$/\1/p' |
96     sort -u > mn.T
97
98   if grep -v '^_[_A-Z]' mn.T > mn.U
99   then
100     echo "Forbidden identifiers: `tr '\012' ' ' <mn.U`" >&2
101     sed 's/^/\\\\</; s/$/\\\\>/' <mn.U | tr '\012' '|' > mn.V
102     echo '' >>mn.V
103     sed 's/^/#define MN_NAME_PAT "/; s/|$/"/' < mn.V > machname.T
104   else
105     echo "No forbidden identifiers defined by this target" >&2
106     echo '#undef MN_NAME_PAT' > machname.T
107   fi
108   rm -f mn.[TUV]
109   mv -f machname.T machname.h
110   ;;
111
112 * )
113   echo genfixes cannot create $1
114   exit 1
115   ;;
116 esac
117
118 exit 0