diff options
author | Matt Messier <mmessier@grapetv.org> | 2007-05-02 14:58:55 -0400 |
---|---|---|
committer | Matt Messier <mmessier@grapetv.org> | 2007-05-02 14:58:55 -0400 |
commit | fa333fe2dc2e77ce69d0e212f65106df25b0c07d (patch) | |
tree | 71ea926ac982b9b7ca803d20b6a78f7a969327ea | |
parent | 0cf6cfae1aa92647a8e4550a2818ef94db2b7c73 (diff) | |
download | xine-lib-fa333fe2dc2e77ce69d0e212f65106df25b0c07d.tar.gz xine-lib-fa333fe2dc2e77ce69d0e212f65106df25b0c07d.tar.bz2 |
Mac OS X Universal Binary support
-rw-r--r-- | configure.ac | 58 | ||||
-rw-r--r-- | contrib/Makefile.am | 84 | ||||
-rwxr-xr-x | contrib/ffmpeg-universal.sh | 130 | ||||
-rw-r--r-- | lib/os_internal.h | 77 | ||||
-rw-r--r-- | m4/optimizations.m4 | 9 | ||||
-rw-r--r-- | src/post/goom/Makefile.am | 4 |
6 files changed, 335 insertions, 27 deletions
diff --git a/configure.ac b/configure.ac index 1068084ea..b806d0f36 100644 --- a/configure.ac +++ b/configure.ac @@ -102,6 +102,54 @@ test "$host" == "$build" && check_athlon=yes AC_CONFIG_HEADERS([config.h]) +AC_ARG_ENABLE([macosx-universal], + AS_HELP_STRING([--enable-macosx-universal], [build a Mac OS X univeral binary (ppc and x86)])) +if test x"$enable_macosx_universal" != x"no" ; then + case "$host_os" in + *darwin*) + dnl x64_64 and ppc64 binaries could also be built, but there is no + dnl version of Mac OS X currently shipping that can run them, so + dnl do not enable them by default for now. + if test x"$enable_macosx_universal" = x"yes" ; then + UNIVERSAL_ARCHES="i386 ppc" + else + UNIVERSAL_ARCHES=`echo "$enable_macosx_universal" | sed -e 's/,/ /g'` + fi + ;; + *) + AC_MSG_ERROR([Universal binaries can only be built on Darwin]) + ;; + esac + + UNIVERSAL_CFLAGS="$UNIVERSAL_CFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk" + UNIVERSAL_LDFLAGS="$UNIVERSAL_LDFLAGS -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" + if test x"$UNIVERSAL_ARCHES" != x"" ; then + # Forcibly disable dependency tracking for Universal builds, because -M + # does not work with multiple -arch arguments on the gcc command-line. + ac_tool_warned=yes + cross_compiling=yes + enable_dependency_tracking=no + host="`echo $host | sed -e s/$host_cpu/universal/g`" + host_cpu=universal + + CFLAGS="$CFLAGS $UNIVERSAL_CFLAGS" + OBJCFLAGS="$OBJCFLAGS $UNIVERSAL_CFLAGS" + LDFLAGS="$LDFLAGS $UNIVERSAL_LDFLAGS" + AC_DEFINE(XINE_MACOSX_UNIVERSAL_BINARY, 1, [Define this if a universal binary is being built for Mac OS X]) + for arch in $UNIVERSAL_ARCHES ; do + UNIVERSAL_CFLAGS="$UNIVERSAL_CFLAGS -arch $arch" + UNIVERSAL_LDFLAGS="$UNIVERSAL_LDFLAGS -arch $arch" + CFLAGS="$CFLAGS -arch $arch" + OBJCFLAGS="$OBJCFLAGS -arch $arch" + LDFLAGS="$LDFLAGS -arch $arch" + done + fi +fi +AM_CONDITIONAL([MACOSX_UNIVERSAL_BINARY], [test x"$enable_macosx_universal" = x"yes"]) +AC_SUBST(UNIVERSAL_ARCHES) +AC_SUBST(UNIVERSAL_CFLAGS) +AC_SUBST(UNIVERSAL_LDFLAGS) + dnl --------------------------------------------- dnl Check for programs. @@ -1796,6 +1844,9 @@ int main() { *-*-mingw32* | *-*-cygwin*) bf_lsbf=1 ;; + universal-*-darwin*) + bf_lsbf=0 + ;; *) AC_MSG_RESULT([unknown]) AC_MSG_ERROR([value of bitfield test isn't known for $host @@ -2088,11 +2139,15 @@ dnl --------------------------------------------- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ asm (".align 3"); ]])], AC_DEFINE([ASMALIGN_1SLN], [1], [define if '.align n' means alignment to (1<<n)-byte boundaries]), :) +AH_TOP([#ifndef __XINE_CONFIG_H__ +#define __XINE_CONFIG_H__ 1 +]) AH_BOTTOM([#ifdef ASMALIGN_1SLN # define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\n\t" #else # define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\n\t" #endif +#endif /* __XINE_CONFIG_H__ */ ]) dnl --------------------------------------------- @@ -2219,6 +2274,9 @@ case "$host_or_hostalias" in AC_DEFINE_UNQUOTED(ARCH_X86_64,,[Define this if you're running x86 architecture 64 bits]) arch_x86="yes" ;; + universal-*-darwin*) + enable_impure_text="yes" + ;; powerpc-*-darwin*) dnl avoid ppc compilation crash AS="$CC" diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 2eabf662a..8433d4ce8 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -49,50 +49,86 @@ disable_popular_codecs=--disable-decoder=cinepak --disable-decoder=flashsv --dis --disable-decoder=wavpack --disable-decoder=wmav1 --disable-decoder=wmav2 --disable-decoder=adpcm_swf endif +configure_options =\ + --disable-shared --enable-static --disable-demuxers --disable-muxers --disable-strip \ + --enable-gpl --enable-pthreads --disable-ffmpeg --disable-ffserver --disable-ffplay + +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 \ + --disable-decoder=sp5x --disable-decoder=targa --disable-decoder=tiertexseqvideo --disable-decoder=tiff \ + --disable-decoder=vmnc --disable-decoder=zlib --disable-decoder=dsicinaudio --disable-decoder=imc \ + --disable-decoder=mp3adu --disable-decoder=mp3on4 --disable-decoder=mpc7 --disable-decoder=sonic \ + --disable-decoder=ws_snd1 --disable-decoder=adpcm_adx --disable-decoder=adpcm_g726 --disable-decoder=dvbsub \ + --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)" + ffmpeg/config.mak: $(srcdir)/ffmpeg/configure Makefile +if MACOSX_UNIVERSAL_BINARY + export CFLAGS="$(VISIBILITY_FLAG)"; \ + export FFMPEG_CONFIGURE_OPTIONS="$(all_configure_options)"; \ + $(srcdir)/ffmpeg-universal.sh -configure "$(srcdir)/ffmpeg" $(UNIVERSAL_ARCHES) +else mkdir -p ffmpeg cd ffmpeg; \ - $(srcdir)/ffmpeg/configure \ - --disable-shared --enable-static \ - --disable-encoders $(dxr3encoder) \ - --enable-encoders $(disable_uncommon_codecs) $(disable_popular_codecs) \ - --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 \ - --disable-decoder=sp5x --disable-decoder=targa --disable-decoder=tiertexseqvideo --disable-decoder=tiff \ - --disable-decoder=vmnc --disable-decoder=zlib --disable-decoder=dsicinaudio --disable-decoder=imc \ - --disable-decoder=mp3adu --disable-decoder=mp3on4 --disable-decoder=mpc7 --disable-decoder=sonic \ - --disable-decoder=ws_snd1 --disable-decoder=adpcm_adx --disable-decoder=adpcm_g726 --disable-decoder=dvbsub \ - --disable-decoder=dvdsub --disable-decoder=theora --disable-decoder=aac --disable-decoder=mpeg4aac \ - --disable-decoder=ac3 --disable-decoder=vorbis \ - --disable-demuxers \ - --disable-muxers \ - --disable-strip \ - --make="$(MAKE)" \ - --cc="$(CC)" \ + $(srcdir)/ffmpeg/configure $(all_configure_options) \ --extra-cflags="$(CFLAGS) $(VISIBILITY_FLAG) -fPIC -DPIC" \ - --extra-ldflags="$(LDFLAGS)" \ - --enable-gpl \ - --enable-pthreads \ - --disable-ffmpeg \ - --disable-ffserver \ - --disable-ffplay; \ + --extra-ldflags="$(LDFLAGS)"; \ 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) +else $(MAKE) -C ffmpeg/libavutil libavutil.a +endif ffmpeg/libavcodec/libavcodec.a: ffmpeg/config.mak +if MACOSX_UNIVERSAL_BINARY + export MAKE="$(MAKE)"; \ + $(srcdir)/ffmpeg-universal.sh -avcodec "$(srcdir)/ffmpeg" $(UNIVERSAL_ARCHES) +else $(MAKE) -C ffmpeg/libavcodec libavcodec.a +endif ffmpeg/libpostproc/libpostproc.a: ffmpeg/config.mak +if MACOSX_UNIVERSAL_BINARY + export MAKE="$(MAKE)"; \ + $(srcdir)/ffmpeg-universal.sh -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 +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 +else -$(MAKE) -C ffmpeg distclean +endif EXTRA_DIST = README.contrib ffmpeg-distfiles diff --git a/contrib/ffmpeg-universal.sh b/contrib/ffmpeg-universal.sh new file mode 100755 index 000000000..811aaa868 --- /dev/null +++ b/contrib/ffmpeg-universal.sh @@ -0,0 +1,130 @@ +#!/bin/sh + +function usage { + echo "usage: $0 <action> <source path> <arch list>" + echo "where: <action> is one of:" + echo " -configure do initial configuration for each architecture" + 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 "" + 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" + echo "using the FFMPEG_CONFIGURE_OPTIONS environment variable." + exit 1 +} + +function run_configure { + local arch=$1 + local ffmpeg_topbuilddir="$2" + + # start over from scratch + rm -rf "$ffmpeg_topbuilddir" + mkdir -p "$ffmpeg_topbuilddir" + pushd "$ffmpeg_topbuilddir" > /dev/null 2>&1 + + # The Makefile should be passing FFMPEG_CONFIGURE_OPTIONS without passing + # any --extra-cflags or --extra-ldflags options. Both CFLAGS and LDFLAGS + # should be in the environment in addition to FFMPEG_CONFIGURE_OPTIONS. + + local CROSS_OPTIONS= + local EXTRA_CFLAGS= + local EXTRA_LDFLAGS= + + if test $HOST_ARCH != $arch; then + EXTRA_CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch $arch" + EXTRA_LDFLAGS="$LDFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch $arch" + if test $arch = i386; then + FFMPEG_ARCH=x86_32 + else + FFMPEG_ARCH=$arch + fi + CROSS_OPTIONS="--cross-compile --arch=$FFMPEG_ARCH" + fi + + echo "$SOURCE_PATH/configure" $CROSS_OPTIONS $FFMPEG_CONFIGURE_OPTIONS \ + --extra-cflags="$EXTRA_CFLAGS" \ + --extra-ldflags="$EXTRA_LDFLAGS" + "$SOURCE_PATH/configure" $CROSS_OPTIONS $FFMPEG_CONFIGURE_OPTIONS \ + --extra-cflags="$EXTRA_CFLAGS" \ + --extra-ldflags="$EXTRA_LDFLAGS" + local retval=$? + + popd > /dev/null 2>&1 + if test $retval -ne 0; then + exit $retval + fi +} + +if test x"$*" = x""; then + usage +fi +case "$1" in + -configure) + MODE=configure + ;; + -avcodec) + MODE=avcodec + ;; + -avutil) + MODE=avutil + ;; + -postproc) + MODE=postproc + ;; + *) + echo "Unrecognized mode: $1" + usage + ;; +esac +shift + +if test x"$1" = x""; then + echo "No source path specified!" + usage +fi +if test ! -d "$1"; then + echo "Source path $1 does not exist!" + exit 1 +fi +SOURCE_PATH="$1" +shift + +HOST_ARCH=`arch` +UNIVERSAL_ARCHES=$* +if test x"$UNIVERSAL_ARCHES" = x""; then + echo "No architecture(s) specified; using $HOST_ARCH only." + UNIVERSAL_ARCHES=$HOST_ARCH +fi +CONFIG_FILES= +LIPO_CMDLINE="-create -output ffmpeg/lib$MODE/lib$MODE.a" +for arch in $UNIVERSAL_ARCHES; do + ffmpeg_topbuilddir="ffmpeg/$arch" + LIPO_CMDLINE="$LIPO_CMDLINE -arch $arch $ffmpeg_topbuilddir/lib$MODE/lib$MODE.a" + case $MODE in + configure) + run_configure $arch "$ffmpeg_topbuilddir" + CONFIG_FILES="$CONFIG_FILES $ffmpeg_topbuilddir/config.h" + ;; + avcodec) + "$MAKE" -C "$ffmpeg_topbuilddir/libavcodec" libavcodec.a || exit $? + ;; + avutil) + "$MAKE" -C "$ffmpeg_topbuilddir/libavutil" libavutil.a || exit $? + ;; + postproc) + "$MAKE" -C "$ffmpeg_topbuilddir/libpostproc" libpostproc.a || 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 diff --git a/lib/os_internal.h b/lib/os_internal.h index dd48e04f7..e461b5581 100644 --- a/lib/os_internal.h +++ b/lib/os_internal.h @@ -1,6 +1,83 @@ #ifndef _XINE_OS_INTERNAL_H #define _XINE_OS_INTERNAL_H +/* When using Apple's GCC, __APPLE__ will be defined. This is a whole lot of + * messiness, but it's necessary in order to perform universal builds properly. + * It's meant to over-ride configure time stuff that would be different at + * compile time. + */ +#if defined(__APPLE__) && defined(XINE_MACOSX_UNIVERSAL_BINARY) + +#if !defined(__ppc__) && !defined(__ppc64__) && !defined(__i386__) && !defined(__x86_64__) +#error unrecognized/unsupported CPU type building for Apple Darwin +#endif + +/* First get rid of anything that initial configure might have set */ +#undef ARCH_PPC +#undef ARCH_X86 +#undef ARCH_X86_32 +#undef ARCH_X86_64 +#undef BITFIELD_LSBF +#undef ENABLE_ALTIVEC +#undef FPM_64BIT +#undef FPM_DEFAULT +#undef FPM_INTEL +#undef FPM_PPC +#undef HAVE_MMX +#undef HOST_ARCH +#undef HOST_DARWIN +#undef SIZEOF_INT +#undef SIZEOF_LONG +#undef SIZEOF_LONG_LONG +#undef WORDS_BIGENDIAN + +#define HOST_DARWIN 1 + +/* WORDS_BIGENDIAN (replaces AC_C_BIGENDIAN autoconf test at compile time) */ +#include <machine/endian.h> +#if BYTE_ORDER == BIG_ENDIAN +#define WORDS_BIGENDIAN 1 +#endif + +/* __ppc__, __ppc64__, __i386__, __x86_64__ are interesting arch macros */ +#if defined(__ppc__) +#define ARCH_PPC +#define FPM_PPC 1 +#define HOST_ARCH "darwin/powerpc" +#define SIZEOF_INT 4 +#define SIZEOF_LONG 4 +#define SIZEOF_LONG_LONG 8 +#elif defined(__ppc64__) +#define ARCH_PPC +#define FPM_64BIT 1 +#define SIZEOF_INT 4 +#define SIZEOF_LONG 8 +#define SIZEOF_LONG_LONG 8 +#define HOST_ARCH "darwin/powerpc64" +#elif defined(__i386__) +#define ARCH_X86 +#define ARCH_X86_32 +#define BITFIELD_LSBF +#define FPM_INTEL 1 +#define HAVE_MMX +#define HOST_ARCH "darwin/i386" +#define SIZEOF_INT 4 +#define SIZEOF_LONG 4 +#define SIZEOF_LONG_LONG 8 +#elif defined(__x86_64__) +#define ARCH_X86 +#define ARCH_X86_64 +#define BITFIELD_LSBF +#define FPM_64BIT 1 +#define HAVE_MMX +#define HOST_ARCH "darwin/x64_64" +#define SIZEOF_INT 4 +#define SIZEOF_LONG 8 +#define SIZEOF_LONG_LONG 8 +#endif + +#endif /* __APPLE__ */ + #include <stddef.h> #include <stdarg.h> diff --git a/m4/optimizations.m4 b/m4/optimizations.m4 index a1f2f2f00..cc5e7c524 100644 --- a/m4/optimizations.m4 +++ b/m4/optimizations.m4 @@ -74,7 +74,13 @@ AC_DEFUN([AC_OPTIMIZATIONS], [ CFLAGS="$wall ${CFLAGS}" DEBUG_CFLAGS="$wall ${DEBUG_CFLAGS}" - case "$host_or_hostalias" in + if test "$enable_macosx_universal"; then + optimize_for_host="universal-darwin" + else + optimize_for_host="$host_or_hostalias" + fi + + case "$optimize_for_host" in i?86-* | k?-* | athlon-* | pentium*) if test "$GCC" = yes -o "${CC##*/}x" = "iccx" ; then @@ -182,6 +188,7 @@ AC_DEFUN([AC_OPTIMIZATIONS], [ ;; *darwin*) CFLAGS="-O3 -pipe -fomit-frame-pointer $m_wm $m_psb -fexpensive-optimizations $f_si -ffast-math $INLINE_FUNCTIONS -no-cpp-precomp -D_INTL_REDIRECT_MACROS $CFLAGS" + OBJCFLAGS="-O3 -pipe -fomit-frame-pointer $m_wm $m_psb -fexpensive-optimizations $f_si -ffast-math $INLINE_FUNCTIONS -no-cpp-precomp -D_INTL_REDIRECT_MACROS $CFLAGS" DEBUG_CFLAGS="-O3 $DEBUG_CFLAGS" ;; ppc-*-linux* | powerpc-*) diff --git a/src/post/goom/Makefile.am b/src/post/goom/Makefile.am index 53a806a7a..481b66b41 100644 --- a/src/post/goom/Makefile.am +++ b/src/post/goom/Makefile.am @@ -19,9 +19,9 @@ xinepost_LTLIBRARIES = xineplug_post_goom.la #AM_CPPFLAGS = -DCPU_POWERPC #endif -if HAVE_MMX +#if HAVE_MMX extra_files = mmx.c xmmx.c -endif +#endif xineplug_post_goom_la_SOURCES = $(extra_files) xine_goom.c \ config_param.c convolve_fx.c cpu_info.c drawmethods.c filters.c flying_stars_fx.c \ |