#!make -f
##############################################################################
# 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/r/dev/lib/tcl -I/r/dev/lib/tk
# TCL_LIB_INC = -I/usr/local/lib/tcl -I/usr/local/lib/tk
  TCL_LIB_INC = -I/r/dev/tk4.0/lib/tcl7.4 -I/r/dev/tk4.0/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/r/dev/src/tcl7.3 -I/r/dev/src/tk3.6
# TCL_HDR_INC =  -I/usr/local/src/tcl7.4 -I/usr/local/src/tk4.0
  TCL_HDR_INC =  -I/r/dev/tk4.0/tcl7.4 -I/r/dev/tk4.0/tk4.0

#
# Set the BLT_DIR macro to the top of the source tree for the BLT
# extension.  This is only required if you want to compile the
# "bltgraph" example program.
#
  BLT_DIR = /r/dev/src/blt-1.5
# BLT_DIR = /usr/local/src/blt-1.5

#
# 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 = -ltk -ltcl -lX11 -lm
# LIB = /r/dev/tk4.0/tk4.0/libtk.a /r/dev/tk4.0/tcl7.4/libtcl.a -lX11 -lm

#
# Change the following macros to describe the C compiler, and options
# to the C compiler for use on the host system.
#
  CC =     gcc
# CFLAGS = -Wall -g -DDEBUG
  CFLAGS = -O6 -static
# CFLAGS = -O6
# CFLAGS = -g

#
# To use Tk version 3.6, set the ET_SRC macro to et36.c.  To use Tk
# version 4.0, set ET_SRC to et40.c.  To use ET with TclX, set ET_SRC
# to etX.c.
#
# IMPORTANT NOTE:  The example programs have been ported to Tk4.0.  This
# means that most of them will no longer work under Tk3.6.
#
# ANOTHER NOTE: If you are using TclX.c, then you'll also need to adjust
# the TCL_LIB_INC, TCL_HDR_INC and LIB macros above.
#
# ET_SRC = et36.c
  ET_SRC = et40.c
# ET_SRC = etX.c

#
# Uncomment the following lines if you are using an non-ANSI C compiler.
#
# CKR  = -DK_AND_R
# ETKR = -k+r

# STOP HERE!
# Nothing else in this file will normally need to be modify when moving 
# from one host to another.
#########################################################################

ET2C      = ./et2c $(ETKR)
LOCAL_CC  = $(CC) $(CFLAGS) $(CKR)

all:	et2c tests

tests:	bell color dclock etwish fontchooser hello perfmon \
        runscript tkedit tkterm browser

clean:	
	rm -f *.o *_.c et36.c et40.c etX.c et2c bell color dclock etwish
	rm -f fontchooser hello perfmon runscript tkedit tkterm browser

et36.c:	et.c.prototype
	sed \
	  -e '/^#if TK40/,/^#endif/d' \
	  -e '/^#if TCLX/,/^#endif/d' \
	  et.c.prototype >et36.c

et40.c:	et.c.prototype
	sed \
	  -e '/^#if TK36/,/^#endif/d' \
	  -e '/^#if TCLX/,/^#endif/d' \
	  et.c.prototype >et40.c

etX.c:	et.c.prototype
	sed \
	  -e '/^#if TK36/,/^#endif/d' \
	  -e '/^#if TK40/,/^#endif/d' \
	  et.c.prototype >etX.c

et2c:	et2c.c
	$(LOCAL_CC) $(TCL_HDR_INC) et2c.c -o $@

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

browser:	browser.c browser.tcl et.o et2c
	$(ET2C) browser.c >browser_.c
	$(LOCAL_CC) -o $@ browser_.c et.o $(LIB)
	rm -f browser_.c

dclock:	dclock.c et.o et2c
	$(ET2C) dclock.c >dclock_.c
	$(LOCAL_CC) -o $@ dclock_.c et.o $(LIB)
	rm -f dclock_.c

fontchooser:	fontchooser.c et.o et2c fontchooser.tcl
	$(ET2C) fontchooser.c >fontchooser_.c
	$(LOCAL_CC) $(TCL_HDR_INC) -o $@ fontchooser_.c et.o $(LIB)
	rm -f fontchooser_.c

color:	color.c color.tcl et.o et2c
	$(ET2C) color.c >color_.c
	$(LOCAL_CC) $(TCL_HDR_INC) -o $@ color_.c et.o $(LIB)
	rm -f color_.c

bell:	bell.c et.o et2c
	$(ET2C) bell.c >bell_.c
	$(LOCAL_CC) $(TCL_HDR_INC) -o $@ bell_.c et.o $(LIB)
	rm -f bell_.c

etwish:	etwish.c et.o et2c
	$(ET2C) etwish.c >etwish_.c
	$(LOCAL_CC) -o $@ etwish_.c et.o $(LIB)
	rm -f etwish_.c

hello:	hello.c et.o et2c
	$(ET2C) hello.c >hello_.c
	$(LOCAL_CC) -o $@ hello_.c et.o $(LIB)
	rm -f hello_.c

index:	index.c et.o et2c
	$(ET2C) index.c >index_.c
	$(LOCAL_CC) $(TCL_HDR_INC) -o $@ index_.c et.o $(LIB)
	rm -f index_.c

tkterm: tkterm.c getpty.o et.o et2c tkterm.tcl
	$(ET2C) tkterm.c >tkterm_.c
	$(LOCAL_CC) $(TCL_HDR_INC) -o $@ tkterm_.c et.o getpty.o $(LIB)
	rm -f tkterm_.c

getpty.o:	getpty.c
	$(LOCAL_CC) -o $@ -c getpty.c

perfmon:	perfmon.c et.o et2c perfmon.tcl
	$(ET2C) perfmon.c >perfmon_.c
	$(LOCAL_CC) -o $@ perfmon_.c et.o $(LIB)
	rm -f perfmon_.c

runscript:	runscript.c et.o et2c
	$(ET2C) runscript.c >runscript_.c
	$(LOCAL_CC) -o $@ runscript_.c et.o $(LIB)
	rm -f runscript_.c

tkedit:	tkedit.c tkedit.tcl et2c et.o
	$(ET2C) tkedit.c >temp.c
	$(LOCAL_CC) -o $@ temp.c et.o $(LIB)
	rm -f temp.c

bltgraph:	bltgraph.c et2c et.o
	$(ET2C) -I$(BLT_DIR)/demos bltgraph.c >temp.c
	$(LOCAL_CC) -o $@ temp.c et.o $(BLT_DIR)/src/libBLT.a $(LIB)
	rm -f temp.c
