Created
December 13, 2017 14:55
-
-
Save x42/8da9b6cb62d127ab8e2a4ec0bc5d48cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## the general idea is to run this script in a pbuilder/cowbuilder | |
## environment (system-wide libs matching the target CPU arch) | |
## keep a copy of the sources here: | |
: ${SRCDIR=/var/tmp/src_cache} | |
## builder location | |
: ${ROOTDIR=$HOME/builder/} | |
## target architecture | |
: ${XARCH=x86_64} # or i686 | |
## concurrency | |
: ${MAKEFLAGS=-j4} | |
## debian packages needed to bootstrap | |
if false; then | |
apt-get -q -y install \ | |
build-essential \ | |
git autoconf automake libtool pkg-config \ | |
curl unzip ed yasm ca-certificates \ | |
zip python python-dev \ | |
libx11-dev libxext-dev libxrender-dev libglu-dev | |
fi | |
############################################################################### | |
set -e | |
## actual build location | |
: ${PREFIX=${ROOTDIR}/x-stack-$XARCH} | |
## target install dir (chroot-like) | |
: ${BUILDD=${ROOTDIR}/x-build-$XARCH} | |
unset PKG_CONFIG_PATH | |
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig | |
export PREFIX | |
export SRCDIR | |
export PATH=${PREFIX}/bin:/usr/lib/ccache/:/usr/bin:/bin:/usr/sbin:/sbin | |
################################################################################ | |
function download { | |
echo "--- Downloading.. $2" | |
test -f ${SRCDIR}/$1 || curl -L -o ${SRCDIR}/$1 $2 | |
} | |
function src { | |
download ${1}.${2} $3 | |
cd ${BUILDD} | |
rm -rf $1 | |
tar xf ${SRCDIR}/${1}.${2} | |
cd $1 | |
} | |
function autoconfconf { | |
set -e | |
echo "======= $(pwd) =======" | |
CPPFLAGS="-I${PREFIX}/include$CPPFLAGS" \ | |
CFLAGS="-O3 -fvisibility=hidden -fPIC -fdata-sections -ffunction-sections" \ | |
CXXFLAGS="-O3 -fvisibility=hidden -fPIC -fdata-sections -ffunction-sections" \ | |
LDFLAGS="-L${PREFIX}/lib -fvisibility=hidden -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed -Wl,--strip-all" \ | |
./configure \ | |
--disable-shared --enable-static \ | |
--prefix=$PREFIX $@ | |
} | |
function autoconfbuild { | |
set -e | |
autoconfconf $@ | |
make $MAKEFLAGS | |
make install | |
} | |
################################################################################ | |
if -d $PREFIX; then | |
echo "Cleaning old stack in $PREFIX" | |
rm -rf $PREFIX | |
fi | |
################################################################################ | |
mkdir -p ${SRCDIR} | |
mkdir -p ${PREFIX} | |
mkdir -p ${BUILDD} | |
#src xz-5.0.7 tar.gz http://tukaani.org/xz/xz-5.0.7.tar.gz | |
#./configure --prefix=${PREFIX} | |
#make | |
#make install | |
# | |
#src tar-1.27 tar.gz http://ftp.gnu.org/gnu/tar/tar-1.27.tar.gz | |
#./configure --prefix=${PREFIX} | |
#make | |
#make install | |
#hash tar | |
# | |
#src m4-1.4.17 tar.gz http://ftp.gnu.org/gnu/m4/m4-1.4.17.tar.gz | |
#autoconfbuild | |
# | |
#src make-4.1 tar.gz http://ftp.gnu.org/gnu/make/make-4.1.tar.gz | |
#autoconfbuild | |
#hash make | |
src zlib-1.2.7 tar.gz ftp://ftp.simplesystems.org/pub/libpng/png/src/history/zlib/zlib-1.2.7.tar.gz | |
CFLAGS="-O3 -fvisibility=hidden -fPIC" \ | |
LDFLAGS="-fvisibility=hidden" \ | |
./configure --static \ | |
--prefix=$PREFIX $@ | |
make $MAKEFLAGS | |
make install | |
#src autoconf-2.69 tar.xz http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz | |
#autoconfbuild | |
#hash autoconf | |
#hash autoreconf | |
# | |
#src automake-1.14 tar.gz http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz | |
#autoconfbuild | |
#hash automake | |
# | |
#src libtool-2.4 tar.gz http://ftp.gnu.org/gnu/libtool/libtool-2.4.tar.gz | |
#autoconfbuild | |
#hash libtoolize | |
# | |
#src make-4.1 tar.gz http://ftp.gnu.org/gnu/make/make-4.1.tar.gz | |
#autoconfbuild | |
#hash make | |
src expat-2.1.0 tar.gz http://prdownloads.sourceforge.net/expat/expat-2.1.0.tar.gz | |
autoconfbuild | |
src libiconv-1.14 tar.gz ftp://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz | |
patch -p1 << EOF | |
--- a/srclib/stdio.in.h 2011-08-07 16:42:06.000000000 +0300 | |
+++ b/srclib/stdio.in.h 2013-01-10 15:53:03.000000000 +0200 | |
@@ -695,7 +695,9 @@ | |
/* It is very rare that the developer ever has full control of stdin, | |
so any use of gets warrants an unconditional warning. Assume it is | |
always declared, since it is required by C89. */ | |
-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); | |
+#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16) | |
+ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); | |
+#endif | |
#endif | |
EOF | |
gl_cv_cc_visibility=no \ | |
autoconfbuild --with-included-gettext --with-libiconv-prefix=$PREFIX | |
src libxml2-2.9.2 tar.gz ftp://xmlsoft.org/libxslt/libxml2-2.9.2.tar.gz | |
CFLAGS=" -O0" CXXFLAGS=" -O0" \ | |
autoconfbuild --with-threads=no --with-zlib=$PREFIX --with-minimum --without-python --without-lzma --with-reader --with-tree --with-sax1 | |
src libpng-1.6.34 tar.xz https://downloads.sourceforge.net/project/libpng/libpng16/1.6.34/libpng-1.6.34.tar.xz | |
autoconfbuild | |
src libffi-3.1 tar.gz ftp://sourceware.org/pub/libffi/libffi-3.1.tar.gz | |
autoconfbuild | |
src gettext-0.19.3 tar.gz http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.3.tar.gz | |
autoconfbuild | |
#src pkg-config-0.28 tar.gz http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz | |
#./configure --prefix=$PREFIX --with-internal-glib | |
#make $MAKEFLAGS | |
#make install | |
src freetype-2.5.3 tar.gz http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gz | |
autoconfbuild -with-harfbuzz=no --with-bzip2=no --with-png=no | |
src fontconfig-2.11.1 tar.bz2 http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.11.1.tar.bz2 | |
sed -i.bak 's/default/hidden/g' src/makealias | |
autoconfconf --enable-libxml2 --disable-docs --sysconfdir=/etc --prefix=/ | |
make $MAKEFLAGS | |
DESTDIR=$PREFIX make install | |
src pixman-0.34.0 tar.gz http://cgit.freedesktop.org/pixman/snapshot/pixman-0.34.0.tar.gz | |
ed Makefile.am << EOF | |
%s/ demos test/ demos/ | |
wq | |
EOF | |
./autogen.sh | |
autoconfconf | |
sed -i.bak 's/default/hidden/g' pixman/pixman-compiler.h | |
make $MAKEFLAGS | |
make install | |
src cairo-1.14.6 tar.xz http://cairographics.org/releases/cairo-1.14.6.tar.xz | |
ed Makefile.in << EOF | |
%s/ test perf// | |
wq | |
EOF | |
ax_cv_c_float_words_bigendian=no \ | |
autoconfbuild --disable-gtk-doc-html --enable-gobject=no --disable-valgrind \ | |
--enable-pdf=no --enable-interpreter=no --enable-ps=no --enable-script=no --enable-svg=no \ | |
--enable-symbol-lookup=no | |
# --enable-xlib --disable-gl --disable-xlib-xcb --enable-xcb-shm | |
src libsndfile-1.0.27 tar.gz http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.27.tar.gz | |
autoconfbuild | |
src libsamplerate-0.1.8 tar.gz http://www.mega-nerd.com/SRC/libsamplerate-0.1.8.tar.gz | |
autoconfbuild | |
################################################################################ | |
echo "Build-deps done" | |
################################################################################ | |
exit | |
#### cd into project to be build | |
#### the commandline below assume a GNU-Makefile which honors various env variables | |
## note: PKG_CONFIG_PATH and PATH are still set | |
make \ | |
PKG_CONFIG_FLAGS=--static \ | |
CFLAGS="-I${PREFIX}/include -fvisibility=hidden -fdata-sections -ffunction-sections $CFLAGS -Wno-deprecated-declarations" \ | |
CXXFLAGS="-I${PREFIX}/include -fvisibility=hidden -fdata-sections -ffunction-sections $CXXFLAGS -Wno-deprecated-declarations" \ | |
LDFLAGS="-L${PREFIX}/lib -fvisibility=hidden -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed -Wl,--strip-all $LDFLAGS" \ | |
"$@" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment