macosx: create_dmg: also install the C language IRMP shared library
[sigrok-util/gsi.git] / cross-compile / macosx / create_dmg
blobeffe378cf08c39026317d3ba5f456761d618b2fb
1 #!/bin/sh
2 ##
3 ## This file is part of the sigrok-util project.
4 ##
5 ## Copyright (C) 2017-2020 Uwe Hermann <uwe@hermann-uwe.de>
6 ##
7 ## This program is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ## GNU General Public License for more details.
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
21 set -e
23 # The path where the installed sigrok libraries/binaries are located.
24 PREFIX=$HOME/sr_macosx
26 if [ "x$1" = "xsigrok-cli" ]; then
27 APPNAME="sigrok-cli"
28 APPNAME_BINARY="sigrok-cli"
29 else
30 APPNAME="PulseView"
31 APPNAME_BINARY="pulseview"
34 # The path where to download files to and where to build packages.
35 BUILDDIR=./build_app_$APPNAME_BINARY
37 # We use Qt 5.5 in order to remain compatible with more versions of Mac OS X.
38 QTVER=qt@5.5
40 # Path to Qt5 binaries.
41 QTBINDIR=`brew list $QTVER | grep bin | head -n 1 | xargs dirname`
42 QTTRANSLATIONSDIR=`brew --prefix $QTVER`/translations
44 # Path to boost libraries.
45 BOOSTLIBDIR=`brew list boost | grep libboost_system | grep -v cmake | head -n 1 | xargs dirname`
47 # Path to Python 3 framework.
48 PYTHONFRAMEWORKDIR=`brew list python3 | grep libpython | head -n 1 | xargs dirname`/../../../..
50 PYVER="3.7"
52 # You usually don't need to change anything below this line.
54 # -----------------------------------------------------------------------------
56 # Remove build directory contents (if any) and create a new build dir.
57 rm -rf $BUILDDIR
58 mkdir $BUILDDIR
59 cd $BUILDDIR
61 APPVER="NIGHTLY"
63 CONTENTSDIR="$APPNAME.app/Contents"
64 MACOSDIR="$CONTENTSDIR/MacOS"
65 FRAMEWORKSDIR="$CONTENTSDIR/Frameworks"
66 SHARE_DIR="$CONTENTSDIR/share"
67 PYDIR="$FRAMEWORKSDIR/Python.framework/Versions/$PYVER"
69 mkdir -p $MACOSDIR $FRAMEWORKSDIR $SHARE_DIR
71 cp $PREFIX/bin/$APPNAME_BINARY $MACOSDIR
72 # Implementation detail: Shared libraries are handled below.
73 cp -R $PREFIX/share/libsigrokdecode $SHARE_DIR
74 rm -rf $SHARE_DIR/libsigrokdecode/decoders/**/__pycache__
75 rm -rf $SHARE_DIR/libsigrokdecode/decoders/common/**/__pycache__
76 cp -R $PREFIX/share/sigrok-firmware $SHARE_DIR
78 if [ "x$APPNAME_BINARY" = "xpulseview" ]; then
79 # Manually copy some boost libs that "macdeployqt" won't copy.
80 cp $BOOSTLIBDIR/libboost_timer-mt.dylib $FRAMEWORKSDIR
81 cp $BOOSTLIBDIR/libboost_chrono-mt.dylib $FRAMEWORKSDIR
82 chmod 644 $FRAMEWORKSDIR/*boost*
84 # Manually copy translations ("macdeployqt" won't copy them).
85 mkdir -p $CONTENTSDIR/translations
86 cp $QTTRANSLATIONSDIR/qt_*.qm $CONTENTSDIR/translations
87 cp $QTTRANSLATIONSDIR/qtbase_*.qm $CONTENTSDIR/translations
90 $QTBINDIR/macdeployqt $APPNAME.app
92 # Copy Python framework and fix it up.
93 cp -R $PYTHONFRAMEWORKDIR $FRAMEWORKSDIR
94 chmod 644 $PYDIR/lib/libpython*.dylib
95 rm -rf $PYDIR/Headers
96 rm -rf $PYDIR/bin
97 rm -rf $PYDIR/include
98 rm -rf $PYDIR/share
99 rm -rf $PYDIR/lib/pkgconfig
100 rm -rf $PYDIR/lib/python$PYVER/lib2to3
101 rm -rf $PYDIR/lib/python$PYVER/distutils
102 rm -rf $PYDIR/lib/python$PYVER/idlelib
103 rm -rf $PYDIR/lib/python$PYVER/test
104 rm -rf $PYDIR/lib/python$PYVER/**/test
105 rm -rf $PYDIR/lib/python$PYVER/tkinter
106 rm -rf $PYDIR/lib/python$PYVER/turtledemo
107 rm -rf $PYDIR/lib/python$PYVER/unittest
108 rm -rf $PYDIR/lib/python$PYVER/__pycache__
109 rm -rf $PYDIR/lib/python$PYVER/**/__pycache__
110 rm -rf $PYDIR/lib/python$PYVER/**/**/__pycache__
111 rm -rf $PYDIR/Resources
112 install_name_tool -change \
113 /usr/local/opt/python/Frameworks/Python.framework/Versions/$PYVER/Python \
114 @executable_path/../Frameworks/Python.framework/Versions/$PYVER/Python \
115 $FRAMEWORKSDIR/libsigrokdecode.*.dylib
116 install_name_tool -change \
117 /usr/local/opt/python/Frameworks/Python.framework/Versions/$PYVER/Python \
118 @executable_path/../Frameworks/Python.framework/Versions/$PYVER/Python \
119 $FRAMEWORKSDIR/libirmp.*.dylib
121 # Add wrapper (sets PYTHONHOME/SIGROK_FIRMWARE_DIR/SIGROKDECODE_DIR).
122 mv $MACOSDIR/$APPNAME_BINARY $MACOSDIR/$APPNAME_BINARY.real
123 cp ../contrib/$APPNAME_BINARY $MACOSDIR
124 chmod 755 $MACOSDIR/$APPNAME_BINARY
126 cp ../contrib/Info.plist_$APPNAME_BINARY $CONTENTSDIR/Info.plist
127 cp ../contrib/$APPNAME_BINARY.icns $CONTENTSDIR/Resources
129 hdiutil create "${APPNAME}-${APPVER}.dmg" -volname "$APPNAME $APPVER" \
130 -fs HFS+ -srcfolder "$APPNAME.app"