TclOO Package

Artifact Content
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Artifact 237adc7e70e60ec97acc2df74eff713f96ad4075:


#
# @[email protected]
#

#========================================================================
# All these assignments are substituted by configure
#========================================================================

PKG_SOURCES	= @[email protected]
PKG_OBJECTS	= @[email protected]

PKG_STUB_SOURCES = @[email protected]
PKG_STUB_OBJECTS = @[email protected]

PKG_TEST_SOURCES = @[email protected]
PKG_TEST_OBJECTS = @[email protected]

PKG_TCL_SOURCES = @[email protected]

PKG_HEADERS	= @[email protected]
[email protected][email protected]

PKG_LIB_FILE	= @[email protected]
PKG_TEST_LIB_FILE = @[email protected]
PKG_STUB_LIB_FILE = @[email protected]

SHELL		= @[email protected]

srcdir		= @[email protected]
prefix		= @[email protected]
exec_prefix	= @[email protected]

bindir		= @[email protected]
libdir		= @[email protected]
includedir	= @[email protected]
datarootdir     = @[email protected]
datadir		= @[email protected]
mandir		= @mand[email protected]

DESTDIR		=

INSTALL_OPTIONS =
INSTALL		= $(SHELL) $(srcdir)/tclconfig/install-sh -c ${INSTALL_OPTIONS}
INSTALL_DATA_DIR = ${INSTALL} -d -m 755
INSTALL_PROGRAM	= ${INSTALL} -m 555
INSTALL_DATA	= ${INSTALL} -m 444
INSTALL_SCRIPT	= ${INSTALL_PROGRAM}
INSTALL_LIBRARY	= ${INSTALL_DATA}

PACKAGE_NAME	= @[email protected]
PACKAGE_VERSION	= @[email protected]
CC		= @[email protected]
CFLAGS_DEFAULT	= @[email protected]
CFLAGS_WARNING	= @[email protected]

[email protected]@
[email protected]@
[email protected][email protected]
[email protected][email protected]
[email protected][email protected]
[email protected][email protected]
[email protected][email protected]
[email protected][email protected]
[email protected]@
[email protected]@
[email protected][email protected]
[email protected][email protected]
[email protected][email protected]
[email protected][email protected]
[email protected][email protected]
[email protected][email protected]
[email protected][email protected]
# Not actually used, but can help when tracing errors
#[email protected][email protected]
#[email protected]@
[email protected][email protected]
[email protected][email protected] @[email protected]
[email protected][email protected]
[email protected]@ $(PKG_CFLAGS)
[email protected]@
[email protected][email protected] @[email protected] @[email protected]
PKG_TEST_LIBS=${PKG_STUB_LIB_FILE}
[email protected]@
[email protected]@
[email protected]@
[email protected]@
#[email protected]@
#[email protected][email protected]
#[email protected][email protected]
#[email protected][email protected]

EXTRA_PATH	= $(top_builddir):$(TCL_BIN_DIR)
PKG_ENV		= TCL_LIBRARY=`@[email protected] $(TCL_SRC_DIR)/library` \
		  @[email protected]="$(EXTRA_PATH):$(@[email protected])" \
		  PATH="$(EXTRA_PATH):$(PATH)" \
		  TCLLIBPATH="$(top_builddir)"
TCLSH_PROG	= @[email protected]
TCLSH		= $(PKG_ENV) $(TCLSH_PROG)

#========================================================================
# None of these assignments are substituted by configure
#========================================================================

SRC_DIR=$(srcdir)
BINARIES=$(PKG_LIB_FILE) $(PKG_STUB_LIB_FILE) $(PKG_TEST_LIB_FILE)
PKG_DIR=$(PACKAGE_NAME)$(PACKAGE_VERSION)
PKG_KIT_ROOT=$(PKG_DIR)-$(PLATFORM)
PKG_KIT=$(PKG_KIT_ROOT).kit
pkglibdir=$(libdir)/$(PKG_DIR)
top_builddir=.
TCL_VERSION_REQ=8.5b1
GDB=gdb
VALGRIND=valgrind
CONFIG_CLEAN_FILES="Makefile tclooConfig.sh"
COMPILE=$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
VPATH=$(SRC_DIR)/generic:$(SRC_DIR)/unix:$(SRC_DIR)/win:$(SRC_DIR)/macosx:$(SRC_DIR)
TESTFLAGS=
KIT_PKG_ROOT=$(PKG_KIT_ROOT).vfs/lib/$(PACKAGE_NAME)
ITERATIONS=1000
TCL_TOOLS_DIR=$(TCL_SRC_DIR)/tools

