# tkHTML-3.2 Makefile, man this is ugly
# hacked from Tix

# Installation Directives:
# these are the default prefixes for installation
prefix      =	/usr
exec_prefix =	${prefix}

# where do you want to keep tkHTML runtime stuff?
# Make sure that 'tkhtmllibdir' in tkHTML.tcl matches tkHTML_LIBDIR
BINDIR = /usr/local/bin
tkHTML_LIBDIR = /usr/local/lib/tkHTML


# Compilation Directives:

TOP_SRC_DIR =	/site/src/lang/tcltk

# what directory are you compiling this in:
tkHTML_SRC_DIR = ${TOP_SRC_DIR}/tkHTML-3.2

# for this version of tkHTML: 
TCL_DIR =	$(prefix)/lib/tcl7.6jp
TK_DIR  =	$(prefix)/lib/tk4.2jp
TIX_DIR = 	$(prefix)/lib/tix4.1

# The directory containing the Tcl library archive file appropriate
# for this version of tkHTML:
#LIB_TCL_DIR = /usr/lib/tcl7.6
LIB_TCL_DIR =	$(TOP_SRC_DIR)/tcl7.6

# The directory containing the Tcl library archive file appropriate
# for this version of Tix:
#LIB_TK_DIR  = /usr/lib/tk4.2
LIB_TK_DIR  =	$(TOP_SRC_DIR)/tk4.2

# and lastly, your tix stuff:
LIB_TIX_DIR = /usr/lib/tix4.1
#LIB_TIX_DIR = $(TOP_SRC_DIR)/Tix4.1.0/unix/tk4.2

# where are the tix bitmaps?
#from tix source tree:
#TIX_BITMAPS_DIR = /usr/src/Tix4.0/library/bitmaps
# installed Tix:
TIX_BITMAPS_DIR = $(LIB_TIX_DIR)/library/bitmaps

# A "-I" switch that can be used when compiling to make all of the
# X11 include files accessible 
X11_INCLUDES =	 -I/usr/X11R6/include

# Linker switch(es) to use to link with the X11 library archive 
X11_LIB_SWITCHES =	-L/usr/X11R6/lib -L/usr/lib
LIBX11=			-lX11

# Libraries to use when linking:  must include at least Tix, Tcl, Xlib,
# and the math library (in that order).  

# static:
#LIBS = /usr/i486-linuxaout/lib/libtix.a /usr/i486-linuxaout/lib/libtk4.0.a \
#   /usr/i486-linuxaout/lib/libtcl.a $(X11_LIB_SWITCHES) -lX11 -lXpm -lm
#LIBS = $(LIB_TIX_DIR)/libtixsam4.1.7.6.a $(LIB_TK_DIR)/unix/libtk4.2.a \
#   $(LIB_TCL_DIR)/unix/libtcl7.6.a $(X11_LIB_SWITCHES) -lX11 -lXpm -lm -ldl
# dynamic
LIBS = -L/usr/lib -ltixsam4.1.7.6 -ltk4.2jp -ltcl7.6jp $(X11_LIB_SWITCHES) -lX11 -lXpm -ldl -lm

# To change the compiler switches, for example to change from -O
# to -g, change the following line:
CFLAGS = -O -DKANJI -DKINPUT2
#CFLAGS = -O2 -m486 #-b i486-linuxaout

# To disable ANSI-C procedure prototypes reverse the comment characters
# on the following lines:
PROTO_FLAGS =
#PROTO_FLAGS = -DNO_PROTOTYPE

# To enable memory debugging reverse the comment characters on the following
# lines.  Warning:  if you enable memory debugging, you must do it
# *everywhere*, including all the code that calls Tcl, and you must use
# ckalloc and ckfree everywhere instead of malloc and free.
MEM_DEBUG_FLAGS =
#MEM_DEBUG_FLAGS = -DTCL_MEM_DEBUG

# Some versions of make, like SGI's, use the following variable to
# determine which shell to use for executing commands:
SHELL =		/bin/sh

#----------------------------------------------------------------
# shouldn't muck with anything below this:


AC_FLAGS =		 -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 -DSTDC_HEADERS=1 -DTK_FILE_READ_PTR=1   
INSTALL =		/usr/bin/ginstall -c
INSTALL_PROGRAM =	${INSTALL}
INSTALL_DATA =		${INSTALL} -m 644

#----------------------------------------------------------------
# The information below should be usable as is. 
# and you shouldn't need to modify it
# either.
#----------------------------------------------------------------


CC =		gcc
CC_SWITCHES =	${CFLAGS} -I${INC_DIR} -I${TCL_DIR} -I${TK_DIR} \
${X11_INCLUDES} \
${AC_FLAGS} ${PROTO_FLAGS} ${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} \
-DTCL_LIBRARY=\"${TCL_DIR}\" \
-DTK_LIBRARY=\"${TK_DIR}\" \
-DTIX_LIBRARY=\"${TIX_DIR}\"
LD = ld -m i386linux
TCLOBJS = tkHTML.tcl config.tcl help.tcl menus.tcl maintext.tcl files.tcl \
toolbar.tcl quickbar.tcl

all: et2c tkHTML

.SUFFIXES: .et

ET_FLAGS = -I$(TCL_DIR) -I$(TK_DIR) -I../library

et2c: et2c.c
	$(CC) $(CC_SWITCHES) et2c.c -o $@

tkHTML.et: tkHTML.et.dist  Makefile
	cat tkHTML.et.dist | sed -e 's|\/BLEAH|${TIX_DIR}|' | sed -e 's|\/UGH|${tkHTML_SRC_DIR}|' > tkHTML.et
	
tkHTML.c: tkHTML.et.dist tkHTML.et bitmaps.c $(TCLOBJS)
	./et2c $(ET_FLAGS) tkHTML.et > tkHTML.c

et41.c : et41.et
	./et2c $(ET_FLAGS) et41.et > et41.c

bitmaps.c : makebitmap.tcl
	#./makebitmap.tcl $(TIX_BITMAPS_DIR) ./bitmap > bitmaps.c

OBJS = et41.o tkHTML.o

HDRS = tix.h

tkHTML: $(OBJS) tkHTML.et
	$(CC) $(CC_SWITCHES) $(OBJS) $(LIBS) -o tkHTML

clean:
	rm -f *.a *.o core errs *~ \#* TAGS *.E a.out errors \
		config.info tkHTML.c tkHTML \
		et41.c et2c tkHTML.et 
install: tkHTML
	@echo Installing binary in ${BINDIR}
	${INSTALL} tkHTML ${BINDIR}
	@echo Installing config.tcl in ${tkHTML_LIBDIR}
	${INSTALL} -m 644 config.tcl ${tkHTML_LIBDIR}

# Now I want to preserve the Makefile on my machine somehow
#
.c.o:
	$(CC) -c $(CC_SWITCHES) $<

# DO NOT DELETE THIS LINE -- make depend depends on it.

