#!/usr/bin/make
#
# Makefile for wapptclsh on unix.  Usage:
#
#    make clean wapptclsh
#
# You need a static build of TCL9 in the directory that TCLDIR specifies.
# To construct such a build:
#
#    (1)  Download and untar the TCL9 sources
#    (2)  CD into the unix subdirectory
#    (3)  ./configure --disable-shared --prefix=$HOME/tcl90
#    (4)  make install
#

CFLAGS = -Os -static
CC = gcc $(CFLAGS)
OPTS = 
TCLDIR ?= $(HOME)/tcl90
TCLLIB_A ?= $(TCLDIR)/lib/libtcl9.0.a
TCLLIB = $(TCLLIB_A) -lm -lz -lpthread -ldl
TCLINC = $(TCLDIR)/include
TCLSH = $(TCLDIR)/bin/tclsh9.0

all: wapptclsh

wapptclsh: wapptclsh.c
	$(CC) -I. -I$(TCLINC) -o $@ $(OPTS) wapptclsh.c $(TCLLIB)

wapptclsh.c:	wapptclsh.c.in wapp.tcl wapptclsh.tcl tclsqlite3.c mkccode.tcl
	$(TCLSH) mkccode.tcl wapptclsh.c.in >$@

env:
	@ echo CC = $(CC)
	@ echo OPTS = $(OPTS)
	@ echo TCLDIR = $(TCLDIR)

clean:	
	rm -f wapptclsh wapptclsh.c
