Index: unix/Makefile.in ================================================================== --- unix/Makefile.in +++ unix/Makefile.in @@ -98,15 +98,15 @@ DEMO_INSTALL_DIR = $(INSTALL_ROOT)@DEMO_DIR@ # 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: TCL_BIN_DIR = @TCL_BIN_DIR@ @@ -308,11 +308,11 @@ TOP_DIR = $(SRC_DIR)/.. 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 #---------------------------------------------------------------- @@ -567,21 +567,21 @@ 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 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 # The following target is configured by autoconf to generate either # a shared library or non-shared library for Tk. @@ -683,11 +683,11 @@ $(SHELL_ENV) ./${WISH_EXE} $(TOP_DIR)/library/demos/widget # 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 VALGRINDARGS=--tool=memcheck --num-callers=8 --leak-resolution=high --leak-check=yes --show-reachable=yes -v @@ -1564,11 +1564,11 @@ 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 $(UNIX_DIR)/configure: $(UNIX_DIR)/configure.ac $(UNIX_DIR)/tcl.m4 \ $(UNIX_DIR)/aclocal.m4 @@ -1721,11 +1721,11 @@ BUILD_HTML = \ @if test -f "$(BUILD_TCLSH)"; then \ $(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 # 'make' from getting confused when someone makes an error in a rule. # Index: unix/configure ================================================================== --- unix/configure +++ unix/configure @@ -707,12 +707,10 @@ CPPFLAGS LDFLAGS CFLAGS CC MAN_FLAGS -BUILD_TCLSH -TCLSH_PROG TCL_STUB_LIB_SPEC TCL_STUB_LIB_FLAG TCL_STUB_LIB_FILE TCL_LIB_SPEC TCL_LIB_FLAG @@ -719,10 +717,15 @@ TCL_LIB_FILE TCL_SRC_DIR TCL_BIN_DIR TCL_PATCH_LEVEL TCL_VERSION +TCL_ACTUAL_SRC_DIR +TCL_SOURCE_MINOR_VERSION +TCL_SOURCE_MAJOR_VERSION +BUILD_TCLSH +TCLSH_PROG target_alias host_alias build_alias LIBS ECHO_T @@ -2303,10 +2306,51 @@ #-------------------------------------------------------------------- # Find and load the tclConfig.sh file #-------------------------------------------------------------------- + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclsh" >&5 +$as_echo_n "checking for tclsh... " >&6; } + if ${ac_cv_path_tclsh+:} false; then : + $as_echo_n "(cached) " >&6 +else + + search_path=`echo ${PATH} | sed -e 's/:/ /g'` + for dir in $search_path ; do + for j in `ls -r $dir/tclsh[8-9]* 2> /dev/null` \ + `ls -r $dir/tclsh* 2> /dev/null` ; do + if test x"$ac_cv_path_tclsh" = x ; then + if test -f "$j" ; then + ac_cv_path_tclsh=$j + break + fi + fi + done + done + +fi + + + if test -f "$ac_cv_path_tclsh" ; then + TCLSH_PROG="$ac_cv_path_tclsh" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TCLSH_PROG" >&5 +$as_echo "$TCLSH_PROG" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: No tclsh avaliable" >&5 +$as_echo "No tclsh avaliable" >&6; } + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclsh in Tcl build directory" >&5 +$as_echo_n "checking for tclsh in Tcl build directory... " >&6; } + BUILD_TCLSH="${TCL_BIN_DIR}"/tclsh + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUILD_TCLSH" >&5 +$as_echo "$BUILD_TCLSH" >&6; } + + + # # Ok, lets find the tcl configuration # First, look for one uninstalled. # the alternative search directory is invoked by --with-tcl @@ -2484,10 +2528,148 @@ eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\"" eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\"" eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\"" + 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 + as_fn_error $? "could not find Tcl sources" "$LINENO" 5 + else + TCL_SOURCE_MAJOR_VERSION=` <<-'EOF' "$TCLSH_PROG" - "$TCL_ACTUAL_SRC_DIR " "1" + 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 + ` + + + + + TCL_SOURCE_MINOR_VERSION=` <<-'EOF' "$TCLSH_PROG" - "$TCL_ACTUAL_SRC_DIR " "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 + ` + + + + + TCL_ACTUAL_SRC_DIR=` <<-'EOF' "$TCLSH_PROG" - "$TCL_ACTUAL_SRC_DIR " "0" + 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 + ` + + + + + fi + + + @@ -2507,53 +2689,10 @@ if test "${TCL_MINOR_VERSION}" -lt 6 ; then as_fn_error $? "${PACKAGE_NAME} ${PACKAGE_VERSION} requires Tcl 8.6+ Found config for Tcl ${TCL_VERSION}" "$LINENO" 5 fi fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclsh" >&5 -$as_echo_n "checking for tclsh... " >&6; } - if ${ac_cv_path_tclsh+:} false; then : - $as_echo_n "(cached) " >&6 -else - - search_path=`echo ${PATH} | sed -e 's/:/ /g'` - for dir in $search_path ; do - for j in `ls -r $dir/tclsh[8-9]* 2> /dev/null` \ - `ls -r $dir/tclsh* 2> /dev/null` ; do - if test x"$ac_cv_path_tclsh" = x ; then - if test -f "$j" ; then - ac_cv_path_tclsh=$j - break - fi - fi - done - done - -fi - - - if test -f "$ac_cv_path_tclsh" ; then - TCLSH_PROG="$ac_cv_path_tclsh" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TCLSH_PROG" >&5 -$as_echo "$TCLSH_PROG" >&6; } - else - # It is not an error if an installed version of Tcl can't be located. - TCLSH_PROG="" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: No tclsh found on PATH" >&5 -$as_echo "No tclsh found on PATH" >&6; } - fi - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclsh in Tcl build directory" >&5 -$as_echo_n "checking for tclsh in Tcl build directory... " >&6; } - BUILD_TCLSH="${TCL_BIN_DIR}"/tclsh - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUILD_TCLSH" >&5 -$as_echo "$BUILD_TCLSH" >&6; } - #------------------------------------------------------------------------ # Handle the --prefix=... option #------------------------------------------------------------------------ Index: unix/configure.ac ================================================================== --- unix/configure.ac +++ unix/configure.ac @@ -30,10 +30,12 @@ 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 if test "${TCL_MAJOR_VERSION}" -lt 9 ; then @@ -45,12 +47,10 @@ AC_MSG_ERROR([${PACKAGE_NAME} ${PACKAGE_VERSION} requires Tcl 8.6+ Found config for Tcl ${TCL_VERSION}]) fi fi -SC_PROG_TCLSH -SC_BUILD_TCLSH #------------------------------------------------------------------------ # Handle the --prefix=... option #------------------------------------------------------------------------ Index: unix/tcl.m4 ================================================================== --- unix/tcl.m4 +++ unix/tcl.m4 @@ -333,10 +333,12 @@ # eval is required to do the TCL_DBGX substitution eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\"" eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\"" 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) AC_SUBST(TCL_SRC_DIR) @@ -430,10 +432,138 @@ AC_SUBST(TK_STUB_LIB_FILE) AC_SUBST(TK_STUB_LIB_FLAG) 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 # will only find a Tcl shell that already exists on the system. # It will not find a Tcl shell in the Tcl build directory or @@ -471,13 +601,11 @@ if test -f "$ac_cv_path_tclsh" ; then 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) ]) #------------------------------------------------------------------------