2017-10-12 08:32:18 +00:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
BUILD_ROOT=$HOME/vbam-build
|
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
build_env() {
|
|
|
|
|
cat <<EOF
|
2017-10-12 08:32:18 +00:00
|
|
|
|
export MACOSX_DEPLOYMENT_TARGET=10.7
|
2017-10-22 22:35:56 +00:00
|
|
|
|
export CFLAGS="-I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -framework Carbon -Wno-unused-command-line-argument -arch x86_64"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
export CPPFLAGS="-I$BUILD_ROOT/root/include"
|
2017-10-22 22:35:56 +00:00
|
|
|
|
export CXXFLAGS="-I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -std=c++11 -stdlib=libc++ -framework Carbon -Wno-unused-command-line-argument -arch x86_64"
|
|
|
|
|
export OBJCXXFLAGS="-I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -std=c++11 -stdlib=libc++ -framework Carbon -Wno-unused-command-line-argument -arch x86_64"
|
|
|
|
|
export LDFLAGS="-L$BUILD_ROOT/root/lib -framework Carbon -Wno-unused-command-line-argument -arch x86_64"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
export CMAKE_PREFIX_PATH="$BUILD_ROOT/root"
|
|
|
|
|
export PKG_CONFIG_PATH="$BUILD_ROOT/root/lib/pkgconfig"
|
2017-10-22 22:35:56 +00:00
|
|
|
|
|
|
|
|
|
export PERL_MB_OPT='--install_base $BUILD_ROOT/root/perl5'
|
|
|
|
|
export PERL_MM_OPT='INSTALL_BASE=$BUILD_ROOT/root/perl5'
|
|
|
|
|
export PERL5LIB="$BUILD_ROOT/root/perl5/lib/perl5"
|
|
|
|
|
export PERL_LOCAL_LIB_ROOT="$BUILD_ROOT/root/perl5"
|
|
|
|
|
|
|
|
|
|
export PATH="$BUILD_ROOT/root/bin:$BUILD_ROOT/root/perl5/bin:$PATH"
|
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eval "$(build_env)"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
|
|
|
|
DISTS='
|
2017-10-22 22:35:56 +00:00
|
|
|
|
nasm http://www.nasm.us/pub/nasm/releasebuilds/2.13.01/nasm-2.13.01.tar.xz bin/nasm
|
|
|
|
|
yasm http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz bin/yasm
|
|
|
|
|
zlib https://zlib.net/zlib-1.2.11.tar.gz lib/libz.a
|
|
|
|
|
xz https://tukaani.org/xz/xz-5.2.3.tar.xz lib/liblzma.a
|
|
|
|
|
bzip2 http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz lib/libbz2.a
|
|
|
|
|
pcre https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.bz2 lib/libpcre.a
|
|
|
|
|
libffi ftp://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz lib/libffi.a
|
|
|
|
|
libiconv https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz lib/libiconv.a
|
2017-10-12 21:31:23 +00:00
|
|
|
|
gettext http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.xz lib/libintl.a
|
2017-10-22 22:35:56 +00:00
|
|
|
|
glib http://mirror.umd.edu/gnome/sources/glib/2.54/glib-2.54.1.tar.xz lib/libglib-2.0.a
|
2017-10-12 21:31:23 +00:00
|
|
|
|
openssl https://www.openssl.org/source/openssl-1.0.2l.tar.gz lib/libssl.a
|
|
|
|
|
libpng https://download.sourceforge.net/libpng/libpng-1.6.32.tar.xz lib/libpng.a
|
|
|
|
|
libjpeg-turbo https://github.com/libjpeg-turbo/libjpeg-turbo/archive/1.5.2.tar.gz lib/libjpeg.a
|
|
|
|
|
libtiff http://dl.maptools.org/dl/libtiff/tiff-3.8.2.tar.gz lib/libtiff.a
|
|
|
|
|
sdl2 https://www.libsdl.org/release/SDL2-2.0.6.tar.gz lib/libSDL2.a
|
2017-10-22 22:35:56 +00:00
|
|
|
|
sfml https://github.com/SFML/SFML/archive/2.4.2.tar.gz lib/libsfml-system-s.a
|
2017-10-12 21:31:23 +00:00
|
|
|
|
wxwidgets https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.3/wxWidgets-3.0.3.tar.bz2 lib/libwx_baseu-3.0.a
|
2017-10-22 22:35:56 +00:00
|
|
|
|
xvidcore http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.bz2 lib/libxvidcore.a
|
|
|
|
|
fribidi http://fribidi.org/download/fribidi-0.19.7.tar.bz2 lib/libfribidi.a
|
|
|
|
|
libass https://github.com/libass/libass/releases/download/0.13.7/libass-0.13.7.tar.xz lib/libass.a
|
|
|
|
|
libgsm http://www.quut.com/gsm/gsm-1.0.17.tar.gz lib/libgsm.a
|
|
|
|
|
libmodplug https://github.com/Konstanty/libmodplug/archive/5a39f5913d07ba3e61d8d5afdba00b70165da81d.tar.gz lib/libmodplug.a
|
|
|
|
|
libopencore-amrnb https://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.5.tar.gz lib/libopencore-amrnb.a
|
|
|
|
|
opus https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz lib/libopus.a
|
|
|
|
|
snappy https://github.com/google/snappy/archive/1.1.7.tar.gz lib/libsnappy.a
|
|
|
|
|
libsoxr https://downloads.sourceforge.net/project/soxr/soxr-0.1.2-Source.tar.xz lib/libsoxr.a
|
|
|
|
|
speex http://downloads.us.xiph.org/releases/speex/speex-1.2.0.tar.gz lib/libspeex.a
|
|
|
|
|
libvorbis https://github.com/xiph/vorbis/archive/v1.3.5.tar.gz lib/libvorbis.a
|
|
|
|
|
libogg http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz lib/libogg.a
|
|
|
|
|
libtheora https://github.com/Distrotech/libtheora/archive/17b02c8c564475bb812e540b551219fc42b1f75f.tar.gz lib/libtheora.a
|
|
|
|
|
vidstab https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz lib/libvidstab.a
|
|
|
|
|
libvo-amrwbenc https://github.com/mstorsjo/vo-amrwbenc/archive/v0.1.3.tar.gz lib/libvo-amrwbenc.a
|
|
|
|
|
mp3lame https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz lib/libmp3lame.a
|
|
|
|
|
libxml2 ftp://xmlsoft.org/libxml2/libxml2-2.9.6.tar.gz lib/libxml2.a
|
|
|
|
|
XML-NamespaceSupport https://cpan.metacpan.org/authors/id/P/PE/PERIGRIN/XML-NamespaceSupport-1.12.tar.gz perl5/lib/perl5/XML/NamespaceSupport.pm
|
|
|
|
|
XML-SAX-Base https://cpan.metacpan.org/authors/id/G/GR/GRANTM/XML-SAX-Base-1.09.tar.gz perl5/lib/perl5/XML/SAX/Base.pm
|
|
|
|
|
XML-SAX https://cpan.metacpan.org/authors/id/G/GR/GRANTM/XML-SAX-0.99.tar.gz perl5/lib/perl5/XML/SAX.pm
|
|
|
|
|
docbook2x https://downloads.sourceforge.net/project/docbook2x/docbook2x/0.8.8/docbook2X-0.8.8.tar.gz bin/docbook2man
|
|
|
|
|
expat https://github.com/libexpat/libexpat/archive/R_2_2_4.tar.gz lib/libexpat.a
|
|
|
|
|
graphite2 https://github.com/silnrsi/graphite/releases/download/1.3.10/graphite2-1.3.10.tgz lib/libgraphite2.a
|
|
|
|
|
freetype http://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.bz2 lib/libfreetype.a
|
|
|
|
|
harfbuzz https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-1.6.0.tar.bz2 lib/libharfbuzz.a
|
|
|
|
|
fontconfig https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.6.tar.bz2 lib/libfontconfig.a
|
|
|
|
|
libbluray ftp://ftp.videolan.org/pub/videolan/libbluray/1.0.0/libbluray-1.0.0.tar.bz2 lib/libbluray.a
|
|
|
|
|
libvpx http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.6.1.tar.bz2 lib/libvpx.a
|
|
|
|
|
libwavpack http://www.wavpack.com/wavpack-5.1.0.tar.bz2 lib/libwavpack.a
|
|
|
|
|
libx264 ftp://ftp.videolan.org/pub/videolan/x264/snapshots/last_stable_x264.tar.bz2 lib/libx264.a
|
|
|
|
|
libx265 https://bitbucket.org/multicoreware/x265/downloads/x265_2.5.tar.gz lib/libx265.a
|
|
|
|
|
libxavs https://github.com/Distrotech/xavs/archive/distrotech-xavs-git.tar.gz lib/libxavs.a
|
|
|
|
|
libzmq https://github.com/zeromq/libzmq/releases/download/v4.2.2/zeromq-4.2.2.tar.gz lib/libzmq.a
|
|
|
|
|
# libzvbi https://downloads.sourceforge.net/project/zapping/zvbi/0.2.35/zvbi-0.2.35.tar.bz2 lib/libzvbi.a
|
2017-10-12 21:31:23 +00:00
|
|
|
|
ffmpeg http://ffmpeg.org/releases/ffmpeg-3.3.4.tar.xz lib/libavformat.a
|
2017-10-12 08:32:18 +00:00
|
|
|
|
'
|
|
|
|
|
|
|
|
|
|
CONFIGURE_ARGS="--disable-shared --enable-static --prefix=$BUILD_ROOT/root"
|
2017-10-22 22:35:56 +00:00
|
|
|
|
|
|
|
|
|
CMAKE_ARGS="-DBUILD_SHARED_LIBS=NO -DENABLE_SHARED=NO -DCMAKE_PREFIX_PATH=$BUILD_ROOT/root -DCMAKE_INSTALL_PREFIX=$BUILD_ROOT/root -DCMAKE_BUILD_TYPE=Release"
|
|
|
|
|
|
|
|
|
|
DIST_PATCHES='
|
|
|
|
|
docbook2x https://sourceforge.net/p/docbook2x/bugs/_discuss/thread/0cfa4055/f6a5/attachment/docbook2x.patch
|
|
|
|
|
graphite2 https://gist.githubusercontent.com/rkitover/418600634d7cf19e2bf1c3708b50c042/raw/b5e9ee6c237a588157a754de6705a56fc315b00a/graphite2-static.patch
|
|
|
|
|
'
|
|
|
|
|
|
|
|
|
|
DIST_PRE_BUILD="
|
|
|
|
|
expat cd expat; sed -i .bak 's/cp \\\$</mv \$</' doc/doc.mk
|
|
|
|
|
libmodplug sed -i .bak '/-mmacosx-version-min=/d' configure.ac; sed -i .bak 's/-lstdc++/-lc++/g' libmodplug.pc.in; rm -f configure
|
|
|
|
|
libzmq sed -i .bak 's/-lstdc++/-lc++/g' src/libzmq.pc.in
|
|
|
|
|
xvidcore cd build/generic; sed -i .bak '/^all:/{ s/ *\\\$(SHARED_LIB)//; }; /^install:/{ s, *\\\$(BUILD_DIR)/\\\$(SHARED_LIB),,; }; s/\\\$(INSTALL).*\\\$(SHARED_LIB).*/:/; s/\\\$(LN_S).*\\\$(SHARED_LIB).*/:/' Makefile
|
|
|
|
|
libx265 cd source
|
|
|
|
|
ffmpeg sed -i .bak 's/-lstdc++/-lc++/g' configure
|
|
|
|
|
"
|
|
|
|
|
|
|
|
|
|
DIST_POST_BUILD="
|
|
|
|
|
"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
|
|
|
|
DIST_OVERRIDES="
|
2017-10-22 22:35:56 +00:00
|
|
|
|
zlib --static --prefix=$BUILD_ROOT/root
|
2017-10-12 08:32:18 +00:00
|
|
|
|
openssl darwin64-x86_64-cc no-shared --prefix=$BUILD_ROOT/root
|
|
|
|
|
"
|
|
|
|
|
|
|
|
|
|
DIST_ARGS="
|
2017-10-22 22:35:56 +00:00
|
|
|
|
pcre --enable-utf8 --enable-pcre8 --enable-pcre16 --enable-pcre32 --enable-unicode-properties --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-jit
|
|
|
|
|
libmodplug CC=clang++ CXX=clang++
|
|
|
|
|
freetype --with-harfbuzz=no
|
|
|
|
|
harfbuzz --with-cairo=no
|
|
|
|
|
libvpx --disable-unit-tests --disable-tools --disable-docs --disable-examples
|
|
|
|
|
libxavs --disable-asm
|
|
|
|
|
libzvbi --without-x --without-doxygen
|
|
|
|
|
libxml2 --without-python
|
|
|
|
|
wxwidgets --with-macosx-version-min=$MACOSX_DEPLOYMENT_TARGET --enable-stl LDFLAGS='$LDFLAGS -stdlib=libc++' --disable-precomp-headers
|
|
|
|
|
libbluray --disable-bdjava
|
|
|
|
|
libopencore-amrnb --disable-compile-c
|
|
|
|
|
vidstab -DUSE_OMP=NO
|
|
|
|
|
ffmpeg --extra-ldflags='-framework CoreText' --pkg-config-flags=--static --enable-nonfree --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-version3 --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-openssl --enable-lzma
|
|
|
|
|
#
|
|
|
|
|
# TODO: add these if possible (from brew) --enable-indev=qtkit --enable-securetransport --enable-chromaprint --enable-ffplay --enable-frei0r --enable-libbs2b --enable-libcaca --enable-libfdk-aac --enable-libgme --enable-libgsm --enable-librtmp --enable-librubberband --enable-libssh --enable-libtesseract --enable-libtwolame --enable-webp --enable-libzimg
|
|
|
|
|
#
|
|
|
|
|
# Possibly also: --enable-libzvbi
|
|
|
|
|
# I could not get libzvbi to build
|
|
|
|
|
#
|
|
|
|
|
# these require > 10.7:
|
|
|
|
|
# --enable-opencl # requires 10.8
|
|
|
|
|
# --enable-videotoolbox # requires 10.8
|
|
|
|
|
"
|
|
|
|
|
|
|
|
|
|
DIST_MAKE_ARGS="
|
|
|
|
|
expat DOCBOOK_TO_MAN=docbook2man
|
2017-10-12 08:32:18 +00:00
|
|
|
|
"
|
|
|
|
|
|
|
|
|
|
main() {
|
2017-10-22 22:35:56 +00:00
|
|
|
|
read_command_line "$@"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
setup
|
2017-10-12 21:31:23 +00:00
|
|
|
|
delete_outdated_dists
|
2017-10-12 08:32:18 +00:00
|
|
|
|
download_dists
|
|
|
|
|
build_dists
|
|
|
|
|
build_project
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
read_command_line() {
|
|
|
|
|
case "$1" in
|
|
|
|
|
--env)
|
|
|
|
|
build_env
|
|
|
|
|
exit 0
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-12 08:32:18 +00:00
|
|
|
|
setup() {
|
2017-10-22 22:35:56 +00:00
|
|
|
|
mkdir -p "$BUILD_ROOT/root/include"
|
|
|
|
|
[ -e "$BUILD_ROOT/root/inc" ] || ln -s "$BUILD_ROOT/root/include" "$BUILD_ROOT/root/inc"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-12 21:31:23 +00:00
|
|
|
|
DIST_NAMES=$( table_column 0 3 "$DISTS")
|
|
|
|
|
DIST_URLS=$( table_column 1 3 "$DISTS")
|
|
|
|
|
DIST_TARGETS=$(table_column 2 3 "$DISTS")
|
|
|
|
|
|
|
|
|
|
DISTS_NUM=$(table_rows "$DISTS")
|
|
|
|
|
|
|
|
|
|
NUM_CPUS=$(sysctl -n hw.ncpu)
|
|
|
|
|
|
|
|
|
|
CHECKOUT=$(find_checkout)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete_outdated_dists() {
|
2017-10-22 22:35:56 +00:00
|
|
|
|
[ ! -d "$BUILD_ROOT/downloads" ] && return 0
|
|
|
|
|
|
2017-10-12 21:31:23 +00:00
|
|
|
|
files=
|
2017-10-12 08:32:18 +00:00
|
|
|
|
i=0
|
2017-10-12 21:31:23 +00:00
|
|
|
|
for dist in $DIST_NAMES; do
|
|
|
|
|
dist_url=$(list_get $i $DIST_URLS)
|
2017-10-22 22:35:56 +00:00
|
|
|
|
dist_file="$BUILD_ROOT/downloads/$dist-${dist_url##*/}"
|
2017-10-12 21:31:23 +00:00
|
|
|
|
|
|
|
|
|
files="$files $dist_file"
|
|
|
|
|
|
2017-10-12 08:32:18 +00:00
|
|
|
|
i=$((i + 1))
|
|
|
|
|
done
|
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
OLDIFS=$IFS
|
|
|
|
|
IFS='
|
|
|
|
|
'; find "$BUILD_ROOT/downloads" -type f -maxdepth 1 -not -name '.*' | \
|
|
|
|
|
while read -r file; do
|
|
|
|
|
IFS=$OLDIFS
|
2017-10-12 21:31:23 +00:00
|
|
|
|
if ! list_contains "$file" $files; then
|
|
|
|
|
echo "\n[32mDeleting outdated dist: [1;34m$file[0m\n"
|
|
|
|
|
rm -f "$file"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
fi
|
|
|
|
|
done
|
2017-10-22 22:35:56 +00:00
|
|
|
|
IFS=$OLDIFS
|
2017-10-12 08:32:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
download_dists() {
|
2017-10-22 22:35:56 +00:00
|
|
|
|
mkdir -p "$BUILD_ROOT/downloads"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
|
|
|
|
i=0
|
2017-10-12 21:31:23 +00:00
|
|
|
|
while [ $i -lt $DISTS_NUM ]; do
|
|
|
|
|
dist_name=$(list_get $i $DIST_NAMES)
|
|
|
|
|
dist_url=$( list_get $i $DIST_URLS)
|
2017-10-22 22:35:56 +00:00
|
|
|
|
orig_dist_file="$BUILD_ROOT/downloads/${dist_url##*/}"
|
|
|
|
|
dist_file="$BUILD_ROOT/downloads/$dist_name-${dist_url##*/}"
|
|
|
|
|
dist_dir="$BUILD_ROOT/dists/$dist_name"
|
|
|
|
|
|
|
|
|
|
cd "$BUILD_ROOT/downloads"
|
2017-10-12 21:31:23 +00:00
|
|
|
|
|
|
|
|
|
if [ ! -e "$dist_file" ]; then
|
|
|
|
|
echo "\n[32mFetching [1;35m$dist_name[0m: [1;34m$dist_url[0m\n"
|
|
|
|
|
curl -LO "$dist_url"
|
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
mv -f "$orig_dist_file" "$dist_file"
|
|
|
|
|
|
2017-10-12 21:31:23 +00:00
|
|
|
|
# force rebuild for new dist file
|
|
|
|
|
rm -f "$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
|
2017-10-22 22:35:56 +00:00
|
|
|
|
rm -rf "$dist_dir"
|
2017-10-12 21:31:23 +00:00
|
|
|
|
fi
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-12 21:31:23 +00:00
|
|
|
|
if [ ! -d "$dist_dir" ]; then
|
|
|
|
|
mkdir -p "$dist_dir"
|
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
tmp_dir="$BUILD_ROOT/dists/tmp"
|
2017-10-12 21:31:23 +00:00
|
|
|
|
mkdir -p "$tmp_dir"
|
|
|
|
|
cd "$tmp_dir"
|
|
|
|
|
|
|
|
|
|
case "$dist_file" in
|
2017-10-22 22:35:56 +00:00
|
|
|
|
*.tar)
|
|
|
|
|
tar xf "$dist_file"
|
|
|
|
|
;;
|
|
|
|
|
*.tar.gz|*.tgz)
|
2017-10-12 21:31:23 +00:00
|
|
|
|
tar zxf "$dist_file"
|
|
|
|
|
;;
|
|
|
|
|
*.tar.xz)
|
|
|
|
|
xzcat "$dist_file" | tar xf -
|
|
|
|
|
;;
|
|
|
|
|
*.tar.bz2)
|
|
|
|
|
bzcat "$dist_file" | tar xf -
|
|
|
|
|
;;
|
|
|
|
|
*.zip)
|
|
|
|
|
unzip -q "$dist_file"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
mv */* "$dist_dir"
|
|
|
|
|
rm -rf "$tmp_dir"
|
2017-10-22 22:35:56 +00:00
|
|
|
|
|
|
|
|
|
# force rebuild if dist dir was deleted
|
|
|
|
|
rm -f "$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
i=$((i + 1))
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
build_dists() {
|
|
|
|
|
i=0
|
2017-10-22 22:35:56 +00:00
|
|
|
|
while [ $i -lt $DISTS_NUM ]; do
|
|
|
|
|
install_artifact="$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
if [ ! -e "$install_artifact" ]; then
|
|
|
|
|
build_dist $(list_get $i $DIST_NAMES)
|
|
|
|
|
fi
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
i=$((i + 1))
|
|
|
|
|
done
|
|
|
|
|
}
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
build_dist() {
|
|
|
|
|
dist=$1
|
|
|
|
|
[ -n "$1" ] || error 'build_dist: dist name required'
|
|
|
|
|
shift
|
|
|
|
|
extra_dist_args=$@
|
2017-10-12 21:31:23 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
cd "$BUILD_ROOT/dists/$dist"
|
2017-10-12 21:31:23 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
echo "\n[32mBuilding [1;35m$dist[0m\n"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
ORIG_LDFLAGS=$LDFLAGS
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
# have to make sure C++ flags are passed when linking, but only for C++ and **NOT** C
|
|
|
|
|
# this fails if there are any .c files in the project
|
|
|
|
|
if [ "$(find . -name '*.cpp' -o -name '*.cc' | wc -l)" -ne 0 -a "$(find . -name '*.c' | wc -l)" -eq 0 ]; then
|
|
|
|
|
export LDFLAGS="$CXXFLAGS $LDFLAGS"
|
|
|
|
|
fi
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
dist_patch "$dist"
|
|
|
|
|
dist_pre_build "$dist"
|
|
|
|
|
|
|
|
|
|
if [ -e configure -o -e configure.ac -o -e configure.in -o -e Makefile.am ]; then
|
|
|
|
|
if [ ! -e configure ]; then
|
|
|
|
|
if [ -e autogen.sh ]; then
|
|
|
|
|
sh autogen.sh
|
|
|
|
|
elif [ -e buildconf.sh ]; then
|
|
|
|
|
sh buildconf.sh
|
|
|
|
|
else
|
|
|
|
|
if [ -d m4 ]; then
|
|
|
|
|
aclocal -I m4
|
|
|
|
|
else
|
|
|
|
|
aclocal
|
|
|
|
|
fi
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
if command -v glibtoolize >/dev/null; then
|
|
|
|
|
glibtoolize
|
|
|
|
|
else
|
|
|
|
|
libtoolize
|
|
|
|
|
fi
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
autoheader || :
|
|
|
|
|
autoconf
|
|
|
|
|
[ -e Makefile.am ] && automake --add-missing
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
eval "set -- $(dist_args "$dist" autoconf) $extra_dist_args"
|
|
|
|
|
./configure "$@"
|
|
|
|
|
eval "set -- $(dist_make_args "$dist")"
|
|
|
|
|
make -j$NUM_CPUS "$@"
|
|
|
|
|
make install prefix=$BUILD_ROOT/root
|
|
|
|
|
elif [ -e CMakeLists.txt ]; then
|
|
|
|
|
mkdir -p build
|
|
|
|
|
cd build
|
|
|
|
|
|
|
|
|
|
eval "set -- $(dist_args "$dist" cmake) $extra_dist_args"
|
|
|
|
|
cmake .. "$@"
|
|
|
|
|
eval "set -- $(dist_make_args "$dist")"
|
|
|
|
|
make -j$NUM_CPUS "$@"
|
|
|
|
|
rm -rf destdir
|
|
|
|
|
mkdir destdir
|
|
|
|
|
make install DESTDIR="$PWD/destdir"
|
|
|
|
|
|
|
|
|
|
cd "destdir/$BUILD_ROOT/root"
|
|
|
|
|
OLDPWD=$PWD
|
|
|
|
|
find . ! -type d | (cd "$BUILD_ROOT/root";IFS='
|
2017-10-12 08:32:18 +00:00
|
|
|
|
'; while read f; do
|
2017-10-22 22:35:56 +00:00
|
|
|
|
mkdir -p "${f%/*}"
|
|
|
|
|
cp -a "$OLDPWD/$f" "$f"
|
|
|
|
|
done)
|
|
|
|
|
elif [ -e Makefile.PL ]; then
|
|
|
|
|
eval "set -- $(dist_args "$dist" perl) $extra_dist_args"
|
|
|
|
|
perl Makefile.PL "$@"
|
|
|
|
|
eval "set -- $(dist_make_args "$dist")"
|
|
|
|
|
make -j$NUM_CPUS "$@"
|
|
|
|
|
make install
|
|
|
|
|
elif [ -e Makefile ]; then
|
|
|
|
|
eval "set -- $(dist_make_args "$dist")"
|
|
|
|
|
make -j$NUM_CPUS "$@"
|
|
|
|
|
make install PREFIX="$BUILD_ROOT/root" INSTALL_ROOT="$BUILD_ROOT/root"
|
|
|
|
|
else
|
|
|
|
|
error "don't know how to build [1;35m$dist[0m"
|
|
|
|
|
fi
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
dist_post_build "$dist"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
export LDFLAGS=$ORIG_LDFLAGS
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
echo "\n[32mDone!!![0m\n"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list_get() {
|
|
|
|
|
i=0
|
|
|
|
|
n=${1:=0}
|
|
|
|
|
shift
|
|
|
|
|
|
|
|
|
|
for item; do
|
|
|
|
|
if [ $i -eq $n ]; then
|
|
|
|
|
echo "$item"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
i=$((i + 1))
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dist_args() {
|
|
|
|
|
dist=$1
|
2017-10-22 22:35:56 +00:00
|
|
|
|
[ -n "$dist" ] || error 'dist_args: dist name required'
|
2017-10-12 08:32:18 +00:00
|
|
|
|
buildsys=$2
|
2017-10-22 22:35:56 +00:00
|
|
|
|
case "$buildsys" in
|
|
|
|
|
autoconf|cmake|perl)
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
error "dist_args: buildsystem type required, must be 'autoconf', 'cmake' or 'perl'"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
2017-10-12 08:32:18 +00:00
|
|
|
|
|
|
|
|
|
args=$(table_line "$dist" "$DIST_OVERRIDES")
|
|
|
|
|
|
|
|
|
|
if [ -z "$args" ]; then
|
|
|
|
|
case "$buildsys" in
|
|
|
|
|
autoconf)
|
|
|
|
|
args="$CONFIGURE_ARGS $(table_line "$dist" "$DIST_ARGS")"
|
|
|
|
|
;;
|
|
|
|
|
cmake)
|
|
|
|
|
args="$CMAKE_ARGS $(table_line "$dist" "$DIST_ARGS")"
|
|
|
|
|
;;
|
2017-10-22 22:35:56 +00:00
|
|
|
|
perl)
|
|
|
|
|
args="$(table_line "$dist" "$DIST_ARGS")"
|
|
|
|
|
;;
|
2017-10-12 08:32:18 +00:00
|
|
|
|
esac
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "$args"
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
dist_make_args() {
|
|
|
|
|
dist=$1
|
|
|
|
|
[ -n "$dist" ] || error 'dist_make_args: dist name required'
|
|
|
|
|
|
|
|
|
|
echo "$(table_line "$dist" "$DIST_MAKE_ARGS")"
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dist_patch() {
|
|
|
|
|
[ -n "$1" ] || error 'dist_patch: dist name required'
|
|
|
|
|
|
|
|
|
|
_patch_url="$(table_line "$1" "$DIST_PATCHES")"
|
|
|
|
|
|
|
|
|
|
[ -n "$_patch_url" ] || return 0
|
|
|
|
|
|
|
|
|
|
echo "\n[32mApplying patch [1;34m$_patch_url[0m to [1;35m$1[0m\n"
|
|
|
|
|
|
|
|
|
|
curl -LO "$_patch_url"
|
|
|
|
|
patch -p1 < "${_patch_url##*/}"
|
|
|
|
|
|
|
|
|
|
echo "\n[32mDone!!![0m\n"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dist_pre_build() {
|
|
|
|
|
[ -n "$1" ] || error 'dist_pre_build: dist name required'
|
|
|
|
|
|
|
|
|
|
_cmd=$(table_line "$1" "$DIST_PRE_BUILD")
|
|
|
|
|
[ -n "$_cmd" ] || return 0
|
|
|
|
|
|
|
|
|
|
echo "\n[32mRunning pre-build for: [1;35m$dist[0m:\n$_cmd\n"
|
|
|
|
|
|
|
|
|
|
eval "$_cmd"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dist_post_build() {
|
|
|
|
|
[ -n "$1" ] || error 'dist_post_build: dist name required'
|
|
|
|
|
|
|
|
|
|
_cmd=$(table_line "$1" "$DIST_POST_BUILD")
|
|
|
|
|
[ -n "$_cmd" ] || return 0
|
|
|
|
|
|
|
|
|
|
if [ -z "$IN_DIST_POST_BUILD" ]; then
|
|
|
|
|
IN_DIST_POST_BUILD=1
|
|
|
|
|
|
|
|
|
|
echo "\n[32mRunning post-build for: [1;35m$dist[0m:\n$_cmd\n"
|
|
|
|
|
|
|
|
|
|
eval "$_cmd"
|
|
|
|
|
|
|
|
|
|
IN_DIST_POST_BUILD=
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-12 08:32:18 +00:00
|
|
|
|
table_line() {
|
|
|
|
|
name=$1
|
|
|
|
|
[ -n "$name" ] || error 'item name required'
|
|
|
|
|
table=$2
|
|
|
|
|
[ -n "$table" ] || error 'table string required'
|
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
table=$(echo "$table" | grep -Ev '^ *#')
|
|
|
|
|
|
2017-10-12 08:32:18 +00:00
|
|
|
|
OLDIFS=$IFS
|
|
|
|
|
IFS='
|
|
|
|
|
'
|
|
|
|
|
for line in $table; do
|
|
|
|
|
IFS=$OLDIFS
|
|
|
|
|
set -- $line
|
|
|
|
|
if [ "$1" = "$name" ]; then
|
|
|
|
|
shift
|
|
|
|
|
echo "$@"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
IFS=$OLDIFS
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
find_checkout() {
|
|
|
|
|
(
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
while [ "$PWD" != / ]; do
|
|
|
|
|
if [ -e src/version.h.in ]; then
|
|
|
|
|
echo "$PWD"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
done
|
|
|
|
|
exit 1
|
|
|
|
|
) || error 'cannot find project checkout'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error() {
|
2017-10-22 22:35:56 +00:00
|
|
|
|
printf >&2 '\n[31mERROR[0m: %s\n\n' "$1"
|
2017-10-12 08:32:18 +00:00
|
|
|
|
[ -z "$2" ] && exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
build_project() {
|
|
|
|
|
echo "\n[32mBuilding project: [1;34m$CHECKOUT[0m\n"
|
|
|
|
|
|
|
|
|
|
mkdir -p "$BUILD_ROOT/project"
|
|
|
|
|
cd "$BUILD_ROOT/project"
|
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
cmake "$CHECKOUT" -DCMAKE_PREFIX_PATH="$BUILD_ROOT/root" -DCMAKE_BUILD_TYPE=Release -DSFML_STATIC_LIBRARIES=TRUE -DENABLE_FFMPEG=ON -DFFMPEG_STATIC=TRUE
|
2017-10-12 08:32:18 +00:00
|
|
|
|
make -j$NUM_CPUS
|
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
codesign -s "Developer ID Application" --deep ./visualboyadvance-m.app || :
|
|
|
|
|
|
|
|
|
|
rm -f ./visualboyadvance-m-Mac.zip
|
|
|
|
|
zip -9r ./visualboyadvance-m-Mac.zip ./visualboyadvance-m.app
|
|
|
|
|
|
2017-10-12 08:32:18 +00:00
|
|
|
|
echo "\n[32mBuild Successful!!![0m\n\nBuild results can be found in: [1;34m$BUILD_ROOT/project[0m\n"
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-12 21:31:23 +00:00
|
|
|
|
table_column() {
|
|
|
|
|
col=$1
|
|
|
|
|
[ -n "$col" ] || error 'table_column: column required'
|
|
|
|
|
row_size=$2
|
|
|
|
|
[ -n "$row_size" ] || error 'table_column: row_size required'
|
|
|
|
|
table=$3
|
|
|
|
|
[ -n "$table" ] || error 'table_column: table required'
|
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
table=$(echo "$table" | grep -Ev '^ *#')
|
|
|
|
|
|
2017-10-12 21:31:23 +00:00
|
|
|
|
i=0
|
|
|
|
|
res=
|
|
|
|
|
for item in $table; do
|
|
|
|
|
if [ $((i % row_size)) -eq "$col" ]; then
|
|
|
|
|
res="$res $item"
|
|
|
|
|
fi
|
|
|
|
|
i=$((i + 1))
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo $res
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
table_rows() {
|
|
|
|
|
table=$1
|
|
|
|
|
[ -n "$table" ] || error 'table_rows: table required'
|
|
|
|
|
|
2017-10-22 22:35:56 +00:00
|
|
|
|
table=$(echo "$table" | grep -Ev '^ *#')
|
|
|
|
|
|
2017-10-12 21:31:23 +00:00
|
|
|
|
i=0
|
|
|
|
|
OLDIFS=$IFS
|
|
|
|
|
IFS='
|
|
|
|
|
'; for line in $table; do
|
|
|
|
|
i=$((i + 1))
|
|
|
|
|
done
|
|
|
|
|
IFS=$OLDIFS
|
|
|
|
|
|
|
|
|
|
echo $i
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list_contains() {
|
|
|
|
|
_item=$1
|
|
|
|
|
[ -n "$_item" ] || error 'list_contains: item required'
|
|
|
|
|
shift
|
|
|
|
|
|
|
|
|
|
for _pos; do
|
|
|
|
|
[ "$_item" = "$_pos" ] && return 0
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-12 08:32:18 +00:00
|
|
|
|
main "$@"
|