#! /bin/sh
if [ x$1 = x ]
then echo fixincludes: no output directory specified
exit 1
fi
LIB=${1?"fixincludes: output directory not specified"}
if [ ! -d $LIB ]; then
mkdir $LIB || exit 1
fi
ORIG_DIR=`${PWDCMD-pwd}`
case $LIB in
/*)
;;
*)
cd $LIB; LIB=`${PWDCMD-pwd}`
;;
esac
echo 'Building fixincludes in ' ${LIB}
if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
rm -f $LIB/ShouldNotExist
LINKS=true
else
LINKS=false
fi
echo 'Making directories:'
shift
if [ $ set /usr/include
fi
INLIST="$@"
for INPUT in ${INLIST} ; do
cd ${ORIG_DIR}
cd ${INPUT}
if $LINKS; then
files=`find . -follow -type d -print 2>/dev/null | sed '/^.$/d'`
else
files=`find . -type d -print | sed '/^.$/d'`
fi
for file in $files; do
rm -rf $LIB/$file
if [ ! -d $LIB/$file ]
then mkdir $LIB/$file
fi
done
treetops="${INPUT} ${LIB}"
if $LINKS; then
echo 'Making internal symbolic directory links'
for file in $files; do
dest=`ls -ld $file | sed -n 's/.*-> //p'`
if [ "$dest" ]; then
cwd=`pwd`
cd ${INPUT}
cd `echo ./$file | sed -n 's&[^/]*$&&p'`
rwd=`pwd`
(cd $dest) > /dev/null 2>&1
if [ $? = 0 ]; then
cd $dest
x=`pwd`
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=`echo $x | sed -n "s&${INPUT}/&&p"`
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
elif expr $x : "${rwd}/.*" > /dev/null; then
y=`echo $x | sed -n "s&${rwd}/&&p"`
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
treetops="$treetops $x ${LIB}/$file"
fi
fi
cd $cwd
fi
done
fi
set - $treetops
while [ $ echo "Finding header files in $1:"
cd ${INPUT}
cd $1
files=`find . -name '*.h' -type f -print`
echo 'Checking header files:'
for file in $files; do
if [ -r $file ]; then
cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
chmod +w $2/$file
chmod a+r $2/$file
sed -e '
s%^\([ ]* s%^\([ ]* s%^\([ ]* s%^\([ ]* s/ s/ s/ s/ s/ / / / / / / / / / / / / / 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
rm $2/$file
else
echo Fixed $file
fi
fi
done
shift; shift
done
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\
' \
-e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
-e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
' \
-e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
-e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
' \
-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
file=stdlib.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 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $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
file=unistd.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 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
| sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /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
file=sys/param.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
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
chmod a+r /tmp/$base
sed -e '/^ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base.sed ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base /tmp/$base.sed
fi
file=stdio.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
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e '/^ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base.sed ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base /tmp/$base.sed
fi
file=dbm.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
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e '/^ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base.sed ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base /tmp/$base.sed
fi
file=sys/mman.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
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e '/^extern caddr_t mmap();$/c\
extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
extern caddr_t mmap ();\
if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base.sed ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base /tmp/$base.sed
fi
file=ftw.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 test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
true
else
echo Checking $file_to_fix
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e '/^extern int ftw(const/i\
static\
extern\
'\
-e 's/extern \(int ftw(const.*\)$/\1/' \
-e '/^extern int nftw/i\
static\
extern\
'\
-e 's/extern \(int nftw.*\)$/\1/' \
-e '/^extern int ftw(),/c\
static\
extern\
int ftw();\
static\
extern\
int nftw();' /tmp/$base > /tmp/$base.sed
if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base.sed ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base /tmp/$base.sed
fi
file=curses.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
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e 's,^typedef[ ]char[ ]bool;$,typedef char bool;\
if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base.sed ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base /tmp/$base.sed
fi
file=regexp.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 "static void getrnge" $file_to_fix > /dev/null; then
true
else
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e '/^static int[ ]*size;/c\
static int size ;\
\
static int getrnge ();' /tmp/$base > /tmp/$base.sed
if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base.sed ${LIB}/$file
chmod a+r ${LIB}/$file
fi
fi
rm -f /tmp/$base /tmp/$base.sed
fi
file=string.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
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e '/ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base.sed ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base /tmp/$base.sed
fi
file=ieeefp.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
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e '/ -e '/ -e '/ /tmp/$base > /tmp/$base.sed
if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base.sed ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base /tmp/$base.sed
fi
file=sys/signal.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
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e '/^struct sigaction {/c\
struct sigaction {' \
-e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base.sed ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base /tmp/$base.sed
fi
file=sys/mkdev.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
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e '/^dev_t makedev(const/c\
static dev_t makedev(const major_t, const minor_t);' \
-e '/^dev_t makedev()/c\
static dev_t makedev();' \
-e '/^major_t major(const/c\
static major_t major(const dev_t);' \
-e '/^major_t major()/c\
static major_t major();' \
-e '/^minor_t minor(const/c\
static minor_t minor(const dev_t);' \
-e '/^minor_t minor()/c\
static minor_t minor();' /tmp/$base > /tmp/$base.sed
if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base.sed ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base /tmp/$base.sed
fi
file=sys/adv.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 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $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
file=sys/netcspace.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 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
| sed 's/NC_/(unsigned long) NC_/' > /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
file=fs/rfs/rf_cache.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
echo ' cat $file_to_fix >> /tmp/$base
echo ' echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
file=sys/erec.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
echo ' cat $file_to_fix >> /tmp/$base
echo ' echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
file=sys/err.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
echo ' cat $file_to_fix >> /tmp/$base
echo ' echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
file=sys/char.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
echo ' cat $file_to_fix >> /tmp/$base
echo ' echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
file=sys/getpages.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
echo ' cat $file_to_fix >> /tmp/$base
echo ' echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
file=sys/map.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
echo ' cat $file_to_fix >> /tmp/$base
echo ' echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
file=sys/cmn_err.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
echo ' cat $file_to_fix >> /tmp/$base
echo ' echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
file=sys/kdebugger.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
echo ' cat $file_to_fix >> /tmp/$base
echo ' echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
file=sys/endian.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 __GNUC__ $file_to_fix > /dev/null; then
true
else
sed -e '/' \
-e '/ -e '/'\
$file_to_fix > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
echo Fixed $file_to_fix
fi
fi
file=sys/stream.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 '
s/extern struct stdata;/struct stdata;/g
s/extern struct strevent;/struct strevent;/g
' $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
file=sys/strsubr.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 '
s/extern struct strbuf;/struct strbuf;/g
s/extern struct uio;/struct uio;/g
s/extern struct thread;/struct thread;/g
s/extern struct proc;/struct proc;/g
' $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
file=rpc/types.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 '
s/const extern/extern const/g
' $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
file=sys/stat.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
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e '/^stat([ ]*[^c]/{
N
N
s/(.*)\n/( /
s/;\n/, /
s/;$/)/
}' \
-e '/^lstat([ ]*[^c]/{
N
N
s/(.*)\n/( /
s/;\n/, /
s/;$/)/
}' \
-e '/^fstat([ ]*[^i]/{
N
N
s/(.*)\n/( /
s/;\n/, /
s/;$/)/
}' \
-e '/^mknod([ ]*[^c]/{
N
N
N
s/(.*)\n/( /
s/;\n/, /g
s/;$/)/
}' \
-e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
-e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
-e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
-e '1,$s/ret\([^u]\)/__ret\1/g' \
-e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
-e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base.sed ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base /tmp/$base.sed
fi
if [ -x /bin/sony ]; then
if /bin/sony; then
file=stdio.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
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e '
s/__filbuf/_filbuf/g
s/__flsbuf/_flsbuf/g
s/__iob/_iob/g
' /tmp/$base > /tmp/$base.sed
mv /tmp/$base.sed /tmp/$base
if cmp $file_to_fix /tmp/$base.sed >/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
file=ctype.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
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
sed -e '
s/__ctype/_ctype/g
' /tmp/$base > /tmp/$base.sed
mv /tmp/$base.sed /tmp/$base
if cmp $file_to_fix /tmp/$base.sed >/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
fi
fi
file=limits.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 '/[ ]FLT_MIN[ ]/i\
'\
-e '/[ ]FLT_MIN[ ]/a\
'\
-e '/[ ]FLT_MAX[ ]/i\
'\
-e '/[ ]FLT_MAX[ ]/a\
'\
-e '/[ ]FLT_DIG[ ]/i\
'\
-e '/[ ]FLT_DIG[ ]/a\
'\
-e '/[ ]DBL_MIN[ ]/i\
'\
-e '/[ ]DBL_MIN[ ]/a\
'\
-e '/[ ]DBL_MAX[ ]/i\
'\
-e '/[ ]DBL_MAX[ ]/a\
'\
-e '/[ ]DBL_DIG[ ]/i\
'\
-e '/[ ]DBL_DIG[ ]/a\
' $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
file=sys/varargs.h
if [ -r ${INPUT}/$file ]; then
echo Replacing $file
cat > ${LIB}/$file << EOF
/* This file was generated by fixincludes. */
EOF
chmod a+r ${LIB}/$file
fi
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 '/define[ ]HUGE_VAL[ ]/i\
'\
-e '/define[ ]HUGE_VAL[ ]/a\
' $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
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 '/^'\
-e '/^' $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
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\
-e '/struct exception/a\
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
file=sys/stream.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[ ]*queue/i\
-e '/struct[ ]*queue/a\
if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
mkdir -p $LIB/`dirname $file`
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base
fi
set -x
file=arpa/inet.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 '/^extern.*htons.*(in_port_t)/d' \
-e '/^extern.*ntohs.*(in_port_t)/d' \
$file_to_fix > /tmp/$base
if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
true
else
echo Fixed $file_to_fix
mkdir -p $LIB/`dirname $file`
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base
fi
echo 'Removing unneeded directories:'
cd $LIB
files=`find . -type d \! -name '.' -print | sort -r`
for file in $files; do
rmdir $LIB/$file > /dev/null 2>&1
done
if $LINKS; then
echo 'Making internal symbolic non-directory links'
cd ${INPUT}
files=`find . -type l -print`
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|"`
if [ -f $target ]; then
ln -s $dest ${LIB}/$file >/dev/null 2>&1
fi
fi
done
fi
cd ${ORIG_DIR}
echo 'Replacing <sys/byteorder.h>'
if [ \! -d $LIB/sys ]; then
mkdir $LIB/sys
fi
rm -f ${LIB}/sys/byteorder.h
cat <<'__EOF__' >${LIB}/sys/byteorder.h
/* Functions to convert `short' and `long' quantities from host byte order
to (internet) network byte order (i.e. big-endian).
Written by Ron Guilmette (rfg@ncd.com).
This isn't actually used by GCC. It is installed by fixinc.svr4.
For big-endian machines these functions are essentially no-ops.
For little-endian machines, we define the functions using specialized
asm sequences in cases where doing so yields better code (e.g. i386). */
extern "C" {
/* Byte order defines. These are as defined on UnixWare 1.1, but with
double underscores added at the front and back. */
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);
/* Convert a host long to a network long. */
/* We must use a new-style function definition, so that this will also
be valid for C++. */
static __inline__ unsigned long
htonl (unsigned long __arg)
{
register unsigned long __result;
__asm__ ("xchg%B0 %b0,%h0\n\
ror%L0 $16,%0\n\
xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
return __result;
}
/* Convert a host short to a network short. */
static __inline__ unsigned short
htons (unsigned int __arg)
{
register unsigned short __result;
__asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
return __result;
}
|| defined (__ns32k__) || defined (__vax__) \
|| defined (__spur__) || defined (__arm__))
/* For other little-endian machines, using C code is just as efficient as
using assembly code. */
/* Convert a host long to a network long. */
static __inline__ unsigned long
htonl (unsigned long __arg)
{
register unsigned long __result;
__result = (__arg >> 24) & 0x000000ff;
__result |= (__arg >> 8) & 0x0000ff00;
__result |= (__arg << 8) & 0x00ff0000;
__result |= (__arg << 24) & 0xff000000;
return __result;
}
/* Convert a host short to a network short. */
static __inline__ unsigned short
htons (unsigned int __arg)
{
register unsigned short __result;
__result = (__arg << 8) & 0xff00;
__result |= (__arg >> 8) & 0x00ff;
return __result;
}
/* Convert a host long to a network long. */
static __inline__ unsigned long
htonl (unsigned long __arg)
{
return __arg;
}
/* Convert a host short to a network short. */
static __inline__ unsigned short
htons (unsigned int __arg)
{
return __arg;
}
/* Convert a network long to a host long. */
static __inline__ unsigned long
ntohl (unsigned long __arg)
{
return htonl (__arg);
}
/* Convert a network short to a host short. */
static __inline__ unsigned short
ntohs (unsigned int __arg)
{
return htons (__arg);
}
} /* extern "C" */
__EOF__
if [ -r ${INPUT}/sys/byteorder.h ]; then
if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then
cat <<'__EOF__' >>${LIB}/sys/byteorder.h
__EOF__
fi
fi
cat <<'__EOF__' >>${LIB}/sys/byteorder.h
__EOF__
chmod a+r ${LIB}/sys/byteorder.h
done
exit 0