3 # Create a MacOS application bundle for pspp
4 # This will install all required dependencies via macports
5 # With option --git it will build pspp from a source tree
6 # The default is to install also pspp from macports
7 # Requires XCode Commandline Tools installed and ready for macports
9 # Copyright (C) 2016 Free Software Foundation, Inc.
10 # Released under GNU General Public License, either version 3
13 # The source tree for pspp is here. This is only required if you
14 # build with option --git
15 psppsource=`pwd`/../..
17 # Check if we are on MacOS
18 if ! test `uname` = "Darwin"; then
19 echo "This only works on MacOS"
23 # Check if XCode is installed - Assume clang indicates xcode.
24 if ! test -f /usr/bin/clang; then
25 echo "/usr/bin/clang not found - please install XCode CLT"
29 # Check the required configuration files
30 if ! test -f ./pspp.bundle; then
31 echo "pspp.bundle is missing"
35 if ! test -f ./Info-pspp.plist; then
36 echo "Info-pspp.plist is missing"
41 if test $# = 1 && test $1 = "--git"; then
42 echo "Trying to build from source"
43 if test -f $psppsource/configure; then
46 echo "Could not find pspp source in: $psppsource"
51 # This is the installation directory which will be used as macports prefix
52 # and as pspp configure prefix.
53 bundleinstall=`pwd`/install
55 export PATH=$bundleinstall/bin:$bundleinstall/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
57 # Target macports install directory for the pspp bundle
58 if test -d $bundleinstall; then
59 echo "Found existing macports directory $bundleinstall"
60 echo "Updating macports packages"
62 port uninstall gtk-mac-bundler
64 echo "Creating Macports installation in $bundleinstall"
70 curl https://distfiles.macports.org/MacPorts/MacPorts-2.3.4.tar.gz -O
71 tar xvzf Macports-2.3.4.tar.gz
73 ./configure --prefix=$bundleinstall \
74 --with-applications-dir=$bundleinstall/Applications \
75 --with-no-root-privileges
80 # Modify the default variants to use quartz
81 echo "-x11 +no_x11 +quartz" > $bundleinstall/etc/macports/variants.conf
84 # Install the packages for pspp
86 port upgrade outdated || true
87 if test $buildfromsource = "true"; then
88 # Install the build dependencies for pspp
89 port install pkgconfig texinfo makeicns cairo fontconfig freetype \
90 gettext glib2 gsl libiconv libxml2 ncurses pango readline zlib atk \
91 gdk-pixbuf2 gtksourceview3 adwaita-icon-theme
92 # Configure and build pspp
96 $psppsource/configure --prefix=$bundleinstall \
97 LDFLAGS=-L$bundleinstalll/lib \
98 CPPFLAGS=-I$bundleinstall/include \
104 # Install the pspp package from macports
105 # This is a custom package for the moment as this requires the relocatable variant
106 echo "Installing pspp from macports package"
107 pushd ./macports-custom-packages/pspp
112 # install the mac gtk-mac-bundler
113 # Custom package for the moment...
114 pushd ./macports-custom-packages/gtk-mac-bundler
118 # Create the icns file
119 makeicns -256 $bundleinstall/share/icons/hicolor/256x256/apps/pspp.png \
120 -32 $bundleinstall/share/icons/hicolor/32x32/apps/pspp.png \
121 -16 $bundleinstall/share/icons/hicolor/16x16/apps/pspp.png \
124 # produce the pspp.app bundle in Desktop
125 export PSPPINSTALL=$bundleinstall
126 gtk-mac-bundler pspp.bundle
128 # Fix the link issue for the relocatable binary in the app bundle
129 # MacOS/pspp - the wrapper from gtk-mac-bundler calling
130 # MacOS/pspp-bin - the wrapper from glibc relocatable calling pspp-bin.bin
131 # but that is in the Resource directory
132 pushd pspp.app/Contents/MacOS
133 ln -s ../Resources/bin/psppire.bin ./pspp-bin.bin
136 # Create the DMG for distribution
137 rm -rf /tmp/psppbundle
138 mkdir /tmp/psppbundle
139 mv ./pspp.app /tmp/psppbundle
141 hdiutil create -fs HFS+ -srcfolder /tmp/psppbundle -volname pspp pspp.dmg
142 rm -rf /tmp/psppbundle
144 echo "Done! Your dmg file is pspp.dmg"
145 echo "You can remove the install directory: $bundleinstall"