# 
# Mach Operating System
# Copyright (c) 1992,1991,1990,1989 Carnegie Mellon University
# All Rights Reserved.
# 
# Permission to use, copy, modify and distribute this software and its
# documentation is hereby granted, provided that both the copyright
# notice and this permission notice appear in all copies of the
# software, derivative works or modified versions, and any portions
# thereof, and that both notices appear in supporting documentation.
# 
# CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
# CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
# ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
# 
# Carnegie Mellon requests users of this software to return to
# 
#  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
#  School of Computer Science
#  Carnegie Mellon University
#  Pittsburgh PA 15213-3890
# 
# any improvements or extensions that they make and grant Carnegie Mellon 
# the rights to redistribute these changes.
#
# HISTORY
# $Log:	Makefile,v $
# Revision 2.34  92/04/08  23:19:13  rpd
# 	Added ns532 to ARCHS.
# 	[92/03/26            jvh]
# 
# Revision 2.33  92/03/05  22:45:49  rpd
# 	Added mach/bootstrap.defs, mach/bootstrap.h.
# 	[92/03/02            rpd]
# 
# 	Changed for new Makefile-include organization.
# 	[92/02/28            rpd]
# 
# Revision 2.32  92/02/19  15:06:05  elf
# 	Changed source location of */exec.h files, from bootstrap to kernel.
# 	Added {mac2,i860,luna88k}/exec.h.
# 	[92/02/19            rpd]
# 	Added Makefile-mkdirs and Makefile-mklinks.
# 	Added sys/varargs.h.
# 	[92/02/10            rpd]
# 
# Revision 2.31  92/02/18  22:15:50  elf
# 	Fixed type in a level 3 rule.
# 	[92/02/18            danner]
# 
# Revision 2.30  92/02/18  17:59:24  elf
# 	Added export of motorola/m88k/m88100/thread_status.h
# 	[92/01/22  18:18:25  danner]
# 
# Revision 2.29  92/01/28  14:31:11  rpd
# 	Added mach/norma_special_ports.h, mach/norma_task.defs,
# 	and mach/vm_param.h.
# 	[92/01/28            rpd]
# 
# Revision 2.28  92/01/24  00:49:28  rpd
# 	Fixed MAKEPSD uses, to fix shadowing.
# 	Removed VPATH.
# 	[92/01/23            rpd]
# 
# Revision 2.27  92/01/23  15:19:50  rpd
# 	Revised for new Makefile organization.
# 	[92/01/16            rpd]
# 

# This makefile installs machine-independent Mach include files.

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

# Files which live in ${MAKETOP}kernel

KERNEL_1 = device/device.defs device/device_reply.defs \
	device/device_request.defs device/device_types.defs \
	device/device_types.h device/net_status.h device/tape_status.h \
	device/tty_status.h mach/boolean.h mach/boot_info.h \
	mach/error.h mach/exc.defs mach/exception.h mach/host_info.h \
	mach/kern_return.h mach/mach.defs mach/mach_host.defs \
	mach/mach_norma.defs mach/mach_param.h mach/mach_port.defs \
	mach/mach_traps.h mach/mach_types.defs mach/mach_types.h \
	mach/machine.h mach/memory_object.defs mach/memory_object.h \
	mach/memory_object_default.defs mach/message.h \
	mach/mig_errors.h mach/msg_type.h mach/notify.defs \
	mach/notify.h mach/policy.h mach/port.h mach/processor_info.h \
	mach/std_types.defs mach/std_types.h mach/syscall_sw.h \
	mach/task_info.h mach/task_special_ports.h mach/thread_info.h \
	mach/thread_special_ports.h mach/thread_status.h \
	mach/thread_switch.h mach/time_value.h mach/vm_attributes.h \
	mach/vm_inherit.h mach/vm_prot.h mach/vm_statistics.h \
	mach/norma_special_ports.h mach/norma_task.defs \
	mach_debug/hash_info.h mach_debug/ipc_info.h \
	mach_debug/mach_debug.defs mach_debug/mach_debug_types.defs \
	mach_debug/mach_debug_types.h mach_debug/vm_info.h \
	mach_debug/zone_info.h sys/varargs.h

# Files which live in ${MAKETOP}bootstrap

BOOTSTRAP_1 = mach/default_pager.defs mach/default_pager_types.defs \
	mach/default_pager_types.h mach/bootstrap.defs

