#! /bin/sh
-#
-# fixinc.svr4 -- Install modified versions of certain ANSI-incompatible
-# native System V Release 4 system include files.
-#
-# Written by Ron Guilmette (rfg@ncd.com).
+# Install modified versions of certain ANSI-incompatible
+# native System V Release 4 system include files.
+# Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc.
+# Contributed by Ron Guilmette (rfg@monkeys.com).
#
# This file is part of GNU CC.
#
#
# You should have received a copy of the GNU General Public License
# along with GNU CC; see the file COPYING. If not, write to
-# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+# the Free Software Foundation, 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
#
# This script munges the native include files provided with System V
# Release 4 systems so as to remove things which are violations of the
#
# See README-fixinc for more information.
-# Directory where gcc sources (and sometimes special include files) live.
-SRCDIR=${3-${SRCDIR-.}}
-
# Directory containing the original header files.
INPUT=${2-${INPUT-/usr/include}}
echo 'Making directories:'
cd ${INPUT}
if $LINKS; then
- files=`ls -LR | sed -n s/:$//p`
+ files=`find . -follow -type d -print 2>/dev/null | sed '/^.$/d'`
else
files=`find . -type d -print | sed '/^.$/d'`
fi
# In case $dest is relative, get to $file's dir first.
cd ${INPUT}
cd `echo ./$file | sed -n 's&[^/]*$&&p'`
+ rwd=`pwd`
# Check that the target directory exists.
# Redirections changed to avoid bug in sh on Ultrix.
(cd $dest) > /dev/null 2>&1
x=`pwd`
# If link leads back into ${INPUT},
# make a similar link here.
- if expr $x : "${INPUT}/.*" > /dev/null; then
+ if expr "$dest" : '[^/][^/]*' >/dev/null && [ ! -h $dest ]; then
+ echo $file '->' $dest': Making link'
+ rm -fr ${LIB}/$file > /dev/null 2>&1
+ ln -s $dest ${LIB}/$file > /dev/null 2>&1
+ elif expr $x : "${INPUT}/.*" > /dev/null; then
# Y gets the actual target dir name, relative to ${INPUT}.
y=`echo $x | sed -n "s&${INPUT}/&&p"`
# DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
echo $file '->' $dots$y ': Making link'
rm -fr ${LIB}/$file > /dev/null 2>&1
ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
+ elif expr $x : "${rwd}/.*" > /dev/null; then
+ # Y gets the actual target dir name, relative to the directory where the link is.
+ y=`echo $x | sed -n "s&${rwd}/&&p"`
+ # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
+ dots=`echo "$file" |
+ sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
+ echo $file '->' $dots$y ': Making link'
+ rm -fr ${LIB}/$file > /dev/null 2>&1
+ ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
else
# If the link is to outside ${INPUT},
# treat this directory as if it actually contained the files.
/#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
/#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
/#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
+ /#[a-z]*if.*[ (!]__i860\([^_]\)/ s/__i860/__i860__/g
+ /#[a-z]*if.*[ (!]i860/ s/\([^_]\)i860/\1__i860__/g
/#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
/#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
/#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
+ s/__STDC__[ ][ ]*!=[ ][ ]*1/!defined (__STRICT_ANSI__)/g
s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
+ s/__STDC__ - 0 == 1/defined (__STRICT_ANSI__)/g
+ /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/
' $2/$file > $2/$file.sed
mv $2/$file.sed $2/$file
if cmp $file $2/$file >/dev/null 2>&1; then
shift; shift
done
+# Install the proper definition of the three standard types in header files
+# that they come from.
+for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
+ if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+ cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
+ chmod +w ${LIB}/$file 2>/dev/null
+ chmod a+r ${LIB}/$file 2>/dev/null
+ fi
+
+ if [ -r ${LIB}/$file ]; then
+ echo Fixing size_t, ptrdiff_t and wchar_t in $file
+ sed \
+ -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
+#ifndef __SIZE_TYPE__\
+#define __SIZE_TYPE__ long unsigned int\
+#endif
+' \
+ -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
+ -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
+#ifndef __PTRDIFF_TYPE__\
+#define __PTRDIFF_TYPE__ long int\
+#endif
+' \
+ -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
+ -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
+#ifndef __WCHAR_TYPE__\
+#define __WCHAR_TYPE__ int\
+#endif
+' \
+ -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
+ ${LIB}/$file > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+ if cmp $file ${LIB}/$file >/dev/null 2>&1; then
+ rm ${LIB}/$file
+ fi
+ fi
+done
+
# Fix first broken decl of getcwd present on some svr4 systems.
file=stdlib.h
static\
#else\
extern\
-#endif'\
+#endif
+'\
-e 's/extern \(int ftw(const.*\)$/\1/' \
-e '/^extern int nftw/i\
#if defined(_STYPES)\
static\
#else\
extern\
-#endif'\
+#endif
+'\
-e 's/extern \(int nftw.*\)$/\1/' \
-e '/^extern int ftw(),/c\
#if !defined(_STYPES)\
fi
# Conditionalize some of <netinet/in.h> on _KERNEL being defined.
-
-file=netinet/in.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep _KERNEL $file_to_fix > /dev/null; then
- true
- else
- sed -e '/#ifdef INKERNEL/i\
-#ifdef _KERNEL' \
- -e '/#endif[ ]*\/\* INKERNEL \*\//a\
-#endif /* _KERNEL */' \
- $file_to_fix > ${LIB}/${file}.sed
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
- echo Fixed $file_to_fix
- fi
-fi
+# This has been taken out because it breaks on some versions of
+# DYNIX/ptx, and it does not seem to do much good on any system.
+# file=netinet/in.h
+# base=`basename $file`
+# if [ -r ${LIB}/$file ]; then
+# file_to_fix=${LIB}/$file
+# else
+# if [ -r ${INPUT}/$file ]; then
+# file_to_fix=${INPUT}/$file
+# else
+# file_to_fix=""
+# fi
+# fi
+# if [ \! -z "$file_to_fix" ]; then
+# echo Checking $file_to_fix
+# if grep _KERNEL $file_to_fix > /dev/null; then
+# true
+# else
+# sed -e '/#ifdef INKERNEL/i\
+# #ifdef _KERNEL
+# ' \
+# -e '/#endif[ ]*\/\* INKERNEL \*\//a\
+# #endif /* _KERNEL */
+# ' \
+# $file_to_fix > ${LIB}/${file}.sed
+# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+# echo Fixed $file_to_fix
+# fi
+# fi
# Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
true
else
sed -e '/# ifdef __STDC__/i\
-# if !defined (__GNUC__) && !defined (__GNUG__)' \
+# if !defined (__GNUC__) && !defined (__GNUG__)
+' \
-e '/# include <sys\/byteorder.h>/s/ / /'\
-e '/# include <sys\/byteorder.h>/i\
-# endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
+# endif /* !defined (__GNUC__) && !defined (__GNUG__) */
+'\
$file_to_fix > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
echo Fixed $file_to_fix
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
sed -e '/[ ]FLT_MIN[ ]/i\
-#ifndef FLT_MIN'\
+#ifndef FLT_MIN
+'\
-e '/[ ]FLT_MIN[ ]/a\
-#endif'\
+#endif
+'\
-e '/[ ]FLT_MAX[ ]/i\
-#ifndef FLT_MAX'\
+#ifndef FLT_MAX
+'\
-e '/[ ]FLT_MAX[ ]/a\
-#endif'\
+#endif
+'\
-e '/[ ]FLT_DIG[ ]/i\
-#ifndef FLT_DIG'\
+#ifndef FLT_DIG
+'\
-e '/[ ]FLT_DIG[ ]/a\
-#endif'\
+#endif
+'\
-e '/[ ]DBL_MIN[ ]/i\
-#ifndef DBL_MIN'\
+#ifndef DBL_MIN
+'\
-e '/[ ]DBL_MIN[ ]/a\
-#endif'\
+#endif
+'\
-e '/[ ]DBL_MAX[ ]/i\
-#ifndef DBL_MAX'\
+#ifndef DBL_MAX
+'\
-e '/[ ]DBL_MAX[ ]/a\
-#endif'\
+#endif
+'\
-e '/[ ]DBL_DIG[ ]/i\
-#ifndef DBL_DIG'\
+#ifndef DBL_DIG
+'\
-e '/[ ]DBL_DIG[ ]/a\
-#endif' $file_to_fix > /tmp/$base
+#endif
+' $file_to_fix > /tmp/$base
if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
true
else
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
sed -e '/define[ ]HUGE_VAL[ ]/i\
-#ifndef HUGE_VAL'\
+#ifndef HUGE_VAL
+'\
-e '/define[ ]HUGE_VAL[ ]/a\
+#endif
+' $file_to_fix > /tmp/$base
+ if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
+ true
+ else
+ echo Fixed $file_to_fix
+ rm -f ${LIB}/$file
+ cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
+ fi
+ rm -f /tmp/$base
+fi
+
+# Solaris math.h and floatingpoint.h define __P without protection,
+# which conflicts with the fixproto definition. The fixproto
+# definition and the Solaris definition are used the same way.
+for file in math.h floatingpoint.h; do
+ base=`basename $file`
+ if [ -r ${LIB}/$file ]; then
+ file_to_fix=${LIB}/$file
+ else
+ if [ -r ${INPUT}/$file ]; then
+ file_to_fix=${INPUT}/$file
+ else
+ file_to_fix=""
+ fi
+ fi
+ if [ \! -z "$file_to_fix" ]; then
+ echo Checking $file_to_fix
+ sed -e '/^#define[ ]*__P/i\
+#ifndef __P
+'\
+ -e '/^#define[ ]*__P/a\
+#endif
+' $file_to_fix > /tmp/$base
+ if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
+ true
+ else
+ echo Fixed $file_to_fix
+ rm -f ${LIB}/$file
+ cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
+ fi
+ rm -f /tmp/$base
+ fi
+done
+
+# The Solaris math.h defines struct exception, which conflicts with
+# the class exception defined in the C++ file std/stdexcept.h. We
+# redefine it to __math_exception. This is not a great fix, but I
+# haven't been able to think of anything better.
+file=math.h
+base=`basename $file`
+if [ -r ${LIB}/$file ]; then
+ file_to_fix=${LIB}/$file
+else
+ if [ -r ${INPUT}/$file ]; then
+ file_to_fix=${INPUT}/$file
+ else
+ file_to_fix=""
+ fi
+fi
+if [ \! -z "$file_to_fix" ]; then
+ echo Checking $file_to_fix
+ sed -e '/struct exception/i\
+#ifdef __cplusplus\
+#define exception __math_exception\
+#endif'\
+ -e '/struct exception/a\
+#ifdef __cplusplus\
+#undef exception\
#endif' $file_to_fix > /tmp/$base
if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
true
for file in $files; do
dest=`ls -ld $file | sed -n 's/.*-> //p'`
if expr "$dest" : '[^/].*' > /dev/null; then
- target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
+ target=${LIB}/`echo $file | sed "s|[^/]*\$|$dest|"`
if [ -f $target ]; then
ln -s $dest ${LIB}/$file >/dev/null 2>&1
fi
#define __PDP_ENDIAN__ 3412
#endif
-#ifdef __GNUC__
-#define __STATIC static
-#else
-#define __STATIC
-#endif
-
#ifdef __STDC__
-__STATIC __inline__ unsigned long htonl (unsigned long);
-__STATIC __inline__ unsigned short htons (unsigned int);
-__STATIC __inline__ unsigned long ntohl (unsigned long);
-__STATIC __inline__ unsigned short ntohs (unsigned int);
+static __inline__ unsigned long htonl (unsigned long);
+static __inline__ unsigned short htons (unsigned int);
+static __inline__ unsigned long ntohl (unsigned long);
+static __inline__ unsigned short ntohs (unsigned int);
#endif /* defined (__STDC__) */
#if defined (__i386__)
/* We must use a new-style function definition, so that this will also
be valid for C++. */
-__STATIC __inline__ unsigned long
+static __inline__ unsigned long
htonl (unsigned long __arg)
{
register unsigned long __result;
/* Convert a host short to a network short. */
-__STATIC __inline__ unsigned short
+static __inline__ unsigned short
htons (unsigned int __arg)
{
register unsigned short __result;
/* Convert a host long to a network long. */
-__STATIC __inline__ unsigned long
+static __inline__ unsigned long
htonl (unsigned long __arg)
{
register unsigned long __result;
/* Convert a host short to a network short. */
-__STATIC __inline__ unsigned short
+static __inline__ unsigned short
htons (unsigned int __arg)
{
register unsigned short __result;
/* Convert a host long to a network long. */
-__STATIC __inline__ unsigned long
+static __inline__ unsigned long
htonl (unsigned long __arg)
{
return __arg;
/* Convert a host short to a network short. */
-__STATIC __inline__ unsigned short
+static __inline__ unsigned short
htons (unsigned int __arg)
{
return __arg;
/* Convert a network long to a host long. */
-__STATIC __inline__ unsigned long
+static __inline__ unsigned long
ntohl (unsigned long __arg)
{
return htonl (__arg);
/* Convert a network short to a host short. */
-__STATIC __inline__ unsigned short
+static __inline__ unsigned short
ntohs (unsigned int __arg)
{
return htons (__arg);
}
-
-#undef __STATIC
-
__EOF__
if [ -r ${INPUT}/sys/byteorder.h ]; then