GStreamerBuildWithMinGW

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
What is the first name of GStreamer hacker Schleef?

The following build script works for me. It assumes you have a working msys/mingw install. Read comments for additional depends.

# builds gstreamer, the base, good & ffmpeg plugin packs, and all the runtime deps *I* use, with MinGW/MSYS
# everything's targeted at /build, so make sure you don't have other stuff there in advance
# takes about 2h on a reasonably high-end box.


#prerequisites:
# need pkg-config in /mingw - http://www.gimp.org/~tml/gimp/win32/pkg-config-0.20.zip
# need glib in /mingw - http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.14/glib-2.14.5.zip
# need intl in /mingw - http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime-0.17-1.zip
# need one more intl in /mingw - http://kent.dl.sourceforge.net/sourceforge/gnuwin32/libintl-0.14.4-bin.zip
# need iconv in /mingw - http://kent.dl.sourceforge.net/sourceforge/gnuwin32/libiconv-1.9.2-1-bin.zip
# need bison in /mingw - http://kent.dl.sourceforge.net/sourceforge/gnuwin32/bison-2.1-bin.zip
# need flex in /mingw - http://kent.dl.sourceforge.net/sourceforge/gnuwin32/flex-2.5.4a-1-bin.zip
# need bash 3 for msys, in / - http://kent.dl.sourceforge.net/sourceforge/mingw/bash-3.1-MSYS-1.0.11-1.tar.bz2
# need all the source tarballs for deps. base names listed at end of the script


# Want to edit this thing while it's running, and timing's handy as well
if [ -z "`echo $0 | grep tmp.bld.sh`" ]
then
  cp -v $0 "`dirname $0`/tmp.bld.sh"
  exec /bin/sh -c "time \"`dirname $0`/tmp.bld.sh\""
fi

basedir="`pwd`"

# Vista UAC heuristics is the worst piece of crap ever. "it's named install so it MUST run as admin"
[ -f /bin/ins.exe ] || cp /bin/install.exe /bin/ins.exe

export INSTALL="/bin/ins"


# Everything assumes you're installing to /build
# force-including one header just for the fun of it.
export CFLAGS="-I/build/include -I/mingw/include -mms-bitfields -include mingwstuff.h"
export PKG_CONFIG_PATH=/build/lib/pkgconfig
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-Wl,--enable-runtime-pseudo-reloc -L/build/lib -L/mingw/lib"
export PATH="$PATH:/build/bin"



# mingw lacks some headers.... Probably a correct way of getting them, but this is easier.
if [ ! -f /mingw/include/alloca.h ]
then
  echo '#ifndef allocaH' > /mingw/include/alloca.h
  echo '#define allocaH' >> /mingw/include/alloca.h
  echo '#include <stdlib.h>' >> /mingw/include/alloca.h
  echo '#ifndef alloca' >> /mingw/include/alloca.h
  echo 'void * alloca(int);' >> /mingw/include/alloca.h
  echo '#endif' >> /mingw/include/alloca.h
  echo '#endif' >> /mingw/include/alloca.h
fi

echo '#ifndef mingwstuffH' > /mingw/include/mingwstuff.h
echo '#define mingwstuffH' >> /mingw/include/mingwstuff.h
echo '#define HAVE_INLINE 1' >> /mingw/include/mingwstuff.h
echo '#define HAVE_ATEXIT 1' >> /mingw/include/mingwstuff.h
echo '#define SIZE_T_MAX 4294967295' >> /mingw/include/mingwstuff.h
echo '#endif' >> /mingw/include/mingwstuff.h


# print something, do it, and whine if it broke
check() {
  echo $*
  $*
  if [ $? -gt 0 ]
  then
    echo "$* failed in `pwd`"
    exit 1
  fi
}