# Files which live in ${MAKETOP}user/libmach

LIBMACH_0 = errorlib.h mach.h mach_error.h mach_init.h setjmp.h strings.h

# Files which live in ${MAKETOP}user/threads

THREADS_0 = cthreads.h

# 'Dummy' files which we create directly in the installation directory

STRANGE_0 = varargs.h mig_errors.h msg_type.h

STRANGE_1 = mach/mach.h mach/vm_param.h

# Files which we create in the object directory

OBJECT_1 = device/device.h device/device_reply.h \
	device/device_request.h mach/exc.h mach/mach_host.h \
	mach/mach_port.h mach/mach_interface.h \
	mach/memory_object_default.h mach/memory_object_user.h \
	mach/notify_user.h mach_debug/mach_debug.h mach/default_pager.h \
	mach/bootstrap.h

# Directories which must exist in the install/release include hierarchies

IDIRS = mach mach_debug sys device

# top-level targets
# We recurse into subdirectories for machine-dependent files.

ARCHS = mips i386 vax sun3 i860 luna88k mac2 ns532

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

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

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

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

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

# installation rules for dummy files

${INSTALLDIR}/include/mig_errors.h :
	${RM} $@
	echo '#include <mach/mig_errors.h>' > $@
	${CHMOD_INC} $@

${INSTALLDIR}/include/msg_type.h :
	${RM} $@
	echo '#include <mach/msg_type.h>' > $@
	${CHMOD_INC} $@

${INSTALLDIR}/include/varargs.h :
	${RM} $@
	echo '#include <sys/varargs.h>' > $@
	${CHMOD_INC} $@

${INSTALLDIR}/include/mach/mach.h :
	${RM} $@
	echo '#include <mach.h>' > $@
	${CHMOD_INC} $@

${INSTALLDIR}/include/mach/vm_param.h :
	${RM} $@
	echo '; DO NOT INCLUDE THIS FILE ;' > $@
	${CHMOD_INC} $@

# rules to create files in the object directory:
# These rules require that subdirectories exist in the object directory;
# the mkodirs target will create them if necessary.

MKODIRS = mach mach_debug device

.INIT :: mkodirs

# mig rules for normal kernel files

MIG_FILES = device/device.h device/device_reply.h \
	device/device_request.h mach/exc.h \
	mach/mach_host.h mach/mach_port.h mach/memory_object_default.h \
	mach_debug/mach_debug.h

${MIG_FILES} : $${@;(.*)\.h;${MAKETOP}kernel/\1.defs}
	${MIG} ${MIGFLAGS} -header $@ -user /dev/null -server /dev/null ${@;(.*)\.h;${MAKETOP}kernel/\1.defs}

# mig rules for files that don't fit the pattern

mach/mach_interface.h : ${MAKETOP}kernel/mach/mach.defs
	${MIG} ${MIGFLAGS} -header $@ -user /dev/null -server /dev/null ${MAKETOP}kernel/mach/mach.defs

mach/memory_object_user.h : ${MAKETOP}kernel/mach/memory_object.defs
	${MIG} ${MIGFLAGS} -header $@ -user /dev/null -server /dev/null ${MAKETOP}kernel/mach/memory_object.defs

mach/notify_user.h : ${MAKETOP}kernel/mach/notify.defs
	${MIG} ${MIGFLAGS} -header $@ -user /dev/null -server /dev/null ${MAKETOP}kernel/mach/notify.defs

mach/default_pager.h : ${MAKETOP}bootstrap/mach/default_pager.defs
	${MIG} ${MIGFLAGS} -header $@ -user /dev/null -server /dev/null ${MAKETOP}bootstrap/mach/default_pager.defs

mach/bootstrap.h : ${MAKETOP}bootstrap/mach/bootstrap.defs
	${MIG} ${MIGFLAGS} -header $@ -user /dev/null -server /dev/null ${MAKETOP}bootstrap/mach/bootstrap.defs

# generic rules for installing/releasing include files

include Makefile-include

# We also make 'machine' links in the install and release directories.
# We do this last so that the linked-to directories have already
# been created.

MKILINKS = include include/mach
MKRLINKS = ${MKILINKS}

preinstall :: mkilinks

install :: mkilinks

release :: mkrlinks

-include Makedep