#========================================================================
# This is something that is found by executing a Tcl script
#========================================================================

PLATFORM:=$(shell echo 'package require platform;puts [platform::generic]' | $(TCLSH))

#========================================================================
# Master rules
#========================================================================

all: package libraries
package: $(PKG_LIB_FILE) pkgIndex.tcl
testpackage: $(PKG_TEST_LIB_FILE)
libraries: $(PKG_STUB_LIB_FILE)
install: all install-package install-libraries install-headers install-doc
kit: sdx_valid $(PKG_KIT)

#========================================================================
# Basic installation rules
#========================================================================

install-package: package
	@mkdir -p $(DESTDIR)$(pkglibdir)
	$(INSTALL_PROGRAM) $(PKG_LIB_FILE) $(DESTDIR)$(pkglibdir)/$(PKG_LIB_FILE)
	$(INSTALL_DATA) pkgIndex.tcl $(DESTDIR)$(pkglibdir)/pkgIndex.tcl
	$(INSTALL_DATA) tclooConfig.sh $(DESTDIR)$(pkglibdir)/tclooConfig.sh
#	for p in $(SRC_DIR)/library/*.tcl ; do \
#	    destp=`basename $$p`; \
#	    echo " Install $$destp $(DESTDIR)$(pkglibdir)/$$destp"; \
#	    $(INSTALL_DATA) $$p $(DESTDIR)$(pkglibdir)/$$destp; \
#	done
install-headers:
	@echo "Installing header files in $(DESTDIR)$(includedir)"
	@mkdir -p $(DESTDIR)$(includedir)
	@list='$(PKG_HEADERS)'; for p in $$list; do \
	    echo "Installing $(SRC_DIR)/$$p" ; \
	    destp=`basename $$p`; \
	    $(INSTALL_DATA) $(SRC_DIR)/$$p $(DESTDIR)$(includedir)/$$destp ; \
	done;
install-private-headers:
	@echo "Installing private header files in $(DESTDIR)$(includedir)"
	@mkdir -p $(DESTDIR)$(includedir)
	@list='$(PKG_PRIVATE_HEADERS)'; for p in $$list; do \
	    echo "Installing $(SRC_DIR)/$$p" ; \
	    destp=`basename $$p`; \
	    $(INSTALL_DATA) $(SRC_DIR)/$$p $(DESTDIR)$(includedir)/$$destp ; \
	done;
install-libraries: libraries
	@echo "Installing $(PKG_STUB_LIB_FILE) in $(DESTDIR)$(pkglibdir)"
	@mkdir -p $(DESTDIR)$(pkglibdir)
	$(INSTALL_DATA) $(PKG_STUB_LIB_FILE) $(DESTDIR)$(pkglibdir)

#========================================================================
# Install documentation. Unix manpages should go in the $(mandir) directory.
#========================================================================

install-doc: doc
	@echo "Installing documentation in $(DESTDIR)$(mandir)"
	@mkdir -p $(DESTDIR)$(mandir)/mann
	@list='$(SRC_DIR)/doc/*.n'; for i in $$list; do \
	    echo "Installing $$i"; \
	    rm -f $(DESTDIR)$(mandir)/mann/`basename $$i`; \
	    $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/mann ; \
	done
	@mkdir -p $(DESTDIR)$(mandir)/man3
	@list='$(SRC_DIR)/doc/*.3'; for i in $$list; do \
	    echo "Installing $$i"; \
	    rm -f $(DESTDIR)$(mandir)/man3/`basename $$i`; \
	    $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man3 ; \
	done

# A do-nothing target at the moment
doc:

#========================================================================
# Run the test suite or benchmarks for the package, or just start a shell
# primed to load the package.
#========================================================================

test: package testpackage libraries
	@echo $(TCLSH_PROG) $(SRC_DIR)/tests/all.tcl $(TESTLOAD) $(TESTFLAGS)
	@$(TCLSH) `$(CYGPATH) $(SRC_DIR)/tests/all.tcl` $(TESTLOAD) $(TESTFLAGS)

benchmarks: package libraries
	@echo Benchmark Iterations = $(ITERATIONS)
	@list='$(SRC_DIR)/benchmarks/*.tcl'; for i in $$list; do \
	    echo "Benchmarking $$i"; \
	    time $(TCLSH) `$(CYGPATH) $$i` $(ITERATIONS); \
	done

