#
# Makefile 1.18 1995/04/05 23:21:25 (David Hinds)
#

# Include site dependent options
include make.options

DIRS = modules cardmgr debug-tools 

help:
	@echo "Pick one of the following targets:"
	@echo -e "\tmake prereq\t\t- check system setup"
	@echo -e "\tmake dep\t\t- build dependencies"
	@echo -e "\tmake all\t\t- build modules and programs"
	@echo -e "\tmake install\t\t- install modules and programs"
	@echo -e "\tmake install-etc\t- install config files"
	@echo -e "\tmake install-man\t- install man pages"

prereq .prereq.ok:
	@./checkme

all:	.prereq.ok
	set -e ; for d in $(DIRS) ; do $(MAKE) -C $$d ; done

clean:
	set -e ; for d in $(DIRS) ; do $(MAKE) -C $$d clean ; done
	rm -f .prereq.ok xtra.options

dep:
	set -e ; for d in $(DIRS) ; do $(MAKE) -C $$d dep ; done

install: .prereq.ok
	set -e ; for d in $(DIRS) ; do $(MAKE) -C $$d install ; done

cardmgr/probe: .prereq.ok
	set -e ; $(MAKE) -C cardmgr probe

install-etc: .prereq.ok cardmgr/probe
	if [ -r /etc/rc.d/rc.pcmcia ] ; then \
	    TARGET=/etc/rc.d/rc.pcmcia.N ; \
	else \
	    TARGET=/etc/rc.d/rc.pcmcia ; \
	fi ; \
	sed -e s/=i82365/=`cardmgr/probe -m`/ rc.pcmcia > $$TARGET ;\
	chmod +x $$TARGET
	mkdir -p $(ETC)
	set -e ; for f in config network pcmem serial ; do \
	    if [ -r $(ETC)/$$f ] ; then \
		cp $$f.sample $(ETC)/$$f.N ; \
	    else \
		cp $$f.sample $(ETC)/$$f ; \
	    fi ; \
	done

install-man:
	set -e ; $(MAKE) -C man install
