diff options
author | das <das> | 2005-05-23 20:24:56 (GMT) |
---|---|---|
committer | das <das> | 2005-05-23 20:24:56 (GMT) |
commit | b1aaa8a9641695afda195f1e3450c10a4de59670 (patch) | |
tree | 6a75bc6224147be902b9f8707503d0ea3eebc0a9 /macosx | |
parent | 3e5059b18e124abb2aacc381e3e3c8c2e95c23c3 (diff) | |
download | tk-b1aaa8a9641695afda195f1e3450c10a4de59670.zip tk-b1aaa8a9641695afda195f1e3450c10a4de59670.tar.gz tk-b1aaa8a9641695afda195f1e3450c10a4de59670.tar.bz2 |
* macosx/Makefile:
* macosx/README:
* macosx/Tk-Info.plist.in (new file):
* macosx/Wish-Info.plist.in (new file):
* unix/Makefile.in:
* unix/configure.in:
* unix/tcl.m4:
* unix/tkUnixInit.c: moved all Darwin framework and TkAqua build
support from macosx/Wish.pbproj and macosx/Makefile into the standard
unix configure/make buildsystem, the project and macosx/Makefile are
no longer required to build Tk.framework and/or TkAqua. TkAqua is now
enabled by the --enable-aqua configure option, and static and
non-framework builds of TkAqua are now available via the standard
configure switches. Tk/X11 can also be built as a framework. The
macosx/Makefile now wraps the unix buildsystem and no longer uses the
projects, embedded builds are still only available via this Makefile,
but for other builds it is not longer required (but its current
functionality is still available for backwards compatibility). The
projects currently do not call through to the Makefile to build
(unlike Tcl.pbproj) so project builds may differ from makefile builds.
Due to issues with spaces in pathnames, 'Wish Shell.app' has been
renamed to 'Wish.app', the macosx/Makefile installs backwards
compatibility symlinks for the old name.
* macosx/tkMacOSXInit.c (TkpInit): added support for Tk resource file
in non-framework and static builds: the resource file is copied into a
__tk_rsrc MachO segment of the library or executable at link time and
extracted into a temporary location at initialization.
* unix/configure: autoconf-2.59
* unix/tkConfig.h.in (new file): autoheader-2.59
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Makefile | 295 | ||||
-rw-r--r-- | macosx/README | 67 | ||||
-rw-r--r-- | macosx/Tk-Info.plist.in | 27 | ||||
-rw-r--r-- | macosx/Wish-Info.plist.in | 46 | ||||
-rw-r--r-- | macosx/tkMacOSXInit.c | 60 |
5 files changed, 377 insertions, 118 deletions
diff --git a/macosx/Makefile b/macosx/Makefile index 2f8f482..9908165 100644 --- a/macosx/Makefile +++ b/macosx/Makefile @@ -1,13 +1,14 @@ -################################################################################ +######################################################################################################## # -# Makefile to build AquaTk on Mac OS X packaged as a Framework -# uses Project Builder command line tool 'pbxbuild' +# Makefile wrapper to build tk on Mac OS X in a way compatible with the tk/macosx Xcode buildsystem +# uses the standard unix build system in tk/unix (which can be used directly instead of this +# if you are not using the tk/macosx projects). # -# RCS: @(#) $Id: Makefile,v 1.15 2004/11/11 01:24:32 das Exp $ +# RCS: @(#) $Id: Makefile,v 1.16 2005/05/23 20:24:59 das Exp $ # -################################################################################ +######################################################################################################## -#------------------------------------------------------------------------------- +#------------------------------------------------------------------------------------------------------- # customizable settings DESTDIR ?= @@ -17,117 +18,263 @@ BUILD_DIR ?= ${CURDIR}/../../build SYMROOT ?= ${BUILD_DIR}/${PROJECT} OBJROOT ?= ${SYMROOT} +EXTRA_CONFIGURE_ARGS ?= EXTRA_MAKE_ARGS ?= INSTALL_PATH ?= /Library/Frameworks APPLICATION_INSTALL_PATH ?= /Applications/Utilities - -PREFIX ?= /usr +PREFIX ?= /usr/local BINDIR ?= ${PREFIX}/bin +LIBDIR ?= ${INSTALL_PATH} MANDIR ?= ${PREFIX}/man -TCL_FRAMEWORK_DIR ?= ${BUILD_DIR}/tcl -TCLSH_DIR ?= ${TCL_FRAMEWORK_DIR} +# tcl build directory (containing tclConfig.sh and Makefile) +TCL_BUILD_DIR ?= ${BUILD_DIR}/tcl/${BUILD_STYLE} +# location of installed tcl, only used if tcl in TCL_BUILD_DIR can't be found +TCL_FRAMEWORK_DIR ?= /Library/Frameworks +TCLSH_DIR ?= ${PREFIX} # set to non-empty value to install manpages in addition to html help: INSTALL_MANPAGES ?= -#------------------------------------------------------------------------------- +# set to non-empty value to build TkX11 instead of TkAqua: +TK_X11 ?= -PROJECT = tk -TARGET = Wish +#------------------------------------------------------------------------------------------------------- +# meta targets -DEVBUILDSTYLE = Development -DEPBUILDSTYLE = Deployment +meta := all install embedded install-embedded clean distclean test -PBXBUILD = /usr/bin/pbxbuild -XCODEBUILD = /usr/bin/xcodebuild +styles := develop deploy -BUILDCMD = `if [ -f $(XCODEBUILD) ]; then \ - echo "$(XCODEBUILD) -project $$(ls -d *.pbproj)"; \ - else echo "$(PBXBUILD)"; fi` +all := ${styles} +all : ${all} -MAKE_VARS := SYMROOT OBJROOT BINDIR APPLICATION_INSTALL_PATH \ - TCL_FRAMEWORK_DIR TCLSH_DIR -MAKE_ARGS_V = $(foreach v,${MAKE_VARS},$v=${$v}) +install := ${styles:%=install-%} +install : ${install} +install-%: action := install- -BUILD = ${BUILDCMD} -target "${TARGET}" ${MAKE_ARGS_V} \ - DYLIB_INSTALL_PATH="${INSTALL_PATH}" \ - ${EXTRA_MAKE_ARGS} ${MAKEOVERRIDES} +embedded := ${styles:%=embedded-%} +embedded : embedded-deploy +install-embedded := ${embedded:%=install-%} +install-embedded : install-embedded-deploy -DEVBUILD = ${BUILD} -buildstyle "${DEVBUILDSTYLE}" -DEPBUILD = ${BUILD} -buildstyle "${DEPBUILDSTYLE}" +clean := ${styles:%=clean-%} +clean : ${clean} +clean-%: action := clean- +distclean := ${styles:%=distclean-%} +distclean : ${distclean} +distclean-%: action := distclean- -INSTALLOPTS = INSTALL_ROOT="${INSTALL_ROOT}" +test := ${styles:%=test-%} +test : ${test} +test-%: action := test- -EMBEDDEDOPTS = EMBEDDED_BUILD=1 +targets := $(foreach v,${meta},${$v}) -################################################################################ +#------------------------------------------------------------------------------------------------------- +# build styles -all: develop deploy +BUILD_STYLE = +CONFIGURE_ARGS = +OBJ_DIR = ${OBJROOT}/${BUILD_STYLE} -install: install-develop install-deploy +develop_make_args := BUILD_STYLE=Development CONFIGURE_ARGS=--enable-symbols +deploy_make_args := BUILD_STYLE=Deployment INSTALL_TARGET=install-strip +embedded_make_args := EMBEDDED_BUILD=1 +install_make_args := INSTALL_BUILD=1 -embedded: embedded-deploy +${targets}: + ${MAKE} ${action}${PROJECT} \ + $(foreach s,${styles} embedded install,$(if $(findstring $s,$@),${${s}_make_args})) -install-embedded: install-embedded-deploy cleanup-embedded +#------------------------------------------------------------------------------------------------------- +# project specific settings -clean: clean-develop clean-deploy +PROJECT := tk +PRODUCT_NAME := Tk -################################################################################ +UNIX_DIR := ${CURDIR}/../unix +VERSION := $(shell awk -F= '/^TK_VERSION/ {print $$2; nextfile}' ${UNIX_DIR}/configure.in) +WISH = wish${VERSION} -develop: - ${DEVBUILD} +BUILD_TARGET := wish +INSTALL_TARGET := install -deploy: - ${DEPBUILD} +ifneq ($(wildcard ${TCL_BUILD_DIR}/tclConfig.sh),) +TCL_DIR := ${TCL_BUILD_DIR} +TCL_FRAMEWORK_DIR := ${TCL_BUILD_DIR}/.. +else +TCL_DIR := ${TCL_FRAMEWORK_DIR}/Tcl.framework +TCL_EXE := ${TCLSH_DIR}/tclsh${VERSION} +MAKE_VARS = TCL_EXE +export DYLD_FRAMEWORK_PATH := ${TCL_FRAMEWORK_DIR} +endif +export CPPROG := cp -p -install-develop: - ${DEVBUILD} install ${INSTALLOPTS} +ifeq (${TK_X11},) +override CONFIGURE_ARGS := ${CONFIGURE_ARGS} --enable-aqua +else +VERSION := ${VERSION}-X11 +endif -install-deploy: - ${DEPBUILD} install ${INSTALLOPTS} +INSTALL_TARGETS = install-binaries install-libraries +ifeq (${EMBEDDED_BUILD},) +INSTALL_TARGETS += install-private-headers install-demos +endif +ifeq (${INSTALL_BUILD}_${EMBEDDED_BUILD}_${BUILD_STYLE},1__Deployment) +INSTALL_TARGETS += html-tk ifneq (${INSTALL_MANPAGES},) -# install manpages - ${MAKE} -C "$(CURDIR)/../unix" -f Makefile.in install-doc \ - SRC_DIR="$(CURDIR)/.." UNIX_DIR="$(CURDIR)/../unix" \ - mandir="$(MANDIR)" ${INSTALLOPTS} ${EXTRA_MAKE_ARGS} +INSTALL_TARGETS += install-doc endif +endif + +MAKE_VARS += INSTALL_ROOT INSTALL_TARGETS VERSION +MAKE_ARGS_V = $(foreach v,${MAKE_VARS},$v='${$v}') -embedded-develop: - ${DEVBUILD} ${EMBEDDEDOPTS} +build-${PROJECT}: target = ${TARGET} +install-${PROJECT}: target = ${INSTALL_TARGET} +clean-${PROJECT} distclean-${PROJECT} test-${PROJECT}: \ + target = $* -embedded-deploy: - ${DEPBUILD} ${EMBEDDEDOPTS} +DO_MAKE = +${MAKE} -C ${OBJ_DIR} ${target} ${MAKE_ARGS_V} ${MAKE_ARGS} ${EXTRA_MAKE_ARGS} -install-embedded-develop: - ${DEVBUILD} install ${INSTALLOPTS} ${EMBEDDEDOPTS} +${PROJECT}: override INSTALL_ROOT := ${OBJ_DIR}/ -install-embedded-deploy: - ${DEPBUILD} install ${INSTALLOPTS} ${EMBEDDEDOPTS} +#------------------------------------------------------------------------------------------------------- +# locations for custom tk install actions -clean-develop: - ${DEVBUILD} clean +ifeq (${INSTALL_BUILD},1) +TOP_DIR := ${INSTALL_ROOT}/ +APP_DIR := ${APPLICATION_INSTALL_PATH} +FMWK_DIR := ${LIBDIR} +else +TOP_DIR := ${SYMROOT} +APP_DIR := . +FMWK_DIR := . +endif -clean-deploy: - ${DEPBUILD} clean +TCL_FMWK_DIR := ${FMWK_DIR}/Tcl.framework/Versions/${VERSION} +TK_FMWK_DIR := ${FMWK_DIR}/${PRODUCT_NAME}.framework/Versions/${VERSION} + +#------------------------------------------------------------------------------------------------------- +# build rules + +${PROJECT}: install-${PROJECT} + +${OBJ_DIR}/Makefile: ${UNIX_DIR}/Makefile.in ${UNIX_DIR}/configure + mkdir -p ${OBJ_DIR} && cd ${OBJ_DIR} && ${UNIX_DIR}/configure -C \ + --prefix=${PREFIX} --bindir=${BINDIR} --libdir=${LIBDIR} \ + --mandir=${MANDIR} --enable-threads --enable-framework \ + --with-tcl=${TCL_DIR} \ + ${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS} + +build-${PROJECT}: ${OBJ_DIR}/Makefile + ${DO_MAKE} +# symolic link hackery to trick +# 'make install INSTALL_ROOT=${OBJ_DIR}' +# into building Tk.framework and wish in ${SYMROOT} + @cd ${OBJ_DIR} && mkdir -p $(dir ./${LIBDIR}) $(dir ./${BINDIR}) ${SYMROOT} && \ + rm -rf ./${LIBDIR} ./${BINDIR} && ln -fs ${SYMROOT} ./${LIBDIR} && \ + ln -fs ${SYMROOT} ./${BINDIR} && ln -fs ${OBJ_DIR}/tktest ${SYMROOT} +ifeq (${TK_X11},) + @rm -f ${OBJ_DIR}/${BINDIR} +endif +# Create symbolic link to Tcl.framework in ${SYMROOT}if necessary + @cd ${SYMROOT} && if [ ! -e Tcl.framework -o -L Tcl.framework ]; then \ + rm -f Tcl.framework && ln -s ${TCL_FRAMEWORK_DIR}/Tcl.framework . ; fi + +install-${PROJECT}: build-${PROJECT} +ifeq (${EMBEDDED_BUILD}_${INSTALL_ROOT},1_) + @echo "Cannot install-embedded with empty INSTALL_ROOT !" && false +else + @rm -rf "${INSTALL_ROOT}/${LIBDIR}/Tk.framework" +endif + ${DO_MAKE} +ifeq (${INSTALL_BUILD},1) +ifeq (${EMBEDDED_BUILD},1) +# if we are embedding frameworks, don't install wish + @rm -f "${INSTALL_ROOT}${BINDIR}/${WISH}" && \ + rmdir -p "${INSTALL_ROOT}${BINDIR}" 2>&- || true +else +# redo prebinding + @cd ${INSTALL_ROOT}/ && \ + if [ ! -d usr/lib ]; then mkdir -p usr && ln -fs /usr/lib usr/ && RM_USRLIB=1; fi; \ + if [ -n "${TK_X11}" -a ! -d usr/X11R6 ]; then mkdir -p usr && ln -fs /usr/X11R6 usr/ && RM_USRX11=1; fi; \ + if [ ! -d System ]; then ln -fs /System . && RM_SYSTEM=1; fi; \ + if [ ! -d ./${LIBDIR}/Tcl.framework ]; then ln -fs ${TCL_FRAMEWORK_DIR}/Tcl.framework ./${LIBDIR}; RM_TCL=1; fi; \ + redo_prebinding -r . "./${TK_FMWK_DIR}/${PRODUCT_NAME}"; \ + if [ -z "${TK_X11}" ]; then redo_prebinding -r . "./${TK_FMWK_DIR}/Resources/Wish.app/Contents/MacOS/Wish"; \ + else redo_prebinding -r . "./${BINDIR}/${WISH}"; fi; \ + if [ -n "$${RM_USRLIB:-}" ]; then rm -f usr/lib; rmdir -p usr 2>&-; fi; \ + if [ -n "$${RM_USRX11:-}" ]; then rm -f usr/X11R6; rmdir -p usr 2>&-; fi; \ + if [ -n "$${RM_SYSTEM:-}" ]; then rm -f System; fi; \ + if [ -n "$${RM_TCL:-}" ]; then rm -f ./${LIBDIR}/Tcl.framework; fi +# install wish symbolic link + @ln -fs ${WISH} ${INSTALL_ROOT}${BINDIR}/wish +endif +endif +ifeq (${BUILD_STYLE}_${EMBEDDED_BUILD},Development_) +# keep copy of debug library around, so that +# Deployment build can be installed on top +# of Development build without overwriting +# the debug library + @cd ${INSTALL_ROOT}${LIBDIR}/${PRODUCT_NAME}.framework/Versions/${VERSION} && \ + ln -f "${PRODUCT_NAME}" "${PRODUCT_NAME}_debug" +endif +ifeq (${TK_X11},) +ifeq (${EMBEDDED_BUILD},) +# install Wish.app link in APPLICATION_INSTALL_PATH and setup 'Wish Shell' compatibility links + @cd ${TOP_DIR} && mkdir -p "./${APP_DIR}" && \ + ln -fsh "$$(echo ./${APP_DIR} | sed -e 's#/[^/][^/]*#/..#g')/${TK_FMWK_DIR}/Resources/Wish.app" "./${APP_DIR}" && \ + ln -fsh Wish.app "./${APP_DIR}/Wish Shell.app" && \ + ln -fsh Wish.app "./${TK_FMWK_DIR}/Resources/Wish Shell.app" && \ + ln -fsh Wish "./${TK_FMWK_DIR}/Resources/Wish.app/Contents/MacOS/Wish Shell" +else +# if we are embedding frameworks, move them into the app and fix their install names + @cd ${TOP_DIR} && \ + rm -rf "./${APP_DIR}/Wish.app" && mkdir -p "./${APP_DIR}" && \ + mv -f "./${TK_FMWK_DIR}/Resources/Wish.app" "./${APP_DIR}" && \ + ln -fsh Wish.app "./${APP_DIR}/Wish Shell.app" && \ + rm -rf "./${APP_DIR}/Wish.app/Contents/Frameworks" && \ + mkdir -p "./${APP_DIR}/Wish.app/Contents/Frameworks" && \ + mv -f "./${FMWK_DIR}"/T{cl,k}.framework "./${APP_DIR}/Wish.app/Contents/Frameworks" && \ + rmdir -p "./${FMWK_DIR}" 2>&- || true && cd "./${APP_DIR}/Wish.app/Contents" && \ + rm -rf Frameworks/T{cl,k}.framework/{,/Versions/$(VERSION)}/{Headers,PrivateHeaders,*_debug,lib*.a,*Config.sh} && \ + fix_install_id ( ) { \ + chmod -RH a+w "$$1"; \ + install_name_tool -id $$(otool -L "$$1" | awk "/$$2\.framework.*[^:]\$$/ {sub(\"^.*/Frameworks\",\"@executable_path/../Frameworks\",\$$1); print \$$1}") "$$1"; \ + chmod -RH a-w "$$1"; \ + } && \ + fix_install_name ( ) { \ + chmod -RH a+w "$$1"; \ + install_name_tool -change $$(otool -L "$$1" | awk "/$$2\.framework.*[^:]\$$/ {print \$$1; sub(\"^.*/Frameworks\",\"@executable_path/../Frameworks\",\$$1); print \$$1}") "$$1"; \ + chmod -RH a-w "$$1"; \ + } && \ + fix_install_id Frameworks/Tcl.framework/Tcl Tcl && fix_install_id Frameworks/Tk.framework/Tk Tk && \ + fix_install_name MacOS/Wish Tcl && fix_install_name MacOS/Wish Tk +endif +endif -################################################################################ +clean-${PROJECT}: %-${PROJECT}: + ${DO_MAKE} + rm -rf ${SYMROOT}/{${PRODUCT_NAME}.framework,${WISH},tktest} + rm -f ${OBJ_DIR}{${LIBDIR},${BINDIR}} && \ + rmdir -p ${OBJ_DIR}$(dir ${LIBDIR}) 2>&- || true && \ + rmdir -p ${OBJ_DIR}$(dir ${BINDIR}) 2>&- || true -cleanup-embedded: - @-cd ${INSTALL_ROOT}/; \ - chmod -RH u+w Library/Frameworks/Tcl.framework; \ - rm -rf Library/Frameworks/Tcl.framework; \ - chmod -RH u+w Library/Frameworks/Tk.framework; \ - rm -rf Library/Frameworks/Tk.framework; \ - rmdir -p Library/Frameworks 2>&-; +distclean-${PROJECT}: %-${PROJECT}: clean-${PROJECT} + ${DO_MAKE} + rm -rf ${OBJ_DIR} + +test-${PROJECT}: %-${PROJECT}: build-${PROJECT} + ${DO_MAKE} -################################################################################ +#------------------------------------------------------------------------------------------------------- -.PHONY: all install embedded clean develop deploy install-develop install-deploy \ -embedded-develop embedded-deploy install-embedded-develop install-embedded-deploy \ -clean-develop clean-deploy cleanup-embedded +.PHONY: ${meta} ${targets} ${PROJECT} build-${PROJECT} install-${PROJECT} \ + clean-${PROJECT} distclean-${PROJECT} .NOTPARALLEL: -################################################################################ +#------------------------------------------------------------------------------------------------------- diff --git a/macosx/README b/macosx/README index d681c00..b06c454 100644 --- a/macosx/README +++ b/macosx/README @@ -1,7 +1,7 @@ TclTkAqua README ---------------- -RCS: @(#) $Id: README,v 1.12 2005/04/09 15:39:09 das Exp $ +RCS: @(#) $Id: README,v 1.13 2005/05/23 20:24:59 das Exp $ This is the README file for the Mac OS X native versions of Tcl & Tk. @@ -47,7 +47,7 @@ OS9 TclTk droplets. - If standard input is a special file of zero length (e.g. /dev/null), Wish brings up the tk console window at startup. This is the case when double -clicking Wish in the Finder (or using 'open Wish\ Shell.app' from the Terminal). +clicking Wish in the Finder (or using 'open Wish.app' from the Terminal). - Tcl extensions will be found in any of: $HOME/Library/Tcl /Library/Tcl /Network/Library/Tcl /System/Library/Tcl @@ -68,12 +68,12 @@ No manpages are installed by default for either tcl or tk. system's standard framework directories: $HOME/Library/Frameworks /Library/Frameworks /Network/Library/Frameworks /System/Library/Frameworks -and 'Wish Shell' as well as /usr/bin/tclsh will work. +and 'Wish' as well as /usr/bin/tclsh will work. -- /usr/bin/wish is a script that calls a copy of 'Wish Shell' contained in +- /usr/bin/wish is a script that calls a copy of 'Wish' contained in Tk.framework/Resources -- if 'Wish Shell' is started from the Finder or via 'open', $argv contains a +- if 'Wish' is started from the Finder or via 'open', $argv contains a "-psn_XXXX" argument. This is the Wish's carbon process serial number, you may need to filter it out for cross platform compatibility of your scripts. @@ -132,14 +132,14 @@ name. So, for instance this code will spin the spinner: This was added in Tk 8.4.2 - If you want to use Remote Debugging with Xcode 1.5 or 2.0, then you need to set -the environment variable XCNOSTDIN to 1 in the Executable editor for Wish Shell. That +the environment variable XCNOSTDIN to 1 in the Executable editor for Wish. That will cause us to force closing stdin & stdout. Otherwise, given how Xcode launches Wish remotely, they will be left open and then Wish & gdb will fight for stdin... 3. Building TclTkAqua --------------------- -- Mac OS X 10.2 (or higher) is required to build Tcl on MacOSX. +- Mac OS X 10.2 (or higher) is required to build TclTkAqua on MacOSX. - Apple's Developer Tools CD needs to be installed (the most recent version matching your OS release, but no earlier than December 2002). This CD should @@ -147,14 +147,14 @@ have come with Mac OS X retail or should be present as a disk image on new macs that came with OSX preinstalled. It can also be downloaded from http://connect.apple.com (after you register for free ADC membership). -- Tcl is built as a Mac OS X framework via the Makefile in tcl/macosx, but can -also be built from Apple's ProjectBuilder IDE using the Tcl.pbproj project (which -calls through to the Makefile). +- Tcl and Tk are built as a Mac OS X frameworks via the Makefiles in tcl/macosx +and tk/macosx, but can also be built directly with the standard unix configure +and make buildsystem in tcl/unix resp. tk/unix. -- TkAqua is built as a Mac OS X frameworks using Apple's ProjectBuilder -IDE, but you do not have to deal with the IDE if you don't want to, the -Makefile in tk/macosx takes care of calling the ProjectBuilder command line tool -with all the details taken care of. +- It is still possible to build with Apple's Xcode IDE using the Tcl.pbproj and +Wish.pbproj projects but this is not recommended anymore (currently Tcl.pbproj +calls through to the tcl/macosx/Makefile; but Wish.pbproj doesn't, so there could +be build differences). - Unpack the tcl and tk source release archives and place the tcl and tk source trees in a common parent directory. @@ -176,9 +176,7 @@ set ${ver} to the empty string instead: set ver="" ;: if your shell is csh ver="" ;: if your shell is sh -- If you're only interested in _building_ TclTkAqua and don't plan on doing -development with the ProjectBuilder projects, using the Makefiles is easiest. -The following steps will build Tcl and Tk from the Terminal, assuming you are +- The following steps will build Tcl and Tk from the Terminal, assuming you are located in the directory containing the tcl and tk source trees: make -C tcl${ver}/macosx make -C tk${ver}/macosx @@ -206,11 +204,11 @@ For example, to build and install only the optimized versions: sudo make -C tcl${ver}/macosx install-deploy sudo make -C tk${ver}/macosx install-deploy -- The Makefiles can also build a version of 'Wish Shell' that has the Tcl and Tk +- The Makefiles can also build a version of 'Wish' that has the Tcl and Tk frameworks embedded in its application package. This allows for standalone deployment of the application with no installation required, e.g. from read-only media. To build & install in this manner, use the 'embedded' target variants of -the Makefiles. For example, to build a standalone 'Wish Shell.app' +the Makefiles. For example, to build a standalone 'Wish.app' in ./embedded/Applications/Utilities: make -C tcl${ver}/macosx embedded make -C tk${ver}/macosx embedded @@ -221,32 +219,19 @@ Notes: require any new compiling or linking, so you can skip the first two makes. (making relinking unnecessary was added in 8.4.2) * the embedded frameworks include only optimized builds and no documentation. - * the standalone Wish has the directory Wish\ Shell.app/Contents/lib in its + * the standalone Wish has the directory Wish.app/Contents/lib in its auto_path. Thus you can place tcl extensions in this directory (i.e. embed them in the app package) and load them with [package require]. -- It is possible to build Tk without without the tcl sourcetree; but in that -case you need to tell the Tk Makefile where the copies of 'Tcl.framework' and -'tclsh8.4' are located that you want to build & link against -(their default location is ${BUILD_DIR}/tcl). - -For instance to use their default systemwide install locations: +- It is possible to build Tk against an installed Tcl.framework; but you will +still need a tcl sourcetree in the location specified in TCL_SRC_DIR in +Tcl.framework/tclConfig.sh. Also, linking with Tcl.framework has to work +exactly as indicated in TCL_LIB_SPEC in Tcl.framework/tclConfig.sh. +If you used non-default install locations for Tcl.framework, specify them as +make overrides to the tk/macosx Makefile, e.g. make -C tk${ver}/macosx \ - TCL_FRAMEWORK_DIR=/Library/Frameworks TCLSH_DIR=/usr/bin + TCL_FRAMEWORK_DIR=$HOME/Library/Frameworks TCLSH_DIR=$HOME/usr/bin sudo make -C tk${ver}/macosx install \ - TCL_FRAMEWORK_DIR=/Library/Frameworks TCLSH_DIR=/usr/bin -[ of course this will only work if /Library/Frameworks does indeed contain a ] -[ Tcl.framework corresponding in version to the Tk.framework you're trying to ] -[ build, and if TCLSH_DIR contains a corresponding /usr/bin/tclsh8.4 ] - -or to use an earlier install of Tcl into INSTALL_ROOT="${TCLTK}/" : - make -C tk${ver}/macosx \ - TCL_FRAMEWORK_DIR=${TCLTK}/Library/Frameworks TCLSH_DIR=${TCLTK}/usr/bin - sudo make -C tk${ver}/macosx install INSTALL_ROOT="${TCLTK}/" \ - TCL_FRAMEWORK_DIR=${TCLTK}/Library/Frameworks TCLSH_DIR=${TCLTK}/usr/bin + TCL_FRAMEWORK_DIR=$HOME/Library/Frameworks TCLSH_DIR=$HOME/usr/bin The Makefile variables TCL_FRAMEWORK_DIR and TCLSH_DIR were added in Tk 8.4.3. - -Note that html help in Tk.framework is only built if TCL_FRAMEWORK_DIR contains -the tcl Makefile (as is the case for the default value of TCL_FRAMEWORK_DIR). - diff --git a/macosx/Tk-Info.plist.in b/macosx/Tk-Info.plist.in new file mode 100644 index 0000000..a392991 --- /dev/null +++ b/macosx/Tk-Info.plist.in @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>@TK_LIB_FILE@</string> + <key>CFBundleGetInfoString</key> + <string>Tk @TK_WINDOWINGSYSTEM@ Library @TK_VERSION@, Copyright © @TK_YEAR@ Tcl Core Team. +Initial MacOS X Port by Jim Ingham <jingham@apple.com> & Ian Reid, Copyright © 2001-2002, Apple Computer, Inc.</string> + <key>CFBundleIdentifier</key> + <string>com.tcltk.tklibrary</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>Tk @TK_WINDOWINGSYSTEM@ Library @TK_VERSION@</string> + <key>CFBundlePackageType</key> + <string>FMWK</string> + <key>CFBundleShortVersionString</key> + <string>@TK_VERSION@@TK_PATCH_LEVEL@</string> + <key>CFBundleSignature</key> + <string>Tk </string> + <key>CFBundleVersion</key> + <string>@TK_VERSION@@TK_PATCH_LEVEL@</string> +</dict> +</plist> diff --git a/macosx/Wish-Info.plist.in b/macosx/Wish-Info.plist.in new file mode 100644 index 0000000..08fff5a --- /dev/null +++ b/macosx/Wish-Info.plist.in @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleDocumentTypes</key> + <array> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>*</string> + </array> + <key>CFBundleTypeName</key> + <string>NSStringPboardType</string> + <key>CFBundleTypeOSTypes</key> + <array> + <string>TEXT</string> + </array> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + </dict> + </array> + <key>CFBundleExecutable</key> + <string>Wish</string> + <key>CFBundleGetInfoString</key> + <string>Wish Shell @TK_VERSION@, Copyright © @TK_YEAR@ Tcl Core Team. +Initial MacOS X Port by Jim Ingham <jingham@apple.com> & Ian Reid, Copyright © 2001-2002, Apple Computer, Inc.</string> + <key>CFBundleIconFile</key> + <string>Wish.icns</string> + <key>CFBundleIdentifier</key> + <string>com.tcltk.wish</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>Wish</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>@TK_VERSION@@TK_PATCH_LEVEL@</string> + <key>CFBundleSignature</key> + <string>WiSH</string> + <key>CFBundleVersion</key> + <string>@TK_VERSION@@TK_PATCH_LEVEL@</string> +</dict> +</plist> diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index b5481ba..14e9cbf 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXInit.c,v 1.9 2005/05/14 20:48:15 das Exp $ + * RCS: @(#) $Id: tkMacOSXInit.c,v 1.10 2005/05/23 20:24:59 das Exp $ */ #include "tkInt.h" @@ -18,6 +18,7 @@ #include "tclInt.h" #include <sys/stat.h> #include <mach-o/dyld.h> +#include <mach-o/getsect.h> /* * The Init script (common to Windows and Unix platforms) is @@ -159,8 +160,61 @@ TkpInit(interp) * FIXME: Should we come up with a more generic way of doing this? */ - Tcl_MacOSXOpenVersionedBundleResources(interp, - "com.tcltk.tklibrary", TK_VERSION, 1, 1024, tkLibPath); + if (Tcl_MacOSXOpenVersionedBundleResources(interp, + "com.tcltk.tklibrary", TK_FRAMEWORK_VERSION, 1, PATH_MAX, tkLibPath) != TCL_OK) { + /* Tk.framework not found, check if resource file is open */ + Handle rsrc = Get1NamedResource('CURS', "\phand"); + if (rsrc) { + ReleaseResource(rsrc); + } else { + struct mach_header *image; + char *data = NULL; + unsigned long size; + int fd = -1; + char fileName[L_tmpnam + 15]; + + /* Get resource data from __tk_rsrc section of tk library file */ +#ifdef HAVE__DYLD_GET_IMAGE_HEADER_CONTAINING_ADDRESS + image = _dyld_get_image_header_containing_address((unsigned long)&TkpInit); + if (image) { + data = getsectdatafromheader(image, SEG_TEXT, "__tk_rsrc", &size); + } +#else + int i, n = _dyld_image_count(); + for (i = 0; i < n; i++) { + image = _dyld_get_image_header(i); + if (image) { + data = getsectdatafromheader(image, SEG_TEXT, "__tk_rsrc", &size); + } + if (data) break; + } +#endif + while (data) { + OSStatus err; + FSRef ref; + SInt16 refNum; + + /* Write resource data to temporary file and open it */ + strcpy(fileName, P_tmpdir); + if (fileName[strlen(fileName) - 1] != '/') { + strcat(fileName, "/"); + } + strcat(fileName, "tkMacOSX_XXXXXX"); + fd = mkstemp(fileName); + if (fd == -1) break; + fcntl(fd, F_SETFD, FD_CLOEXEC); + if (write(fd, data, size) == -1) break; + err = FSPathMakeRef(fileName, &ref, NULL); + if (err != noErr) break; + err = FSOpenResourceFile(&ref, 0, NULL, fsRdPerm, &refNum); + break; + } + if (fd != -1) { + unlink(fileName); + close(fd); + } + } + } /* * If we don't have a TTY and stdin is a special character file of length 0, |