# Makefile for the mktclapp examples included in the Debian package.
# Written by edrx, 2000jan20.  Public domain.
# Files with names like hello_.c are generated by mktclapp.
# hello.tcl can be a copy of hello0.tcl or hellob.tcl; see the README.
# Note that no ".c" depends on a ".tcl" (because we're not using
# "-standalone").

# This makefile is meant to be used from the "README" shell script in
# /usr/doc/mktclapp/examples/README; you may set the environment
# variables TCL and TK before calling the script if you want to use
# other versions of the Tcl and Tk libraries.
#
# (find-node "(make)Setting" "FOO ?= bar")
# (find-node "(make)Origin Function")
# (find-fline "README")

TCL	?= 8.2
TK	?= 8.2

all: hello

mktclapp.h:
	mktclapp -header > mktclapp.h


hello_.c: hello.c
	mktclapp -dont-strip-tcl -read-stdin \
		hello.c  -main-script hello.tcl  > hello_.c

hello_.o: hello_.c mktclapp.h

hello.o: hello.c mktclapp.h

hello: hello_.o hello.o
	gcc -ltk$(TK) -ltcl$(TCL) -L/usr/X11R6/lib -lX11 -lm -ldl \
		-o hello hello_.o hello.o


factor_.c: factor.c factor.tcl
	mktclapp -dont-strip-tcl -notk -read-stdin \
		factor.c  > factor_.c

factor_.o: factor_.c mktclapp.h

factor.o: factor.c mktclapp.h

factor: factor_.o factor.o
	gcc -ltcl$(TCL) -lm -ldl \
		-o factor factor_.o factor.o


factor_e.c: factor.c
	mktclapp -notk -extension Factor \
		factor.c  > factor_e.c

factor_e.o: factor_e.c mktclapp.h

factor.so: factor_e.o factor.o
	gcc -shared -o factor.so  factor_e.o factor.o


clean:
	rm -fv mktclapp.h				\
		hello_.c hello_.o hello.o hello		\
		factor_.c factor_.o factor.o factor
