]>
Commit | Line | Data |
---|---|---|
87774eb0 RK |
1 | #! /bin/sh |
2 | # Install modified versions of certain ANSI-incompatible | |
3 | # native Sequent DYNIX/ptx System V Release 3.2 system include files. | |
6052e619 | 4 | # Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc. |
87774eb0 RK |
5 | # Contributed by Bill Burton <billb@progress.com> |
6 | # Portions adapted from fixinc.svr4 and fixincludes. | |
7 | # | |
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. | |
14 | # | |
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. | |
19 | # | |
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 | |
3f63df56 RK |
22 | # the Free Software Foundation, 59 Temple Place - Suite 330, |
23 | # Boston, MA 02111-1307, USA. | |
87774eb0 RK |
24 | # |
25 | # This script munges the native include files provided with DYNIX/ptx | |
26 | # so as to remove things which are violations of the ANSI C standard. | |
27 | # This is done by first running fixinc.svr4 which does most of the | |
28 | # work. A few includes have fixes made to them afterwards by this | |
29 | # script. Once munged, the resulting new system include files are | |
30 | # placed in a directory that GNU C will search *before* searching the | |
31 | # /usr/include directory. This script should work properly for most | |
32 | # DYNIX/ptx systems. For other types of systems, you should use the | |
33 | # `fixincludes' script instead. | |
34 | # | |
35 | # See README-fixinc for more information. | |
36 | ||
37 | # Directory containing the original header files. | |
38 | INPUT=${2-${INPUT-/usr/include}} | |
39 | ||
40 | # Fail if no arg to specify a directory for the output. | |
41 | if [ x$1 = x ] | |
42 | then echo fixincludes: no output directory specified | |
43 | exit 1 | |
44 | fi | |
45 | ||
46 | # Directory in which to store the results. | |
47 | LIB=${1?"fixincludes: output directory not specified"} | |
48 | ||
49 | # Make sure it exists. | |
50 | if [ ! -d $LIB ]; then | |
51 | mkdir $LIB || exit 1 | |
52 | fi | |
53 | ||
54 | ORIG_DIR=`pwd` | |
55 | ||
56 | # Make LIB absolute if it is relative. | |
57 | # Don't do this if not necessary, since may screw up automounters. | |
58 | case $LIB in | |
59 | /*) | |
60 | ;; | |
61 | *) | |
62 | LIB=$ORIG_DIR/$LIB | |
63 | ;; | |
64 | esac | |
65 | ||
66 | echo 'Running fixinc.svr4' | |
67 | # DYNIX/ptx has dirname so this is no problem | |
68 | `dirname $0`/fixinc.svr4 $* | |
69 | echo 'Finished fixinc.svr4' | |
70 | ||
71 | echo 'Building fixincludes in ' ${LIB} | |
72 | ||
73 | # Copied from fixincludes. | |
74 | # Don't use or define the name va_list in stdio.h. | |
75 | # This is for ANSI and also to interoperate properly with gcc's varargs.h. | |
76 | file=stdio.h | |
77 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
78 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
79 | chmod +w ${LIB}/$file 2>/dev/null | |
80 | chmod a+r ${LIB}/$file 2>/dev/null | |
81 | fi | |
82 | ||
83 | if [ -r ${LIB}/$file ]; then | |
84 | echo Fixing $file, use of va_list | |
85 | # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list | |
86 | (echo "#define __need___va_list" | |
87 | echo "#include <stdarg.h>") > ${LIB}/${file}.sed | |
88 | # Use __gnuc_va_list in arg types in place of va_list. | |
89 | # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the | |
90 | # trailing parentheses and semicolon save all other systems from this. | |
91 | # Define __va_list__ (something harmless and unused) instead of va_list. | |
92 | # Don't claim to have defined va_list. | |
93 | sed -e 's@ va_list @ __gnuc_va_list @' \ | |
94 | -e 's@ va_list)@ __gnuc_va_list)@' \ | |
95 | -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \ | |
96 | -e 's@ va_list@ __va_list__@' \ | |
97 | -e 's@\*va_list@*__va_list__@' \ | |
98 | -e 's@ __va_list)@ __gnuc_va_list)@' \ | |
99 | -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \ | |
100 | -e 's@VA_LIST@DUMMY_VA_LIST@' \ | |
101 | -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \ | |
102 | ${LIB}/$file >> ${LIB}/${file}.sed | |
103 | ||
104 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
105 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
106 | rm -f ${LIB}/$file | |
107 | fi | |
108 | fi | |
109 | ||
110 | # In pwd.h, PTX 1.x needs stdio.h included since FILE * was added in a | |
111 | # prototype later on in the file. | |
112 | file=pwd.h | |
113 | base=`basename $file` | |
114 | if [ -r ${LIB}/$file ]; then | |
115 | file_to_fix=${LIB}/$file | |
116 | else | |
117 | if [ -r ${INPUT}/$file ]; then | |
118 | file_to_fix=${INPUT}/$file | |
119 | else | |
120 | file_to_fix="" | |
121 | fi | |
122 | fi | |
123 | if [ \! -z "$file_to_fix" ]; then | |
124 | echo Checking $file_to_fix | |
125 | if grep stdio $file_to_fix > /dev/null; then | |
126 | true | |
127 | else | |
6052e619 | 128 | sed -e '/#include <sys\/types\.h>/a\ |
87774eb0 RK |
129 | \ |
130 | #if defined(__STDC__) || defined(__cplusplus)\ | |
131 | #include <stdio.h>\ | |
2dbb8078 RK |
132 | #endif /* __STDC__ */ |
133 | ' \ | |
87774eb0 RK |
134 | $file_to_fix > ${LIB}/${file}.sed |
135 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
136 | echo Fixed $file_to_fix | |
137 | fi | |
138 | fi | |
139 | ||
140 | # Copied from fixincludes. | |
141 | # math.h puts the declaration of matherr before the definition | |
142 | # of struct exception, so the prototype (added by fixproto) causes havoc. | |
143 | file=math.h | |
144 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
145 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
146 | chmod +w ${LIB}/$file 2>/dev/null | |
147 | chmod a+r ${LIB}/$file 2>/dev/null | |
148 | fi | |
149 | ||
150 | if [ -r ${LIB}/$file ]; then | |
151 | echo Fixing $file, matherr declaration | |
152 | sed -e '/^struct exception/,$b' \ | |
153 | -e '/matherr/i\ | |
154 | struct exception; | |
155 | '\ | |
156 | ${LIB}/$file > ${LIB}/${file}.sed | |
157 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
158 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
159 | rm -f ${LIB}/$file | |
160 | fi | |
161 | fi | |
162 | ||
163 | # In netinet/in.h, the network byte swapping asm functions supported by the | |
164 | # native cc compiler on PTX 1.x and 2.x is not supported in gcc. Instead, | |
165 | # include <sys/byteorder.h> written out by the fixinc.svr4 script which has | |
166 | # these same routines written in an asm format supported by gcc. | |
167 | file=netinet/in.h | |
168 | base=`basename $file` | |
169 | if [ -r ${LIB}/$file ]; then | |
170 | file_to_fix=${LIB}/$file | |
171 | else | |
172 | if [ -r ${INPUT}/$file ]; then | |
173 | file_to_fix=${INPUT}/$file | |
174 | else | |
175 | file_to_fix="" | |
176 | fi | |
177 | fi | |
178 | if [ \! -z "$file_to_fix" ]; then | |
179 | echo Checking $file_to_fix | |
180 | if grep __GNUC__ $file_to_fix > /dev/null; then | |
181 | true | |
182 | else | |
183 | sed -e '/#define NETSWAP/a\ | |
184 | \ | |
185 | #if defined (__GNUC__) || defined (__GNUG__)\ | |
186 | #include <sys/byteorder.h>\ | |
2dbb8078 | 187 | #else /* not __GNUC__ */ |
87774eb0 RK |
188 | ' \ |
189 | -e '/#endif[ ]*\/\* NETSWAP \*\//i\ | |
2dbb8078 RK |
190 | #endif /* not __GNUC__ */ |
191 | ' \ | |
87774eb0 RK |
192 | $file_to_fix > ${LIB}/${file}.sed |
193 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
194 | echo Fixed $file_to_fix | |
195 | fi | |
196 | fi | |
197 | ||
31031edd | 198 | # /usr/include/sys/mc_param.h has an embedded asm for the cpuid instruction |
d3332269 RK |
199 | # on the P5. This is not used by anything else so we ifdef it out. |
200 | file=sys/mc_param.h | |
201 | if [ -r ${LIB}/$file ]; then | |
202 | file_to_fix=${LIB}/$file | |
203 | else | |
204 | if [ -r ${INPUT}/$file ]; then | |
205 | file_to_fix=${INPUT}/$file | |
206 | else | |
207 | file_to_fix="" | |
208 | fi | |
209 | fi | |
210 | if [ \! -z "$file_to_fix" ]; then | |
211 | echo Checking $file_to_fix | |
212 | if grep __GNUC__ $file_to_fix > /dev/null; then | |
213 | true | |
214 | else | |
215 | sed -e '/__asm/,/}/{ | |
216 | /__asm/i\ | |
217 | #if !defined (__GNUC__) && !defined (__GNUG__) | |
218 | /}/a\ | |
219 | #endif | |
220 | }' \ | |
221 | $file_to_fix > ${LIB}/${file}.sed | |
222 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
223 | echo Fixed $file_to_fix | |
224 | fi | |
225 | fi | |
226 | ||
31031edd | 227 | # /usr/include/sys/mc_param.h has an embedded asm for the cpuid instruction |
d3332269 RK |
228 | # on the P5. This is not used by anything else so we ifdef it out. |
229 | file=sys/mc_param.h | |
230 | if [ -r ${LIB}/$file ]; then | |
231 | file_to_fix=${LIB}/$file | |
232 | else | |
233 | if [ -r ${INPUT}/$file ]; then | |
234 | file_to_fix=${INPUT}/$file | |
235 | else | |
236 | file_to_fix="" | |
237 | fi | |
238 | fi | |
239 | if [ \! -z "$file_to_fix" ]; then | |
240 | echo Checking $file_to_fix | |
241 | if grep __GNUC__ $file_to_fix > /dev/null; then | |
242 | true | |
243 | else | |
244 | sed -e '/__asm/,/}/{ | |
245 | /__asm/i\ | |
246 | #if !defined (__GNUC__) && !defined (__GNUG__) | |
247 | /}/a\ | |
248 | #endif | |
249 | }' \ | |
250 | $file_to_fix > ${LIB}/${file}.sed | |
251 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
252 | echo Fixed $file_to_fix | |
253 | fi | |
254 | fi | |
255 | ||
87774eb0 RK |
256 | exit 0 |
257 |