# find the tarball, unpack it and cd into the dir
prebuild() {
  cd "$basedir"
  fname=`find . -maxdepth 1 -type f -iname $1\* | sed 's,^./,,' | grep -e tar.bz2 -e tar.gz -e tbz2 -e tgz`
  if [ ! -f "$fname" ]
  then
    echo "Couldn't find $1 sources"
    exit 1
  fi
  libname="`echo $fname | sed -e 's,[.]tar.bz2$,,' -e 's,[.]tar.gz$,,' -e 's,[.]tgz$,,' -e 's,[.]tbz2$,,'`"
  if [ -n "`echo $fname | grep -e 'bz2$'`" ]
  then
    tarflags="j"
  else
    tarflags="z"
  fi
  if [ -d "$libname" ]
  then
    echo "$libname exists. rm it."
    exit 1
  fi
  check tar ${tarflags}xf $fname 
  check cd $libname
}

# enable shared/static if supported
doconf() {
  if [ -n "`./configure --help | grep enable-shared`" ]
  then
    f1="--enable-shared"
  fi
  if [ -n "`./configure --help | grep enable-static`" ]
  then
    f2="--enable-static"
  fi
  check ./configure --prefix=/build $f1 $f2 $*
}

# just call the passed patchfunction if it's not --
dopatch() {
  if [ -n "$1" ]
  then
    $1
    if [ $? -gt 0 ]
    then
      echo "patches failed: $1"
      exit 1
    fi
  fi
}

# 
dobuild() {
  check make
}

#
doinstall() {
  check make install
}


# condbuild file-to-test-for tarball-prefix patchfunction configure-options
# build the specified lib unless the specified testfile exists in /build/lib
condbuild() {
  testfile="$1"
  lib="$2"
  patchfunc="$3"
  shift
  shift
  shift
  if [ ! -f "/build/lib/$testfile" ]
  then
    echo -ne "\033];$lib\007"
    prebuild $lib
    doconf $*
    [ "$patchfunc" = "--" ] || dopatch "$patchfunc"
    dobuild
    doinstall
  fi
}



#big ugly hack, the sed script in this file doesn't work with mingw sed so I hardcoded the versions
libiconvpatch() {
  check cp -v $basedir/libiconv.windows.windres-options windows/windres-options
}



# gettext wants to link with atexit.c, for some reason it thinks we're on Sun and have on_exit
gettextpatch() {
  cat gettext-tools/gnulib-lib/Makefile | sed -r 's,atexit[.][col]+,,' > gettext-tools/gnulib-lib/Makefile.tmp && mv gettext-tools/gnulib-lib/Makefile.tmp gettext-tools/gnulib-lib/Makefile
}

# vorbis should preferrably link to ogg
vorbispatch() {
  cat lib/Makefile | 
  sed 's,libvorbisfile_la_LDFLAGS =,libvorbisfile_la_LDFLAGS = -logg ,' | 
  sed 's,libvorbisenc_la_LDFLAGS =,libvorbisenc_la_LDFLAGS = -logg ,' > lib/Makefile.tmp && 
  mv lib/Makefile.tmp lib/Makefile
}


# fixing some obvious bugs in liboilcpu, such as e.g. a bare #elif (do they even build before release?)
# disabling the unguarded sig* use in liboilcpu
# disabling SSE and turning off the sse stack alignment wrapper which is broken
# disabling the jpeg test, it's broken
# most of these have been filed with liboil's bugtracker
oilpatch() {
  cat liboil/sse/sse_wrapper.h | 
  sed 's,USE_SSE_WRAPPER,USE_SSE_WRAPPER_NOT,g' > liboil/sse/sse_wrapper.h.tmp &&
  mv liboil/sse/sse_wrapper.h.tmp liboil/sse/sse_wrapper.h
  cat liboil/liboilcpu.c | 
  sed -r -e 's,(sigset_t set;),//\1,' -e 's,(sigemptyset .&set.;),//\1,' \
        -e 's,(sigaddset .&set. SIGILL.;),//\1,' \
        -e 's,(sigprocmask .SIG_UNBLOCK. &set. NULL.;),//\1,' \
        -e 's,^#elif$,#else,' \
        -e 's,return _oil_ticks_per_second,return 1,' \
        -e '/which might cause problems".*/n;s/#if 0/#if 1/' > liboil/liboilcpu.c.tmp && mv liboil/liboilcpu.c.tmp liboil/liboilcpu.c
  cat examples/Makefile | sed 's,SUBDIRS = jpeg,SUBDIRS = ,' > examples/Makefile.tmp && mv examples/Makefile.tmp examples/Makefile
}


