add script to compile dependencies

This commit is contained in:
Chris Lee 2019-04-28 19:24:51 +02:00
parent 10723b1db5
commit b9c313cd18
2 changed files with 95 additions and 5 deletions

79
packaging/compile-deps.sh Executable file
View file

@ -0,0 +1,79 @@
#!/bin/bash
PS4='\e[99;33m${BASH_SOURCE}:$LINENO\e[0m '
set -e
set -x
sudo apt-get install ninja-build python2.7 wget
sudo apt-get build-dep libx11-6 libxrender1 libcairo2 libglib2.0-0 libpango-1.0-0 libimlib2 librsvg2-2
export PKG_CONFIG_PATH=""
DEPS=$HOME/tint2-deps
X11=$(pkg-config --modversion x11)
XRENDER=$(pkg-config --modversion xrender)
XCOMPOSITE=$(pkg-config --modversion xcomposite)
XDAMAGE=$(pkg-config --modversion xdamage)
XEXT=$(pkg-config --modversion xext)
XRANDR=$(pkg-config --modversion xrandr)
XINERAMA=$(pkg-config --modversion xinerama)
IMLIB=$(pkg-config --modversion imlib2)
GLIB=$(pkg-config --modversion glib-2.0)
CAIRO=$(pkg-config --modversion cairo)
PANGO=$(pkg-config --modversion pango)
PIXBUF=$(pkg-config --modversion gdk-pixbuf-2.0)
RSVG=$(pkg-config --modversion librsvg-2.0)
mkdir -p $DEPS/src
function two_digits() {
echo "$@" | cut -d. -f 1-2
}
function download_and_build() {
URL="$1"
shift
CFGARGS="$@"
ARCHIVE="$(basename "$URL")"
NAME="$(echo "$ARCHIVE" | sed s/\.tar.*$//g)"
cd "$DEPS/src"
rm -rf "$ARCHIVE"
rm -rf "$NAME"
wget "$URL" -O "$ARCHIVE"
tar xf "$ARCHIVE"
cd "$NAME"
export PKG_CONFIG_PATH="$DEPS/lib/pkgconfig"
export PATH="$DEPS/bin:$PATH"
export CFLAGS="-O0 -fno-common -fno-omit-frame-pointer -rdynamic -fsanitize=address -g"
export LDFLAGS="-Wl,--no-as-needed -Wl,-z,defs -O0 -fno-common -fno-omit-frame-pointer -rdynamic -fsanitize=address -fuse-ld=gold -g -ldl -lasan"
if [[ -x ./configure ]]
then
./configure "--prefix=$DEPS" "$@"
make -j
make install
elif [[ -f meson.build ]]
then
mkdir build
cd build
meson "--prefix=$DEPS" "$@" ..
ninja install
else
echo "unknown build method"
exit 1
fi
}
download_and_build "https://www.x.org/archive/individual/lib/libX11-$X11.tar.gz" --enable-static=no
download_and_build "https://www.x.org/archive//individual/lib/libXrender-$XRENDER.tar.gz" --enable-static=no
download_and_build "https://www.x.org/archive//individual/lib/libXcomposite-$XCOMPOSITE.tar.gz" --enable-static=no
download_and_build "https://www.x.org/archive//individual/lib/libXdamage-$XDAMAGE.tar.gz" --enable-static=no
download_and_build "https://www.x.org/archive//individual/lib/libXext-$XEXT.tar.gz" --enable-static=no
download_and_build "https://www.x.org/archive//individual/lib/libXrandr-$XRANDR.tar.gz" --enable-static=no
download_and_build "https://www.x.org/archive//individual/lib/libXinerama-$XINERAMA.tar.gz" --enable-static=no
download_and_build "https://downloads.sourceforge.net/enlightenment/imlib2-$IMLIB.tar.bz2" --enable-static=no
download_and_build "https://ftp.gnome.org/pub/gnome/sources/glib/$(two_digits "$GLIB")/glib-$GLIB.tar.xz" --enable-debug=yes
download_and_build "https://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/$(two_digits "$PIXBUF")/gdk-pixbuf-$PIXBUF.tar.xz"
download_and_build "https://cairographics.org/snapshots/cairo-$CAIRO.tar.xz"
download_and_build "https://ftp.gnome.org/pub/gnome/sources/pango/$(two_digits "$PANGO")/pango-$PANGO.tar.xz"
download_and_build "https://ftp.gnome.org/pub/gnome/sources/librsvg/$(two_digits "$RSVG")/librsvg-$RSVG.tar.xz" --enable-pixbuf-loader

21
packaging/configure vendored
View file

@ -52,6 +52,7 @@ def pkg_config(lib):
lf = _pkgconfig(lib, '--libs-only-l')
cf = _pkgconfig(lib, '--cflags')
ldf = _pkgconfig(lib, '--libs-only-L')
print("Found", lib, "in:", ldf)
return (lf, cf, ldf)
@ -110,6 +111,14 @@ def install_dir(prefix, suffix, dest_dir, dest_suffix=''):
return result
def remove_duplicates(ls):
result = []
for x in ls:
if x not in result:
result.append(x)
return result
class Executable(object):
def __init__(self, name):
self.name = name
@ -126,9 +135,9 @@ class Executable(object):
f.write('# Executable: {}\n'.format(self.name))
ninja_write_vars(f, **{
'cc_' + self.name: self.cc,
'cflags_' + self.name: ninja_join(self.cflags),
'lflags_' + self.name: ninja_join(self.lflags),
'libs_' + self.name: ninja_join(self.libs)})
'cflags_' + self.name: ninja_join(remove_duplicates(self.cflags)),
'lflags_' + self.name: ninja_join(remove_duplicates(self.lflags)),
'libs_' + self.name: ninja_join(remove_duplicates(self.libs))})
ninja_write_rule(f, 'cc_' + self.name,
command='$cc_{} -MMD -MT $out -MF $out.d $cflags_{} -c $in -o $out'.format(self.name, self.name),
description='CC $out',
@ -339,11 +348,13 @@ for dep in ['x11',
'xext',
'xrender',
'xrandr>=1.3',
'gmodule-2.0',
'gio-2.0',
'glib-2.0',
'gobject-2.0',
'pangocairo',
'pango',
'cairo',
'glib-2.0',
'gobject-2.0',
'imlib2>=1.4.2']:
lib, cf, lf = pkg_config(dep)
LIBS += lib