#
# P_R_P_Q_# (C) COPYRIGHT IBM CORPORATION 1987,1988
# LICENSED MATERIALS - PROPERTY OF IBM
# REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
#
# $Header: Makefile_ca,v 12.1 88/11/19 16:53:42 ericm Exp $ 
# $Source: /ibm/acis/usr/src/include/RCS/Makefile_ca,v $ 
#
# Doing a make install builds /usr/include
#
# Define SHARED to indicate whether you want
# symbolic links to the system source (``symlinks''),
# or a separate copy (``copies'').
# (latter useful in environments where it's
# not possible to keep /sys publicly readable)
#
# Define SYSDIR to be the location of the system sources
# directory.  Usually this will just be /sys, but in cross-machine
# development it could be something else (such as /acis/sys).
#
# The ``rm -rf''s used below are safe because rm doesn't
# follow symbolic links.
#
DESTDIR=
SYSDIR=/sys
SUBDIRS=arpa pascal protocols
IDIRS=	${DESTDIR}/usr/include/arpa \
	${DESTDIR}/usr/include/pascal \
	${DESTDIR}/usr/include/protocols
STD=	a.out.h ar.h assert.h ctype.h curses.h ndbm.h debug.h disktab.h \
	fcntl.h fstab.h grp.h ieee.h lastlog.h math.h memory.h mntent.h mp.h mtab.h \
	netdb.h nlist.h pwd.h ranlib.h resolv.h setjmp.h \
	sgtty.h stab.h stdio.h string.h strings.h struct.h \
	sysexits.h time.h ttyent.h utmp.h varargs.h vfont.h time.h tzfile.h

# OTHERPLACES was a symbolic link in /usr/src/include the ucb version.
OTHERPLACES=/usr/src/usr.lib/libcurses/curses.h
LINKS=	errno.h signal.h syslog.h syscall.h
MACHINE=ca
MACHDEP=${MACHINE} caif caio cacons
NETDIRS=net netimp netinet netns
NFSDIRS=ufs nfs rpc
AFSDIRS=afs afsint
SYSDIRS=${NETDIRS} sys stand stand${MACHINE} ${NFSDIRS} \
	${MACHDEP} ${AFSDIRS} rpcsvc dfs
RPCDIRS=yp
SHARED=	symlinks
TAGSFILE=tags

all:

install: ${SHARED} ${IDIRS}
	for i in ${STD}; do \
		install -c -m 444 $$i ${DESTDIR}/usr/include/$$i; \
	done
	for i in ${OTHERPLACES}; do \
		install -c -m 444 $$i ${DESTDIR}/usr/include/`basename $$i`; \
	done
	for i in ${SUBDIRS}; do \
		(cd $$i; for j in *.[ih]; do \
			install -c -m 444 $$j ${DESTDIR}/usr/include/$$i/$$j; \
		done); \
	done
	for i in ${RPCDIRS}; do \
		(cd ../lib/libc/$$i; \
		make ${MFLAGS} install DESTDIR=${DESTDIR} );\
	done
	for i in ${LINKS}; do \
		rm -f ${DESTDIR}/usr/include/$$i; \
		ln -s sys/$$i ${DESTDIR}/usr/include/$$i; \
	done
	for i in "" io if cons; do \
		rm -f ${DESTDIR}/usr/include/machine$$i; \
		ln -s ./${MACHINE}$$i ${DESTDIR}/usr/include/machine$$i; \
	done
	rm -f ${DESTDIR}/usr/include/frame.h
	ln -s machine/frame.h ${DESTDIR}/usr/include/frame.h

${IDIRS}:
	mkdir $@

symlinks:
	for i in ${SYSDIRS}; do \
		rm -rf ${DESTDIR}/usr/include/$$i; \
		ln -s /sys/$$i ${DESTDIR}/usr/include/$$i; \
	done
	rm -rf ${DESTDIR}/usr/include/sys
	ln -s ${SYSDIR}/h ${DESTDIR}/usr/include/sys

copies:
	for i in ${SYSDIRS}; do \
		rm -rf ${DESTDIR}/usr/include/$$i; \
		cd /sys; \
		tar cf - $$i/*.h | (cd ${DESTDIR}/usr/include; tar xpfB -); \
	done
	rm -rf ${DESTDIR}/usr/include/sys;
	mkdir ${DESTDIR}/usr/include/sys; 
	chmod 775 ${DESTDIR}/usr/include/sys;
	(cd ${SYSDIR}/h; tar cf - *.h | (cd ${DESTDIR}/usr/include/sys; tar xpf -))

tags:
	cwd=/usr/include; \
	for i in ${STD} ${LINKS}; do \
		ctags -a -f ${TAGSFILE} $$cwd/$$i; \
	done

clean:
	rm -f tags
