# Change to reflect your system:

# NOTE: TCL_INCL is relative to the "main" sub dir!
TCL_INCL= -I../../../tcl7.5/generic

# For Linux:
#LD_SHARED=	cc -shared
#SHLIB_CFLAGS= 

# For sun solaris:
LD_SHARED=	/usr/ccs/bin/ld -G -z text
SHLIB_CFLAGS= -fPIC

#----------------------
OV = 0.57b3

main = main
MAIN_DIST = \
	$(main)/base.tcl \
	$(main)/debug.tcl \
	$(main)/inherit.tcl \
	$(main)/minherit.tcl \
	$(main)/obtcl.tcl \
	$(main)/obtcl2.tcl \
	$(main)/obtcl.c \
	$(main)/utils.tcl \
	$(main)/crunch_spec \
	$(main)/obtcl_mkindex \
	$(main)/obtcl_mkindex.tcl \
	$(main)/options.tcl \
	$(main)/vars.tcl \
	$(main)/vars1_tcl \
	$(main)/vars2_tcl \
	$(main)/skip.awk \
	$(main)/test.tst

widg = widgets
WIDGETS_DIST = \
	$(widg)/wutils.tcl \
	$(widg)/wbase.tcl \
	$(widg)/ComboBox.tcl \
	$(widg)/Buttons.tcl \
	$(widg)/Entry.tcl \
	$(widg)/Forms.tcl \
	$(widg)/LabelBox.tcl \
	$(widg)/LblWidg.tcl \
	$(widg)/Layout.tcl \
	$(widg)/Listbox.tcl \
	$(widg)/PanedW.tcl \
	$(widg)/ScrFrame.tcl \
	$(widg)/ScrText.tcl \
	$(widg)/ScrWidget.tcl \
	$(widg)/SelctBox.tcl \
	$(widg)/Table.tcl \
	$(widg)/Tabs.tcl \
	$(widg)/TkManText.tcl

expr = experim
EXPERIM_DIST = \
	$(expr)/base_2.tcl \
	$(expr)/Cpanel.tcl \
	$(expr)/Inspect.tcl \
	$(expr)/Tree.tcl \
	$(expr)/TxtTree.tcl

demo = demo
DEMO_DIST = \
	$(demo)/demo \
	$(demo)/docs \
	$(demo)/images/teapot.ppm \
	$(demo)/panedw \
	$(demo)/tabs \
	$(demo)/tricks.tcl \
	$(demo)/wrap

doc = doc
DOC_DIST = \
	$(doc)/man.macros \
	$(doc)/obTcl.ascii \
	$(doc)/obTcl.cat \
	$(doc)/obTcl.n \
	$(doc)/obTcl.tkman

tests = tests
TESTS_DIST = \
	$(tests)/runtests \
	$(tests)/testutils.tcl \
	$(tests)/testopt.tst \
	$(tests)/iclassvars.tst \
	$(tests)/classvars.tst \
	$(tests)/instvars.tst

old = old
OLD_DIST = \
	$(old)/options.tcl

#----------------------

OBTCL_DIST = COPYRIGHT README Makefile \
	$(MAIN_DIST) \
	$(WIDGETS_DIST) \
	$(EXPERIM_DIST) \
	$(DEMO_DIST) \
	$(DOC_DIST) \
	$(TESTS_DIST) \
	$(OLD_DIST)

TCL_CRUNCH = \
	 ./tcl_cruncher/tcl_cruncher.man \
	 ./tcl_cruncher/tcl_cruncher.c \
	 ./tcl_cruncher/README \
	 ./tcl_cruncher/CHANGES \
	 ./tcl_cruncher/LICENSE \
	 ./tcl_cruncher/Makefile \
	 ./tcl_cruncher/tcl_compiler_crash_tests

TCLINDEX_DIRS = $(main) $(widg) $(expr)
TCLINDEX_FILES = $(MAIN_DIST) $(WIDGETS_DIST) $(EXPERIM_DIST)

all: tclIndex test

lib: dll
dll: $(main)/obtcl$(OV).so
$(main)/obtcl$(OV).so: $(main)/obtcl.c
	( cd $(main); \
	  $(CC) $(SHLIB_CFLAGS) -c -DOBTCL_VERSION='"$(OV)"' $(TCL_INCL) obtcl.c; \
	  $(LD_SHARED) obtcl.o -o obtcl$(OV).so )

oldtest:
	( cd $(main); cat obtcl.tcl test.tst | tclsh7.4 )
test:
	tests/runtests

./tcl_cruncher/tcl_cruncher:
	( cd tcl_cruncher ; make )

crunch: ./tcl_cruncher/tcl_cruncher
	( cd $(main); \
	  ../tcl_cruncher/tcl_cruncher -d crunch_spec \
		utils.tcl obtcl.tcl inherit.tcl base.tcl | \
		./skip.awk > obtcl.crunched )

crunchAll: ./tcl_cruncher/tcl_cruncher
	  ./tcl_cruncher/tcl_cruncher -d $(main)/crunch_spec \
		$(main)/utils.tcl $(main)/obtcl.tcl \
		$(main)/inherit.tcl $(main)/base.tcl \
		$(EXPERIM_DIST) $(WIDGETS_DIST) | \
		./$(main)/skip.awk > ALL.crunched

strip:
	( cd $(main); \
	  cat utils.tcl obtcl.tcl inherit.tcl base.tcl | \
	  ./skip.awk > obtcl.stripped )

man: $(doc)/obTcl.n
	( cd $(doc); \
	  groff -man obTcl.n -Tascii > obTcl.ascii; \
	  cat obTcl.ascii | rman -k -f TkMan > obTcl.tkman )

# Specify which vars?_tcl implementation to use explicitly:
#
tclIndex: $(TCLINDEX_FILES)
	$(main)/obtcl_mkindex -one_index "$(TCLINDEX_DIRS)" \*.tcl

allIndex: $(TCLINDEX_FILES)
	($(main)/obtcl_mkindex -f tclIndex.ALL . $(main)/ALL)

distrib: tclIndex
	rm -rf obTcl-$(OV)
	mkdir obTcl-$(OV)
	cp README obTcl-$(OV).README
	tar cf - tclIndex $(OBTCL_DIST) $(TCL_CRUNCH) \
		| (cd obTcl-$(OV); tar xvf -)
	tar cvf obTcl-$(OV).tar obTcl-$(OV)
	gzip -f obTcl-$(OV).tar
