Completely revised buildscript.

This commit is contained in:
ZipFile
2011-10-09 00:32:08 +02:00
parent 5a068ccaa3
commit c8e4976570
+70 -118
View File
@@ -3,11 +3,57 @@
verbose=0
msg=
notify=0
s_configure=
s_stepmania=
s_data=
s_rebuild=
num_jobs=1
usage () {
echo "Usage: $0 [OPTION] [-- [CONFIGURE_OPTIONS]]"
echo 'Build StepMania.'
echo "CONFIGURE_OPTIONS are passed to StepMania's configure."
echo ''
echo ' -c, --configure stop after configuring StepMania.'
echo ' -s, --stepmania stop after building StepMania'
echo ' (do not copy binaries).'
echo ' -d, --data generate GameData.smzip.'
echo ' -r, --rebuild rebuild StepMania (soft).'
echo ' -j#, --jobs=# pass -j# to make.'
echo ' -h, --help print this help and exit.'
echo ' -v, --verbose increase verbosity (up to 2).'
echo ' --version print version and exit.'
exit $1
}
if which notify-send >/dev/null 2>&1; then
#Comment the following line out to disable notify.
notify=1
fi
if which getopt >/dev/null 2>&1; then
set -- `getopt -l configure,stepmania,data,rebuild,help \
-l jobs::,verbose,version -- drcshj::v $*`
fi
while [ $# -gt 0 ]; do
arg=$1
shift
case $arg in
-c|--configure) s_configure=yes ;;
-s|--stepmania) s_stepmania=yes ;;
-d|--data) s_data=yes ;;
-r|--rebuild) s_rebuild=yes ;;
-h|--help) usage 0 ;;
-j|--jobs) num_jobs=$1; shift ;;
-v|--verbose) verbose=$[verbose+1] ;;
--version) version ;;
--) break ;;
*) usage 1 ;;
esac
done
message () {
msg=$1
if [ $verbose -gt 0 ]; then
@@ -15,7 +61,7 @@ message () {
else
echo -n "$msg..."
fi
if [ $notify -gt 0 ]; then
if [ $notify -gt 0 ] && [ $verbose -eq 0 ]; then
notify-send "StepMania build script" "$msg..."
fi
}
@@ -26,7 +72,7 @@ success () {
else
echo okay.
fi
if [ $notify -gt 0 ]; then
if [ $notify -gt 0 ] && [ $verbose -eq 0 ]; then
notify-send "StepMania build script" "$msg...okay."
fi
}
@@ -41,11 +87,11 @@ failure () {
echo "$msg...failed$error"
else
echo failed$error
echo "Consider passing --verbose to $0. Pass --help for details."
fi
if [ $notify -gt 0 ]; then
if [ $notify -gt 0 ] && [ $verbose -eq 0 ]; then
notify-send "StepMania build script failed" "$msg...failed$error"
fi;
echo "Consider passing --verbose to $0. Pass --help for details."
exit 1
}
@@ -61,143 +107,49 @@ call () {
success
}
usage () {
echo "Usage: $0 [OPTION] [-- [CONFIGURE_OPTIONS]]"
echo 'Build StepMania with a statically linked ffmpeg.'
echo "CONFIGURE_OPTIONS are passed to StepMania's configure."
echo ''
echo ' -d, --download stop after ffmpeg download.'
echo ' -f, --ffmpeg stop after building ffmpeg.'
echo ' -c, --configure stop after configuring StepMania.'
echo ' -s, --stepmania stop after building StepMania'
echo ' (do not copy binaries).'
echo ' -j#, --jobs=# pass -j# to make.'
echo ' -h, --help print this help and exit.'
echo ' -v, --verbose increase verbosity (up to 2).'
echo ' --version print version and exit.'
exit $1
}
version () {
echo 'build.sh (StepMania) 2.62'
echo 'build.sh (StepMania) 2.63'
echo 'Copyright (C) 2006-2009 Steve Checkoway'
echo 'StepMania is Copyright (C) 2001-2011 Chris Danford et al.'
echo 'sm-ssc is Copyright (C) 2009-2011 the spinal shark collective'
exit 0
}
if ! test -x configure; then
msg='Checking for configure'
verbose=1
failure 'file not found.'
fi
if which getopt >/dev/null 2>&1; then
set -- `getopt -l download,ffmpeg,configure,stepmania,help \
-l jobs::,verbose,version -- dfcshj::v $*`
fi
s_download=
s_ffmpeg=
s_configure=
s_stepmania=
num_jobs=1
while [ $# -gt 0 ]; do
arg=$1
shift
case $arg in
-d|--download) s_download=yes ;;
-f|--ffmpeg) s_ffmpeg=yes ;;
-c|--configure) s_configure=yes ;;
-s|--stepmania) s_stepmania=yes ;;
-h|--help) usage 0 ;;
-j|--jobs) num_jobs=$1; shift ;;
-v|--verbose) verbose=$[verbose+1] ;;
--version) version ;;
--) break ;;
*) usage 1 ;;
esac
done
version=0.6.1
ffmpeg=ffmpeg-$version
directory=http://ffmpeg.org/releases
if [ ! -d $ffmpeg ]; then
message 'Downloading ffmpeg'
if which bzip2 &>/dev/null; then
zipcommand=jxf
ffmarc=ffmpeg-$version.tar.bz2
elif which gzip &>/dev/null; then
zipcommand=zxf
ffmarc=ffmpeg-$version.tar.gz
if [ -n "$s_data" ]; then
message 'Generating GameData.smzip'
if [ -f _build/Makefile ]; then
cd _build
call make dist-hook
mv ./GameData.smzip ../
cd ..
else
failure 'Install either bzip2 or gzip.'
failure "You need to configure StepMania first."
fi
if which curl &>/dev/null; then
get='curl -O'
elif which wget &>/dev/null; then
get=wget
else
failure 'Install either curl or wget.'
fi
call $get $directory/$ffmarc
message 'Extracting ffmpeg'
call tar -$zipcommand $ffmarc
message 'Cleaning up temporary files'
call rm $ffmarc
exit 0
fi
if [ -n "$s_download" ]; then exit 0; fi
args='--enable-static --disable-debug
--enable-memalign-hack --disable-network --enable-small
--disable-encoders --disable-ffserver
--enable-demuxer=avi
--enable-demuxer=h261 --enable-demuxer=h263 --enable-demuxer=h264
--enable-demuxer=m4v --enable-demuxer=mjpeg --enable-demuxer=mov
--enable-demuxer=mpegps --enable-demuxer=mpegts
--enable-demuxer=mpegvideo --enable-demuxer=ogg
--enable-demuxer=rawvideo --enable-demuxer=yuv4mpegpipe
--enable-decoder=h261 --enable-decoder=h263
--enable-decoder=h263i --enable-decoder=h264 --enable-decoder=huffyuv
--enable-decoder=mjpeg --enable-decoder=mjpegb
--enable-decoder=mpeg_xvmc --enable-decoder=mpeg1video
--enable-decoder=mpeg2video --enable-decoder=mpeg4
--enable-decoder=mpegvideo --enable-decoder=msmpeg4v1
--enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3
--enable-decoder=rawvideo --enable-decoder=theora
--enable-parser=h261 --enable-parser=h263 --enable-parser=h264
--enable-parser=mjpeg --enable-parser=mpeg4video
--enable-parser=mpegaudio --enable-parser=mpegvideo
--enable-parser=ac3
--extra-cflags=-Dattribute_deprecated='
if [ ! -f $ffmpeg/_inst/lib/libavcodec.a ]; then
cd $ffmpeg
message 'Configuring ffmpeg'
call ./configure --prefix="`pwd`/_inst" $args
message 'Building ffmpeg'
call make --jobs="$num_jobs" install-libs install-headers
cd ..
fi
if [ -n "$s_ffmpeg" ]; then exit 0; fi
if [ ! -f _build/src/config.h ]; then
if [ ! -f _build/src/config.h ] || [ -n "$s_rebuild" ]; then
message 'Configuring StepMania'
mkdir -p _build
cd _build
call ../configure --with-ffmpeg=../$ffmpeg/_inst "$@"
call ../configure "$@"
cd ..
fi
if [ -n "$s_configure" ]; then exit 0; fi
if [ ! -f _build/src/stepmania ]; then
if [ ! -f _build/src/stepmania ] || [ -n "$s_rebuild" ]; then
message 'Building StepMania'
cd _build || failure
cd _build
call make --jobs="$num_jobs"
cd ..
fi
if [ -n "$s_stepmania" ]; then exit 0; fi
if [ ! -f stepmania -o ! -f GtkModule.so ]; then
if [ ! -f stepmania -o ! -f GtkModule.so ] || [ -n "$s_rebuild" ]; then
message 'Copying StepMania binaries'
call cp _build/src/stepmania .
# todo: check for existence of GtkModule.so -freem
#_build/src/GtkModule.so . # we tend to not have this file!
cp _build/src/stepmania .
if [ -e _build/src/GtkModule.so ]; then
cp _build/src/GtkModule.so . # we tend to not have this file!
fi
success
fi