CXXFLAGS=-g -O -I/usr/local/include/tcl8.4 -I/usr/local/include/tk8.4 \
		-I/usr/local/include -I/usr/X11R6/include
OBJS = c++tk.o
LDARGS=  $(OBJS) -lm -L/usr/local/lib -L/usr/X11R6/lib -ltk84 -ltcl84 -lX11 -lm

TK_LIB=	/usr/local/lib/tk8.4
TCL_SCRIPTS= 	tk bgerror button choosedir clrpick comdlg console dialog \
		entry focus listbox menu mkpsenc msgbox obsolete \
	 	optMenu palette panedwindow pkgIndex safetk scale scrlbar \
		spinbox tearoff text tkfbox unsupported xmfbox

DEPS= c++tk.h tcl_scripts.h

.if defined(TIX)
LDARGS+= -ltixsam8184
DEPS+= tix_scripts.h
CXXFLAGS+= -DTIX
.endif

c++tk.o: ${DEPS}

tcl_scripts.h:
	for i in $(TCL_SCRIPTS); do ./mkstr script_$$i < $(TK_LIB)/$$i.tcl; done > tcl_scripts.h
	echo "static char *packages[] = {" >> tcl_scripts.h
	for i in $(TCL_SCRIPTS); do echo "   script_$$i,"; done >> tcl_scripts.h
	echo "   0};" >> tcl_scripts.h

.if defined(TIX)
tix_scripts.h:
	./mkstr script_tix  < EFileBox2.tcl > tix_scripts.h
	echo "static char *tix_packages[] = { script_tix, 0 };" >> tix_scripts.h
.endif
clean: 
	rm -f *.o tcl_scripts.h tix_scripts.h

