#
# Mach Operating System
# Copyright (c) 1989 Carnegie-Mellon University
# All rights reserved.  The CMU software License Agreement specifies
# the terms and conditions for use and redistribution.
#  
# HISTORY
# $Log:	Makefile,v $
# Revision 2.15  92/04/08  23:18:35  rpd
# 	Fixed to do crt0.o early.
# 	[92/04/01            rpd]
# 
# 	Added cross-compilation support.
# 	[92/03/19            jvh]
# 
# Revision 2.14  92/03/05  22:45:09  rpd
# 	Changed to use double-colon rules.
# 	[92/02/28            rpd]
# 
# Revision 2.13  92/02/19  15:05:46  elf
# 	Added Makefile-subdirs and Makefile-mkdirs.
# 	[92/02/10            rpd]
# 
# Revision 2.12  92/01/27  16:42:46  rpd
# 	Changed recursive make commands to use '+'.
# 	[92/01/27            rpd]
# 
# Revision 2.11  92/01/24  00:49:15  rpd
# 	Changed to use RECURSE_TEMPLATE.
# 	[92/01/23            rpd]
# 
# Revision 2.10  92/01/23  15:19:31  rpd
# 	Revised for new Makefile organization.
# 	[92/01/16            rpd]
# 

include ${MAKETOP}Makefile-common
# more definitions, for recursive makes
include ${MAKETOP}Makefile-subdirs
# more definitions, for mkodirs/mkidirs/mkrdirs
include ${MAKETOP}Makefile-mkdirs

# RECURSE_TEMPLATE normally creates subdirectories itself before cd'ing
# into them, but in our case it needs a little help because we do the
# directories in a strange order. The mkodirs target will create
# these if necessary.

MKODIRS = kernel kernel/src user

# These subdirectories must exist in the host install/release directories.
# The mkhidirs and mkhrdirs targets will create them.

MKHIDIRS = include bin lib etc man man/man1 man/man2 man/man3
MKHRDIRS = ${MKHIDIRS}

# These subdirectories must exist in the install/release directories.
# The mkidirs and mkrdirs targets will create them.

MKIDIRS = ${MKHIDIRS} special
MKRDIRS = ${MKIDIRS}

.INIT :: mkodirs

all :: install

# Order is important: we must install some include files, then do mig,
# finish the include files, then libraries, bootstrap, kernel.

DIRS = kernel/src/mig include user user/libmach user/threads bootstrap \
	kernel/src/doconf kernel/src/config kernel/src/makeboot kernel

RECURSE = ${RECURSE_TEMPLATE/RECURSE_DIRS/${DIRS}}

# Before we can even compile mig, we need to install include files
# (that don't require mig) and create crt0.o (in case we are not
# cross-compiling and our crt0.o will be used by mig).

INCLUDE_RECURSE = ${RECURSE_TEMPLATE/RECURSE_DIRS/include}
LIBMACH_RECURSE = ${RECURSE_TEMPLATE;RECURSE_DIRS;user/libmach}

install :: mkidirs mkhidirs
	+${INCLUDE_RECURSE/RECURSE_TARGET/preinstall}
	+${LIBMACH_RECURSE;RECURSE_TARGET;$(INSTALLDIR)/lib/crt0.o}
	+${RECURSE/RECURSE_TARGET/install}

release :: mkrdirs mkhrdirs
	+${RECURSE/RECURSE_TARGET/release}

clean ::
	+${RECURSE/RECURSE_TARGET/clean}

-include Makedep
