#
# makefile for shelllib.o
#
LIBS 		=  	-lm -ltermcap
CPP 		= 	/lib/cpp
CFLAGS 		= 	-g  -DNEW -DNLIST_BUG -DTERMIO -D$(MACHINE) $(DEC_HACK)
SYS  		= 	../sys
DHB		= 	../ss
SIMINCLUDE 	= 	-I. -I$(SYS) -I$(DHB)
INSTALL_DIR =	$(INSTALL)
INSTALL_LIB 	= 	$(INSTALL_DIR)/lib
INSTALL_INCLUDE	= 	$(INSTALL_DIR)/include
INSTALL_STARTUP	= 	$(INSTALL_DIR)/startup
LIBRARY_NAME 	= 	shell
FUNCTIONS 	= 	shellfuncs
EXT_HEADER	=	shell_ext.h
TARGET_OBJ	=	shelllib.o

default: $(TARGET_OBJ)

OBJECTS =	\
		shell_argv.o \
		shell_batch.o \
		shell_convert.o \
		shell_char.o \
		shell_debug.o \
		shell_edit.o \
		shell_env.o \
		shell_error.o \
		shell_esc.o \
		shell_exec.o \
		shell_func.o \
		shell_hash.o \
		shell_history.o \
		shell_info.o \
		shell_io.o \
		shell_job.o \
		shell_lib.o \
		shell_load.o \
		shell_log.o \
		shell_misc.o \
		shell_numeric.o \
		shell_ops.o \
		shell_prompt.o \
		shell_script.o \
		shell_setup.o \
		shell_sh.o \
		shell_status.o \
		shell_string.o \
		shell_sys.o \
		shell_tty.o 


HEADERS = 	\
		shell.h \
		shell_struct.h

.c.o:
	$(CC) $(CFLAGS) $(SIMINCLUDE) $< -c 

# $(OBJECTS) : $(HEADERS)

# make the function list section of the symbol table

$(LIBRARY_NAME)_f@.c : $(FUNCTIONS) $(SYS)/code_func
	- $(SYS)/code_func $(FUNCTIONS) $(LIBRARY_NAME) \
	  > $(LIBRARY_NAME)_f@.c

SYMBOLTAB = $(LIBRARY_NAME)_f@.o 

$(TARGET_OBJ): $(OBJECTS)  $(SYMBOLTAB)
	ld -r -o $(TARGET_OBJ) $(OBJECTS) $(SYMBOLTAB) -ltermcap

demo: interp_demo.o $(TARGET_OBJ) ../sys/utillib.o ../shell/shelllib.o
	$(CC) interp_demo.o $(TARGET_OBJ) \
	../shell/shellib.o ../sys/utillib.o -o demo $(LIBS)

install: $(TARGET_OBJ)
	-(cp $(TARGET_OBJ) $(INSTALL_LIB))
	-(cp *.h $(INSTALL_INCLUDE))
	-(cp *.g $(INSTALL_STARTUP))

clean: 
	-(rm -rf *.o *@.c)