# sdp requires getaddrinfo/freeaddrinfo which aren't around in mingw. 
gstbasepatch() {
  cat gst-libs/gst/Makefile | grep -v 'sdp \\' > gst-libs/gst/Makefile.tmp && mv gst-libs/gst/Makefile.tmp gst-libs/gst/Makefile
}

# disable mmx, doesn't build. I'll live with the C implementation.
# define random/srandom as rand/srand, and turn off the "(s)rand is forbidden" stuff
gstffmpegpatch() {
  for f in configure configure.ac
  do
    cat gst-libs/ext/ffmpeg/$f | sed 's,HAVE_MMX=yes,HAVE_MMX=no,g' > gst-libs/ext/ffmpeg/$f.tmp && mv gst-libs/ext/ffmpeg/$f.tmp gst-libs/ext/ffmpeg/$f
  done
  cat gst-libs/ext/ffmpeg/libavutil/internal.h | sed -e 's,#define rand ,#define random rand //#define rand ,g' -e 's,#define srand ,#define srandom srand//#define srand ,g' > gst-libs/ext/ffmpeg/libavutil/internal.h.tmp && mv gst-libs/ext/ffmpeg/libavutil/internal.h.tmp gst-libs/ext/ffmpeg/libavutil/internal.h
}


condbuild libz.a zlib
condbuild libpng.a libpng
condbuild libiconv.a libiconv libiconvpatch
condbuild libxml2.a libxml2 -- --without-ftp --without-http --without-python 
condbuild libgettextpo.a gettext gettextpatch --enable-threads=win32 --enable-nls --disable-java --disable-native-java --disable-rpath --enable-relocatable  --disable-openmp --with-included-glib --with-included-gettext --with-included-libcroco --without-emacs 
condbuild libglib-2.0.la glib -- --enable-debug=no
condbuild libogg.a libogg
condbuild libvorbis.a libvorbis vorbispatch
condbuild libtheora.a libtheora -- --disable-examples
condbuild libFLAC.a flac
condbuild libspeex.a speex
condbuild libao.a libao
condbuild liboil-0.3.a liboil oilpatch
condbuild libgstreamer-0.10.a gstreamer -- --disable-rpath --disable-nls --enable-registry --enable-enumtypes --disable-net --disable-debug --disable-examples --enable-tests --enable-failing-tests --enable-largefile
condbuild libgstfft-0.10.a gst-plugins-base gstbasepatch --disable-rpath --disable-nls --disable-examples --disable-x --disable-xvideo --disable-xshm --disable-gst_v4l --disable-alsa --disable-gnome_vfs --disable-libvisual --disable-pango --disable-freetypetest --disable-cdparanoia
condbuild libgstvideo-0.10.a gst-plugins-good -- --disable-rpath --disable-nls --disable-examples --disable-gconftool --disable-oss --disable-sunaudio --disable-osx_audio --disable-osx_video --disable-gst_v4l2 --disable-x --disable-xshm --disable-xvideo --disable-aalib --disable-aalibtest --disable-cairo --disable-esd --disable-esdtest --disable-gconf --disable-gdk_pixbuf --disable-libcaca --disable-dv1394 --disable-shout2 --disable-shout2test
condbuild libgstfft-0.10.a gst-ffmpeg gstffmpegpatch

And here's the libiconv.windows.windres-options file

escape=
if test "$1" = "--escape"; then
  escape=yes
  shift
fi

{
  echo "-DPACKAGE_VERSION_STRING=\"1.12\""
  echo "-DPACKAGE_VERSION_MAJOR=1"
  echo "-DPACKAGE_VERSION_MINOR=12"
  echo "-DPACKAGE_VERSION_SUBMINOR=0"
} |
{
  if test -n "$escape"; then
    sed -e 's,\(["\\]\),\\\1,g'
  else
    cat
  fi
}