# $Id: Makefile,v 1.4 1993/06/08 06:07:42 david Exp $

# CONFIGURE: Choose your compiler.
# CC = cc
CC = gcc

# CONFIGURE: What directories of include files need to be scanned?
#	The package depends on the TCL include files.  If you have others
#	in mind, add them to the INCLUDES line.
TCL_INCLUDE = -I/usr/local/include
INCLUDES = $(TCL_INCLUDE) $(TK_INCLUDE)

# CONFIGURE: Compilation settings.
#	I like for lint-like warnings to be given on every compile.
#	I also like to find and fix every thing the compiler chatters
#	at me about.  That way, real errors don't get lost in the noise.
#
#	The following is set up for `gcc'.  If you like a different
#	compiler then use the proper settings.
#
WARNINGS = -pedantic -Wall
OPTIMIZE = -O2
DEBUG    = -g
#
#	The following are probably good settings for /bin/cc.
#
# WARNINGS =
# OPTIMIZE = -O
# DEBUG    =

# CONFIGURE: Where will the minterp-specific files be installed?
MINTERP_LIBRARY = /usr/local/lib/minterp
MINTERP_LIB_DEF = -DMINTERP_LIBRARY=\"$(MINTERP_LIBRARY)\"

# CONFIGURE: TCL and TK libraries.
#	How do you link in the libraries?  Some people leave them down
#	in the source tree.  I prefer to install them in /usr/local
#	so that the source can be tar'd & gzip'd.
#
TCL_LIB = -ltcl
TK_LIB  = -L/usr/local/lib 
# TK_LIB  = -L/usr/local/lib -ltk

# CONFIGURE: Combine all desired compiler settings here.
#
CFLAGS = $(WARNINGS) $(INCLUDES) $(OPTIMIZE) $(DEBUG) $(MINTERP_LIB_DEF)

# CONFIGURE: Combine desired linker settings here.
LDFLAGS = $(TK_LIB) $(TCL_LIB) $(OPTIMIZE) $(DEBUG)

# CONFIGURE: Do you need to `ranlib' libraries?
#	Some systems (System V notably) do not require this.  But
#	SunOS 4.1 and other BSDish systems do.
# RANLIB = :
RANLIB = ranlib

# CONFIGURE: Where is everything going to be installed?
DEST_BIN = /usr/local/bin
DEST_LIB = /usr/local/lib
DEST_INC = /usr/local/include
DEST_MAN = /usr/local/man
DEST_TCL = /usr/local/lib/tcl
DEST_TK  = /usr/local/lib/tk


################# Shouldn't need to configure any farther ###############

CLEANABLES = libminterp.a *.o mtcl mwish

all: libminterp.a mtcl mwish

mtcl: main.o libminterp.a
	$(CC) -o mtcl main.o libminterp.a $(LDFLAGS)

mwish: mwish.o libminterp.a
	$(CC) -o mwish mwish.o libminterp.a $(LDFLAGS) -ltk -lX11 -lm

libminterp.a: interp.o
	ar curv libminterp.a interp.o
	$(RANLIB) libminterp.a

interp.o: interp.c interp.h

install: all
	cp mtcl mwish $(DEST_BIN)
	cp libminterp.a $(DEST_LIB)
	$(RANLIB) $(DEST_LIB)/libminterp.a
	cp interp.h $(DEST_INC)
	cp interp.man interpBase.man minterp-lib.man $(DEST_MAN)/manl
	cp interpApi.man $(DEST_MAN)/man3
	cp minterp.tcl $(DEST_TCL)
	echo auto_mkindex $(DEST_TCL) "*.tcl" | ./mtcl
	cp interpBaseC.tcl fileBrowserC.tcl cmdwinC.tcl 7segC.tcl $(MINTERP_LIBRARY)
	echo auto_index_modules $(MINTERP_LIBRARY) "*C.tcl" | ./mtcl

clean:
	rm -f $(CLEANABLES) a.out junk *~
