1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
|
#! /bin/sh
#
# Creates standalone Windows application directory from Pd build.
#
# Make sure Pd has been configured and built before running this.
#
# stop on error
set -e
TK=
prototype_tk=true
build_tk=false
# pthread dll name
PTHREAD_DLL=libwinpthread-1.dll
# include sources
sources=false
# strip binaries
strip=true
STRIP=${STRIP-strip}
STRIPARGS=${STRIPARGS-"--strip-unneeded -R .note -R .comment"}
# build dir, relative to working directory
custom_builddir=false
BUILD=..
# Help message
#----------------------------------------------------------
help() {
cat <<EOF
Usage: $0 [OPTIONS] [VERSION]
Creates a Pd app directory for Windows.
Uses the included Tk 8.5 in pdprototype.tgz by default
Options:
-h,--help display this help message
-t,--tk VER or DIR use a specific precompiled Tcl/Tk directory or download
and build a specific version using tcltk-build.sh
-s,--sources include source files in addition to headers
(default: ${sources})
-n,--no-strip do not strip binaries (default: do strip)
--builddir DIR set Pd build directory path (default: ${BUILD})
Arguments:
VERSION optional string to use in dir name ie. pd-VERSION
Examples:
# create pd directory
$0
# create pd-0.48-1 directory, uses specified version string
$0 0.48-1
# create pd directory with source files
$0 --sources
# create pd-0.48-1 directory, download and build Tcl/Tk 8.5.19
$0 --tk 8.5.19 0.48-1
# create pd-0.48-1 directory, use Tcl/Tk 8.5.19 built with tcltk-dir.sh
$0 --tk tcltk-8.5.19 0.48-1
EOF
}
# Parse command line arguments
#----------------------------------------------------------
while [ "$1" != "" ] ; do
case $1 in
-t|--tk)
shift 1
if [ $# = 0 ] ; then
echo "-t,--tk option requires a VER or DIR argument" 1>&2
exit 1
fi
TK="$1"
prototype_tk=false
;;
-s|--sources)
sources=true
;;
-n|--no-strip)
strip=false
;;
--builddir)
if [ $# = 0 ] ; then
echo "--builddir option requires a DIR argument" 1>&2
exit 1
fi
shift 1
BUILD=${1%/} # remove trailing slash
custom_builddir=true
;;
-h|--help)
help
exit 0
;;
*)
break ;;
esac
shift 1
done
# check for version argument and set app path in the dir the script is run from
if [ "x$1" != "x" ] ; then
APP=$(pwd)/pd-$1
else
# version not specified
APP=$(pwd)/pd
fi
# Go
#----------------------------------------------------------
# make sure custom build directory is an absolute path
if [ "x$custom_builddir" = "xtrue" ] ; then
if [ "x${BUILD#/}" = "x${BUILD}" ] ; then
# BUILD isn't absolute as it doesn't start with '/'
BUILD="$(pwd)/$BUILD"
fi
fi
# is $TK a version or a directory?
if [ -d "$TK" ] ; then
# directory, make sure it's absolute
if [ "x${TK#/}" = "x${TK}" ] ; then
TK="$(pwd)/$TK"
fi
else
# version, so it will be downloaded & built
build_tk=true
fi
# change to the dir of this script
cd $(dirname $0)
echo "==== Creating $(basename $APP)"
# remove old app dir if found
if [ -d $APP ] ; then
echo "removing existing directory"
rm -rf $APP
fi
# install to app directory
make -C $BUILD install DESTDIR=$APP prefix=/
# don't need man pages
rm -rf $APP/share
# place headers together in src directory
mv $APP/include $APP/src
mv $APP/src/pd/* $APP/src
rm -rf $APP/src/pd
# move folders from lib/pd into top level directory
rm -rf $APP/lib/pd/bin
for d in $APP/lib/pd/*; do
mv $d $APP/
done
rm -rf $APP/lib/
# install sources
if [ "x$sources" = xtrue ] ; then
mkdir -p $APP/src
cp -v ../src/*.c $APP/src/
cp -v ../src/*.h $APP/src/
for d in $APP/extra/*/; do
s=${d%/}
s=../extra/${s##*/}
cp -v "${s}"/*.c "${d}"
done
fi
# untar pdprototype.tgz
tar -xf pdprototype.tgz -C $APP/ --strip-components=1
if [ "x$prototype_tk" = xfalse ] ; then
# remove bundled tcl & tk as we'll install our own,
# keep dlls needed by pd & externals
rm -rf $APP/bin/tcl* $APP/bin/tk* \
$APP/bin/wish*.exe $APP/bin/tclsh*.exe \
$APP/lib
# remove headers which should be provided by MinGW
rm -f $APP/src/pthread.h
# build, if needed
if [ "x$build_tk" = xtrue ] ; then
echo "Building tcltk-$TK"
./tcltk-dir.sh $TK
TK=tcltk-${TK}
else
echo "Using $TK"
fi
# install tcl & tk
cp -R $TK/bin $APP/
cp -R $TK/lib $APP/
# remove bundled Tcl packages Pd doesn't need
rm -rf $APP/lib/itcl* $APP/lib/sqlite* $APP/lib/tdbc*
fi
# install pthread from MinGW from:
# * Windows: $MINGW_PREFIX/bin
# * Linux cross-compile: $MINGW_PREFIX/lib
if [ "x${MINGW_PREFIX}" != "x" ] ; then
if [ -e $MINGW_PREFIX/bin/$PTHREAD_DLL ] ; then
cp -v $MINGW_PREFIX/bin/$PTHREAD_DLL $APP/bin
elif [ -e $MINGW_PREFIX/lib/$PTHREAD_DLL ] ; then
cp -v $MINGW_PREFIX/lib/$PTHREAD_DLL $APP/bin
fi
fi
# copy info and resources not handled via "make install"
cp -v ../README.txt $APP/
cp -v ../LICENSE.txt $APP/
cp -vR ../font $APP/
# strip executables,
# use temp files as stripping in place doesn't seem to work reliably on Windows
if [ "x$strip" = xtrue ] ; then
find "${APP}" -type f '(' -iname "*.exe" -o -iname "*.com" -o -iname "*.dll" ')' \
| while read file ; do \
"${STRIP}" ${STRIPARGS} -o "$file.stripped" "$file" && \
mv "$file.stripped" "$file" && \
echo "stripped $file" ; \
done
fi
# set permissions and clean up
find $APP -type f -exec chmod -x {} +
find $APP -type f '(' -iname "*.exe" -o -iname "*.com" ')' -exec chmod +x {} +
find $APP -type f '(' -iname "*.la" -o -iname "*.dll.a" -o -iname "*.am" ')' -delete
find $APP/bin -type f -not -name "*.*" -delete
# finished
touch $APP
echo "==== Finished $(basename $APP)"
|