# 
# Mach Operating System
# Copyright (c) 1992 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-mkdirs,v $
# Revision 2.4  92/04/08  23:26:58  rpd
# 	Added mkhidirs and mkhrdirs.
# 	[92/03/23            rpd]
# 
# Revision 2.3  92/03/05  22:47:24  rpd
# 	Changed to use double-colon rules for top-level targets.
# 	[92/02/28            rpd]
# 
# Revision 2.2  92/02/15  19:34:16  rpd
# 	Created from Makefile-common.
# 	[92/02/10            rpd]
# 

# Makefile-mkdirs has definitions and rules useful to Makefiles
# which must create subdirectories (or rely on subdirectories existing)
# in the object, install, or release directories.
#
# Using direct dependencies on directories to create directories is
# unwise, because when the modtime of the directory changes things
# will be unnecessarily remade.  It would be nice if make had a syntax
# for depending on the existence of a directory/file, but it doesn't.


# The mkodirs target can be used to create subdirectories
# in the object directory.  It is normally used with
#
#	MKODIRS = ...
#
#	.INIT :: mkodirs

mkodirs ::
	+@-for dir in ${MKODIRS}; do \
	  [ -d $$dir ] || \
	  { echo "mkdir $$dir"; mkdir $$dir; } \
	done

# The mkidirs target can be used to create subdirectories
# in the install directory.  It is normally used with
#
#	MKIDIRS = ...
#
#	install :: mkidirs ...

mkidirs ::
	@-[ -d ${INSTALLDIR} ] || \
	  { echo "mkdir ${INSTALLDIR}"; mkdir ${INSTALLDIR}; }
	@-for dir in ${MKIDIRS;.*;${INSTALLDIR}/&}; do \
	  [ -d $$dir ] || \
	  { echo "mkdir $$dir"; mkdir $$dir; } \
	done

# The mkrdirs target can be used to create subdirectories
# in the release directory.  It is normally used with
#
#	MKRDIRS = ${MKIDIRS}
#
#	release :: mkrdirs ...

mkrdirs ::
	@-[ -d ${TRELEASEDIR} ] || \
	  { echo "mkdir ${TRELEASEDIR}"; mkdir ${TRELEASEDIR}; };
	@-for dir in ${MKRDIRS;.*;${TRELEASEDIR}/&}; do \
	  [ -d $$dir ] || \
	  { echo "mkdir $$dir"; mkdir $$dir; } \
	done

# The mkhidirs and mkhrdirs targets are similar, except
# that they use HOST_INSTALLDIR and HOST_TRELEASEDIR.

mkhidirs ::
	@-[ -d ${HOST_INSTALLDIR} ] || \
	  { echo "mkdir ${HOST_INSTALLDIR}"; mkdir ${HOST_INSTALLDIR}; }
	@-for dir in ${MKHIDIRS;.*;${HOST_INSTALLDIR}/&}; do \
	  [ -d $$dir ] || \
	  { echo "mkdir $$dir"; mkdir $$dir; } \
	done

mkhrdirs ::
	@-[ -d ${HOST_TRELEASEDIR} ] || \
	  { echo "mkdir ${HOST_TRELEASEDIR}"; mkdir ${HOST_TRELEASEDIR}; };
	@-for dir in ${MKHRDIRS;.*;${HOST_TRELEASEDIR}/&}; do \
	  [ -d $$dir ] || \
	  { echo "mkdir $$dir"; mkdir $$dir; } \
	done
