3 ## This program is not part of PSPP but is used to help build PSPP
4 ## Copyright (C) 2021 John Darrington
6 ## This program is free software: you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation, either version 3 of the License, or
9 ## (at your option) any later version.
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ## GNU General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This script downloads (if necessary) and builds the required
20 # dependencies of PSPP. You may find it useful when cross building.
21 # Sadly, it it very likely that you'll have to tweak the order of the
22 # packages, the versions of the packages, their CFLAGS and other
23 # details in order to succesfully build for any particular
24 # architecture. In its current form, it has been tweaked for building
27 required_native_programs="awk sha256sum tar sed gtk-encode-symbolic-svg ninja meson cat grep pkg-config"
29 for p in $required_native_programs; do
30 if ! type "$p" > /dev/null; then
31 echo $p must be installed and in PATH;
36 while test $# -gt 0; do
41 SANDBOX=${1##--sandbox=};;
43 SRC_TARBALL_DIR=${1##--tarballs=};;
47 printf "Usage: $0 --arch=<arch> --sandbox=<dir> [--tarballs=<dir>]\n";
54 if test -z "$SANDBOX" -o -z "$arch"; then
55 printf "Usage: $0 --arch=<arch> --sandbox=<dir> [--tarballs=<dir>]\n";
59 SANDBOX=`eval echo $SANDBOX`
61 if test -z "$SRC_TARBALL_DIR"; then
62 SRC_TARBALL_DIR="$SANDBOX/tarballs"
65 SRC_TARBALL_DIR=`eval echo $SRC_TARBALL_DIR`
67 test "x$noclean" = "xyes" || rm -rIf $SANDBOX
69 default_build_procs=$(expr $(cat /proc/cpuinfo | grep -c '^processor') + 1)
71 mkdir -p $SRC_TARBALL_DIR
77 cat > $SANDBOX/cross-file.txt <<EOF
89 objcopy = '$arch-objcopy'
91 pkgconfig = 'pkg-config'
92 windres = '$arch-windres'
95 tarballs="zlib-1.2.11.tar.gz"
96 tarballs="$tarballs libiconv-1.16.tar.gz"
97 tarballs="$tarballs gettext-0.21.tar.xz"
98 tarballs="$tarballs libffi-3.3.tar.gz"
99 tarballs="$tarballs pixman-0.40.0.tar.gz"
100 tarballs="$tarballs libpng-1.6.37.tar.gz"
101 tarballs="$tarballs libxml2-2.9.10.tar.gz"
102 tarballs="$tarballs freetype-2.10.4.tar.xz"
103 tarballs="$tarballs fribidi-1.0.10.tar.xz"
104 tarballs="$tarballs harfbuzz-2.7.4.tar.xz"
105 tarballs="$tarballs glib-2.67.6.tar.xz"
106 tarballs="$tarballs cairo-1.17.4.tar.xz"
107 tarballs="$tarballs pango-1.48.0.tar.xz"
108 tarballs="$tarballs atk-2.36.0.tar.xz"
109 tarballs="$tarballs gdk-pixbuf-2.42.2.tar.xz"
110 tarballs="$tarballs libepoxy-1.5.5.tar.xz"
111 tarballs="$tarballs gtk+-3.24.27.tar.xz"
112 tarballs="$tarballs gsl-2.6.tar.gz"
113 tarballs="$tarballs gtksourceview-3.24.9.tar.xz"
114 tarballs="$tarballs spread-sheet-widget-0.8.tar.gz"
115 tarballs="$tarballs hicolor-icon-theme-0.17.tar.xz"
116 tarballs="$tarballs adwaita-icon-theme-3.38.0.tar.xz"
118 mkdir -p $SANDBOX/Source
119 for t in $tarballs ; do
123 url="ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.2.tar.gz";
124 hash=30306e0c76e0f9f1f0de987cf1c82a5c21e1ce6568b9227f7da5b71cbea86c9d;;
126 url="ftp://ftp.gnu.org/gnu/readline/readline-8.1.tar.gz";
127 hash=f8ceb4ee131e3232226a17f51b164afc46cd0b9e6cef344be87c65962cb82b02;;
128 termcap-1.3.1.tar.gz)
129 url="ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz";
130 hash=91a0e22e5387ca4467b5bcb18edf1c51b930262fd466d5fda396dd9d26719100;;
131 fontconfig-2.12.6.tar.bz2)
132 url="https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.6.tar.bz2";
133 hash=cf0c30807d08f6a28ab46c61b8dbd55c97d2f292cf88f3a07d3384687f31f017;;
134 adwaita-icon-theme-3.38.0.tar.xz)
135 url="https://download.gnome.org/sources/adwaita-icon-theme/3.38/adwaita-icon-theme-3.38.0.tar.xz";
136 hash=6683a1aaf2430ccd9ea638dd4bfe1002bc92b412050c3dba20e480f979faaf97;;
137 librsvg-2.31.0.tar.bz2)
138 url="https://ftp.acc.umu.se/pub/GNOME/sources/librsvg/2.31/librsvg-2.31.0.tar.bz2";
139 hash=320b61ef5e6d65624f3733a83134df012a4156ed7f7ae38a6ed19febe1bfa732;;
140 librsvg-2.49.5.tar.xz)
141 url="https://download.gnome.org/sources/librsvg/2.49/librsvg-2.49.5.tar.xz";
142 hash=daa64941bb4732bdf51b902a72c6e04063235cfce6986d910ba0759c76917795;;
143 librsvg-2.51.0.tar.xz)
144 url="https://ftp.acc.umu.se/pub/GNOME/sources/librsvg/2.51/librsvg-2.51.0.tar.xz";
145 hash=89d32e38445025e1b1d9af3dd9d3aeb9f6fce527aeecbecf38b369b34c80c038;;
146 hicolor-icon-theme-0.17.tar.xz)
147 url="https://icon-theme.freedesktop.org/releases/hicolor-icon-theme-0.17.tar.xz";
148 hash=317484352271d18cbbcfac3868eab798d67fff1b8402e740baa6ff41d588a9d8;;
150 url="https://ftp.gnu.org/gnu/gettext/gettext-0.21.tar.xz";
151 hash=d20fcbb537e02dcf1383197ba05bd0734ef7bf5db06bdb241eb69b7d16b73192;;
152 spread-sheet-widget-0.8.tar.gz)
153 url="https://alpha.gnu.org/gnu/ssw/spread-sheet-widget-0.8.tar.gz"
154 hash=8589d8298fcf3b5850d0968b04801a4f40faf0555544f6cc9d954b0162e9954b;;
155 gtksourceview-3.24.9.tar.xz)
156 url="https://download.gnome.org/sources/gtksourceview/3.24/gtksourceview-3.24.9.tar.xz"
157 hash=699d76a453e6a3d3331906346e3dbfa25f2cbc9ec090e46635e9c6bb595e07c2;;
158 libepoxy-1.5.5.tar.xz)
159 url="https://github.com/anholt/libepoxy/releases/download/1.5.5/libepoxy-1.5.5.tar.xz"
160 hash=261663db21bcc1cc232b07ea683252ee6992982276536924271535875f5b0556;;
161 gdk-pixbuf-2.42.2.tar.xz)
162 url="https://download.gnome.org/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.2.tar.xz";
163 hash=83c66a1cfd591d7680c144d2922c5955d38b4db336d7cd3ee109f7bcf9afef15;;
164 gobject-introspection-1.67.1.tar.xz)
165 url="https://download.gnome.org/sources/gobject-introspection/1.67/gobject-introspection-1.67.1.tar.xz";
168 url="https://download.gnome.org/sources/atk/2.36/atk-2.36.0.tar.xz";
169 hash=fb76247e369402be23f1f5c65d38a9639c1164d934e40f6a9cf3c9e96b652788;;
171 url="https://download.gnome.org/sources/gtk+/3.24/gtk%2B-3.24.27.tar.xz";
172 hash=f71c067570339f9f8efac7bb87717a2c52279cb50223fb8b5ba7085930757a26;;
174 url="https://cairographics.org/snapshots/cairo-1.17.4.tar.xz";
175 hash=74b24c1ed436bbe87499179a3b27c43f4143b8676d8ad237a6fa787401959705;;
176 harfbuzz-2.7.4.tar.xz)
177 url="https://github.com/harfbuzz/harfbuzz/releases/download/2.7.4/harfbuzz-2.7.4.tar.xz";
178 hash=6ad11d653347bd25d8317589df4e431a2de372c0cf9be3543368e07ec23bb8e7;;
179 fribidi-1.0.10.tar.xz)
180 url="https://github.com/fribidi/fribidi/releases/download/v1.0.10/fribidi-1.0.10.tar.xz";
181 hash=7f1c687c7831499bcacae5e8675945a39bacbad16ecaa945e9454a32df653c01;;
182 fontconfig-2.13.0.tar.bz2)
183 url="https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.0.tar.bz2";
184 hash=91dde8492155b7f34bb95079e79be92f1df353fcc682c19be90762fd3e12eeb9;;
186 url="ftp://sourceware.org/pub/libffi/libffi-3.3.tar.gz";
187 hash=72fba7922703ddfa7a028d513ac15a85c8d54c8d67f55fa5a4802885dc652056;;
189 url="https://zlib.net/fossils/zlib-1.2.11.tar.gz";
190 hash=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1;;
191 pixman-0.40.0.tar.gz)
192 url="https://www.cairographics.org/releases/pixman-0.40.0.tar.gz";
193 hash=6d200dec3740d9ec4ec8d1180e25779c00bc749f94278c8b9021f5534db223fc;;
194 libpng-1.6.37.tar.gz)
195 url="https://download.sourceforge.net/libpng/libpng-1.6.37.tar.gz";
196 hash=daeb2620d829575513e35fecc83f0d3791a620b9b93d800b763542ece9390fb4;;
197 freetype-2.10.4.tar.xz)
198 url="https://download.savannah.gnu.org/releases/freetype/freetype-2.10.4.tar.xz";
199 hash=86a854d8905b19698bbc8f23b860bc104246ce4854dcea8e3b0fb21284f75784;;
201 url="https://download.gnome.org/sources/glib/2.67/glib-2.67.6.tar.xz";
202 hash=dd7f563509b410e8f94ef2d4cc7f74620a6b29d7c5d529fedec53c5e8018d9c5;;
204 url="https://download.gnome.org/sources/pango/1.48/pango-1.48.0.tar.xz";
205 hash=391f26f3341c2d7053e0fb26a956bd42360dadd825efe7088b1e9340a65e74e6;;
207 hash=da17985df314cb07d066ab5424f59c21ce973ece05b7de4df04d798ec8511c8b;;
209 url="https://ftp.gnu.org/gnu/gsl/gsl-2.6.tar.gz";
210 hash=b782339fc7a38fe17689cb39966c4d821236c28018b6593ddb6fd59ee40786a8;;
211 libiconv-1.16.tar.gz)
212 url="https://ftp.gnu.org/gnu/libiconv/libiconv-1.16.tar.gz";
213 hash=e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04;;
214 libxml2-2.9.10.tar.gz)
215 url="ftp://xmlsoft.org/libxml2/libxml2-2.9.10.tar.gz";
216 hash=aafee193ffb8fe0c82d4afef6ef91972cbaf5feea100edc2f262750611b4be1f;;
220 # Fetch the tarball if we don't already have it.
221 if ! test -e $SRC_TARBALL_DIR/$t; then
222 (cd $SRC_TARBALL_DIR && wget $url)
227 # Don't check the hash for this since it's changing rapidly
229 *) # Check that it hasn't been corrupted or compromised
230 h=`(cd $SRC_TARBALL_DIR && sha256sum $t) | awk '{print $1}'`
231 if ! test "$hash" = $h ; then
232 echo "Hash for $t is invalid" ;
239 # No network access should be necessary after this point
240 for t in $tarballs ; do
241 # Unpack the tarballs into the Source directory
260 echo "Unknown archive suffix: $t";
265 (cd $SANDBOX/Source && $unarch $SRC_TARBALL_DIR/$t)
268 rm -rf $SANDBOX/Build/$pkg
269 mkdir -p $SANDBOX/Build/$pkg
270 build_procs=$default_build_procs
272 # Deal with the special cases here
274 cd $SANDBOX/Build/$pkg && \
275 CC=$arch-gcc LDSHAREDLIBC="" $SANDBOX/Source/$pkg/configure --prefix="$SANDBOX/Install" && \
276 make -j $build_procs && make install
278 # And now the generic cases
280 depdir=$SANDBOX/Install
281 build_system="autoconf"
283 prefix=$SANDBOX/Install
286 extra_cflags="-fstack-protector";;
288 extra_config_flags="GSL_LDFLAGS=-XCClinker -fstack-protector";
289 extra_cflags="-fstack-protector";;
291 extra_config_flags="--disable-tools --enable-introspection=no --disable-gtk-doc-html"
295 build_system="meson";
298 build_system="meson";
299 meson_opts="-Dintrospection=false -Dtests=false -Ddemos=false -Dexamples=false";
302 build_system="meson";
303 meson_opts="-Dintrospection=disabled -Dbuiltin_loaders=all -Dnative_windows_loaders=true -Dinstalled_tests=false -Dman=false";
305 gobject-introspection-*)
306 build_system="meson";
307 meson_opts=-Dpython=python3;
310 build_system="meson";
311 meson_opts=-Dintrospection=false;
314 build_system="meson";
315 meson_opts="-Dtests=false";
316 extra_cflags=-Wno-format; #no-format seems to be necessary for 32 bit builds
319 build_system="meson";
320 meson_opts=-Dglib=disabled;
323 extra_config_flags="--enable-static=no";
326 extra_config_flags="--enable-libxml2 --disable-docs";
329 extra_config_flags=--without-python;
332 extra_config_flags="--enable-shared=yes";
333 # We only need gettext-runtime
334 pre_configure="sed -i -e /^SUBDIRS/s/libtextstyle.gettext-tools// $SANDBOX/Source/$pkg/Makefile.in";
337 build_system="meson";
338 extra_cflags="-fstack-protector";
339 extra_ldflags="-fstack-protector";
341 spread-sheet-widget-*)
344 extra_config_flags="--enable-relocatable";
345 extra_build="make -j $build_procs install-html install-pdf";
346 prefix=$SANDBOX/Bundle;
349 case $build_system in
351 PKG_CONFIG_LIBDIR="$SANDBOX/Install/lib/pkgconfig" \
352 meson setup --prefix=$prefix \
354 --cross-file=$SANDBOX/cross-file.txt \
355 -Dc_link_args="-L$SANDBOX/Install/lib $extra_ldflags" \
356 -Dc_args="-I$SANDBOX/Install/include $extra_cflags" \
357 --wrap-mode=nodownload \
359 $SANDBOX/Source/$pkg $SANDBOX/Build/$pkg &&
360 ninja -j $build_procs -C $SANDBOX/Build/$pkg &&
361 meson install -C $SANDBOX/Build/$pkg
365 cd $SANDBOX/Build/$pkg && \
366 $SANDBOX/Source/$pkg/configure \
369 "$extra_config_flags" \
370 CFLAGS="$extra_cflags" \
371 CPPFLAGS="-I $depdir/include $extra_cppflags" \
372 LDFLAGS="-L$depdir/lib $extra_ldflags" \
373 PKG_CONFIG_LIBDIR="$depdir/lib/pkgconfig" &&
374 make -j $build_procs && make install && $extra_build
377 echo I have no idea how to build $SANDBOX/Source/$pkg
386 printf "You can now configure pspp with a command similar to:\n"
387 printf "configure --host=\"$arch\" CPPFLAGS=\"-I $SANDBOX/Install/include\" LDFLAGS=\"-L$SANDBOX/Install/lib\" PKG_CONFIG_LIBDIR=\"$SANDBOX/Install/lib/pkgconfig\"\n"