#! /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 'Running fixinc.svr4'
`dirname $0`/fixinc.svr4 $*
echo 'Finished fixinc.svr4'
echo 'Building fixincludes in ' ${LIB}
shift
if [ $ set /usr/include
fi
INLIST="$@"
for INPUT in ${INLIST} ; do
cd ${ORIG_DIR}
cd ${INPUT}
file=stdio.h
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 $file, use of va_list
(echo "#define __need___va_list"
echo "#include <stdarg.h>") > ${LIB}/${file}.sed
sed -e 's@ va_list @ __gnuc_va_list @' \
-e 's@ va_list)@ __gnuc_va_list)@' \
-e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
-e 's@ va_list@ __va_list__@' \
-e 's@\*va_list@*__va_list__@' \
-e 's@ __va_list)@ __gnuc_va_list)@' \
-e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
-e 's@VA_LIST@DUMMY_VA_LIST@' \
-e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \
${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 -f ${LIB}/$file
fi
fi
file=pwd.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 stdio $file_to_fix > /dev/null; then
true
else
sed -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=math.h
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 $file, matherr declaration
sed -e '/^struct exception/,$b' \
-e '/matherr/i\
struct exception;
'\
${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 -f ${LIB}/$file
fi
fi
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 __GNUC__ $file_to_fix > /dev/null; then
true
else
sed -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/mc_param.h
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 '/__asm/,/}/{
/__asm/i\
/}/a\
}' \
$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/mc_param.h
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 '/__asm/,/}/{
/__asm/i\
/}/a\
}' \
$file_to_fix > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
echo Fixed $file_to_fix
fi
fi
done
if [ x${INSTALL_ASSERT_H} != x ]
then
cd ${ORIG_DIR}
rm -f include/assert.h
cp ${srcdir}/assert.h include/assert.h || exit 1
chmod a+r include/assert.h
fi
exit 0