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 # Fail if no arg to specify a directory for the output.
39 then echo fixincludes
: no output directory specified
43 # Directory in which to store the results.
44 LIB
=${1?"fixincludes: output directory not specified"}
46 # Make sure it exists.
47 if [ ! -d $LIB ]; then
51 ORIG_DIR
=`${PWDCMD-pwd}`
53 # Make LIB absolute if it is relative.
54 # Don't do this if not necessary, since may screw up automounters.
59 cd $LIB; LIB
=`${PWDCMD-pwd}`
63 echo 'Running fixinc.svr4'
64 # DYNIX/ptx has dirname so this is no problem
65 `dirname $0`/fixinc.svr4 $
*
66 echo 'Finished fixinc.svr4'
68 echo 'Building fixincludes in ' ${LIB}
69 # Directory containing the original header files.
71 if [ $# -eq 0 ] ; then
77 for INPUT
in ${INLIST} ; do
81 # Copied from fixincludes.
82 # Don't use or define the name va_list in stdio.h.
83 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
85 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
86 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
87 chmod +w
${LIB}/$file 2>/dev
/null
88 chmod a
+r
${LIB}/$file 2>/dev
/null
91 if [ -r ${LIB}/$file ]; then
92 echo Fixing
$file, use of va_list
93 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
94 (echo "#define __need___va_list"
95 echo "#include <stdarg.h>") > ${LIB}/${file}.
sed
96 # Use __gnuc_va_list in arg types in place of va_list.
97 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
98 # trailing parentheses and semicolon save all other systems from this.
99 # Define __not_va_list__ (something harmless and unused) instead of va_list.
100 # Don't claim to have defined va_list.
101 sed -e 's@ va_list @ __gnuc_va_list @' \
102 -e 's@ va_list)@ __gnuc_va_list)@' \
103 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
104 -e 's@ va_list@ __not_va_list__@' \
105 -e 's@\*va_list@*__not_va_list__@' \
106 -e 's@ __va_list)@ __gnuc_va_list)@' \
107 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
108 -e 's@VA_LIST@DUMMY_VA_LIST@' \
109 -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \
110 ${LIB}/$file >> ${LIB}/${file}.
sed
112 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
113 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
118 # In pwd.h, PTX 1.x needs stdio.h included since FILE * was added in a
119 # prototype later on in the file.
121 base
=`basename $file`.$$
122 if [ -r ${LIB}/$file ]; then
123 file_to_fix
=${LIB}/$file
125 if [ -r ${INPUT}/$file ]; then
126 file_to_fix
=${INPUT}/$file
131 if [ \
! -z "$file_to_fix" ]; then
132 echo Checking
$file_to_fix
133 if grep stdio
$file_to_fix > /dev
/null
; then
136 sed -e '/#include <sys\/types\.h>/a\
138 #if defined(__STDC__) || defined(__cplusplus)\
140 #endif /* __STDC__ */
142 $file_to_fix > ${LIB}/${file}.
sed
143 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
144 echo Fixed
$file_to_fix
148 # Copied from fixincludes.
149 # math.h puts the declaration of matherr before the definition
150 # of struct exception, so the prototype (added by fixproto) causes havoc.
152 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
153 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
154 chmod +w
${LIB}/$file 2>/dev
/null
155 chmod a
+r
${LIB}/$file 2>/dev
/null
158 if [ -r ${LIB}/$file ]; then
159 echo Fixing
$file, matherr declaration
160 sed -e '/^struct exception/,$b' \
164 ${LIB}/$file > ${LIB}/${file}.
sed
165 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
166 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
171 # In netinet/in.h, the network byte swapping asm functions supported by the
172 # native cc compiler on PTX 1.x and 2.x is not supported in gcc. Instead,
173 # include <sys/byteorder.h> written out by the fixinc.svr4 script which has
174 # these same routines written in an asm format supported by gcc.
176 base
=`basename $file`.$$
177 if [ -r ${LIB}/$file ]; then
178 file_to_fix
=${LIB}/$file
180 if [ -r ${INPUT}/$file ]; then
181 file_to_fix
=${INPUT}/$file
186 if [ \
! -z "$file_to_fix" ]; then
187 echo Checking
$file_to_fix
188 if grep __GNUC__
$file_to_fix > /dev
/null
; then
191 sed -e '/#define NETSWAP/a\
193 #if defined (__GNUC__) || defined (__GNUG__)\
194 #include <sys/byteorder.h>\
195 #else /* not __GNUC__ */
197 -e '/#endif[ ]*\/\* NETSWAP \*\//i\
198 #endif /* not __GNUC__ */
200 $file_to_fix > ${LIB}/${file}.
sed
201 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
202 echo Fixed
$file_to_fix
206 # /usr/include/sys/mc_param.h has an embedded asm for the cpuid instruction
207 # on the P5. This is not used by anything else so we ifdef it out.
209 if [ -r ${LIB}/$file ]; then
210 file_to_fix
=${LIB}/$file
212 if [ -r ${INPUT}/$file ]; then
213 file_to_fix
=${INPUT}/$file
218 if [ \
! -z "$file_to_fix" ]; then
219 echo Checking
$file_to_fix
220 if grep __GNUC__
$file_to_fix > /dev
/null
; then
225 #if !defined (__GNUC__) && !defined (__GNUG__)
229 $file_to_fix > ${LIB}/${file}.
sed
230 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
231 echo Fixed
$file_to_fix
235 # /usr/include/sys/mc_param.h has an embedded asm for the cpuid instruction
236 # on the P5. This is not used by anything else so we ifdef it out.
238 if [ -r ${LIB}/$file ]; then
239 file_to_fix
=${LIB}/$file
241 if [ -r ${INPUT}/$file ]; then
242 file_to_fix
=${INPUT}/$file
247 if [ \
! -z "$file_to_fix" ]; then
248 echo Checking
$file_to_fix
249 if grep __GNUC__
$file_to_fix > /dev
/null
; then
254 #if !defined (__GNUC__) && !defined (__GNUG__)
258 $file_to_fix > ${LIB}/${file}.
sed
259 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
260 echo Fixed
$file_to_fix