shell: package libraries
	@echo $(TCLSH_PROG) $(SCRIPT)
	@$(TCLSH) $(SCRIPT)

valgrind: package libraries
	@echo $(VALGRIND) $(TCLSH_PROG) $(SCRIPT)
	@$(PKG_ENV) $(VALGRIND) $(TCLSH_PROG) $(SCRIPT)

valgrindtest: package libraries
	@echo $(VALGRIND) $(TCLSH_PROG) $(SRC_DIR)/tests/all.tcl $(TESTLOAD) $(TESTFLAGS)
	@$(PKG_ENV) $(VALGRIND) $(TCLSH_PROG) `$(CYGPATH) $(SRC_DIR)/tests/all.tcl` $(TESTLOAD) $(TESTFLAGS) -singleproc 1

valgrindshell: binaries libraries
	$(PKG_ENV) valgrind $(VALGRINDARGS) $(TCLSH_PROG) $(SCRIPT)

#========================================================================
# These rules say how to run tclsh in a hostile Windows environment, while
# still working on Unix.
#========================================================================

gdb.run:
	@echo "catch {puts \"target exec [file attributes [file normalize [info nameofexecutable]] -shortname]\";exit};puts \"target exec [file normalize [info nameofexecutable]]\"" | $(TCLSH) > [email protected]
	@echo "set env TCL_LIBRARY=$(TCL_SRC_DIR)/library" >> [email protected]
	@echo "set env LD_LIBRARY_PATH=$(EXTRA_PATH):$(LD_LIBRARY_PATH)" >> [email protected]
	@echo "set env TCLLIBPATH=$(top_builddir)" >> [email protected]
	@sh -c 'test x$${OSTYPE} = xmsys && echo "set new-console off" >> [email protected]' || true

gdb: package libraries gdb.run
	@echo gdb $(TCLSH_PROG) $(ARGS)
	@gdb --command=gdb.run $(ARGS)
	@rm gdb.run
gdbtest: package libraries gdb.run
	@echo "set args `$(CYGPATH) $(SRC_DIR)/tests/all.tcl` $(TESTLOAD) $(TESTFLAGS) -singleproc 1" >>gdb.run
	@echo gdb $(TCLSH_PROG) $(MANGLED)
	@gdb --command=gdb.run
	@rm gdb.run

#========================================================================
# The rules for actually doing the build of the package.
#========================================================================

$(PKG_LIB_FILE): $(PKG_OBJECTS)
	-rm -f $(PKG_LIB_FILE)
	${MAKE_LIB}
	$(RANLIB) $(PKG_LIB_FILE)
$(PKG_STUB_LIB_FILE): $(PKG_STUB_OBJECTS)
	-rm -f $(PKG_STUB_LIB_FILE)
	${MAKE_STUB_LIB}
	$(RANLIB_STUB) $(PKG_STUB_LIB_FILE)
$(PKG_TEST_LIB_FILE): $(PKG_STUB_LIB_FILE)
	$(MAKE) PKG_TEST_LIB_FILE=dummy PKG_LIB_FILE=$(PKG_TEST_LIB_FILE) \
		PKG_OBJECTS="$(PKG_TEST_OBJECTS)" \
		LIBS="$(PKG_TEST_LIBS)" \
		CFLAGS="${SHLIB_CFLAGS} -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS" \
		$(PKG_TEST_LIB_FILE)
[email protected]@:
	$(COMPILE) -c `$(CYGPATH) $<` -o [email protected]
.rc.$(RES):
	$(RC) [email protected] $(RCFLAGS) "$<"
pkgIndex.tcl: Makefile
	[email protected] Creating pkgIndex.tcl
	@( \
	echo 'if {[catch {package require Tcl $(TCL_VERSION_REQ)}]} return'; \
	echo 'package ifneeded $(PACKAGE_NAME) $(PACKAGE_VERSION) \
	    [list load [file join $$dir $(PKG_LIB_FILE)] $(PACKAGE_NAME)]' \
	) > pkgIndex.tcl
Makefile: $(SRC_DIR)/Makefile.in $(top_builddir)/config.status
	cd $(top_builddir) \
	  && [email protected] CONFIG_HEADERS= $(SHELL) ./config.status

#========================================================================
# How to rebuild the package's stub table.
#========================================================================

