##
# version: [$Id: Makefile,v 5.123 1995/01/18 01:21:59 hitman Exp $]
# updates: All updates are handled by RCS 
# Author: The Hitman 1994	
#

# Installation and baseline information
include src/sys_config

PROGS = bbs_script_fn menu_edit
SEGMENTS = bbs compiler
all: depends $(SEGMENTS)

# Install the program and go from there.
#
# I should make this a script and run the script as the install program.
# the following in very confusing.
#
install: install_database all
	@mkdir -p $(DIR)
	@echo "Installing The 'No-Name BBS System'...\c"
	@tar cf - `cat install_database` | (cd ${DIR} ; tar xf - ) 2> /dev/null
	@for FILE in README.bbs-$(BASELINE) bbs-$(BASELINE)-src.lsm ; \
	do \
		if [ -f $$FILE ]; then \
			cp -f $$FILE $(DIR)/ ; \
		fi ; \
	done 
	@echo "...DONE!"
	@make permissions

permissions:
	@echo "Setting Up Permissions..."
	@sh -c " cd $(DIR) ; \
	chmod 444 main.dat ; \
	chmod 555 $(PROGS) ; \
	if [ -f README.bbs ]; then \
		$(NROFF) README.bbs > README.bbs-$(BASELINE) ; \
	fi ; \
	if [ -f bbs--src.lsm ]; then \
		mv -f bbs--src.lsm bbs-$(BASELINE)-src.lsm ; \
	else \
		echo \"Couldn't find file.\" ; \
	fi ; \
	rm -f README.bbs "
	
	@echo "Install Complete -------------------"

depends:
	@cd src ; cp /dev/null .depends ; make depends

bbs: 
	@if [ -f ./bbs_script_fn ]; then  \
		mv -f ./bbs_script_fn ./bbs_script_fn~ ;\
	fi
	@cd src ; make bbs_script_fn ; cd ..
	@cp src/bbs_script_fn .

compiler:
	@if [ -f ./menu_edit ]; then  \
		mv -f ./menu_edit ./menu_edit~ ;\
	fi
	@cd src ; make menu_edit ; cd ..
	@cp src/menu_edit .

config:
	@(cd src ; sh ./Configure)
	@echo "You have everything configured now, please type 'make install' to install the rest the program"

clean:
	@rm -f $(PROGS) *.out
	@cd src ; make clean ; cd ..
