Skip to content

Instantly share code, notes, and snippets.

@svagionitis
Last active September 28, 2015 08:01
Show Gist options
  • Save svagionitis/8905a554834af4355462 to your computer and use it in GitHub Desktop.
Save svagionitis/8905a554834af4355462 to your computer and use it in GitHub Desktop.
Build gstreamer and plugins from the git repositories specifying the branch
#!/bin/sh -ex
mkdir -p sysroot
PREFIX_DIR=$(readlink -e sysroot)
mkdir -p $PREFIX_DIR/include
INCLUDE_DIR=$(readlink -e $PREFIX_DIR/include/)
mkdir -p $PREFIX_DIR/lib
LIB_DIR=$(readlink -e $PREFIX_DIR/lib/)
mkdir -p $LIB_DIR/pkgconfig
PKG_CONFIG_PATH=$(readlink -e $LIB_DIR/pkgconfig/)
mkdir -p manifest
MF_DIR=$(readlink -e manifest)
mkdir -p $PREFIX_DIR/bin
BIN_DIR=$(readlink -e $PREFIX_DIR/bin/)
mkdir -p $PREFIX_DIR/share
DATA_DIR=$(readlink -e $PREFIX_DIR/share/)
mkdir -p $PREFIX_DIR/etc
CONFIG_DIR=$(readlink -e $PREFIX_DIR/etc/)
mkdir -p src
SOURCE_DIR=$(readlink -e src)
mkdir -p build
BUILD_DIR=$(readlink -e build)
COMMON_ARGS="--prefix=${PREFIX_DIR} --enable-shared --disable-static --host=x86_64-linux-gnu"
MAKE="make -j16"
modules="\
gstreamer \
gst_plugins_base \
gst_libav \
gst_plugins_good \
gst_plugins_bad"
export PKG_CONFIG_PATH
CFLAGS="-O0 -g -pthread"
LD=gold
export CFLAGS
export LD
# run autotools configure out of tree
prep() {
local S
local B
S=$1
B=$2
cd $S
libtoolize
if [ ! -e configure ]; then
if [ -e bootstrap.sh ]; then
./bootstrap.sh
else
NOCONFIGURE=1 ./autogen.sh
fi
fi
mkdir -p $B
cd ${B}
echo ${EXTRA_CONFIGURE_ARGS}
${S}/configure ${COMMON_ARGS} ${EXTRA_CONFIGURE_ARGS}
EXTRA_CONFIGURE_ARGS=""
}
build_git_autoconf_module() {
local module
local repo
local branch
local S
local B
module=$1
repo=$2
branch=$3
S=${SOURCE_DIR}/${module}
B=${BUILD_DIR}/${module}
if [ ! -d $S ]; then
cd ${SOURCE_DIR}
# Swallow clone
#git clone --depth 1 ${repo} $S
git clone ${repo} $S
(cd $S
local current_branch
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ $current_branch != $branch ]; then
git checkout -b $branch origin/$branch
fi
# not everybody needs this, but it doesn't hurt
git submodule init
git submodule update
)
fi
if [ ! -e $B/Makefile ]; then
prep $S $B
fi
cd $B
$MAKE
make install
}
build_gst() {
build_git_autoconf_module $1 "git://anongit.freedesktop.org/gstreamer/$1" "1.4"
}
gstreamer() {
build_gst "gstreamer"
}
gst_plugins_base() {
build_gst "gst-plugins-base"
}
gst_plugins_good() {
EXTRA_CONFIGURE_ARGS="--enable-soup"
build_gst "gst-plugins-good"
}
gst_plugins_bad() {
EXTRA_CONFIGURE_ARGS=" --disable-x11 --disable-sdl --disable-gl --disable-sdltest --disable-examples"
build_gst "gst-plugins-bad"
}
gst_libav() {
build_gst "gst-libav"
}
ffmpeg() {
local oldargs
oldargs=$COMMON_ARGS
COMMON_ARGS="--prefix=${PREFIX_DIR}"
build_git_autoconf_module "ffmpeg" "git://source.ffmpeg.org/ffmpeg.git" "master"
COMMON_ARGS=$oldargs
}
libsoup() {
local oldargs
oldargs=$COMMON_ARGS
COMMON_ARGS="--prefix=${PREFIX_DIR}"
EXTRA_CONFIGURE_ARGS="--without-gnome --disable-gtk-doc --disable-glibtest"
build_git_autoconf_module "libsoup" "git://git.gnome.org/libsoup" "libsoup-2.4"
COMMON_ARGS=$oldargs
}
help() {
echo "the automagic gstreamer stack builder"
echo
echo "build all: <$0>"
echo
echo "build a module: <$0> <module>"
echo
echo "where module is one of:"
for m in $modules; do
echo $m
done
}
check_and_build() {
local module
local manifest
module=$1
manifest=$MF_DIR/$module
if [ ! -e $manifest ]; then
echo building $module
$module
touch $manifest
else
echo not touching $module
fi
}
if [ "$#" -eq 0 ]; then
for m in $modules; do
echo checking $m
check_and_build $m
done
else
$1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment