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. |
---|
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 |
---|
22 | # the Free Software Foundation, 59 Temple Place - Suite 330, |
---|
23 | # Boston, MA 02111-1307, USA. |
---|
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 |
---|
128 | sed -e '/#include \<sys\types\.h\>/a\ |
---|
129 | \ |
---|
130 | #if defined(__STDC__) || defined(__cplusplus)\ |
---|
131 | #include <stdio.h>\ |
---|
132 | #endif /* __STDC__ */' \ |
---|
133 | $file_to_fix > ${LIB}/${file}.sed |
---|
134 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file |
---|
135 | echo Fixed $file_to_fix |
---|
136 | fi |
---|
137 | fi |
---|
138 | |
---|
139 | # Copied from fixincludes. |
---|
140 | # math.h puts the declaration of matherr before the definition |
---|
141 | # of struct exception, so the prototype (added by fixproto) causes havoc. |
---|
142 | file=math.h |
---|
143 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then |
---|
144 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" |
---|
145 | chmod +w ${LIB}/$file 2>/dev/null |
---|
146 | chmod a+r ${LIB}/$file 2>/dev/null |
---|
147 | fi |
---|
148 | |
---|
149 | if [ -r ${LIB}/$file ]; then |
---|
150 | echo Fixing $file, matherr declaration |
---|
151 | sed -e '/^struct exception/,$b' \ |
---|
152 | -e '/matherr/i\ |
---|
153 | struct exception; |
---|
154 | '\ |
---|
155 | ${LIB}/$file > ${LIB}/${file}.sed |
---|
156 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file |
---|
157 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
---|
158 | rm -f ${LIB}/$file |
---|
159 | fi |
---|
160 | fi |
---|
161 | |
---|
162 | # In netinet/in.h, the network byte swapping asm functions supported by the |
---|
163 | # native cc compiler on PTX 1.x and 2.x is not supported in gcc. Instead, |
---|
164 | # include <sys/byteorder.h> written out by the fixinc.svr4 script which has |
---|
165 | # these same routines written in an asm format supported by gcc. |
---|
166 | file=netinet/in.h |
---|
167 | base=`basename $file` |
---|
168 | if [ -r ${LIB}/$file ]; then |
---|
169 | file_to_fix=${LIB}/$file |
---|
170 | else |
---|
171 | if [ -r ${INPUT}/$file ]; then |
---|
172 | file_to_fix=${INPUT}/$file |
---|
173 | else |
---|
174 | file_to_fix="" |
---|
175 | fi |
---|
176 | fi |
---|
177 | if [ \! -z "$file_to_fix" ]; then |
---|
178 | echo Checking $file_to_fix |
---|
179 | if grep __GNUC__ $file_to_fix > /dev/null; then |
---|
180 | true |
---|
181 | else |
---|
182 | sed -e '/#define NETSWAP/a\ |
---|
183 | \ |
---|
184 | #if defined (__GNUC__) || defined (__GNUG__)\ |
---|
185 | #include <sys/byteorder.h>\ |
---|
186 | #else /* not __GNUC__ */\ |
---|
187 | ' \ |
---|
188 | -e '/#endif[ ]*\/\* NETSWAP \*\//i\ |
---|
189 | #endif /* not __GNUC__ */' \ |
---|
190 | $file_to_fix > ${LIB}/${file}.sed |
---|
191 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file |
---|
192 | echo Fixed $file_to_fix |
---|
193 | fi |
---|
194 | fi |
---|
195 | |
---|
196 | exit 0 |
---|
197 | |
---|