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, 1996, 1997 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.
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)
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, 59 Temple Place - Suite 330,
23 # Boston, MA 02111-1307, USA.
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.
35 # See README-fixinc for more information.
37 # Directory containing the original header files.
38 INPUT
=${2-${INPUT-/usr/include}}
40 # Fail if no arg to specify a directory for the output.
42 then echo fixincludes
: no output directory specified
46 # Directory in which to store the results.
47 LIB
=${1?"fixincludes: output directory not specified"}
49 # Make sure it exists.
50 if [ ! -d $LIB ]; then
56 # Make LIB absolute if it is relative.
57 # Don't do this if not necessary, since may screw up automounters.
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'
71 echo 'Building fixincludes in ' ${LIB}
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.
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
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
104 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
105 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
110 # In pwd.h, PTX 1.x needs stdio.h included since FILE * was added in a
111 # prototype later on in the file.
113 base
=`basename $file`
114 if [ -r ${LIB}/$file ]; then
115 file_to_fix
=${LIB}/$file
117 if [ -r ${INPUT}/$file ]; then
118 file_to_fix
=${INPUT}/$file
123 if [ \
! -z "$file_to_fix" ]; then
124 echo Checking
$file_to_fix
125 if grep stdio
$file_to_fix > /dev
/null
; then
128 sed -e '/#include <sys\/types\.h>/a\
130 #if defined(__STDC__) || defined(__cplusplus)\
132 #endif /* __STDC__ */
134 $file_to_fix > ${LIB}/${file}.
sed
135 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
136 echo Fixed
$file_to_fix
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.
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
150 if [ -r ${LIB}/$file ]; then
151 echo Fixing
$file, matherr declaration
152 sed -e '/^struct exception/,$b' \
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
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.
168 base
=`basename $file`
169 if [ -r ${LIB}/$file ]; then
170 file_to_fix
=${LIB}/$file
172 if [ -r ${INPUT}/$file ]; then
173 file_to_fix
=${INPUT}/$file
178 if [ \
! -z "$file_to_fix" ]; then
179 echo Checking
$file_to_fix
180 if grep __GNUC__
$file_to_fix > /dev
/null
; then
183 sed -e '/#define NETSWAP/a\
185 #if defined (__GNUC__) || defined (__GNUG__)\
186 #include <sys/byteorder.h>\
187 #else /* not __GNUC__ */
189 -e '/#endif[ ]*\/\* NETSWAP \*\//i\
190 #endif /* not __GNUC__ */
192 $file_to_fix > ${LIB}/${file}.
sed
193 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
194 echo Fixed
$file_to_fix
198 # /usr/include/sys/mc_param.h has an embedded asm for the cpuid instruction
199 # on the P5. This is not used by anything else so we ifdef it out.
201 if [ -r ${LIB}/$file ]; then
202 file_to_fix
=${LIB}/$file
204 if [ -r ${INPUT}/$file ]; then
205 file_to_fix
=${INPUT}/$file
210 if [ \
! -z "$file_to_fix" ]; then
211 echo Checking
$file_to_fix
212 if grep __GNUC__
$file_to_fix > /dev
/null
; then
217 #if !defined (__GNUC__) && !defined (__GNUG__)
221 $file_to_fix > ${LIB}/${file}.
sed
222 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
223 echo Fixed
$file_to_fix
227 # /usr/include/sys/mc_param.h has an embedded asm for the cpuid instruction
228 # on the P5. This is not used by anything else so we ifdef it out.
230 if [ -r ${LIB}/$file ]; then
231 file_to_fix
=${LIB}/$file
233 if [ -r ${INPUT}/$file ]; then
234 file_to_fix
=${INPUT}/$file
239 if [ \
! -z "$file_to_fix" ]; then
240 echo Checking
$file_to_fix
241 if grep __GNUC__
$file_to_fix > /dev
/null
; then
246 #if !defined (__GNUC__) && !defined (__GNUG__)
250 $file_to_fix > ${LIB}/${file}.
sed
251 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
252 echo Fixed
$file_to_fix