# $Id: Makefile,v 1.5 1993/07/17 00:37:43 dhb Exp $
# $Log: Makefile,v $
# Revision 1.5  1993/07/17  00:37:43  dhb
# Separate clean and rcsclean targets
#
# Revision 1.4  1993/07/01  15:58:47  dhb
# Added RCSRELEASE stuff
#
# Revision 1.3  1993/02/12  17:34:23  dhb
# added freeze target to create rcs configurations
# added rcsclean to clean target
# both targets ensure .h .g Makefile and funcs files exist
#
# Revision 1.2  1992/12/11  20:00:24  dhb
# Added RCS check out rules
#
# Revision 1.1  1992/12/11  19:06:20  dhb
# Initial revision
#

#
# Makefile for toollib.o
#

CPP 		= 	/lib/cpp
CFLAGS 		= 	$(COPT) -D$(MACHINE) $(DEC_HACK)
INSTALL_DIR	= 	$(INSTALL)
INSTALL_LIB 	= 	$(INSTALL_DIR)/lib
INSTALL_INCLUDE	= 	$(INSTALL_DIR)/include
INSTALL_STARTUP	= 	$(INSTALL_DIR)/startup
SYS			= ../sys
SIMINCLUDE 	= 	-I. -I../sys -I../shell -I../sim -I../ss -I../segment -I../hh -I../buffer -I../olf  -I../concen
LIBRARY_NAME 	= 	tools
FUNCTIONS 	= 	toolfuncs
STRUCTURES 	= 	tool_struct.h
EXT_HEADER	=	tool_ext.h
TARGET_OBJ	= 	toollib.o

default: $(TARGET_OBJ) 

.SUFFIXES: .c,v .c .h,v .h

.h,v.h:
	co -r$(RCSRELEASE) $*.h

.c,v.o:
	co -r$(RCSRELEASE) $*.c
	cc -c $(CFLAGS) $(SIMINCLUDE) $*.c
	rm -f $*.c

OBJECTS =	\
		emrqmin.o \
		expfit.o \
		NIH_parser.o \
		new_parser.o \
		cell_parms.o \
		traverse.o \
		coord_geom.o \
		cell_sheet.o \
		conn_3d.o \
		curvefit3.o \
		lump_p.o \
		mrqmin.o \
		mrqcof.o \
		gaussj.o \
		nrutil.o \
		covsrt.o \
		readplot.o \
		spike_parms5.o \
		spline.o \
		brent.o \
		zbrent.o \
		rall_calc.o \
		egg.o \
		plane.o \
		rand_comp.o \
		curvematch.o \
		scale_parms.o \
		nmin.o \
		splinmin.o \
		parmin.o \
		newmatch.o \
		shapematch.o

HEADERS = 	\
		tools.h 

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

# $(OBJECTS) : $(HEADERS)

# make the data structure section of the symbol table

$(LIBRARY_NAME)_d@.c : $(STRUCTURES) $(SYS)/code_sym
	- $(CPP) $(STRUCTURES) /tmp/$(STRUCTURES) $(SIMINCLUDE)
	- $(SYS)/code_sym /tmp/$(STRUCTURES) $(LIBRARY_NAME) \
	  -I $(EXT_HEADER) -NI -o $(LIBRARY_NAME)_d@.c
	- rm /tmp/$(STRUCTURES)

# 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

# make the library header function
$(LIBRARY_NAME)_l@.c : $(LIBRARY_NAME)_f@.c $(LIBRARY_NAME)_d@.c $(SYS)/code_lib $(OBJECTS)
	 - $(SYS)/code_lib $(LIBRARY_NAME) -o $(LIBRARY_NAME)_l@.c



SYMBOLTAB = $(LIBRARY_NAME)_d@.o $(LIBRARY_NAME)_f@.o $(LIBRARY_NAME)_l@.o

$(TARGET_OBJ): $(OBJECTS) $(SYMBOLTAB)
	$(LD) -r -o $(TARGET_OBJ) $(OBJECTS) $(SYMBOLTAB)

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

freeze:
	rcsclean
	rcsfreeze $(VERSION)
	co Makefile *.h,v *.g,v $(FUNCTIONS)

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

rcsclean: clean
	- rcsclean
	co -r$(RCSRELEASE) Makefile *.h,v *.g,v $(FUNCTIONS)
