echo This shell script will create a new link directive file, extract
echo a few missing objects from the C libraries, and create a new
echo sys/time.h header file.

echo
echo cd /lib
cd /lib

echo cp shlib.ifile shlib_c.ifile
cp shlib.ifile shlib_c.ifile

echo editing shlib_c.ifile
ex - shlib_c.ifile << "EOF"
1,$s/^PC/xPC/
1,$s/^BC/xBC/
1,$s/^UP/xUP/
1,$s/^ospeed/xospeed/
1,$s/^LINES/xLINES/
1,$s/^COLS/xCOLS/
1,$s/^tgetflag/xtgetflag/
1,$s/^tgetent/xtgetent/
1,$s/^tgetstr/xtgetstr/
1,$s/^tgetnum/xtgetnum/
1,$s/^tgoto/xtgoto/
1,$s/^tputs/xtputs/
1,$s/^wrefresh/xwrefresh/
1,$s/^initscr/xinitscr/
1,$s/^cbreak/xcbreak/
1,$s/^nl/xnl/
1,$s/^flushinp/xflushinp/
1,$s/^noecho/xnoecho/
1,$s/^savetty/xsavetty/
1,$s/^resetty/xresetty/
1,$s/^echo/xecho/
1,$s/^nocbreak/xnocbreak/
1,$s/^nonl/xnonl/
1,$s/^keypad/xkeypad/
1,$s/^endwin/xendwin/
1,$s/^printw/xprintw/
1,$s/^fixterm/xfixterm/
1,$s/^resetterm/xresetterm/
1,$s/^setterm/xsetterm/
1,$s/^baudrate/xbaudrate/
w
q
EOF

echo ar x libc.a doprnt.o setvbuf.o
ar x libc.a doprnt.o setvbuf.o

echo creating /usr/include/sys/time.h
cat > /usr/include/sys/time.h << "EOF"
/*
 * The sys/time.h stuff extracted from select.h in the UIPC code.
 */

#ifndef sys_time_h
#define sys_time_h

struct timeval {
	long	tv_sec;		/* seconds */
	long	tv_usec;	/* and microseconds */
};

/*
 * Operations on timevals.
 *
 * NB: timercmp does not work for >= or <=.
 */
#define	timerisset(tvp)		((tvp)->tv_sec || (tvp)->tv_usec)
#define	timercmp(tvp, uvp, cmp)	\
	((tvp)->tv_sec cmp (uvp)->tv_sec || \
	 (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
#define	timerclear(tvp)		(tvp)->tv_sec = (tvp)->tv_usec = 0

#endif
EOF

if [ ! -f /lib/libuipc.a -a ! -f /usr/lib/libuipc.a ] ;then
	echo "Can't find the uipc library..."
	echo "Pcomm v2.0 *REQUIRES* this public domain socket emulation library"
fi
