# 
# 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 
# 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 the
# rights to redistribute these changes.
# 
#
# HISTORY
# $Log:	Makefile-bin,v $
# Revision 2.3  92/03/05  22:47:15  rpd
# 	Changed to use double-colon rules for top-level targets.
# 	Moved man page rules to Makefile-man.
# 	[92/02/28            rpd]
# 
# Revision 2.2  92/01/22  23:17:53  rpd
# 	Created.
# 	[92/01/17            rpd]
# 

# Makefile-bin is intended for simple binaries.
# Makefiles using it should look like
#
#	include ${MAKETOP}Makefile-common
#
#	PROGRAM = foo
#
#	OBJECTS = foo.o bar.o
#	LIBRARIES = SERVERS MACH WHATEVER
#
#	include ${MAKETOP}Makefile-bin
#	-include Makedep
#
# For each library (eg, WHATEVER) Makefile-common (or the Makefile itself)
# should define ${LIBWHATEVER} as what's given to ld and define ${DEPWHATEVER}
# as what's used to generate a dependency on the library.  For example,
#	LIBWHATEVER = -lwhatever
#	DEPWHATEVER = ${DEP_TEMPLATE/NAME/libwhatever.a}
# or
#	DEPWHATEVER =
# if a dependency on the library is not desired.
#
# If for some reason the binary should be installed in a directory
# other than bin/, the Makefile can redefine BINDIR.
# (Its normal definition is in Makefile-common.)
#
# Makefile-man can be used to install man pages associated with the binary.

IBINTARGET = ${INSTALLDIR}/${BINDIR}${PROGRAM}

TBINTARGET = ${TRELEASEDIR}/${BINDIR}${PROGRAM}

FBINTARGET = ${FRELEASEDIR}/${BINDIR}${PROGRAM}

# Top-level targets:
# If the Makefile wants to do more stuff, it can also have its own
# all/install/release/clean rules.

all :: ${PROGRAM}

install :: ${IBINTARGET}

release :: ${TBINTARGET}

clean ::
	${RM} ${IBINTARGET}

# installation rules

${IBINTARGET} : ${PROGRAM}
	${RM} $@
	${CP} $? $@
	${STRIP} $@
	${CHMOD_BIN} $@

# release rules

${TBINTARGET} : ${FBINTARGET}
	${RM} $@
	${CP} $? $@

# build rules

LIBS = ${LIBRARIES/.*/${LIB&}}
DEPS = ${LIBRARIES/.*/${DEP&}} ${DEPCRT0}

${PROGRAM} : ${OBJECTS}
	${RM} $@ $@.out
	${DEPS/%/$@} ${CC} -o $@.out ${CFLAGS} ${OBJECTS} ${LIBS} && \
	${MV} $@.out $@
