#
# Copyright 1987 Apple Computer, Inc.
# $Header: makefile,v 1.25 88/09/06 10:40:01 root Exp $
#
# $Log:	makefile,v $
# Revision 1.25  88/09/06  10:40:01  root
# Took out toolbox version stuff
# 
# Revision 1.24  88/07/21  23:56:40  rpd
# make install was not cleaning up /tmp/tb
# 
# Revision 1.23  88/06/30  23:47:41  rpd
# Fixed boo boo in make install
# 
# Revision 1.22  88/06/30  23:04:48  rpd
# Fixed up make install for the build.
# 
# Revision 1.21  88/06/16  12:38:15  rpd
# Redid the installation procedure to fit into Malcolm's stuff better.
# 
# Revision 1.20  88/04/17  14:33:41  rpd
# Added SYSFOLDER variable.
# 
# Revision 1.19  87/10/09  11:48:51  rpd
# Now, make install creates toolbox.version
# 
# Revision 1.18  87/09/03  20:53:26  rpd
# Now, make install only creates one cpio archive.
# 
# Revision 1.17  87/06/27  03:00:27  rpd
# Removed /usr/bin from list of directories to create in make install.
# This was only needed for screenrestore which died long ago.
# 
# Revision 1.16  87/06/18  00:32:04  rpd
# Added text directory
# 
# Revision 1.15  87/06/13  12:55:44  rpd
# Added some useful comments
# 
# Revision 1.14  87/06/13  01:08:25  rpd
# Added launch directory
# Added kludge to rm tl after everything get dones.  This leaves two links
# of tl; one for rez and one for derez.  Eventually, these will actually be
# links to launch and tl will be out of business.
# 
# Revision 1.13  87/06/11  01:51:00  rpd
# Added /usr/lib/mac/examples/term to list of directories to install
# 
# Revision 1.12  87/05/27  01:13:11  rpd
# in make install, moved *.h into tb2.cpio so both will fit on floppies
# 
# Revision 1.11  87/05/22  14:07:57  rpd
# Added /usr/lib/mac/examples
# 
# Revision 1.10  87/04/11  19:03:40  rpd
# Beefed up make install.  Now it creates seperate cpio files to be placed
# on different floppies.
# 
# Revision 1.9  87/04/02  17:50:42  rpd
# Killed install of /usr/local and /usr/local/bin
# Added /usr/bin and /usr/toolboxbin
# 
# Revision 1.8  87/04/02  13:40:20  rpd
# Added nasty hack to builing or libmac.a so that we can circumven some
# of the bugs in ar and ld.
# 
# Revision 1.7  87/04/01  15:03:19  rpd
# Added etc to make install
# 
# Revision 1.6  87/03/31  22:10:48  rpd
# Added /usr/local/bin to make install
# 
# Revision 1.5  87/03/13  16:05:06  rpd
# Fixed permissions on created directories
# 
# Revision 1.4  87/03/13  01:46:33  rpd
# Added data directory
# Moved installation of uinter0 into data
# Pulled low.o out of list of files to stuff into libmac.a
# Moved libmac.a from /usr/lib/mac into /usr/lib
# 
# Revision 1.3  87/03/12  18:03:19  rpd
# Added inc to list of directories
# Removed make cpio
# Added make install
# 
# Revision 1.2  87/01/19  21:26:41  rpd
# added MAIN_DIR
# 
# Revision 1.1  87/01/15  23:01:23  rpd
# Initial revision
# 

# This is the top level makefile for the UNIX toolbox software.

# To clean out all object code, etc., use "make clean"
# To rebuild everything, use "make all" or just "make"
# To run some simple tests, use "make test"
# To do an installation, use "make install".  This will leave a cpio archive
#	in /tmp with a name begining with "toolbox."

# There are also three entries used by the global build procedure:

# "make pass1" will install all directories, include, text, and data files.
#	This pass does not depend on any external files.
# "make pass2" will build and install libmac.a and /usr/lib/maccrt0.o
#	This pass depends on various include files, but it does not depend
#	on any object files.
# "make pass3" will build and install all executables.
#	This pass depends on things like libc.a, libat.a, /usr/lib/maccrt0.o
#	and /usr/lib/low.ld

# ***NOTE:***
# This package is one of those annoying software packages that must be
# installed before it can be recompiled.  This is because the rez utility
# is used to compile resource files.  Someday this may change, but
# don't count on it.

MAIN_DIR =	.
include make.global

PASS1 =		tools inc text data
PASS2 =		wrappers lib
PASS3 =		launch tests misc
DIRS =		${PASS1} ${PASS2} ${PASS3}
INS_DIR =	/tmp

all:
	for i in ${DIRS}; do \
	    cd $$i; \
	    make all; \
	    cd ..; \
	done

clean:
	for i in ${DIRS}; do \
	    cd $$i; \
	    make clean; \
	    cd ..; \
	done

test:
	for i in ${DIRS}; do \
	    cd $$i; \
	    make test; \
	    cd ..; \
	done

install:	pass1 pass2 pass3
	cd ${INS_DIR}/tb; \
	find . ! -type d -print | cpio -o > ${INS_DIR}/toolbox.cpio;
	rm -rf ${INS_DIR}/tb

pass1:
	for i in ${PASS1}; do \
	    cd $$i; \
	    make all; \
	    cd ..; \
	done
	rm -rf ${INS_DIR}/tb
	mkdir ${INS_DIR}/tb
	${INSTALL} -t d -p 0755 etc usr usr/toolboxbin usr/lib \
		${SYSFOLDER} ${SYSFOLDER}/examples ${SYSFOLDER}/examples/term \
		${SYSFOLDER}/rincludes usr/include usr/include/mac \
		${INS_DIR}/tb
	for i in ${PASS1}; do \
	    cd $$i; \
	    make install DESTPATH=${INS_DIR}/tb; \
	    cd ..; \
	done

pass2:
	for i in ${PASS2}; do \
	    cd $$i; \
	    make all; \
	    cd ..; \
	done
	for i in ${PASS2}; do \
	    cd $$i; \
	    make install DESTPATH=${INS_DIR}/tb; \
	    cd ..; \
	done
	rm -rf tmp
	mkdir tmp
	cd tmp; \
	ar x ../lib/shared.a; \
	ar x ../wrappers/wrappers.a; \
	ar cr libmac.a *; \
	ar d libmac.a mpwlib.o; \
	ar r libmac.a mpwlib.o; \
	mv libmac.a ..
	${INSTALL} libmac.a ${INS_DIR}/tb/usr/lib;
	rm -rf libmac.a tmp

pass3:
	for i in ${PASS3}; do \
	    cd $$i; \
	    make all; \
	    cd ..; \
	done
	for i in ${PASS3}; do \
	    cd $$i; \
	    make install DESTPATH=${INS_DIR}/tb; \
	    cd ..; \
	done

