From df32fc663d62928583bef5f72e20075dfe81e2f0 Mon Sep 17 00:00:00 2001 From: Austen Dicken Date: Fri, 30 Mar 2012 18:05:58 -0500 Subject: [PATCH] More FFMpeg adjustments Since many distros don't have packages for FFMpeg 0.10 yet, allow a static prebuilt package to be specifiec with --with-static-ffmpeg=/path/to/ffmpeg. Also recreate the functionality of ./Utils/build.sh to now pull FFMpeg 0.10.2 from the web, statically build it, and link it into Stepmania. --- Utils/build.sh | 10 ++++---- autoconf/m4/video.m4 | 59 ++++++++++++++++++++++++++++++++++++++------ src/Makefile.am | 11 ++++++--- 3 files changed, 63 insertions(+), 17 deletions(-) diff --git a/Utils/build.sh b/Utils/build.sh index 00b07d4884..0420902fc7 100755 --- a/Utils/build.sh +++ b/Utils/build.sh @@ -21,7 +21,7 @@ usage () { echo ' (do not copy binaries).' echo ' -d, --data generate GameData.smzip.' echo ' -r, --rebuild rebuild StepMania (soft).' - echo ' -f, --ffmpeg build with ffmpeg 0.6.1.' + echo ' -f, --ffmpeg build with ffmpeg 0.10.2.' echo ' -j#, --jobs=# pass -j# to make.' echo ' -h, --help print this help and exit.' echo ' -v, --verbose increase verbosity (up to 2).' @@ -132,7 +132,7 @@ if [ -n "$s_data" ]; then fi if [ -n "$s_ffmpeg" ]; then - ffversion=0.6.1 + ffversion=0.10.2 ffmpeg=ffmpeg-$ffversion if [ ! -d $ffmpeg ]; then message 'Downloading ffmpeg' @@ -155,10 +155,10 @@ if [ -n "$s_ffmpeg" ]; then call $get "http://ffmpeg.org/releases/$ffmarc" message 'Extracting ffmpeg' call tar -$zipcommand $ffmarc - message 'Cleaning up temporary files' +# message 'Cleaning up temporary files' # call rm $ffmarc fi - args="--enable-static --enable-gpl --enable-version3 --enable-nonfree --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libxvid --disable-debug --enable-memalign-hack --disable-network --enable-small --disable-encoders --disable-ffserver --extra-cflags=-Dattribute_deprecated=" + args="--enable-static --enable-gpl --enable-version3 --enable-nonfree --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --disable-libvpx --disable-vaapi --enable-libxvid --disable-debug --enable-memalign-hack --disable-network --enable-small --disable-encoders --disable-ffserver --extra-cflags=-Dattribute_deprecated=" cd $ffmpeg message 'Configuring ffmpeg' call ./configure --prefix="`pwd`/_inst" $args @@ -172,7 +172,7 @@ if [ ! -f _build/src/config.h ] || [ -n "$s_rebuild" ]; then mkdir -p _build cd _build if [ -n "$s_ffmpeg" ]; then - call ../configure --with-ffmpeg=../$ffmpeg/_inst "$@" + call ../configure --with-ffmpeg --with-static-ffmpeg=../$ffmpeg/_inst "$@" else call ../configure "$@" fi diff --git a/autoconf/m4/video.m4 b/autoconf/m4/video.m4 index 2d77e7bb12..0d3a91a4cd 100644 --- a/autoconf/m4/video.m4 +++ b/autoconf/m4/video.m4 @@ -5,6 +5,9 @@ AC_REQUIRE([SM_STATIC]) AC_ARG_WITH(ffmpeg, AS_HELP_STRING([--without-ffmpeg],[Disable ffmpeg support]), with_ffmpeg=$withval, with_ffmpeg=yes) AC_ARG_WITH(static-ffmpeg, AS_HELP_STRING([--with-static-ffmpeg],[Statically link ffmpeg libraries]), with_static_ffmpeg=$withval, with_static_ffmpeg=no) +VIDEO_CFLAGS= +VIDEO_LIBS= + if test "$with_static_ffmpeg" = "yes"; then LIB_PRE=$START_STATIC LIB_POST=$END_STATIC @@ -12,14 +15,51 @@ fi have_ffmpeg=no if test "$with_ffmpeg" = "yes"; then - AC_CHECK_LIB(avutil, av_free, have_libavutil=yes, have_libavutil=no) - AC_CHECK_LIB(avformat, av_guess_format, have_libavformat=yes, have_libavformat=no) - AC_CHECK_LIB(avcodec, avcodec_init, have_libavcodec=yes, have_libavcodec=no) - AC_CHECK_LIB(swscale, sws_scale, have_libswscale=yes, have_libswscale=no) - if test "$have_libavutil" = "yes" -a "$have_libavformat" = "yes" -a "$have_libavcodec" = "yes" -a "$have_libswscale" = "yes"; then - have_ffmpeg=yes - LIBS="$LIBS $LIB_PRE -lavutil -lavcodec -lavformat -lswscale $LIB_POST" - AC_DEFINE(HAVE_FFMPEG, 1, [FFMPEG support available]) + if test "$with_static_ffmpeg" = "yes" -o "$with_static_ffmpeg" = "no"; then + AC_CHECK_LIB(avutil, av_free, have_libavutil=yes, have_libavutil=no) + AC_CHECK_LIB(avcodec, avcodec_init, have_libavcodec=yes, have_libavcodec=no) + AC_CHECK_LIB(avformat, av_guess_format, have_libavformat=yes, have_libavformat=no) + AC_CHECK_LIB(swscale, sws_scale, have_libswscale=yes, have_libswscale=no) + if test "$have_libavutil" = "yes" -a "$have_libavformat" = "yes" -a "$have_libavcodec" = "yes" -a "$have_libswscale" = "yes"; then + have_ffmpeg=yes + VIDEO_LIBS="$LIB_PRE -lswscale -lavformat -lswscale -lavcodec -lavutil $LIB_POST $VIDEO_LIBS" + AC_DEFINE(HAVE_FFMPEG, 1, [FFMPEG support available]) + fi + else + if test "$(echo $with_static_ffmpeg | cut -c 1)" != "/"; then + with_static_ffmpeg="$(/bin/pwd)/$with_static_ffmpeg" + fi + + ffmpeg_save_CFLAGS="$CFLAGS" + ffmpeg_save_CXXFLAGS="$CXXFLAGS" + ffmpeg_save_LIBS="$LIBS" + + FFMPEG_CFLAGS="-I$with_static_ffmpeg/include" + + FFMPEG_LIBS="$with_static_ffmpeg/lib/libavutil.a $FFMPEG_LIBS" + FFMPEG_LIBS="$with_static_ffmpeg/lib/libavcodec.a $FFMPEG_LIBS" + FFMPEG_LIBS="$with_static_ffmpeg/lib/libavformat.a $FFMPEG_LIBS" + FFMPEG_LIBS="$with_static_ffmpeg/lib/libswscale.a $FFMPEG_LIBS" + + CFLAGS="$FFMPEG_CFLAGS $CFLAGS" + CXXFLAGS="$FFMPEG_CFLAGS $CXXFLAGS" + LIBS="$FFMPEG_LIBS -lpthread $LIBS" + + AC_CHECK_FUNC([av_free], have_libavutil=yes, have_libavutil=no) + AC_CHECK_FUNC([avcodec_init], have_libavcodec=yes, have_libavcodec=no) + AC_CHECK_FUNC([av_guess_format], have_libavformat=yes, have_libavformat=no) + AC_CHECK_FUNC([sws_scale], have_libswscale=yes, have_libswscale=no) + + if test "$have_libavutil" = "yes" -a "$have_libavformat" = "yes" -a "$have_libavcodec" = "yes" -a "$have_libswscale" = "yes"; then + have_ffmpeg=yes + AC_DEFINE(HAVE_FFMPEG, 1, [FFMPEG support available]) + VIDEO_CFLAGS="$FFMPEG_CFLAGS $VIDEO_CFLAGS" + VIDEO_LIBS="$FFMPEG_LIBS $VIDEO_LIBS" + fi + + CFLAGS="$ffmpeg_save_CFLAGS" + CXXFLAGS="$ffmpeg_save_CXXFLAGS" + LIBS="$ffmpeg_save_LIBS" fi fi @@ -28,4 +68,7 @@ LIB_POST= AM_CONDITIONAL(HAVE_FFMPEG, test "$have_ffmpeg" = "yes") +AC_SUBST(VIDEO_CFLAGS) +AC_SUBST(VIDEO_LIBS) + ]) diff --git a/src/Makefile.am b/src/Makefile.am index 4672074eec..a6f957a9d2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -601,7 +601,9 @@ libtomcrypt_a_CPPFLAGS = -I$(srcdir)/libtomcrypt/src/headers $(AM_CPPFLAGS) noinst_LIBRARIES += libtomcrypt.a -main_CPPFLAGS = -I$(top_srcdir)/extern/jsoncpp/include +main_CPPFLAGS = \ + $(VIDEO_CFLAGS) \ + -I$(top_srcdir)/extern/jsoncpp/include #-I$(top_srcdir)/extern/glew-1.5.8/include main_SOURCES = $(PNG) \ @@ -618,9 +620,10 @@ main_SOURCES = $(PNG) \ $(GlobalSingletons) main_LDADD = \ - $(AUDIO_LIBS) \ - $(XLIBS) \ - libtomcrypt.a libtommath.a + $(VIDEO_LIBS) \ + $(AUDIO_LIBS) \ + $(XLIBS) \ + libtomcrypt.a libtommath.a nodist_stepmania_SOURCES = ver.cpp