source: trunk/third/gcc/fixinc.irix @ 11288

Revision 11288, 4.5 KB checked in by ghudson, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r11287, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1#! /bin/sh
2# Install modified versions of certain problematic Irix include files.
3# Copyright (C) 1997 Free Software Foundation, Inc.
4# Contributed by Brendan Kehoe (brendan@cygnus.com).
5#
6# This file is part of GNU CC.
7#
8# GNU CC is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2, or (at your option)
11# any later version.
12#
13# GNU CC is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with GNU CC; see the file COPYING.  If not, write to
20# the Free Software Foundation, 59 Temple Place - Suite 330,
21# Boston, MA 02111-1307, USA.
22#
23#       See README-fixinc for more information.
24
25# Directory containing the original header files.
26INPUT=${2-${INPUT-/usr/include}}
27
28# Fail if no arg to specify a directory for the output.
29if [ x$1 = x ]
30then echo fixincludes: no output directory specified
31exit 1
32fi
33
34# Directory in which to store the results.
35LIB=${1?"fixincludes: output directory not specified"}
36
37# Make sure it exists.
38if [ ! -d $LIB ]; then
39  mkdir $LIB || exit 1
40fi
41
42ORIG_DIR=`pwd`
43
44# Make LIB absolute if it is relative.
45# Don't do this if not necessary, since may screw up automounters.
46case $LIB in
47/*)
48        ;;
49*)
50        LIB=$ORIG_DIR/$LIB
51        ;;
52esac
53
54echo 'Building fixincludes in ' ${LIB}
55
56#
57# Note: For Irix, we deliberately don't try to create the directory trees,
58#       since we only modify math.h, limits.h and unistd.h.  If we
59#       ADD ANY OTHERS, the "Making directories:" and symlinks code from
60#       fixinc.svr4 may have to go back in.
61
62# The Irix math.h defines struct exception, which conflicts with
63# the class exception defined in the C++ file std/stdexcept.h.  We
64# redefine it to __math_exception.  This is not a great fix, but I
65# haven't been able to think of anything better.
66file=math.h
67base=`basename $file`
68if [ -r ${LIB}/$file ]; then
69  file_to_fix=${LIB}/$file
70else
71  if [ -r ${INPUT}/$file ]; then
72    file_to_fix=${INPUT}/$file
73  else
74    file_to_fix=""
75  fi
76fi
77if [ \! -z "$file_to_fix" ]; then
78  echo Checking $file_to_fix
79  sed -e '/struct exception/i\
80#ifdef __cplusplus\
81#define exception __math_exception\
82#endif'\
83      -e '/struct exception/a\
84#ifdef __cplusplus\
85#undef exception\
86#endif' $file_to_fix > /tmp/$base
87  if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
88    true
89  else
90    echo Fixed $file_to_fix
91    rm -f ${LIB}/$file
92    cp /tmp/$base ${LIB}/$file
93    chmod a+r ${LIB}/$file
94  fi
95  rm -f /tmp/$base
96fi
97
98# In limits.h, put #ifndefs around things that are supposed to be defined
99# in float.h to avoid redefinition errors if float.h is included first.
100
101file=limits.h
102base=`basename $file`
103if [ -r ${LIB}/$file ]; then
104  file_to_fix=${LIB}/$file
105else
106  if [ -r ${INPUT}/$file ]; then
107    file_to_fix=${INPUT}/$file
108  else
109    file_to_fix=""
110  fi
111fi
112if [ \! -z "$file_to_fix" ]; then
113  echo Checking $file_to_fix
114  sed -e '/[    ]FLT_MIN[       ]/i\
115#ifndef FLT_MIN
116'\
117      -e '/[    ]FLT_MIN[       ]/a\
118#endif
119'\
120      -e '/[    ]FLT_MAX[       ]/i\
121#ifndef FLT_MAX
122'\
123      -e '/[    ]FLT_MAX[       ]/a\
124#endif
125'\
126      -e '/[    ]FLT_DIG[       ]/i\
127#ifndef FLT_DIG
128'\
129      -e '/[    ]FLT_DIG[       ]/a\
130#endif
131'\
132      -e '/[    ]DBL_MIN[       ]/i\
133#ifndef DBL_MIN
134'\
135      -e '/[    ]DBL_MIN[       ]/a\
136#endif
137'\
138      -e '/[    ]DBL_MAX[       ]/i\
139#ifndef DBL_MAX
140'\
141      -e '/[    ]DBL_MAX[       ]/a\
142#endif
143'\
144      -e '/[    ]DBL_DIG[       ]/i\
145#ifndef DBL_DIG
146'\
147      -e '/[    ]DBL_DIG[       ]/a\
148#endif
149' $file_to_fix > /tmp/$base
150  if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
151    true
152  else
153    echo Fixed $file_to_fix
154    rm -f ${LIB}/$file
155    cp /tmp/$base ${LIB}/$file
156    chmod a+r ${LIB}/$file
157  fi
158  rm -f /tmp/$base
159fi
160
161# The Irix unistd.h will introduce a call to __vfork in its libc, but the
162# function is never actually prototyped.
163file=unistd.h
164base=`basename $file`
165if [ -r ${LIB}/$file ]; then
166  file_to_fix=${LIB}/$file
167else
168  if [ -r ${INPUT}/$file ]; then
169    file_to_fix=${INPUT}/$file
170  else
171    file_to_fix=""
172  fi
173fi
174if [ \! -z "$file_to_fix" ]; then
175  echo Checking $file_to_fix
176  sed -e '/__vfork/i\
177extern pid_t __vfork(void);'\
178     $file_to_fix > /tmp/$base
179  if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
180    true
181  else
182    echo Fixed $file_to_fix
183    rm -f ${LIB}/$file
184    cp /tmp/$base ${LIB}/$file
185    chmod a+r ${LIB}/$file
186  fi
187  rm -f /tmp/$base
188fi
189
190exit 0
Note: See TracBrowser for help on using the repository browser.