summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Messier <mmessier@grapetv.org>2007-05-15 03:03:10 -0400
committerMatt Messier <mmessier@grapetv.org>2007-05-15 03:03:10 -0400
commitd90df04ae2c5283649101cb08e041e277a335274 (patch)
tree9419aa3e2cc78f1d36518378d89bd2a288264d14
parent8aeaff301f34f29fb53e01d5de49535409cb3077 (diff)
downloadxine-lib-d90df04ae2c5283649101cb08e041e277a335274.tar.gz
xine-lib-d90df04ae2c5283649101cb08e041e277a335274.tar.bz2
Cleanups and fixes for building ffmpeg
-rw-r--r--configure.ac1
-rw-r--r--contrib/Makefile.am77
-rwxr-xr-xcontrib/ffmpeg-universal.sh77
3 files changed, 103 insertions, 52 deletions
diff --git a/configure.ac b/configure.ac
index f721454b7..2511e5dda 100644
--- a/configure.ac
+++ b/configure.ac
@@ -767,6 +767,7 @@ dnl optimizations can be enabled by explicitly specifying --enable-optimizations
AC_ARG_ENABLE([optimizations],
[AS_HELP_STRING([--disable-optimizations], [Don't try to guess what optimization to enable])],
[], [test x"$enable_debug" != x"no" && enable_optimizations="no"])
+AM_CONDITIONAL([DISABLE_OPTIMIZATIONS], [test x"$enable_optimizations" = x"no"])
if test x"$enable_optimizations" = x"no"; then
O1_CFLAGS="$O0_CLFAGS"
O2_CFLAGS="$O0_CFLAGS"
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 8ad34d968..1ebb7d5d1 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -2,17 +2,15 @@ SUBDIRS = libmpcdec libxdg-basedir libdca
srcdir = $(shell cd @srcdir@; pwd)
-CC = @CC@
-CFLAGS = @CFLAGS@
-LDFLAGS = @LDFLAGS@
-VISIBILITY_FLAG = @VISIBILITY_FLAG@
+ffmpeg_builder = $(srcdir)/ffmpeg-universal.sh
if ENABLE_DXR3
dxr3encoder = --enable-encoder=mpeg1video
endif
if FFMPEG_DISABLE_UNCOMMON_CODECS
-disable_uncommon_codecs=--disable-decoder=aasc --disable-decoder=asv1 --disable-decoder=asv2 --disable-decoder=avs \
+disable_uncommon_codecs = \
+ --disable-decoder=aasc --disable-decoder=asv1 --disable-decoder=asv2 --disable-decoder=avs \
--disable-decoder=cscd --disable-decoder=cyuv --disable-decoder=dvvideo --disable-decoder=eightbps \
--disable-decoder=flic --disable-decoder=flv --disable-decoder=fourxm --disable-decoder=fraps \
--disable-decoder=huffyuv --disable-decoder=idcin --disable-decoder=interplay_video --disable-decoder=kmvc \
@@ -37,7 +35,8 @@ disable_uncommon_codecs=--disable-decoder=aasc --disable-decoder=asv1 --disable-
endif
if FFMPEG_DISABLE_POPULAR_CODECS
-disable_popular_codecs=--disable-decoder=cinepak --disable-decoder=flashsv --disable-decoder=h261 --disable-decoder=h263 \
+disable_popular_codecs = \
+ --disable-decoder=cinepak --disable-decoder=flashsv --disable-decoder=h261 --disable-decoder=h263 \
--disable-decoder=h263i --disable-decoder=h264 --disable-decoder=indeo2 --disable-decoder=indeo3 \
--disable-decoder=mjpeg --disable-decoder=mjpegb --disable-decoder=mpeg1video --disable-decoder=mpeg2video \
--disable-decoder=mpeg4 --disable-decoder=mpegvideo --disable-decoder=msmpeg4v1 --disable-decoder=msmpeg4v2 \
@@ -53,7 +52,22 @@ configure_options =\
--disable-shared --enable-static --disable-demuxers --disable-muxers --disable-strip \
--enable-gpl --enable-pthreads --disable-ffmpeg --disable-ffserver --disable-ffplay
-disable_decoders =\
+if DEBUG_BUILD
+configure_options += --enable-debug
+else
+configure_options += --disable-debug
+endif
+if PROFILING_BUILD
+configure_options += --enable-gprof
+endif
+if DISABLE_OPTIMIZATIONS
+configure_options += --disable-opts
+endif
+if HAVE_MLIB
+configure_options += --enable-sunmlib
+endif
+
+disable_decoders = \
--disable-decoder=bmp --disable-decoder=cavs --disable-decoder=cljr --disable-decoder=dsicinvideo \
--disable-decoder=ffv1 --disable-decoder=ffvhuff --disable-decoder=gif --disable-decoder=mdec \
--disable-decoder=mpeg_xvmc --disable-decoder=mszh --disable-decoder=png --disable-decoder=rawvideo \
@@ -64,31 +78,28 @@ disable_decoders =\
--disable-decoder=dvdsub --disable-decoder=theora --disable-decoder=aac --disable-decoder=mpeg4aac \
--disable-decoder=ac3 --disable-decoder=vorbis
-all_configure_options = $(configure_options) \
- --disable-encoders $(dxr3encoder) \
- --enable-encoders $(disable_uncommon_codecs) $(disable_popular_codecs) \
- $(disable_decoders) \
- --make="$(MAKE)" \
- --cc="$(CC)"
+all_configure_options = \
+ $(configure_options) --make="$(MAKE)" --cc="$(CC)" \
+ --disable-encoders $(dxr3encoder) $(disable_decoders) \
+ $(disable_uncommon_codecs) $(disable_popular_codecs)
-ffmpeg/config.mak: $(srcdir)/ffmpeg/configure Makefile
+ffmpeg/config.mak: ffmpeg/configure Makefile $(ffmpeg_builder)
if MACOSX_UNIVERSAL_BINARY
- export CFLAGS="$(VISIBILITY_FLAG)"; \
- export FFMPEG_CONFIGURE_OPTIONS="$(all_configure_options)"; \
- $(srcdir)/ffmpeg-universal.sh -configure "$(srcdir)/ffmpeg" $(UNIVERSAL_ARCHES)
+ export CFLAGS="$(VISIBILITY_FLAG)"; \
+ export FFMPEG_CONFIGURE_OPTIONS="$(all_configure_options)"; \
+ $(ffmpeg_builder) -configure "$(srcdir)/ffmpeg" $(UNIVERSAL_ARCHES)
else
mkdir -p ffmpeg
cd ffmpeg; \
$(srcdir)/ffmpeg/configure $(all_configure_options) \
- --extra-cflags="$(CFLAGS) $(VISIBILITY_FLAG) -fPIC -DPIC" \
- --extra-ldflags="$(LDFLAGS)"; \
+ --extra-cflags="$(VISIBILITY_FLAG) -fPIC -DPIC" \
cd ..
endif
ffmpeg/libavutil/libavutil.a: ffmpeg/config.mak
if MACOSX_UNIVERSAL_BINARY
export MAKE="$(MAKE)"; \
- $(srcdir)/ffmpeg-universal.sh -avutil "$(srcdir)/ffmpeg" $(UNIVERSAL_ARCHES)
+ $(ffmpeg_builder) -avutil "$(srcdir)/ffmpeg" $(UNIVERSAL_ARCHES)
else
$(MAKE) -C ffmpeg/libavutil libavutil.a
endif
@@ -96,7 +107,7 @@ endif
ffmpeg/libavcodec/libavcodec.a: ffmpeg/config.mak
if MACOSX_UNIVERSAL_BINARY
export MAKE="$(MAKE)"; \
- $(srcdir)/ffmpeg-universal.sh -avcodec "$(srcdir)/ffmpeg" $(UNIVERSAL_ARCHES)
+ $(ffmpeg_builder) -avcodec "$(srcdir)/ffmpeg" $(UNIVERSAL_ARCHES)
else
$(MAKE) -C ffmpeg/libavcodec libavcodec.a
endif
@@ -104,28 +115,23 @@ endif
ffmpeg/libpostproc/libpostproc.a: ffmpeg/config.mak
if MACOSX_UNIVERSAL_BINARY
export MAKE="$(MAKE)"; \
- $(srcdir)/ffmpeg-universal.sh -postproc "$(srcdir)/ffmpeg" $(UNIVERSAL_ARCHES)
+ $(ffmpeg_builder) -postproc "$(srcdir)/ffmpeg" $(UNIVERSAL_ARCHES)
else
$(MAKE) -C ffmpeg/libpostproc libpostproc.a
endif
clean-local:
if MACOSX_UNIVERSAL_BINARY
- for arch in $(UNIVERSAL_ARCHES); do \
- $(MAKE) -C ffmpeg/$$arch clean; \
- done
- rm -f ffmpeg/libavcodec/libavcodec.a ffmpeg/libavutil/libavutil.a ffmpeg/libpostproc/libpostproc.a
+ export MAKE="$(MAKE)"; \
+ $(ffmpeg_builder) -clean "$(srcdir)/ffmpeg" $(UNIVERSAL_ARCHES)
else
-$(MAKE) -C ffmpeg clean
endif
distclean-local:
if MACOSX_UNIVERSAL_BINARY
- for arch in $(UNIVERSAL_ARCHES); do \
- $(MAKE) -C ffmpeg/$$arch distclean; \
- done
- rm -f ffmpeg/config.mak ffmpeg/config.h
- rm -f ffmpeg/libavcodec/libavcodec.a ffmpeg/libavutil/libavutil.a ffmpeg/libpostproc/libpostproc.a
+ export MAKE="$(MAKE)"; \
+ $(ffmpeg_builder) -distclean "$(srcdir)/ffmpeg" $(UNIVERSAL_ARCHES)
else
-$(MAKE) -C ffmpeg distclean
endif
@@ -133,10 +139,7 @@ endif
EXTRA_DIST = README.contrib ffmpeg-distfiles
dist-hook:
- while read entry; do \
- test -d $(srcdir)/$$entry && \
- mkdir -p $(distdir)/$$entry; \
- test -f $(srcdir)/$$entry && \
- cp -p $(srcdir)/$$entry $(distdir)/$$entry; \
+ while read entry; do \
+ test -d $(srcdir)/$$entry && mkdir -p $(distdir)/$$entry; \
+ test -f $(srcdir)/$$entry && cp -p $(srcdir)/$$entry $(distdir)/$$entry; \
done < $(srcdir)/ffmpeg-distfiles
-
diff --git a/contrib/ffmpeg-universal.sh b/contrib/ffmpeg-universal.sh
index 811aaa868..6e27c56b8 100755
--- a/contrib/ffmpeg-universal.sh
+++ b/contrib/ffmpeg-universal.sh
@@ -7,6 +7,8 @@ function usage {
echo " -avcodec build libavcodec.a for each architecture"
echo " -avutil build libavutil.a for each architecture"
echo " -postproc build libpostproc.a for each architecture"
+ echo " -clean clean for each architecture"
+ echo " -distclean distclean for each architecture"
echo ""
echo "Configuration must be done before any library builds. Options to be passed"
echo "to ffmpeg's configure command-line should be passed in the environment"
@@ -50,10 +52,18 @@ function run_configure {
--extra-ldflags="$EXTRA_LDFLAGS"
local retval=$?
- popd > /dev/null 2>&1
- if test $retval -ne 0; then
- exit $retval
+ # We're building ffmpeg to put it into a shared library, but ffmpeg thinks
+ # it's building to put it into a static library or program image, so it
+ # adds -mdynamic-no-pic to its list of options as an optimization. This is
+ # fine in Tiger if later linked with -Wl,-read_only_relocs,warning, but it
+ # isn't fine on other versions of Mac OS X.
+ if test -f config.mak; then
+ cat config.mak | sed -e '/OPTFLAGS=/s/-mdynamic-no-pic//g' > config.tmp
+ mv -f config.tmp config.mak
fi
+
+ popd > /dev/null 2>&1
+ `exit $retval` || exit $retval
}
if test x"$*" = x""; then
@@ -72,6 +82,12 @@ case "$1" in
-postproc)
MODE=postproc
;;
+ -clean)
+ MODE=clean
+ ;;
+ -distclean)
+ MODE=distclean
+ ;;
*)
echo "Unrecognized mode: $1"
usage
@@ -90,6 +106,19 @@ fi
SOURCE_PATH="$1"
shift
+TOP_BUILD_PATH="`pwd`/ffmpeg"
+if test -f "$TOP_BUILD_PATH/configure"; then
+ # Building in place. Create a temporary build directory and use that
+ # instead, but place the final output from lipo into the original
+ # build directory.
+ BUILD_PATH="$TOP_BUILD_PATH/build"
+else
+ BUILD_PATH="$TOP_BUILD_PATH"
+fi
+# This doesn't make sense for -configure, but it does for everything else.
+# The -configure mode won't ever use it anyway.
+OUTPUT_FILENAME="$BUILD_PATH/lib$MODE/lib$MODE.a"
+
HOST_ARCH=`arch`
UNIVERSAL_ARCHES=$*
if test x"$UNIVERSAL_ARCHES" = x""; then
@@ -97,9 +126,9 @@ if test x"$UNIVERSAL_ARCHES" = x""; then
UNIVERSAL_ARCHES=$HOST_ARCH
fi
CONFIG_FILES=
-LIPO_CMDLINE="-create -output ffmpeg/lib$MODE/lib$MODE.a"
+LIPO_CMDLINE="-create -output $OUTPUT_FILENAME"
for arch in $UNIVERSAL_ARCHES; do
- ffmpeg_topbuilddir="ffmpeg/$arch"
+ ffmpeg_topbuilddir="$BUILD_PATH/$arch"
LIPO_CMDLINE="$LIPO_CMDLINE -arch $arch $ffmpeg_topbuilddir/lib$MODE/lib$MODE.a"
case $MODE in
configure)
@@ -115,16 +144,34 @@ for arch in $UNIVERSAL_ARCHES; do
postproc)
"$MAKE" -C "$ffmpeg_topbuilddir/libpostproc" libpostproc.a || exit $?
;;
+ clean)
+ "$MAKE" -C "$ffmpeg_topbuilddir" clean || exit $?
+ ;;
+ distclean)
+ "$MAKE" -C "$ffmpeg_topbuilddir" distclean || exit $?
+ ;;
esac
done
-if test "$MODE" != "configure"; then
- mkdir -p ffmpeg/lib$MODE
- lipo $LIPO_CMDLINE
-else
- # Now that configuration is done, create config.h in the top-level ffmpeg
- # directory. Pull out only what's needed by xine-lib, removing any possible
- # platform conflicts
- grep -h "define CONFIG_.*_DECODER" $CONFIG_FILES | uniq > ffmpeg/config.h
- touch ffmpeg/config.mak
-fi
+case $MODE in
+ configure)
+ # Now that configuration is done, create config.h in the top-level
+ # ffmpeg directory. Pull out only what's needed by xine-lib, removing
+ # any possible platform conflicts
+ grep -h "define CONFIG_.*_DECODER" $CONFIG_FILES | uniq > "$BUILD_PATH/config.h"
+ touch "$BUILD_PATH/config.mak"
+ ;;
+ clean)
+ rm -f "$BUILD_PATH/libavcodec/libavcodec.a" "$BUILD_PATH/libavutil/libavutil.a" \
+ "$BUILD_PATH/libpostproc/libpostproc.a"
+ ;;
+ distclean)
+ rm -f "$BUILD_PATH/config.mak" "$BUILD_PATH/config.h"
+ rm -f "$BUILD_PATH/libavcodec/libavcodec.a" "$BUILD_PATH/libavutil/libavutil.a" \
+ "$BUILD_PATH/libpostproc/libpostproc.a"
+ ;;
+ *)
+ mkdir -p "`dirname "$OUTPUT_FILENAME"`"
+ lipo $LIPO_CMDLINE
+ ;;
+esac