INSTALLDIR	=	$(HOME)/Unix/bin

all::
	@$(MAKE) utils "WHAT='Making'"

install::	$(INSTALLDIR)
	@$(MAKE) utils "ARGS=install" INSTALLDIR=$(INSTALLDIR) "WHAT='Installing'"

dist::	all cleanobj cleanbak

# This handles make'ing each of the needed utilities.  If SOURCEDIRS
# is not specified, then it dynamically lists the directories and
# uses those.
utils::
	@if [ -n "$(SOURCEDIRS)" ] ; then srcdirs=$(SOURCEDIRS); \
	else \
	    srcdirs="" ; \
	    for file in * nofiles ; do \
		if [ -r $$file/Makefile ] ; then srcdirs="$$srcdirs $$file" ; fi ; \
	    done ; \
	fi ; \
	for dir in $$srcdirs nodirs ; do \
	    if [ $$dir = nodirs ] ; then continue; fi; \
	    echo $(WHAT) $$dir ; \
	    (cd $$dir ; make $(ARGS) INSTALLDIR=$(INSTALLDIR)) \
	done;

fat::
	@$(MAKE) utils "ARGS=fat" "WHAT='Building'"

obese::
	@$(MAKE) utils "ARGS=obese" "WHAT='Building'"

sparc::
	@$(MAKE) utils "ARGS=sparc" "WHAT='Building'"

hppa::
	@$(MAKE) utils "ARGS=hppa" "WHAT='Building'"

intel::
	@$(MAKE) utils "ARGS=intel" "WHAT='Building'"

moto::
	@$(MAKE) utils "ARGS=moto" "WHAT='Building'"

strip::
	@$(MAKE) utils "ARGS=strip" "WHAT='Stripping'"

clean::
	@$(MAKE) utils "ARGS=clean" "WHAT='Cleaning'"

cleanobj::
	@$(MAKE) utils "ARGS=cleanobj" "WHAT='Cleaning'"

cleanbak::
	@$(MAKE) utils "ARGS=cleanbak" "WHAT='Cleaning'"
	rm -f *~

$(INSTALLDIR):
	mkdirs $(INSTALLDIR)
