# $Id: Makefile,v 1.13 2000/01/14 14:15:17 toshi Exp $

# SRC should be used only in 'backup-sys'.
# otherwise we will not be able to override SYS.
SRC=	/usr/src
SYS=	$(SRC)/sys

# safety sentinel
.TARGET:	msg

msg:
	@echo "welcome to PAO world!  read documents first."

all: kernel userland

kernel: backup-sys patch install-include

userland: devices tools install-tools

backup-sys:
	rm -rf $(SRC)/sys.ORG && mkdir -p $(SRC)/sys.ORG
	cd $(SYS) && tar cf - . | tar xf - -C $(SRC)/sys.ORG

restore-sys:
	rm -rf $(SYS) && mkdir -p $(SYS)
	cd $(SRC)/sys.ORG && tar cf - . | tar xf - -C $(SYS)

patch:
	cd $(SYS) && patch -p3 -E < $(.CURDIR)/sys/sys-pao.diff

install-include:
	cd $(SYS)/i386/include && \
	    ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 \
		apm_bios.h clock.h cpu.h if_cnwioctl.h scc.h wavelan.h \
			${INCLUDEDIR}/machine/
	rm -f ${INCLUDEDIR}/pccard/*.h
	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 \
		$(SYS)/pccard/*.h ${INCLUDEDIR}/pccard/

devices:
	cd /dev && sh MAKEDEV card0 card1 card2 card3

tools:
	(cd $(.CURDIR)/usr.sbin; make SYS=$(SYS))

install-tools: tools
	(cd $(.CURDIR)/usr.sbin; make SYS=$(SYS) install)

install-etc:
	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 0644 \
	    etc/rc.pccard etc/etc.i386/disktab /etc/
	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 0755 \
	    etc/pccard_ether etc/pccard_ether_remove etc/pccard_scsi /etc/
	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 0644 \
	    etc/pccard.conf.sample /etc/pccard.conf
	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 0644 \
	    etc/defaults/rc.conf /etc/defaults/
	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 0755 \
	    etc/etc.i386/MAKEDEV /dev/

clean:
	(cd $(.CURDIR)/usr.sbin; make SYS=$(SYS) clean)
	rm -f *~