(expand_asm, expand_asm_operands): Change error message text.
[official-gcc.git] / gcc / fixinc.ptx
blob7cac092d40138e6af39477fb143c88f7898074f6
1 #! /bin/sh
2 # Install modified versions of certain ANSI-incompatible
3 # native Sequent DYNIX/ptx System V Release 3.2 system include files.
4 # Copyright (C) 1994 Free Software Foundation, Inc.
5 # Contributed by Bill Burton <billb@progress.com>
6 # Portions adapted from fixinc.svr4 and fixincludes.
8 # This file is part of GNU CC.
9 #
10 # GNU CC is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
13 # any later version.
15 # GNU CC is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with GNU CC; see the file COPYING. If not, write to
22 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 # This script munges the native include files provided with DYNIX/ptx
25 # so as to remove things which are violations of the ANSI C standard.
26 # This is done by first running fixinc.svr4 which does most of the
27 # work. A few includes have fixes made to them afterwards by this
28 # script. Once munged, the resulting new system include files are
29 # placed in a directory that GNU C will search *before* searching the
30 # /usr/include directory. This script should work properly for most
31 # DYNIX/ptx systems. For other types of systems, you should use the
32 # `fixincludes' script instead.
34 # See README-fixinc for more information.
36 # Directory containing the original header files.
37 INPUT=${2-${INPUT-/usr/include}}
39 # Fail if no arg to specify a directory for the output.
40 if [ x$1 = x ]
41 then echo fixincludes: no output directory specified
42 exit 1
45 # Directory in which to store the results.
46 LIB=${1?"fixincludes: output directory not specified"}
48 # Make sure it exists.
49 if [ ! -d $LIB ]; then
50 mkdir $LIB || exit 1
53 ORIG_DIR=`pwd`
55 # Make LIB absolute if it is relative.
56 # Don't do this if not necessary, since may screw up automounters.
57 case $LIB in
58 /*)
61 LIB=$ORIG_DIR/$LIB
63 esac
65 echo 'Running fixinc.svr4'
66 # DYNIX/ptx has dirname so this is no problem
67 `dirname $0`/fixinc.svr4 $*
68 echo 'Finished fixinc.svr4'
70 echo 'Building fixincludes in ' ${LIB}
72 # Copied from fixincludes.
73 # Don't use or define the name va_list in stdio.h.
74 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
75 file=stdio.h
76 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
77 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
78 chmod +w ${LIB}/$file 2>/dev/null
79 chmod a+r ${LIB}/$file 2>/dev/null
82 if [ -r ${LIB}/$file ]; then
83 echo Fixing $file, use of va_list
84 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
85 (echo "#define __need___va_list"
86 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
87 # Use __gnuc_va_list in arg types in place of va_list.
88 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
89 # trailing parentheses and semicolon save all other systems from this.
90 # Define __va_list__ (something harmless and unused) instead of va_list.
91 # Don't claim to have defined va_list.
92 sed -e 's@ va_list @ __gnuc_va_list @' \
93 -e 's@ va_list)@ __gnuc_va_list)@' \
94 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
95 -e 's@ va_list@ __va_list__@' \
96 -e 's@\*va_list@*__va_list__@' \
97 -e 's@ __va_list)@ __gnuc_va_list)@' \
98 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
99 -e 's@VA_LIST@DUMMY_VA_LIST@' \
100 -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \
101 ${LIB}/$file >> ${LIB}/${file}.sed
103 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
104 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
105 rm -f ${LIB}/$file
109 # In pwd.h, PTX 1.x needs stdio.h included since FILE * was added in a
110 # prototype later on in the file.
111 file=pwd.h
112 base=`basename $file`
113 if [ -r ${LIB}/$file ]; then
114 file_to_fix=${LIB}/$file
115 else
116 if [ -r ${INPUT}/$file ]; then
117 file_to_fix=${INPUT}/$file
118 else
119 file_to_fix=""
122 if [ \! -z "$file_to_fix" ]; then
123 echo Checking $file_to_fix
124 if grep stdio $file_to_fix > /dev/null; then
125 true
126 else
127 sed -e '/#include \<sys\types\.h\>/a\
129 #if defined(__STDC__) || defined(__cplusplus)\
130 #include <stdio.h>\
131 #endif /* __STDC__ */' \
132 $file_to_fix > ${LIB}/${file}.sed
133 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
134 echo Fixed $file_to_fix
138 # Copied from fixincludes.
139 # math.h puts the declaration of matherr before the definition
140 # of struct exception, so the prototype (added by fixproto) causes havoc.
141 file=math.h
142 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
143 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
144 chmod +w ${LIB}/$file 2>/dev/null
145 chmod a+r ${LIB}/$file 2>/dev/null
148 if [ -r ${LIB}/$file ]; then
149 echo Fixing $file, matherr declaration
150 sed -e '/^struct exception/,$b' \
151 -e '/matherr/i\
152 struct exception;
154 ${LIB}/$file > ${LIB}/${file}.sed
155 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
156 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
157 rm -f ${LIB}/$file
161 # In netinet/in.h, the network byte swapping asm functions supported by the
162 # native cc compiler on PTX 1.x and 2.x is not supported in gcc. Instead,
163 # include <sys/byteorder.h> written out by the fixinc.svr4 script which has
164 # these same routines written in an asm format supported by gcc.
165 file=netinet/in.h
166 base=`basename $file`
167 if [ -r ${LIB}/$file ]; then
168 file_to_fix=${LIB}/$file
169 else
170 if [ -r ${INPUT}/$file ]; then
171 file_to_fix=${INPUT}/$file
172 else
173 file_to_fix=""
176 if [ \! -z "$file_to_fix" ]; then
177 echo Checking $file_to_fix
178 if grep __GNUC__ $file_to_fix > /dev/null; then
179 true
180 else
181 sed -e '/#define NETSWAP/a\
183 #if defined (__GNUC__) || defined (__GNUG__)\
184 #include <sys/byteorder.h>\
185 #else /* not __GNUC__ */\
187 -e '/#endif[ ]*\/\* NETSWAP \*\//i\
188 #endif /* not __GNUC__ */' \
189 $file_to_fix > ${LIB}/${file}.sed
190 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
191 echo Fixed $file_to_fix
195 exit 0