From 87b7cf5ec1f75920a54fada8b9c1af8fe44d0aa9 Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Sat, 26 May 2012 23:14:19 +0000 Subject: [PATCH 1/1] add configure options and fixes for cross-compiling --- configure | 67 +++++++++++++++------------ src/mlt++/configure | 2 +- src/modules/qimage/configure | 34 +++++++------- src/modules/swfdec/Makefile | 2 +- src/modules/videostab/stab/estimate.c | 2 +- 5 files changed, 58 insertions(+), 49 deletions(-) diff --git a/configure b/configure index 89307f34..8ae178f0 100755 --- a/configure +++ b/configure @@ -27,6 +27,8 @@ General build options: --disable-sse2 - Compile without SSE2 support (default: on) --arch='arch' - Compile for a specific architecture (default: none) --cpu='cpu' - Compile for a specific CPU (default: none) + --target-os='os' - Cross-compile to a specific OS (default: $(uname -s)) + --target-arch='arch' - Cross-compile to a specific CPU architecture Module disable options: @@ -69,6 +71,7 @@ build_config() echo "LARGE_FILE=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" + [ "$amd64" = "true" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64" [ "$arch" != "" ] && echo "TARGETARCH=-march=$arch" [ "$cpu" != "" ] && echo "TARGETCPU=-mcpu=$cpu" if [ "$optimisations" = "true" ] @@ -84,13 +87,11 @@ build_config() case $targetos in Darwin) - sysctl -a hw | grep "x86_64: 1" > /dev/null && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64" echo "CFLAGS+=-fPIC -D__DARWIN__ `sdl-config --cflags`" echo "SHFLAGS=-dynamiclib" echo "LDFLAGS+=`sdl-config --libs`" ;; Linux|GNU/kFreeBSD|GNU) - [ "$(uname -m)" = "x86_64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64" [ "$optimisations" = "true" ] && echo "OPTIMISATIONS+=-ffast-math" echo "CFLAGS+=-fPIC -pthread" @@ -100,7 +101,6 @@ build_config() echo "LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed" ;; FreeBSD) - [ "$(uname -m)" = "amd64" -o "$(uname -m)" = "x86_64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64" [ "$optimisations" = "true" ] && echo "OPTIMISATIONS+=-ffast-math" echo "CFLAGS+=-fPIC -pthread" @@ -109,7 +109,6 @@ build_config() echo "LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed" ;; NetBSD) - [ "$(uname -m)" = "amd64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64" [ "$optimisations" = "true" ] && echo "OPTIMISATIONS+=-ffast-math" echo "CFLAGS+=-pthread" @@ -118,7 +117,6 @@ build_config() echo "LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed" ;; MinGW) - [ "$(uname -m)" = "x86_64" ] && echo "ARCH_X86_64=1" && echo "CFLAGS+=-DARCH_X86_64" [ "$optimisations" = "true" ] && echo "OPTIMISATIONS+=-ffast-math" echo "SHFLAGS=-shared" @@ -193,33 +191,15 @@ export gpl=false export gpl3=false export arch= export cpu= -export targetos= - -# Determine OS -targetos=$(uname -s) -# Chose appropriate suffix for libraries -case $targetos in - Darwin) - LIBSUF=".dylib" - ;; - Linux|FreeBSD|NetBSD) - LIBSUF=".so" - ;; - MINGW32_NT-*) - targetos="MinGW" - LIBSUF=".dll" - ;; - *) - LIBSUF=".so" - ;; -esac -export LIBSUF +export targetos=$(uname -s) +export targetarch= +export amd64=false # Iterate through arguments for i in "$@" do case $i in - --help ) help=1 ;; + --help ) help=1 ;; --prefix=* ) prefix="${i#--prefix=}" ;; --libdir=* ) libdir="${i#--libdir=}" ;; --datadir=* ) datadir="${i#--datadir=}" ;; @@ -231,11 +211,40 @@ do --disable-sse2 ) sse2=false ;; --enable-gpl ) gpl=true ;; --enable-gpl3 ) gpl3=true ;; - --arch=* ) arch="${i#--arch=}" ;; - --cpu=* ) cpu="${i#--cpu=}" ;; + --arch=* ) arch="${i#--arch=}" ;; + --cpu=* ) cpu="${i#--cpu=}" ;; + --target-os=* ) targetos="${i#--target-os=}" ;; + --target-arch=* ) targetarch="${i#--target-arch=}" ;; esac done +# Chose appropriate suffix for libraries +case $targetos in + Darwin) + LIBSUF=".dylib" + if [ "$targetarch" = "" ] + then + sysctl -a hw | grep "x86_64: 1" > /dev/null + [ "$?" = "0" ] && targetarch="amd64" + fi + ;; + Linux|FreeBSD|NetBSD) + LIBSUF=".so" + ;; + MINGW32_NT-*|MinGW|mingw) + targetos="MinGW" + LIBSUF=".dll" + ;; + *) + LIBSUF=".so" + ;; +esac +export LIBSUF + +# Determine if we are compiling for 64-bit Intel architecture +[ "$targetarch" = "" ] && targetarch=$(uname -m) +[ "$targetarch" = "amd64" -o "$targetarch" = "x86_64" ] && amd64=true + # Determine the libdir if it's not specified in the args [ "$libdir" = "" ] && libdir=$prefix/lib [ "$datadir" = "" ] && datadir=$prefix/share diff --git a/src/mlt++/configure b/src/mlt++/configure index 98e470af..0a4d37a1 100755 --- a/src/mlt++/configure +++ b/src/mlt++/configure @@ -18,6 +18,6 @@ case $targetos in MinGW) echo LIBSUF=.dll echo "CXXFLAGS+=-Wall $WARNINGS -DPIC" - echo "LIBFLAGS=-enable-auto-import -shared" + echo "LIBFLAGS=-Wl,-enable-auto-import -shared" ;; esac >> config.mak diff --git a/src/modules/qimage/configure b/src/modules/qimage/configure index d97aad56..b8560685 100755 --- a/src/modules/qimage/configure +++ b/src/modules/qimage/configure @@ -31,8 +31,8 @@ else ;; esac - qimage_includedir=/usr/include/qt4 - qimage_libdir=/usr/lib/qt4 + qimage_includedir= + qimage_libdir= if [ ! -d "$qimage_libdir" -o ! -d "$qimage_includedir" ] then @@ -95,19 +95,8 @@ else fi fi - pkg-config --exists 'QtGui >= 4' - if [ $? -eq 0 ] && [ "$force_qt3" = "" ] + if [ -d "$qimage_libdir" -a -d "$qimage_includedir" ] then - echo "Qt version 4.x detected, will compile Qt4 qimage producer" - qt4_found=true - echo "#define USE_QT4" >> config.h - echo "USE_QT4=1" >> config.mak - echo QTCXXFLAGS=$(pkg-config --cflags QtCore QtGui QtXml QtSvg ) >> config.mak - echo QTLIBS=$(pkg-config --libs QtCore QtGui QtXml QtSvg) >> config.mak - - elif [ -d "$qimage_libdir" -a -d "$qimage_includedir" ] - then - # test if we have a Qt3 or Qt4 if [ -f "$qimage_libdir/libQtCore.so" ] || [ -d "$qimage_libdir/QtGui.framework" ] || [ -f "$qimage_libdir/libQtCore4.a" ] && [ "$force_qt3" = "" ] then @@ -130,7 +119,7 @@ else elif [ -f "$qimage_libdir/libQtCore4.a" ] then echo QTCXXFLAGS=-I$qimage_includedir >> config.mak - echo QTLIBS=-enable-auto-import -L$qimage_libdir -lQtCore4 -lQtGui4 -lQtXml4 -lQtSvg4 >> config.mak + echo QTLIBS=-Wl,-enable-auto-import -L$qimage_libdir -lQtCore4 -lQtGui4 -lQtXml4 -lQtSvg4 >> config.mak else echo QTCXXFLAGS=-I$qimage_includedir >> config.mak echo QTLIBS=-L$qimage_libdir -lQtCore -lQtGui -lQtXml -lQtSvg >> config.mak @@ -153,8 +142,19 @@ else fi fi else - echo "qimage: QT environment not found - disabling" - touch ../disable-qimage + pkg-config --exists 'QtGui >= 4' + if [ $? -eq 0 ] && [ "$force_qt3" = "" ] + then + echo "Qt version 4.x detected, will compile Qt4 qimage producer" + qt4_found=true + echo "#define USE_QT4" >> config.h + echo "USE_QT4=1" >> config.mak + echo QTCXXFLAGS=$(pkg-config --cflags QtCore QtGui QtXml QtSvg ) >> config.mak + echo QTLIBS=$(pkg-config --libs QtCore QtGui QtXml QtSvg) >> config.mak + else + echo "qimage: QT environment not found - disabling" + touch ../disable-qimage + fi fi [ "$gpl3" = "true" ] && echo GPL3=1 >> config.mak exit 0 diff --git a/src/modules/swfdec/Makefile b/src/modules/swfdec/Makefile index 32d5d5d4..e6839e73 100644 --- a/src/modules/swfdec/Makefile +++ b/src/modules/swfdec/Makefile @@ -10,7 +10,7 @@ TARGET = ../libmltswfdec$(LIBSUF) OBJS = producer_swfdec.o ifeq ($(targetos), MinGW) -LDFLAGS += -enable-auto-import -lz +LDFLAGS += -Wl,enable-auto-import -lz endif SRCS := $(OBJS:.o=.c) diff --git a/src/modules/videostab/stab/estimate.c b/src/modules/videostab/stab/estimate.c index 8d39cec6..15851535 100644 --- a/src/modules/videostab/stab/estimate.c +++ b/src/modules/videostab/stab/estimate.c @@ -18,7 +18,7 @@ #include #include #include -#if !defined(__DARWIN__) && !defined(__FreeBSD__) +#if !defined(__DARWIN__) && !defined(__FreeBSD__) && !defined(WIN32) #include #endif -- 2.39.2