## Makefile for random MIME support tools
##  lcs	 -- March 1998
##
## NOTE: MUST be run under GNU make (gmake) for %-rules.
## $Id: Makefile,v 1.2 1998/04/02 02:19:50 lcs Exp $

## architectures we support directly.
ARCHS=sun4x_55 sgi_53

## install target directories
INSTALLBIN=../arch/$(ATHENA_SYS)/bin
INSTALLETC=../arch/$(ATHENA_SYS)/etc
INSTALLSCRIPT=../share/scripts
INSTALLSHARE=../share

## files we install in etc:
ETCFILES=mailcap mhn_defaults

## executable names, go into bin
EXECUTABLES=applefile

## scripts, linked from share/scripts.
SCRIPTS=unbinhex guess

## things in the toplevel of share; setup scripts, usw.
SHARE=magic setup.csh setup.sh

## files we link from the share directory

all: tools

clean:
	-rm -f $(EXECUTABLES)

tools: $(EXECUTABLES) $(SCRIPTS)

# deploy the build products
install: all $(ETCFILES:%=$(INSTALLETC)/%)
	for name in $(SCRIPTS) ; do \
	    cp $$name $(INSTALLSCRIPT) ; \
	    rm $(INSTALLBIN)/$$name || true; \
	    ln -s ../../../share/scripts/$$name $(INSTALLBIN) ; \
	    done
	cp $(EXECUTABLES) $(INSTALLBIN)
	cp $(SHARE) $(INSTALLSHARE)

# deploy the build products in a test hierarchy
test:
	$(MAKE) INSTALLBIN=../test/arch/$(ATHENA_SYS)/bin \
	    INSTALLETC=../test/arch/$(ATHENA_SYS)/etc \
	    INSTALLSCRIPT=../test/share/scripts \
	    INSTALLSHARE=../test/share \
	    install

## splice together mailcap files from common and platform-specific elements.
$(INSTALLETC)/mailcap: mailcap-common mailcap-$(ATHENA_SYS)
	cat mailcap-$(ATHENA_SYS) mailcap-common > $@

$(INSTALLETC)/mhn_defaults: $(INSTALLETC)/mailcap mhn_defaults_prefix
	grep -v '^#' mhn_defaults_prefix > $@
	./mailcap2mhn < $(INSTALLETC)/mailcap >> $@

applefile.c: applefile.h

applefile: applefile.c
