##############################################################################
# Compiling options
##############################################################################
#
# 1) Path of tcl/tk start-up scripts (depending on version and tcl installation)
#
# 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/local/lib/tcl8.0 -I/usr/local/lib/tk8.0
#TCL_LIB_INC = -I/usr/lib/tcl7.4 -I/usr/X11R6/lib/tk4.0
#
##########################################################################
#
# 2) Path of C header files tcl.h and tk.h (depending on tcl installation)
#
# 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/local/include
#TCL_HDR_INC = -I/usr/include/tcl
#
###########################################################################
#
# 3) Path of tcl/tk libraries (depending on version and tcl installation)
#
# 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.
# tcl7.5/7.6 needs the libdl library!
#
  LIB = -L/usr/local/lib -L/usr/X11R6/lib -ltk8.0 -ltcl8.0 -lX11 -ldl -lm
#  LIB = -L/usr/X11R6/lib -ltk4.0 -ltcl7.4 -lX11 -lm
#
############################################################################
#
# 4) Name of the et source (depending on version)
#
  ET_SRC = et80.c
#
#############################################################################
#
# 5) C compiler options
#
# 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
#
############################################################################
#
# 6) et2c options
#
# Call for et2c (-dynamic is usefull for debugging, but slower)
#
# ET2C = ./et2c -dynamic
 ET2C = ./et2c
#
######################################################################
# Installation options                                               #
######################################################################
#
# 1) Installation directories for ts
#
# TS_BASE	Base directory for ts
#
# TS_BIN	Installation dir for ts binary

#TS_BASE = /home/jens/ts-9712
#TS_BIN  = /home/jens/ts-9712
TS_BASE = /usr/local/lib/ts
TS_BIN  = /usr/local/bin
#
######################################################################
#
# 2) other settings
#
# TS_PARAM      Global parameter file
#
TS_PARAM = $(TS_BASE)/texshell.cfg

#
# Do not change anything after this line
#
#############################################

.SUFFIXES: .et .tcl

OBJECTS=ts.o exec.o getpty.o et.o
TCLS=ts_dlg.tcl ts_filedlg.tcl ts_ide.tcl ts_help.tcl ts_param.tcl \
  ts_prtdlg.tcl ts_edit.tcl ts.tcl ts_term.tcl ts_opt.tcl ts_template.tcl \
  ts_prj.tcl

.et.c:
	$(ET2C) $< >$*.c

.c.o:
	$(CC) -c $(CFLAGS) $(TCL_HDR_INC) -DTS_BASE=\"$(TS_BASE)\" $<

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) $(LIB)

install:
	install -d $(TS_BASE)/bitmaps
	install -d $(TS_BASE)/help
	rm -rf $(TS_BASE)/help/*
	install -d $(TS_BASE)/help/ger
	install -d $(TS_BASE)/help/eng
	install -d $(TS_BASE)/templates
	install -c -m 644 *.cfg $(TS_BASE)
	install -c -m 755 ts ts_err $(TS_BIN)
	install -c -m 644 bitmaps/*.ico $(TS_BASE)/bitmaps
	cp -a help/* $(TS_BASE)/help
	chmod 755 $(TS_BASE)/help/eng
	chmod 755 $(TS_BASE)/help/eng/latex
	chmod 755 $(TS_BASE)/help/ger
	chmod 755 $(TS_BASE)/help/ger/latex
	chmod 755 $(TS_BASE)/bitmaps
	install -c -m 644 templates/* $(TS_BASE)/templates

clean:
	rm -f ts et2c *.o *.aux *.log *.dvi core
