xhost + # Workaround for: QXcbConnection: Could not connect to display :0
[appimagekit.git] / build-tool-osx.sh
blobc0baaf0f43bae197600a6ae8cc0cc9dbf60e9959
1 #!/bin/bash
3 # This script installs the required build-time dependencies
4 # and builds AppImageTool on OSX
7 small_FLAGS="-Os -ffunction-sections -fdata-sections"
8 CC="cc -O2 -Wall -Wno-deprecated-declarations -Wno-unused-result"
10 STRIP="strip"
11 JOBS=${JOBS:-1}
13 echo $KEY | md5sum
15 set -e
16 set -x
18 HERE="$(dirname "$(readlink -f "${0}")")"
19 cd "$HERE"
21 # Fetch git submodules
22 git submodule init
23 git submodule update
25 # Clean up from previous run
26 rm -rf build/ || true
28 # Build lzma always static because the runtime gets distributed with
29 # the generated .AppImage file.
30 if [ ! -e "./xz-5.2.3/build/lib/liblzma.a" ] ; then
31 wget -c http://tukaani.org/xz/xz-5.2.3.tar.gz
32 tar xf xz-5.2.3.tar.gz
33 cd xz-5.2.3
34 mkdir -p build/lib
35 CFLAGS="-Wall $small_FLAGS" ./configure --prefix=$(pwd)/build --libdir=$(pwd)/build/lib --enable-static --disable-shared
36 make -j$JOBS && make install
37 cd -
40 # Patch squashfuse_ll to be a library rather than an executable
42 cd squashfuse
43 if [ ! -e ./ll.c.orig ]; then
44 patch -p1 --backup < ../squashfuse.patch
45 patch -p1 --backup < ../squashfuse_dlopen.patch
47 if [ ! -e ./squashfuse_dlopen.c ]; then
48 cp ../squashfuse_dlopen.c .
50 if [ ! -e ./squashfuse_dlopen.h ]; then
51 cp ../squashfuse_dlopen.h .
54 # Build libsquashfuse_ll library
56 if [ ! -e ./Makefile ] ; then
57 export ACLOCAL_FLAGS="-I /usr/share/aclocal"
58 glibtoolize --force
59 aclocal
60 autoheader
61 automake --force-missing --add-missing
62 autoreconf -fi || true # Errors out, but the following succeeds then?
63 autoconf
64 sed -i "" '/PKG_CHECK_MODULES.*/,/,:./d' configure # https://github.com/vasi/squashfuse/issues/12
65 CFLAGS="-Wall $small_FLAGS" ./configure --disable-demo --disable-high-level --without-lzo --without-lz4 --with-xz=$(pwd)/../xz-5.2.3/build
67 # Patch Makefile to use static lzma
68 sed -i "" "s|XZ_LIBS = -llzma -L$(pwd)/../xz-5.2.3/build/lib|XZ_LIBS = -Bstatic -llzma -L$(pwd)/../xz-5.2.3/build/lib|g" Makefile
71 bash --version
73 make -j$JOBS
75 cd ..
77 # Build mksquashfs with -offset option to skip n bytes
78 # https://github.com/plougher/squashfs-tools/pull/13
79 cd squashfs-tools
80 if [ ! -e squashfs-tools/action.c.orig ] ; then
81 patch -p1 --backup < ../squashfs_osx.patch
83 cd squashfs-tools
85 # Patch squashfuse-tools Makefile to link against static llzma
86 sed -i "" "s|CFLAGS += -DXZ_SUPPORT|CFLAGS += -DXZ_SUPPORT -I../../xz-5.2.3/build/include|g" Makefile
87 sed -i "" "s|LIBS += -llzma|LIBS += -Bstatic -llzma -L../../xz-5.2.3/build/lib|g" Makefile
89 make -j$JOBS XZ_SUPPORT=1 mksquashfs # LZ4_SUPPORT=1 did not build yet on CentOS 6
90 $STRIP mksquashfs
92 cd ../../
94 pwd
96 mkdir build
97 cd build
99 cp ../squashfs-tools/squashfs-tools/mksquashfs .
102 # Compile appimagetool but do not link - glib version
104 $CC -DVERSION_NUMBER=\"$(git describe --tags --always --abbrev=7)\" -D_FILE_OFFSET_BITS=64 -I../squashfuse/ \
105 $(pkg-config --cflags glib-2.0) -g -Os ../getsection.c -c ../appimagetool.c
107 # Now statically link against libsquashfuse - glib version
109 # statically link against liblzma
110 $CC -o appimagetool appimagetool.o ../elf.c ../getsection.c -DENABLE_BINRELOC ../binreloc.c \
111 ../squashfuse/.libs/libsquashfuse.a ../squashfuse/.libs/libfuseprivate.a \
112 -L../xz-5.2.3/build/lib \
113 -ldl -lpthread \
114 $(pkg-config --cflags --libs glib-2.0) -lz -llzma