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