summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authoryorick <yorick>2019-03-27 08:30:52 (GMT)
committeryorick <yorick>2019-03-27 08:30:52 (GMT)
commitc059c38dd316f4ecaad42e687677a498ef381be8 (patch)
tree4d023ec65c70c927f5d24b9945eee805e45b14cd /unix
parent8bbc14293d2224c22250cce49da45f36c2ca72ae (diff)
downloadtk-c059c38dd316f4ecaad42e687677a498ef381be8.zip
tk-c059c38dd316f4ecaad42e687677a498ef381be8.tar.gz
tk-c059c38dd316f4ecaad42e687677a498ef381be8.tar.bz2
Improve ability to find Tcl sources at build time. This introduces a new
build-time dependency: A working tclsh version 8.6 or higher must be available in the build environment.
Diffstat (limited to 'unix')
-rw-r--r--unix/Makefile.in16
-rw-r--r--unix/configure.ac4
-rw-r--r--unix/tcl.m4133
3 files changed, 140 insertions, 13 deletions
diff --git a/unix/Makefile.in b/unix/Makefile.in
index 86a8a61..56c343b 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -100,11 +100,11 @@ DEMO_INSTALL_DIR = $(INSTALL_ROOT)$(TK_LIBRARY)/demos
# The directory containing the Tcl sources and headers appropriate
# for this version of Tk ("srcdir" will be replaced or has already
# been replaced by the configure script):
-TCL_GENERIC_DIR = @TCL_SRC_DIR@/generic
+TCL_GENERIC_DIR = @TCL_ACTUAL_SRC_DIR@/generic
# The directory containing the platform specific Tcl sources and headers
# appropriate for this version of Tk:
-TCL_PLATFORM_DIR = @TCL_SRC_DIR@/unix
+TCL_PLATFORM_DIR = @TCL_ACTUAL_SRC_DIR@/unix
# The directory containing the Tcl library archive file appropriate
# for this version of Tk:
@@ -310,7 +310,7 @@ GENERIC_DIR = $(TOP_DIR)/generic
TTK_DIR = $(GENERIC_DIR)/ttk
UNIX_DIR = $(TOP_DIR)/unix
BMAP_DIR = $(TOP_DIR)/bitmaps
-TOOL_DIR = @TCL_SRC_DIR@/tools
+TOOL_DIR = @TCL_ACTUAL_SRC_DIR@/tools
TEST_DIR = $(TOP_DIR)/tests
MAC_OSX_DIR = $(TOP_DIR)/macosx
XLIB_DIR = $(TOP_DIR)/xlib
@@ -566,7 +566,7 @@ DEMOPROGS = browse hello ixset rmt rolodex square tcolor timer widget
SHELL_ENV = \
@LD_LIBRARY_PATH_VAR@="`pwd`:${TCL_BIN_DIR}:$${@LD_LIBRARY_PATH_VAR@}"; \
export @LD_LIBRARY_PATH_VAR@; \
- TCL_LIBRARY=@TCL_SRC_DIR@/library; export TCL_LIBRARY; \
+ TCL_LIBRARY=@TCL_ACTUAL_SRC_DIR@/library; export TCL_LIBRARY; \
TK_LIBRARY=@TK_SRC_DIR@/library; export TK_LIBRARY;
all: binaries libraries doc
@@ -576,7 +576,7 @@ binaries: ${LIB_FILE} ${WISH_EXE}
libraries:
$(TOP_DIR)/doc/man.macros:
- $(INSTALL_DATA) @TCL_SRC_DIR@/doc/man.macros $(TOP_DIR)/doc/man.macros
+ $(INSTALL_DATA) $(TCLDIR)/doc/man.macros $(TOP_DIR)/doc/man.macros
doc: $(TOP_DIR)/doc/man.macros
@@ -682,7 +682,7 @@ demo:
# This target can be used to run wish inside either gdb or insight
gdb: ${WISH_EXE}
@echo "set env @LD_LIBRARY_PATH_VAR@=\"`pwd`:${TCL_BIN_DIR}:$${@LD_LIBRARY_PATH_VAR@}\"" > gdb.run
- @echo "set env TCL_LIBRARY=@TCL_SRC_DIR@/library" >> gdb.run
+ @echo "set env TCL_LIBRARY=@TCL_ACTUAL_SRC_DIR@/library" >> gdb.run
@echo "set env TK_LIBRARY=@TK_SRC_DIR@/library" >> gdb.run
gdb ./${WISH_EXE} --command=gdb.run
rm gdb.run
@@ -1534,7 +1534,7 @@ DISTROOT = /tmp/dist
DISTNAME = tk${VERSION}${PATCH_LEVEL}
ZIPNAME = tk${MAJOR_VERSION}${MINOR_VERSION}${PATCH_LEVEL}-src.zip
DISTDIR = $(DISTROOT)/$(DISTNAME)
-TCLDIR = @TCL_SRC_DIR@
+TCLDIR = @TCL_ACTUAL_SRC_DIR@
DIST_INSTALL_DATA = CPPROG='cp -p' $(INSTALL) -m 644
DIST_INSTALL_SCRIPT = CPPROG='cp -p' $(INSTALL) -m 755
@@ -1691,7 +1691,7 @@ BUILD_HTML = \
$(SHELL_ENV) TCLSH="$(BUILD_TCLSH)"; else \
TCLSH="$(TCL_EXE)"; fi ;\
"$${TCLSH}" $(TOOL_DIR)/tcltk-man2html.tcl --htmldir="$(HTML_INSTALL_DIR)" \
- --srcdir=$(TOP_DIR)/.. $(BUILD_HTML_FLAGS)
+ --tk --srcdir=$(TOP_DIR) $(BUILD_HTML_FLAGS)
#
# The list of all the targets that do not correspond to real files. This stops
diff --git a/unix/configure.ac b/unix/configure.ac
index 5f5213d..a8c403b 100644
--- a/unix/configure.ac
+++ b/unix/configure.ac
@@ -32,6 +32,8 @@ LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv"
#--------------------------------------------------------------------
# Find and load the tclConfig.sh file
#--------------------------------------------------------------------
+SC_PROG_TCLSH
+SC_BUILD_TCLSH
SC_PATH_TCLCONFIG
SC_LOAD_TCLCONFIG
@@ -47,8 +49,6 @@ Found config for Tcl ${TCL_VERSION}])
fi
fi
-SC_PROG_TCLSH
-SC_BUILD_TCLSH
#------------------------------------------------------------------------
# Handle the --prefix=... option
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 2f114d7..0d4970d 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -336,6 +336,8 @@ AC_DEFUN([SC_LOAD_TCLCONFIG], [
eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
+ SC_TCL_FIND_SOURCES()
+
AC_SUBST(TCL_VERSION)
AC_SUBST(TCL_PATCH_LEVEL)
AC_SUBST(TCL_BIN_DIR)
@@ -432,6 +434,133 @@ AC_DEFUN([SC_LOAD_TKCONFIG], [
AC_SUBST(TK_STUB_LIB_SPEC)
])
+
+#------------------------------------------------------------------------
+# SC_TCL_FIND_SOURCES
+# Find a directory containing Tcl sources that match the version required by
+# tclConfig.sh. The sources indicated by tclConfig.sh are preferred.
+#
+# Arguments:
+# none
+#
+# Results:
+# Substitutes the following vars:
+# TCL_SOURCE_MAJOR_VERSION
+# TCL_SOURCE_MINOR_VERSION
+# TCL_ACTUAL_SRC_DIR
+#------------------------------------------------------------------------
+
+AC_DEFUN([SC_TCL_FIND_SOURCES],[
+ [TCL_ACTUAL_SRC_DIR=` <<-'EOF' "$TCLSH_PROG" - "$srcdir" "$TCL_SRC_DIR" \
+ "$TCL_MAJOR_VERSION" "$TCL_MINOR_VERSION"
+
+ proc cat fname {
+ set chan [open $fname]
+ try {
+ read $chan
+ } finally {
+ close $chan
+ }
+ }
+
+ proc main {argv0 argv} {
+ try {
+ lassign $argv -> srcdir tcl_src_dir majortarget minortarget
+ lappend candidates $tcl_src_dir
+ set srcdir [file dirname [file normalize $srcdir/...]]
+ set topsrcdir [file dirname $srcdir]
+ set sources [file dirname $topsrcdir]
+ foreach dirname [glob -nocomplain -directory $sources *] {
+ if {$dirname ni $candidates} {
+ lappend candidates $dirname
+ }
+ }
+ foreach candidate $candidates {
+ set res [check $candidate $majortarget $minortarget]
+ if {$res eq {}} continue else {
+ puts -nonewline $res
+ break
+ }
+ }
+ set status 0
+ } on error {tres topts} {
+ puts stderr [dict get $topts -errorinfo]
+ set status 1
+ }
+ exit $status
+ }
+
+ proc check {candidate majortarget minortarget} {
+ set tclh $candidate/generic/tcl.h
+
+ if {![file exists $tclh]} {
+ return {}
+ }
+
+ set version [tclhversion [cat $tclh]]
+ if {[llength $version]} {
+ lassign $version major minor
+ if {[package vcompare $major.$minor \
+ $majortarget.$minortarget] >= 0} {
+ return [list $candidate $major $minor]
+ }
+ }
+
+ return {}
+ }
+
+ proc tclhversion data {
+ if {[regexp -line {^#define\s+_TCL} $data]} {
+ if {[
+ regexp -line {^#define\s+TCL_VERSION\s+\"([^.])+\.([^.\"]+)} \
+ $data -> major minor
+ ]} {
+ return [list $major $minor]
+ }
+ }
+ return {}
+ }
+ main $argv0 $argv
+ EOF
+ ]
+ `
+
+ if test "x${TCL_ACTUAL_SRC_DIR}" = x; then
+ AC_MSG_ERROR([could not find Tcl sources])
+ else
+ TCL_SOURCE_MAJOR_VERSION=SC_TCL_LINDEX([$TCL_ACTUAL_SRC_DIR] ,1)
+ AC_SUBST(TCL_SOURCE_MAJOR_VERSION)
+ TCL_SOURCE_MINOR_VERSION=SC_TCL_LINDEX([$TCL_ACTUAL_SRC_DIR] ,2)
+ AC_SUBST(TCL_SOURCE_MINOR_VERSION)
+ TCL_ACTUAL_SRC_DIR=SC_TCL_LINDEX([$TCL_ACTUAL_SRC_DIR] ,0)
+ AC_SUBST(TCL_ACTUAL_SRC_DIR)
+ fi
+])
+
+
+#------------------------------------------------------------------------
+# SC_TCL_LINDEX
+#------------------------------------------------------------------------
+
+AC_DEFUN([SC_TCL_LINDEX],
+ [[` <<-'EOF' "$TCLSH_PROG" - "$1" "$2"
+ proc main {argv0 argv} {
+ try {
+ lassign $argv -> list index
+ puts -nonewline [lindex $list $index]
+ set status 0
+ } on error {tres topts} {
+ puts stderr [dict get $topts -errorinfo]
+ set status 1
+ }
+ exit $status
+ }
+ main $argv0 $argv
+ EOF
+ ]]
+ `
+)
+
#------------------------------------------------------------------------
# SC_PROG_TCLSH
# Locate a tclsh shell installed on the system path. This macro
@@ -473,9 +602,7 @@ AC_DEFUN([SC_PROG_TCLSH], [
TCLSH_PROG="$ac_cv_path_tclsh"
AC_MSG_RESULT([$TCLSH_PROG])
else
- # It is not an error if an installed version of Tcl can't be located.
- TCLSH_PROG=""
- AC_MSG_RESULT([No tclsh found on PATH])
+ AC_MSG_RESULT([No tclsh avaliable])
fi
AC_SUBST(TCLSH_PROG)
])