##############################################################################
# INSTALLATION INSTRUCTIONS:
# Modify the following macros to give them values suitable for your
# site, then type "make".
#
# Change the following macro to identify the directories on the host system
# which contain the Tcl/Tk start-up scripts.  To find these directories,
# type:
#      echo 'puts $auto_path; destroy .' >temp; wish -f temp; rm temp
#
TCL_LIB_INC = -I/usr/lib/tcl7.4 -I/usr/lib/tk4.0
#
# Change the following macro to identify the directories on the host system
# which contain the Tcl/Tk source code header files, tcl.h tclInt.h tk.h
# tkInt.h and so forth.  This is normally the same directory in which the
# source code to Tcl/Tk was originally unpacked.
#
TCL_HDR_INC = -I/usr/include/tcl
#
# Change the following macro to contain the sequence of library files
# which must be linked into any Tcl/Tk program.  This is normally the
# same on all systems.
#
  LIB = -L/usr/X11R6/lib -ltk -ltcl -lX11 -lm
#
#
# Installation directories for ts
#
# TS_INS_DIR	Installation dir for ts binary
# TS_ICO_DIR    Installation dir for ts icons
# TS_HLP_DIR	Installation dir for ts help files
# TS_HLP_LAN    Help language, "ger" or "eng"
#
TS_INS_DIR = /usr/local/bin
TS_ICO_DIR = /usr/local/include/bitmaps
TS_HLP_DIR = /usr/local/lib/ts/help
TS_HLP_LAN = ger
#
# Change the following macros to describe the C compiler, and options
# to the C compiler for use on the host system.
# Set the macro DEBUG for debugging info.
#
  CC =     gcc
# CFLAGS = -Wall -g -DDEBUG
  CFLAGS = -Wall -O2
# CFLAGS = -O6 -static
# CFLAGS = -O6
#
# To use TK version 4.0, set ET_SRC to et40.c.
#
  ET_SRC = et40.c

ET2C = ./et2c
#
# Do not change anything after this line
#
#############################################

.SUFFIXES: .et .tcl

OBJECTS=ts.o exec.o getpty.o et.o
TCLS=bindings.tcl dialog.tcl exec.tcl filedlg.tcl ide.tcl help.tcl params.tcl \
  printdlg.tcl searchdlg.tcl tedit.tcl ts.tcl tkterm.tcl

.et.c:
	et2c $< >$*.c

.c.o:
	$(CC) -c $(CFLAGS) $(TCL_HDR_INC) -DICONDIR=\"$(TS_ICO_DIR)\" -DHELPDIR=\"$(TS_HLP_DIR)\" $<

all: et2c ts

et2c:   et2c.c
	$(CC) $(CFLAGS) $(TCL_HDR_INC) et2c.c -o $@

et.o:   $(ET_SRC) et2c
	$(ET2C) $(ETKR) $(TCL_LIB_INC) $(ET_SRC) >et_.c
	$(CC) $(CFLAGS) $(TCL_HDR_INC) -c et_.c -o $@
	rm -f et_.c

ts.c: $(TCLS)

ts: $(OBJECTS)
	$(CC) -o ts $(OBJECTS) -ltk -ltcl -L/usr/X11R6/lib -lX11 -lm

install:
	install -d $(TS_ICO_DIR)
	install -d $(TS_HLP_DIR)
	install -c -m 755 ts ts_err $(TS_INS_DIR)
	install -c -m 644 ico/*.ico $(TS_ICO_DIR)
	install -c -m 644 help/$(TS_HLP_LAN)/*.hlp $(TS_HLP_DIR)

clean:
	rm *.o *.aux *.log core
