##
#	version: $Id: Makefile,v 5.124 1995/01/18 01:35:10 hitman Exp $ 
#	updates: All updates are handled by RCS 
# 	Author: The Hitman 1994	
#

# System Dependent configurations and Installation information
include sys_config

## Other Information -----------------------------------
PROG = bbs_script_fn
VERSION = version.h
PROGS = $(PROG) menu_edit
SUB_DIRECTORIES = NONE

OBJS__menu_edit = \
	menu_edit.o \
	dis_version.o \
	menu_data_filename.o \
	menu_text_filename.o

OBJS__bbs_script_fn = \
	check_speed.o \
	set_up_env.o \
	is_bbs_running.o \
	dis_screen.o \
	pause.o \
	menu_data_filename.o \
	header_filename.o \
	header_rnd_filename.o \
	help_filename.o \
	dis_menu.o \
	interp_from_menu.o \
	dis_filename.o \
	get_menu_info.o \
	my_random.o \
	hshgen_k.o \
	get_comm.o \
	goodbye.o \
	interpre.o \
	redraw_screen.o \
	error_handle.o \
	command_not_found.o \
	show_prompt.o \
	shell_display.o \
	login.o


OBJS__read_menu = \
	read_menu_main.o \
	menu_data_filename.o

# Don't forget to update the line below that looks for the depends (search: depends)
OBJS = \
	$(OBJS__read_menu) \
	$(OBJS__bbs_script_fn)

HEADER = \
	bbs_director.h \
	menu_info.h \
	hsh_glob.h \
	hshgen_s.h \
	hshgen_h.h \
	control.h \
	functbl.h \
	finite_kernel_version.h \
	statetbl.h \
	$(VERSION)


all: $(VERSION) depends $(PROGS)

#--------------------------------------
menu_edit: $(HEADER) $(OBJS__menu_edit)
	$(CC) $(FIN_OPT) $(OBJS__menu_edit) $(LIB) -o menu_edit

#--------------------------------------
read_menu: $(HEADER) $(OBJS__read_menu)
	$(CC) $(FIN_OPT) $(OBJS__read_menu) $(LIB) -o read_menu

#--------------------------------------
bbs_script_fn: $(HEADER) $(OBJS__bbs_script_fn)
	$(CC) $(FIN_OPT) $(OBJS__bbs_script_fn) $(LIB) -o bbs_script_fn

help: help/help.txt help/lockout.txt
	@echo "Making help screen..."
	@groff help/help.txt > screen/help.screen
	@echo "Making lockout screen..."
	@groff help/lockout.txt > screen/lockout.screen
	@head -15 screen/lockout.screen > temp ; mv temp  screen/lockout.screen

# The Function Table
functbl.h: control.h
	@echo "Updating the function table..."
	@grep "^#d" control.h | grep -v "__" > functbl.h

#--------------------------------------
#	Version information
#		This gets compiled into your programs.  This is some what
#		system dependend, but basic commands are used.
#
$(VERSION): ver
	@echo "Updating $(VERSION)..."
	@echo "/* DO NOT EDIT, USE: make $(VERSION) */" > $(VERSION) 
	@echo "/* file: version.h */" >> $(VERSION)
	@echo "/* purpose: inform user of version */" >> $(VERSION)
	@echo "#define CCVER		\"`$(CCVER)`\"" >> $(VERSION) 
	@echo "#define PROGRAM		\"$(PROG)\"" >> $(VERSION)
	@echo "#define OSVER		\"`uname -sr`\"" >> $(VERSION)
	@echo "#define COPYRIGHT	\"1993-94 GNU General Software License\"" >> $(VERSION)
	@echo "#define VER			\"`cat ver`, b$(BASELINE)\"" >> $(VERSION) 
	@echo "#define COMPBY		\"`whoami`\"" >> $(VERSION)
	@echo "#define SUPPORT_ADDRESS		\"$(SUPPORT_ADDRESS)\"" >> $(VERSION)
	@echo "/* End-Of-$(VERSION) */" >> $(VERSION)

# clean gets all objects, junk, and creatable headers.
clean:
	@rm -rf $(OBJS) *.o core *.out $(PROGS) *.*~ version.h functbl.h *.BAK

#--------------------------------------
#       Updates the end of this makefile, user still has to clean out the
#               older version of the update.
#
depends: $(HEADER)
	@echo "Updating the dependents..."
	@cp /dev/null .depends
	@if [ "$(UPDAT_OPT)" != "NONE" ]; then \
		for NAME in $(OBJS__bbs_script_fn:.o=.c) $(OBJS__menu_edit:.o=.c) $(OBJS__read_menu:.o=.c); \
		do \
			if [ -f $$NAME ]; then \
				$(CC) $(UPDAT_OPT) $$NAME >> .depends ; \
			fi ; \
		done ; \
	fi
	@if [ "$(SUB_DIRECTORIES)" != "NONE" ]; then \
		for DIRECT in $(SUB_DIRECTORIES) ; \
		do \
			cp /dev/null $$DIRECT/.depends ; \
			cd $$DIRECT ; ${MAKE} depends ; cd .. ; \
		done ; \
	fi

#--------End of Documentation----------
include .depends
