#! /bin/sh
# Install modified versions of certain ANSI-incompatible system header files
# which are fixed to work correctly with ANSI C
# and placed in a directory that GNU C will search.
# This works properly on a Sun in system version 3.4;
# for other versions, you had better check.

# Directory in which to store the results.
LIB=/usr/local/lib/gcc-include

mkdir ${LIB}
for dir in sys sun sundev sunwindow; do
  if [ -d /usr/include/$dir ]; then
    mkdir ${LIB}/$dir
  fi
done

cp /usr/include/sys/ioctl.h ${LIB}/sys/ioctl.h
chmod +w ${LIB}/sys/ioctl.h
ex ${LIB}/sys/ioctl.h <<EOF
g/_IO/s/(\(.\),/('\1',/
g/#define._IO/s/'x'/x/g
wq
EOF

for file in sys/mtio.h sys/vcmd.h sys/des.h  \
	    vaxuba/qvioctl.h \
	    sun/dkio.h sun/fbio.h sun/gpio.h sun/ndio.h  \
            sundev/kbio.h sundev/msio.h sundev/fpareg.h sundev/mcpcmd.h  \
	    sundev/msreg.h sundev/vuid_event.h sunwindow/win_ioctl.h; do
  if [ -r /usr/include/$file ]; then
    cp /usr/include/$file ${LIB}/$file
    chmod +w ${LIB}/$file
    ex ${LIB}/$file <<EOF
    g/_IO/s/(\(.\),/('\1',/
    wq
EOF
  fi
done

cp /usr/include/sys/ttychars.h ${LIB}/sys/ttychars.h
chmod +w ${LIB}/sys/ttychars.h
ex ${LIB}/sys/ttychars.h << EOF
g/CTRL/s/(\(.\))/('\1')/
g/#define.CTRL/s/'c'/c/g
wq
EOF
