#!/bin/bash
#anri4 support binary build script
#tested on g4 powerbook under osx 10.4
#
#requirements:
#mp4box, mplayer/mencoder, wget, and x264 build without extra programs
#afconvert source should already be present on your system
#ffmpeg requires svn and gnu make 3.81 or newer (as make)
#sanitize local environment, you might need to change this
mkdir -p bin log src zip
ln -f "$(which svn)" bin/svn
ln -f "$(which make)" bin/make
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS DYLD_LIBRARY_PATH PKG_CONFIG_PATH
export PATH="$PWD/bin:/bin:/sbin:/usr/bin:/usr/sbin"
hash -r
#the patch stops afconvert from exiting with an error when failing to shorten
#the length of a sound file, but i might actually need to fix the bug
#rather than just comment it out. only testing will tell...
build-afconvert () {
local dir=AudioFileTools
local fulldir=/Developer/Examples/CoreAudio/Services/$dir
if [ ! -e $fulldir ]; then
echo "afconvert source not found, cannot build"
return
fi
rm -rf src/$dir bin/afconvert
cp -R $fulldir src/$dir
cd src
patch -p0 <<'END_OF_PATCH'
diff -Nru AudioFileTools/Utility/CAAudioFileConverter.cpp AudioFileTools-patched/Utility/CAAudioFileConverter.cpp
--- AudioFileTools/Utility/CAAudioFileConverter.cpp 2008-11-06 23:49:03.000000000 -0500
+++ AudioFileTools-patched/Utility/CAAudioFileConverter.cpp 2008-11-06 23:50:22.000000000 -0500
@@ -372,7 +372,7 @@
break;
}
- if (decoding) {
+ if (0) {
// fix up the destination file's length if necessary and possible
SInt64 nframes = mSrcFile.GetNumberFrames();
if (nframes != 0) {
END_OF_PATCH
xcodebuild -project $dir/$dir.xcode -target afconvert
ln $dir/build/afconvert ../bin/afconvert
cd ..
}
#if you see a complaint about vm_allocate failing
#upgrade built-in make (gnu make 3.80) to 3.81 or newer
#remember to define it (and svn) above if it isn't in the path
build-ffmpeg () {
local ffmpeg=ffmpeg-r15761
local url=svn://svn.mplayerhq.hu/ffmpeg/trunk
rm -rf src/ffmpeg bin/ffmpeg
cd src
if [ -e ../zip/$ffmpeg.tar.bz2 ]; then
tar -xjf ../zip/$ffmpeg.tar.bz2
else
svn export -r 15761 $url ffmpeg
tar -cf ../zip/$ffmpeg.tar ffmpeg
bzip2 ../zip/$ffmpeg.tar
fi
cd ffmpeg
./configure
make
ln ffmpeg ../../bin/ffmpeg
cd ../..
}
build-mencoder () {
echo "mencoder is built by mplayer, so use that target instead"
}
#-force_cpusubtype_ALL is listed as darwin only, so a linux build might need to change this
build-mplayer () {
local mplayer=MPlayer-1.0rc2
local url=http://www11.mplayerhq.hu/MPlayer/releases/
rm -rf src/$mplayer bin/mplayer bin/mencoder
if [ ! -e zip/$mplayer.tar.bz2 ]; then
curl $url/$mplayer.tar.bz2 -o zip/$mplayer.tar.bz2
fi
cd src
tar -xjf ../zip/$mplayer.tar.bz2
cd $mplayer
CFLAGS=-force_cpusubtype_ALL ./configure --enable-largefiles --disable-freetype --disable-fontconfig --disable-gl --disable-openal --disable-x11
make
ln mplayer ../../bin/mplayer
ln mencoder ../../bin/mencoder
cd ../..
}
#the -soname option to the dynamic lib build command is invalid on osx,
#and we only want to use the static lib anyway, so the patch just comments it out,
#makes mp4box link against the static lib, and fixes a namespace collision.
build-mp4box () {
local gpac=gpac-2008-11-01
local url=-d:pserver:anonymous:@gpac.cvs.sourceforge.net:/cvsroot/gpac
rm -rf src/gpac bin/mp4box
cd src
if [ -e ../zip/$gpac.tar.bz2 ]; then
tar -xjf ../zip/$gpac.tar.bz2
else
cvs $url login
cvs -z3 $url export -D 2008-11-01 gpac
tar -cf ../zip/$gpac.tar gpac
bzip2 ../zip/$gpac.tar
fi
patch -p0 <<'END_OF_PATCH'
diff -Nru gpac/applications/mp4box/Makefile gpac-patched/applications/mp4box/Makefile
--- gpac/applications/mp4box/Makefile 2008-10-06 05:41:13.000000000 -0400
+++ gpac-patched/applications/mp4box/Makefile 2008-11-02 23:25:41.000000000 -0500
@@ -35,8 +35,8 @@
else
EXT=
PROG=MP4Box
-#LINKFLAGS+=-lgpac_static $(EXTRALIBS) $(GPAC_SH_FLAGS) -lz
-LINKFLAGS+=-lgpac -lz $(OGL_LIBS)
+LINKFLAGS+=-lgpac_static $(EXTRALIBS) $(GPAC_SH_FLAGS) -lz
+#LINKFLAGS+=-lgpac -lz $(OGL_LIBS)
endif
diff -Nru gpac/src/Makefile gpac-patched/src/Makefile
--- gpac/src/Makefile 2008-10-06 08:58:56.000000000 -0400
+++ gpac-patched/src/Makefile 2008-11-02 23:27:29.000000000 -0500
@@ -206,7 +206,7 @@
$(LIB): $(LIBGPAC_UTILS) $(LIBGPAC_IETF) $(LIBGPAC_BIFS) $(LIBGPAC_ODF) $(LIBGPAC_LASER) $(LIBGPAC_ISOM) $(LIBGPAC_SCENEMANAGER) $(LIBGPAC_TERMINAL) compositor scenegraph mediatools mcrypt $(OBJSPIC)
ar cr ../bin/gcc/libgpac_static.a $(OBJS)
ranlib ../bin/gcc/libgpac_static.a
- $(CC) $(SHFLAGS) -Wl,-soname,$(LIB) $(LDFLAGS) -o ../bin/gcc/$@ $(OBJSPIC) $(EXTRALIBS)
+ #$(CC) $(SHFLAGS) -Wl,-soname,$(LIB) $(LDFLAGS) -o ../bin/gcc/$@ $(OBJSPIC) $(EXTRALIBS)
dep: depend
diff -Nru gpac/src/scenegraph/base_scenegraph.c gpac-patched/src/scenegraph/base_scenegraph.c
--- gpac/src/scenegraph/base_scenegraph.c 2008-10-31 09:42:57.000000000 -0400
+++ gpac-patched/src/scenegraph/base_scenegraph.c 2008-11-03 00:39:19.000000000 -0500
@@ -1601,7 +1601,7 @@
return 0;
}
-char szNameBuffer[1024];
+static char szNameBuffer[1024];
GF_EXPORT
const char *gf_node_get_class_name(GF_Node *node)
{
diff -Nru gpac/src/scenegraph/xml_ns.c gpac-patched/src/scenegraph/xml_ns.c
--- gpac/src/scenegraph/xml_ns.c 2008-10-24 09:06:24.000000000 -0400
+++ gpac-patched/src/scenegraph/xml_ns.c 2008-11-03 00:39:43.000000000 -0500
@@ -391,7 +391,7 @@
return DOM_String_datatype;
}
-char szNameBuffer[1024];
+static char szNameBuffer[1024];
const char*gf_svg_get_attribute_name(GF_Node *node, u32 tag)
{
END_OF_PATCH
cd gpac
chmod 700 configure
./configure --disable-ssl --disable-opengl
make lib
make -C applications/mp4box
ln bin/gcc/MP4Box ../../bin/mp4box
cd ../..
}
build-wget () {
local wget=wget-1.11.4
local url=ftp://ftp.gnu.org/gnu/wget
rm -rf src/$wget bin/wget
if [ ! -e zip/$wget.tar.bz2 ]; then
curl $url/$wget.tar.bz2 -o zip/$wget.tar.bz2
fi
cd src
tar -xjf ../zip/$wget.tar.bz2
cd $wget
./configure --disable-rpath --without-ssl
make
ln src/wget ../../bin/wget
cd ../..
}
build-yasm () {
local yasm=yasm-0.7.2
local url=http://www.tortall.net/projects/yasm/releases
rm -rf src/$yasm bin/yasm
if [ ! -e zip/$yasm.tar.gz ]; then
curl $url/$yasm.tar.gz -o zip/$yasm.tar.gz
fi
cd src
tar -xzf ../zip/$yasm.tar.gz
cd $yasm
./configure
make
ln yasm ../../bin/yasm
cd ../..
}
#info on versions used by anri
#0.59.859 ce13bb6 ce13bb6e8108657599433031df9c260c9f81b49d 2008-05-20
#0.64.995 2324c70 2324c7074585b8b3f56e49ae41df9cbca06f6185 2008-09-29
#fetch tarball from the next day to include the specified revision
#the patch removes the dependency on git to determine the revision
build-x264 () {
local x264=x264-snapshot-20080521-2245
local url=ftp://ftp.videolan.org/pub/videolan/x264/snapshots
if [ ! -e src/gpac ]; then
echo "gpac not found but needed for mp4 output"
echo "build mp4box first, then build x264 without deleting src/gpac"
return
fi
rm -rf src/$x264 bin/x264
if [ ! -e zip/$x264.tar.bz2 ]; then
curl $url/$x264.tar.bz2 -o zip/$x264.tar.bz2
fi
cd src
tar -xjf ../zip/$x264.tar.bz2
patch -p0 <<'END_OF_PATCH'
diff -Nru x264-snapshot-20080521-2245/version.sh x264-patched/version.sh
--- x264-snapshot-20080521-2245/version.sh 2008-05-21 16:45:10.000000000 -0400
+++ x264-patched/version.sh 2008-12-04 14:13:25.000000000 -0500
@@ -1,4 +1,7 @@
#!/bin/sh
+echo "#define X264_VERSION \" r859\"" >> config.h
+echo "#define X264_POINTVER \"0.59.859\"" >> config.h
+exit
git-rev-list HEAD | sort > config.git-hash
LOCALVER=`wc -l config.git-hash | awk '{print $1}'`
if [ $LOCALVER \> 1 ] ; then
END_OF_PATCH
cd $x264
#$PATH adjustment is so x264's configure can find yasm for cpu-specific assembly support
PATH=$PATH:../../bin CFLAGS="-I$PWD/../gpac/include" LDFLAGS="-L$PWD/../gpac/bin/gcc" ./configure --enable-mp4-output
make
ln x264 ../../bin/x264
cd ../..
}
programs=(afconvert ffmpeg mencoder mplayer mp4box wget yasm x264)
for arg; do
for program in ${programs[*]}; do
if [[ $program == $arg || $arg == "all" ]]; then
echo "$program build started"
time build-$program >log/$program.out 2>log/$program.err
echo "$program build finished"
fi
done
done