Compilation 查找用于macOS的预编译或编译Tcl/Tk框架
我是Tcl/Tk的初学者,但我已经需要部署一个包含Tcl/Tk框架的.app(因为.app需要依赖自己的Tcl/Tk版本,而不是macOS标准和旧的Tcl/Tk)。有人能告诉我在哪里可以找到预编译的框架,或是如何在macOS上编译它们的分步指南吗Compilation 查找用于macOS的预编译或编译Tcl/Tk框架,compilation,frameworks,tcl,tk,Compilation,Frameworks,Tcl,Tk,我是Tcl/Tk的初学者,但我已经需要部署一个包含Tcl/Tk框架的.app(因为.app需要依赖自己的Tcl/Tk版本,而不是macOS标准和旧的Tcl/Tk)。有人能告诉我在哪里可以找到预编译的框架,或是如何在macOS上编译它们的分步指南吗 在这方面,半天的搜索并不是很有成效。我想我的需求一点也不特别,因为我看到很多应用都有自己的Tcl/Tk框架。(注:我需要从Perl访问这些框架,但这不会有任何区别。)这是我的构建脚本。您将需要进行修改以适应 你的需要 我对init.tcl进行了修改,
在这方面,半天的搜索并不是很有成效。我想我的需求一点也不特别,因为我看到很多应用都有自己的Tcl/Tk框架。(注:我需要从Perl访问这些框架,但这不会有任何区别。)这是我的构建脚本。您将需要进行修改以适应 你的需要
- 我对init.tcl进行了修改,以便tcl在适当的位置进行搜索 并且不会首先查看MacOS标准位置。这部分 脚本将从Tcl/Tk 8.7开始中断。它还有一条路径是 非常特定于我的安装(“darwin 64 tcl库”部分)。 保留它不会有任何伤害,或者您可以根据需要修改路径
- 我使应用程序可重新定位,以便它可以从任何位置运行。 这可能是一个安全问题。建议进行额外处理 安装后完成,以将库路径设置为静态位置
MacOS Mojave仍在进行各种错误修复。 其他人可能会提出其他建议 变量:
- macosxminver:编译Tcl/Tk的MacOS的最早版本
- INSTLOC:安装位置。把它指向目标以外的地方 目录,然后将文件复制到目标目录。 请注意,脚本会完全删除INSTLOC目录。
- sver:简短的Tcl版本。唯一使用它的地方是在SRCDIR定义中。 根据您的SRCDIR目录结构,您可能不需要这个
- 版本:Tcl版本号
- mver:Tcl主要版本号
- SRCDIR:Tcl/Tk源代码树所在的位置。为此目的 脚本中,我有一个具有以下结构的目录:
tcl868/
tcl8.6.8/
tk8.6.8/
tclbuild.sh:
#!/bin/bash
macosxminver=10.9
sver=868cp
ver=8.6.8
mver=8.6
tclmver=$mver
tkmver=$mver
SRCDIR=$HOME/t/tcl${sver}
INSTLOC=$HOME/t/localB
if [[ $1 != "" ]]; then
INSTLOC=$1
fi
if [[ -d $INSTLOC ]]; then
rm -rf $INSTLOC
fi
mkdir $INSTLOC
cd $SRCDIR
test -d build && rm -rf build
cd $SRCDIR
cd tcl${ver}
if [[ $? -eq 0 ]]; then
f=library/init.tcl
if [[ ! -f $f-orig ]]; then
cp -pf $f $f-orig
fi
cp -pf $f-orig $f
ed $f << _HERE_
/issafe/
i
foreach Dir [list \$::tcl_library [file dirname \$::tcl_library]] {
if { [string match *Tcl.framework* \$Dir] } {
regsub Tcl.framework \$Dir Tk.framework Dir
if {\$Dir ni \$::auto_path} {
lappend ::auto_path \$Dir
}
}
}
# This needs to be at the end
# The real wish executable is in an odd place.
# Find the tcl directory in the path.
set Dir [file dirname [info nameofexecutable]]
if { [string match *MacOS* \$Dir] } {
regsub {MacOS.*} \$Dir {MacOS} Dir
set Dir [file join \$Dir darwin 64 tcl lib]
lappend ::auto_path \$Dir
} else {
set Dir [file join [file dirname [file dirname \\
[info nameofexecutable]]] lib]
}
.
?catch
?set Dir
.,.+4 s/^/#/
/catch
.+1,.+5 s/^/#/
w
q
_HERE_
make -C macosx \
PREFIX="" \
CFLAGS_OPTIMIZE="-O2 -mmacosx-version-min=${macosxminver}" \
INSTALL_ROOT=$INSTLOC install
cd $SRCDIR
chmod u+w $INSTLOC/bin/tclsh${tclmver}
install_name_tool -change \
"/Library/Frameworks/Tcl.framework/Versions/${tclmver}/Tcl" \
@executable_path/../Library/Frameworks/Tcl.framework/Versions/${tclmver}/Tcl \
$INSTLOC/bin/tclsh${tclmver}
fi
cd $SRCDIR
cd tk${ver}
if [[ $? -eq 0 ]]; then
make -C macosx \
PREFIX="" \
CFLAGS_OPTIMIZE="-O2 -mmacosx-version-min=${macosxminver}" \
INSTALL_ROOT=$INSTLOC install
cd $SRCDIR
chmod u+w $INSTLOC/Library/Frameworks/Tk.framework/Versions/${tkmver}/Resources/Wish.app/Contents/MacOS/Wish
install_name_tool -change \
"/Library/Frameworks/Tk.framework/Versions/${tkmver}/Tk" \
@executable_path/../../../../Tk \
$INSTLOC/Library/Frameworks/Tk.framework/Versions/${tkmver}/Resources/Wish.app/Contents/MacOS/Wish
install_name_tool -change \
"/Library/Frameworks/Tcl.framework/Versions/${tclmver}/Tcl" \
@executable_path/../../../../../../../Tcl.framework/Versions/${tclmver}/Tcl \
$INSTLOC/Library/Frameworks/Tk.framework/Versions/${tkmver}/Resources/Wish.app/Contents/MacOS/Wish
fi
cd $SRCDIR
find $INSTLOC -type f -print0 | xargs -0 chmod u+w
exit 0
#/bin/bash
macosxminver=10.9
sver=868cp
ver=8.6.8
mver=8.6
tclmver=$mver
tkmver=$mver
SRCDIR=$HOME/t/tcl${sver}
INSTLOC=$HOME/t/localB
如果[[$1!=”“];然后
INSTLOC=1美元
fi
如果[-d$INSTLOC]];然后
rm-rf$INSTLOC
fi
mkdir$INSTLOC
cd$SRCDIR
测试-d构建和rm-rf构建
cd$SRCDIR
cd tcl${ver}
如果[$?-eq 0]];然后
f=库/init.tcl
如果[!-f$f-orig]];然后
cp-pf$f$f-orig
fi
cp-pf$f-orig$f
ed$f这是我的构建脚本。您将需要进行修改以适应
你的需要
- 我对init.tcl进行了修改,以便tcl在适当的位置进行搜索
并且不会首先查看MacOS标准位置。这部分
脚本将从Tcl/Tk 8.7开始中断。它还有一条路径是
非常特定于我的安装(“darwin 64 tcl库”部分)。
保留它不会有任何伤害,或者您可以根据需要修改路径
- 我使应用程序可重新定位,以便它可以从任何位置运行。
这可能是一个安全问题。建议进行额外处理
安装后完成,以将库路径设置为静态位置
现在我个人推荐Tcl/Tk 8.6.8,但它必须使用
早期的XCode版本(我在Sierra上使用XCode命令行工具9.2)。
MacOS Mojave仍在进行各种错误修复。
其他人可能会提出其他建议
变量:
- macosxminver:编译Tcl/Tk的MacOS的最早版本
- INSTLOC:安装位置。把它指向目标以外的地方
目录,然后将文件复制到目标目录。
请注意,脚本会完全删除INSTLOC目录。
- sver:简短的Tcl版本。唯一使用它的地方是在SRCDIR定义中。
根据您的SRCDIR目录结构,您可能不需要这个
- 版本:Tcl版本号
- mver:Tcl主要版本号
- SRCDIR:Tcl/Tk源代码树所在的位置。为此目的
脚本中,我有一个具有以下结构的目录:
目录结构:
tcl868/
tcl8.6.8/
tk8.6.8/
tclbuild.sh:
#!/bin/bash
macosxminver=10.9
sver=868cp
ver=8.6.8
mver=8.6
tclmver=$mver
tkmver=$mver
SRCDIR=$HOME/t/tcl${sver}
INSTLOC=$HOME/t/localB
if [[ $1 != "" ]]; then
INSTLOC=$1
fi
if [[ -d $INSTLOC ]]; then
rm -rf $INSTLOC
fi
mkdir $INSTLOC
cd $SRCDIR
test -d build && rm -rf build
cd $SRCDIR
cd tcl${ver}
if [[ $? -eq 0 ]]; then
f=library/init.tcl
if [[ ! -f $f-orig ]]; then
cp -pf $f $f-orig
fi
cp -pf $f-orig $f
ed $f << _HERE_
/issafe/
i
foreach Dir [list \$::tcl_library [file dirname \$::tcl_library]] {
if { [string match *Tcl.framework* \$Dir] } {
regsub Tcl.framework \$Dir Tk.framework Dir
if {\$Dir ni \$::auto_path} {
lappend ::auto_path \$Dir
}
}
}
# This needs to be at the end
# The real wish executable is in an odd place.
# Find the tcl directory in the path.
set Dir [file dirname [info nameofexecutable]]
if { [string match *MacOS* \$Dir] } {
regsub {MacOS.*} \$Dir {MacOS} Dir
set Dir [file join \$Dir darwin 64 tcl lib]
lappend ::auto_path \$Dir
} else {
set Dir [file join [file dirname [file dirname \\
[info nameofexecutable]]] lib]
}
.
?catch
?set Dir
.,.+4 s/^/#/
/catch
.+1,.+5 s/^/#/
w
q
_HERE_
make -C macosx \
PREFIX="" \
CFLAGS_OPTIMIZE="-O2 -mmacosx-version-min=${macosxminver}" \
INSTALL_ROOT=$INSTLOC install
cd $SRCDIR
chmod u+w $INSTLOC/bin/tclsh${tclmver}
install_name_tool -change \
"/Library/Frameworks/Tcl.framework/Versions/${tclmver}/Tcl" \
@executable_path/../Library/Frameworks/Tcl.framework/Versions/${tclmver}/Tcl \
$INSTLOC/bin/tclsh${tclmver}
fi
cd $SRCDIR
cd tk${ver}
if [[ $? -eq 0 ]]; then
make -C macosx \
PREFIX="" \
CFLAGS_OPTIMIZE="-O2 -mmacosx-version-min=${macosxminver}" \
INSTALL_ROOT=$INSTLOC install
cd $SRCDIR
chmod u+w $INSTLOC/Library/Frameworks/Tk.framework/Versions/${tkmver}/Resources/Wish.app/Contents/MacOS/Wish
install_name_tool -change \
"/Library/Frameworks/Tk.framework/Versions/${tkmver}/Tk" \
@executable_path/../../../../Tk \
$INSTLOC/Library/Frameworks/Tk.framework/Versions/${tkmver}/Resources/Wish.app/Contents/MacOS/Wish
install_name_tool -change \
"/Library/Frameworks/Tcl.framework/Versions/${tclmver}/Tcl" \
@executable_path/../../../../../../../Tcl.framework/Versions/${tclmver}/Tcl \
$INSTLOC/Library/Frameworks/Tk.framework/Versions/${tkmver}/Resources/Wish.app/Contents/MacOS/Wish
fi
cd $SRCDIR
find $INSTLOC -type f -print0 | xargs -0 chmod u+w
exit 0
#/bin/bash
macosxminver=10.9
sver=868cp
ver=8.6.8
mver=8.6
tclmver=$mver
tkmver=$mver
SRCDIR=$HOME/t/tcl${sver}
INSTLOC=$HOME/t/localB
如果[[$1!=”“];然后
INSTLOC=1美元
fi
如果[-d$INSTLOC]];然后
rm-rf$INSTLOC
fi
mkdir$INSTLOC
cd$SRCDIR
测试-d构建和rm-rf构建
cd$SRCDIR
cd tcl${ver}
如果[$?-eq 0]];然后
f=库/init.tcl
如果[!-f$f-orig]];然后
cp-pf$f$f-orig
fi
cp-pf$f-orig$f
ed$f我在Mojave上编译了几分钟后,建议的脚本失败,错误如下:
ERROR: version conflict for package "Tcl": have 8.5.9, need 8.6-
If running this script from 'make html', set the NATIVE_TCLSH environment
variable to point to an installed tclsh8.6 (or the equivalent tclsh86.exe
on Windows).
make[3]: *** [html-tcl] Error 1
make[2]: *** [install-strip] Error 2
make[1]: *** [install-tcl] Error 2
make: *** [install-deploy] Error 2
tclbuild.sh: line 74: cd: /Users/xl/t/tcl869cp: No such file or directory
tclbuild.sh: line 83: cd: /Users/xl/t/tcl869cp: No such file or directory
tclbuild.sh: line 84: cd: tk8.6.9: No such file or directory
tclbuild.sh: line 103: cd: /Users/xl/t/tcl869cp: No such file or directory
我拥有最新的Tcl/Tk(8.6.9)资源和如上所述的相同文件夹结构。编译几分钟后,建议的脚本在Mojave上失败,错误如下:
ERROR: version conflict for package "Tcl": have 8.5.9, need 8.6-
If running this script from 'make html', set the NATIVE_TCLSH environment
variable to point to an installed tclsh8.6 (or the equivalent tclsh86.exe
on Windows).
make[3]: *** [html-tcl] Error 1
make[2]: *** [install-strip] Error 2
make[1]: *** [install-tcl] Error 2
make: *** [install-deploy] Error 2
tclbuild.sh: line 74: cd: /Users/xl/t/tcl869cp: No such file or directory
tclbuild.sh: line 83: cd: /Users/xl/t/tcl869cp: No such file or directory
tclbuild.sh: line 84: cd: tk8.6.9: No such file or directory
tclbuild.sh: line 103: cd: /Users/xl/t/tcl869cp: No such file or directory
我有最新的Tcl/Tk(8.6.9)资源和如上所述的相同文件夹结构。只是想知道:在Tcl中使用支持框架的构建机制有什么问题:make-C/path/to/your/Tcl/src/macosx install
。另见。它们对我来说很好,没什么区别。脚本做了更多的工作,以确保构建是可重新定位的,并在其安装位置工作。thx对于解释,当然值得添加到内置构建机制中?使用8.6.9,顺便说一句,我希望看到init.tcl脚本“修复”,这样它就可以帮助我们了