#	$NetBSD: Makefile,v 1.13 1999/01/28 19:05:43 scottr Exp $
#
# Makefile for export-restricted sources.  This hierarchy shouldn't make
# it outside of the US.

.if defined(NBUILDJOBS)
_J= -j${NBUILDJOBS}
.endif

SUBDIR+= include
SUBDIR+= lib bin libexec sbin usr.bin usr.sbin

beforeinstall:
.ifndef _SLAVE_BUILD
.ifmake build
	@echo -n "Domestic build started at: "
	@date
.endif
.ifndef DESTDIR
	(cd ${.CURDIR}/../etc && ${MAKE} DESTDIR=/ distrib-dirs)
.else
	(cd ${.CURDIR}/../etc && ${MAKE} distrib-dirs)
.endif
.endif

afterinstall:
.if !defined(NOMAN) && !defined(NOSHARE) && !defined(_SLAVE_BUILD)
	(cd ${.CURDIR}/../share/man && ${MAKE} makedb)
.endif

build: beforeinstall
.ifndef EXPORTABLE_SYSTEM
.if !defined(DESTDIR) || (${DESTDIR} == "/" || empty(DESTDIR))
.if exists(${.CURDIR}/usr.bin/compile_et)
	(cd ${.CURDIR}/usr.bin/compile_et && ${MAKE} cleandir && \
	    ${MAKE} depend && ${MAKE} ${_J} NOMAN= && ${MAKE} NOMAN= install)
.endif
.if exists(${.CURDIR}/usr.bin/make_cmds)
	(cd ${.CURDIR}/usr.bin/make_cmds && ${MAKE} cleandir && \
	    ${MAKE} depend && ${MAKE} ${_J} NOMAN= && ${MAKE} NOMAN= install)
.endif
.endif
.if !defined(UPDATE) && !defined(_SLAVE_BUILD)
	${MAKE} cleandir
.endif
	${MAKE} includes
# libtelnet depends on libdes and libkrb.  libkrb depends on
# libcom_err.
.if exists(${.CURDIR}/lib/libdes)
	(cd ${.CURDIR}/lib/libdes && \
	    ${MAKE} depend && ${MAKE} ${_J} NOMAN= && ${MAKE} NOMAN= install)
.endif
.if exists(${.CURDIR}/lib/libcom_err)
	(cd ${.CURDIR}/lib/libcom_err && \
	    ${MAKE} depend && ${MAKE} ${_J} NOMAN= && ${MAKE} NOMAN= install)
.endif
.if exists(${.CURDIR}/lib/libkrb)
	(cd ${.CURDIR}/lib/libkrb && \
	    ${MAKE} depend && ${MAKE} ${_J} NOMAN= && ${MAKE} NOMAN= install)
.endif
	(cd ${.CURDIR}/lib && \
	    ${MAKE} depend && ${MAKE} ${_J} NOMAN= && ${MAKE} NOMAN= install)
	${MAKE} depend && ${MAKE} ${_J} && ${MAKE} install
.ifndef _SLAVE_BUILD
	@echo -n "Domestic build finished at: "
	@date
.endif
.endif

.include <bsd.subdir.mk>