genstubs: $(TCL_TOOLS_DIR)/genStubs.tcl $(SRC_DIR)/generic/tclOO.decls
	@echo $(TCLSH_PROG) $(TCL_TOOLS_DIR)/genStubs.tcl $(SRC_DIR)/generic $(SRC_DIR)/generic/tclOO.decls
	@$(TCLSH) `$(CYGPATH) $(TCL_TOOLS_DIR)/genStubs.tcl` `$(CYGPATH) $(SRC_DIR)/generic` `$(CYGPATH) $(SRC_DIR)/generic/tclOO.decls`

#========================================================================
# Build a starkit - this is experimental!
#========================================================================

sdx_valid:
	@test "$(SDX)" != "none" || ( echo "Cannot build kit; no sdx!"; false )
$(PKG_KIT): $(PKG_LIB_FILE)
	[email protected] -p $(KIT_PKG_ROOT)/$(PLATFORM)
	cp $(PKG_LIB_FILE) $(KIT_PKG_ROOT)/$(PLATFORM)
	[email protected] Creating $(KIT_PKG_ROOT)/pkgIndex.tcl
	@( \
	echo 'if {[catch {package require Tcl $(TCL_VERSION_REQ)}]} return'; \
	echo 'package ifneeded $(PACKAGE_NAME) $(PACKAGE_VERSION)' \
	    '[list load [file join $$dir $(PLATFORM) $(PKG_LIB_FILE)] $(PACKAGE_NAME)]' \
	) > $(KIT_PKG_ROOT)/pkgIndex.tcl
	$(SDX) wrap $(PKG_KIT)
	[email protected] -rf $(PKG_KIT_ROOT).vfs $(PKG_KIT_ROOT).bat

#========================================================================
# How to clean up after a build.
#========================================================================

clean:
	-test -z "$(BINARIES)" || rm -f $(BINARIES)
	-rm -f *.$(OBJEXT) core *.core
	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean: clean
	-rm -f *.tab.c
	-rm -f $(CONFIG_CLEAN_FILES)
	-rm -f config.cache config.log config.status

#========================================================================
# Distribution creation (FROM sampleextension)
# You may need to tweak this target to make it work correctly.
#========================================================================

#COMPRESS	= tar cvf $(PKG_DIR).tar $(PKG_DIR); compress $(PKG_DIR).tar
COMPRESS	= tar zcvf $(PKG_DIR).tar.gz $(PKG_DIR)
DIST_ROOT	= /tmp/dist
DIST_DIR	= $(DIST_ROOT)/$(PKG_DIR)

dist-clean:
	rm -rf $(DIST_DIR) $(DIST_ROOT)/$(PKG_DIR).tar.*

dist: dist-clean
	mkdir -p $(DIST_DIR)
	cp -p $(srcdir)/ChangeLog $(srcdir)/README* $(srcdir)/license* \
		$(srcdir)/aclocal.m4 $(srcdir)/configure $(srcdir)/*.in \
		$(DIST_DIR)/
	chmod 664 $(DIST_DIR)/Makefile.in $(DIST_DIR)/aclocal.m4
	chmod 775 $(DIST_DIR)/configure $(DIST_DIR)/configure.in

	for i in $(srcdir)/*.[ch]; do \
	    if [ -f $$i ]; then \
		cp -p $$i $(DIST_DIR)/ ; \
	    fi; \
	done;

	mkdir $(DIST_DIR)/tclconfig
	cp $(srcdir)/tclconfig/install-sh $(srcdir)/tclconfig/tcl.m4 \
		$(DIST_DIR)/tclconfig/
	chmod 664 $(DIST_DIR)/tclconfig/tcl.m4
	chmod +x $(DIST_DIR)/tclconfig/install-sh

	list='demos generic library mac tests unix win'; \
	for p in $$list; do \
	    if test -d $(srcdir)/$$p ; then \
		mkdir $(DIST_DIR)/$$p; \
		cp -p $(srcdir)/$$p/*.* $(DIST_DIR)/$$p/; \
	    fi; \
	done
	mkdir $(DIST_DIR)/doc
	for p in $(srcdir)/doc/*.?; do \
	    soelim -I $(srcdir)/doc $$p >$(DIST_DIR)/doc/`basename $$p`; \
	done

	(cd $(DIST_ROOT); $(COMPRESS);)

#========================================================================
# Magic declarations to make.
#========================================================================

.SUFFIXES: .c .$(OBJEXT) .rc .$(RES)
.PHONY: all package clean depend distclean doc install libraries test kit
.PHONY: sdx_valid doc dist dist-clean benchmarks shell genstubs gdb gdbtest
.PHONY: valgrind valgrindtest testpackage