1#!/bin/sh 2 3cwd=`pwd` 4 5# -- build adonthell 6if [ ! -f "configure" ]; then 7 if [ ! -f "autogen.sh" ]; then 8 echo "This script must be run in the adonthell-0.3.x directory" 9 exit 1 10 fi 11 ./autogen.sh 12fi 13 14if [ -f "Makefile" ]; then 15 make distclean 16fi 17 18if [ -d "build" ]; then 19 rm -rf build 20fi 21 22mkdir build 23 24APP=adonthell-0.3.exe 25 26# -- strip version from application name 27appname=`echo "$APP" | sed 's/-.*//'` 28 29# -- application folder name starts with capital 30first=`echo ${appname:0:1} | tr 'a-z' 'A-Z'` 31bundle=$first${appname:1} 32bindir=$bundle/bin 33moduledir=$bundle/modules 34pythondir=$bundle/lib/python3.6 35 36echo "Creating $bundle" 37 38# -- cleanup existing bundle 39rm -rf $bundle 40 41# -- create bundle structure 42mkdir -p $bundle 43mkdir -p $bindir 44mkdir -p $moduledir 45mkdir -p $pythondir 46 47cd build 48 49# -- create resource file 50cat > adonthell.rc << EOF 511 VERSIONINFO 52FILEVERSION 0,3,8,0 53PRODUCTVERSION 0,3,8,0 54BEGIN 55 BLOCK "StringFileInfo" 56 BEGIN 57 BLOCK "080904E4" 58 BEGIN 59 VALUE "CompanyName", "The Adonthell Team" 60 VALUE "FileDescription", "Adonthell RPG Engine" 61 VALUE "FileVersion", "0.3.8" 62 VALUE "InternalName", "adonthell" 63 VALUE "LegalCopyright", "© 2018 The Adonthell Team" 64 VALUE "OriginalFilename", "adonthell-0.3.exe" 65 VALUE "ProductName", "Adonthell" 66 VALUE "ProductVersion", "0.3.8" 67 END 68 END 69 70 BLOCK "VarFileInfo" 71 BEGIN 72 VALUE "Translation", 0x809, 1252 73 END 74END 75EOF 76windres adonthell.rc -O coff -o adonthell.res 77 78# -- prepare application 79prefix=${cwd}/${bundle} 80 81configure_args="--disable-unix-install --disable-pyc --prefix=$prefix --datadir=$prefix --mandir=/tmp --with-py-cflags='-I$MINGW_PREFIX/include/python3.6m'" 82linker_args="-L$MINGW_PREFIX/lib $cwd/build/adonthell.res -static-libgcc -static-libstdc++" 83 84echo "Configuring $appname. This may take a while ..." 85CXXFLAGS="-I$MINGW_PREFIX/usr/local/include" LDFLAGS=$linker_args ../configure $configure_args > /dev/null 86if [ $? -ne 0 ]; then 87 exit 1 88fi 89 90# -- compile application 91echo "Building $appname ..." 92make V=0 -j 2 93if [ $? -ne 0 ]; then 94 exit 1 95fi 96 97 98# -- install application 99make V=0 install 100if [ $? -ne 0 ]; then 101 exit 1 102fi 103 104cd .. 105 106function copyLibs 107{ 108 # -- find all non-standard shared libraries used by app 109 for i in `ldd $1 | awk '/=>/ { print $3 }' | grep -i -v -e system32 -e '?'` ; do 110 111 # -- strip path from library name 112 libname=`echo "$i" | sed 's/.*\///'` 113 114 # -- copy them to the bundle framework directory, if not there yet 115 if [ ! -f $bindir/$libname ] ; then 116 echo "Adding $i to $bindir" 117 cp "$i" $bindir 118 copyLibs $bindir/$libname 119 fi 120 done 121} 122 123# -- copy shared libraries used by application 124copyLibs "$bindir/$APP" 125 126# -- copy libvorbis and dependencies 127libvorbis=`find $MINGW_PREFIX/bin/ -name libvorbisfile-*.dll -exec basename {} \;` 128if test "x$libvorbis" != "x" ; then 129 cp "$MINGW_PREFIX/bin/$libvorbis" "$bindir" 130 copyLibs "$bindir/$libvorbis" 131else 132 echo "*** Cannot find libvorbis. Background music will not work ..." 133fi 134 135function removeDbgSyms 136{ 137 local relpath="@executable_path/../Frameworks" 138 echo "Stripping debug symbols from $1" 139 140 # -- remove debugging information 141 strip -S $1 142} 143 144# -- clean 145removeDbgSyms $bindir/$APP 146for i in `find $bindir -name *.dll` ; do 147 removeDbgSyms "$i" 148done 149 150# -- copy required python modules from the standard library 151# 152# Note that this list is for Python 3.6.2 as provided by 153# mingw64 and will have to be adjusted for other versions 154# of Python. 155# 156# Instead of hardcoding the required files, perhaps a similar 157# approach as with the make_linux_appimg.sh could be used. 158py3_modules=" 159__future__.py 160_bootlocale.py 161_collections_abc.py 162_sitebuiltins.py 163_weakrefset.py 164abc.py 165bisect.py 166codecs.py 167collections/__init__.py 168collections/abc.py 169contextlib.py 170copyreg.py 171encodings/__init__.py 172encodings/aliases.py 173encodings/cp*.py 174encodings/latin_1.py 175encodings/mbcs.py 176encodings/utf_8.py 177functools.py 178genericpath.py 179hashlib.py 180heapq.py 181importlib/__init__.py 182importlib/abc.py 183importlib/machinery.py 184importlib/util.py 185imp.py 186io.py 187keyword.py 188lib-dynload/_blake2-cpython-36m.dll 189lib-dynload/_codecs_*-cpython-36m.dll 190lib-dynload/_md5-cpython-36m.dll 191lib-dynload/_random-cpython-36m.dll 192lib-dynload/_sha1-cpython-36m.dll 193lib-dynload/_sha256-cpython-36m.dll 194lib-dynload/_sha3-cpython-36m.dll 195lib-dynload/_sha512-cpython-36m.dll 196lib-dynload/_sysconfigdata_m_win32_.py 197lib-dynload/math-cpython-36m.dll 198linecache.py 199ntpath.py 200operator.py 201os.py 202random.py 203reprlib.py 204re.py 205site.py 206sre_compile.py 207sre_constants.py 208sre_parse.py 209stat.py 210sysconfig.py 211traceback.py 212token.py 213tokenize.py 214types.py 215warnings.py 216weakref.py" 217 218IFS=' 219' 220 221for i in $py3_modules ; do 222 target=`dirname $i` 223 if [ ! -d $pythondir/$target ] ; then 224 mkdir $pythondir/$target 225 fi 226 cp $MINGW_PREFIX/lib/python3.6/$i $pythondir/$target 227done 228