Skip to content
Browse files

linux: link ffmpeg statically

  • Loading branch information...
1 parent e211654 commit 974a3c0e97b817ca358a959a026db95330673642 @FernetMenta FernetMenta committed Jan 11, 2014
Showing with 57 additions and 15 deletions.
  1. +11 −0 Makefile.in
  2. +18 −1 configure.in
  3. +2 −2 lib/DllAvCodec.h
  4. +1 −1 lib/DllAvFilter.h
  5. +4 −4 lib/DllAvFormat.h
  6. +2 −2 lib/DllAvUtil.h
  7. +1 −1 lib/DllPostProc.h
  8. +2 −2 lib/DllSwResample.h
  9. +2 −2 lib/DllSwScale.h
  10. +14 −0 lib/Makefile.in
View
11 Makefile.in
@@ -488,6 +488,17 @@ ifeq ($(findstring freebsd,@ARCH@),freebsd)
DYNOBJSXBMC+= xbmc/freebsd/freebsd.a
endif
+ifeq (@USE_STATIC_FFMPEG@,1)
+DYNOBJSXBMC += lib/ffmpeg/libavcodec/libavcodec.a \
+ lib/ffmpeg/libavfilter/libavfilter.a \
+ lib/ffmpeg/libswresample/libswresample.a \
+ lib/ffmpeg/libavformat/libavformat.a \
+ lib/ffmpeg/libavutil/libavutil.a \
+ lib/ffmpeg/libpostproc/libpostproc.a \
+ lib/ffmpeg/libswscale/libswscale.a
+LIBS+= @GNUTLS_ALL_LIBS@ @VORBISENC_ALL_LIBS@
+endif
+
OBJSXBMC:=$(filter-out $(DYNOBJSXBMC), $(OBJSXBMC))
MAINOBJS=xbmc/xbmc.o
View
19 configure.in
@@ -598,6 +598,7 @@ MAKE="${MAKE:-make}"
OBJDUMP="${OBJDUMP:-objdump}"
use_external_ffmpeg=no
+use_static_ffmpeg=no
# ffmpeg needs the output of uname -s (e.x. linux, darwin) for the target_os
# there is no autoconf variable which will give
@@ -627,13 +628,17 @@ case $host in
if test "$use_cpu" = "no" -a "$cross_compiling" = "yes"; then
use_arch="x86"
use_cpu="i686"
+ else
+ target_platform=target_linux
fi
;;
x86_64-*-linux-gnu*|x86_64-*-linux-uclibc*)
ARCH="x86_64-linux"
if test "$use_cpu" = "no" -a "$cross_compiling" = "yes"; then
use_arch="x86_64"
use_cpu="x86_64"
+ else
+ target_platform=target_linux
fi
;;
i386-*-freebsd*)
@@ -867,6 +872,15 @@ elif test "$use_arch" = "arm"; then
fi
fi
fi
+if test "$target_platform" = "target_linux"; then
@Fneufneu
Team Kodi member
Fneufneu added a note Feb 4, 2014

this stuff is not target linux specific, it's needed for ffmpeg static building.
so it's better to have:

if [ "$use_static_ffmpeg" = "yes" ]; then

and i think i'll add use_static_ffmpeg=yes for FreeBSD all well.

@wsnipex
Team Kodi member
wsnipex added a note Feb 4, 2014

indeed. The current state probably also breaks libxbmc.so on linux

@FernetMenta
Team Kodi member
FernetMenta added a note Feb 4, 2014

use_static_ffmeg is set some lines down from here and can't be used for comparison here.

@wsnipex
Team Kodi member
wsnipex added a note Feb 4, 2014

this should work:
set use_static_ffmeg instead of target_platform=target_linux on lines 632 and 641, then here test this instead:
if test "$use_static_ffmpeg" = "yes" -a "$use_shared_lib" != "yes";

@sraue
Team Kodi member
sraue added a note Feb 5, 2014

added in #4154 (partly, which means i dont have tested with libxbmc.so and dont enabled static building on platformas other then i*86, x86_64, arm)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ USE_STATIC_FFMPEG=1
+ use_static_ffmpeg=yes
+ AC_DEFINE([USE_STATIC_FFMPEG], [1], [link ffmpeg statically])
+ # ffmpeg may depend on gnutls and vorbisenc, we add those libs at the end of linker
+ # command in order to resolve any missing symbols
+ GNUTLS_ALL_LIBS=`${PKG_CONFIG} --static --libs-only-l --silence-errors gnutls`
+ VORBISENC_ALL_LIBS=`${PKG_CONFIG} --static --libs-only-l --silence-errors vorbisenc`
+fi
# Checks for library functions.
AC_FUNC_ALLOCA
@@ -2601,6 +2615,7 @@ AC_SUBST(DISABLE_FISHBMC)
AC_SUBST(DISABLE_PROJECTM)
AC_SUBST(USE_SKIN_TOUCHED)
AC_SUBST(USE_EXTERNAL_FFMPEG)
+AC_SUBST(USE_STATIC_FFMPEG)
AC_SUBST(USE_LIBAV_HACKS)
AC_SUBST(PYTHON_VERSION)
AC_SUBST(OUTPUT_FILES)
@@ -2645,6 +2660,8 @@ AC_SUBST(USE_ANDROID)
AC_SUBST(GTEST_CONFIGURED)
AC_SUBST(USE_DOXYGEN)
AC_SUBST(USE_PVR_ADDONS)
+AC_SUBST(GNUTLS_ALL_LIBS)
+AC_SUBST(VORBISENC_ALL_LIBS)
# pushd and popd are not available in other shells besides bash, so implement
# our own pushd/popd functions
@@ -2802,7 +2819,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
--disable-ffserver \
--disable-ffmpeg \
--disable-crystalhd \
- --enable-shared \
+ `if test "$use_static_ffmpeg" = "yes"; then echo --enable-static; else echo --enable-shared; fi` \
--disable-doc \
--enable-postproc \
--enable-gpl \
View
4 lib/DllAvCodec.h
@@ -94,7 +94,7 @@ class DllAvCodecInterface
virtual AVDictionary* av_frame_get_metadata(const AVFrame* frame)=0;
};
-#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG)
// Use direct layer
class DllAvCodec : public DllDynamic, DllAvCodecInterface
@@ -166,7 +166,7 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface
// DLL faking.
virtual bool ResolveExports() { return true; }
virtual bool Load() {
-#if !defined(TARGET_DARWIN)
+#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG)
CLog::Log(LOGDEBUG, "DllAvCodec: Using libavcodec system library");
#endif
return true;
View
2 lib/DllAvFilter.h
@@ -104,7 +104,7 @@ class DllAvFilterInterface
#endif
};
-#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG)
// Use direct mapping
class DllAvFilter : public DllDynamic, DllAvFilterInterface
{
View
8 lib/DllAvFormat.h
@@ -41,7 +41,7 @@ extern "C" {
void xbmc_read_frame_flush(AVFormatContext *s);
#else
#include "libavformat/avformat.h"
- #if defined(TARGET_DARWIN)
+ #if defined(TARGET_DARWIN) || defined(USE_STATIC_FFMPEG)
void ff_read_frame_flush(AVFormatContext *s); // internal replacement
#define xbmc_read_frame_flush ff_read_frame_flush
#endif
@@ -73,7 +73,7 @@ class DllAvFormatInterface
virtual int av_read_play(AVFormatContext *s)=0;
virtual int av_read_pause(AVFormatContext *s)=0;
virtual int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)=0;
-#if (!defined USE_EXTERNAL_FFMPEG) && (!defined TARGET_DARWIN)
+#if (!defined USE_EXTERNAL_FFMPEG) && (!defined TARGET_DARWIN) && (!defined USE_STATIC_FFMPEG)
virtual int avformat_find_stream_info_dont_call(AVFormatContext *ic, AVDictionary **options)=0;
#endif
virtual int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)=0;
@@ -108,7 +108,7 @@ class DllAvFormatInterface
#endif
};
-#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG)
// Use direct mapping
class DllAvFormat : public DllDynamic, DllAvFormatInterface
@@ -170,7 +170,7 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface
// DLL faking.
virtual bool ResolveExports() { return true; }
virtual bool Load() {
-#if !defined(TARGET_DARWIN)
+#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG)
CLog::Log(LOGDEBUG, "DllAvFormat: Using libavformat system library");
#endif
CSingleLock lock(DllAvCodec::m_critSection);
View
4 lib/DllAvUtil.h
@@ -116,7 +116,7 @@ class DllAvUtilInterface
#endif
};
-#if defined (USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
+#if defined (USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG)
// Use direct layer
class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
{
@@ -174,7 +174,7 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
// DLL faking.
virtual bool ResolveExports() { return true; }
virtual bool Load() {
-#if !defined(TARGET_DARWIN)
+#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG)
CLog::Log(LOGDEBUG, "DllAvUtilBase: Using libavutil system library");
#endif
return true;
View
2 lib/DllPostProc.h
@@ -78,7 +78,7 @@ class DllPostProcInterface
virtual void pp_free_context(pp_context *ppContext)=0;
};
-#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG)
// We call directly.
class DllPostProc : public DllDynamic, DllPostProcInterface
View
4 lib/DllSwResample.h
@@ -60,7 +60,7 @@ class DllSwResampleInterface
virtual int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensation_distance) = 0;
};
-#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG)
// Use direct mapping
class DllSwResample : public DllDynamic, DllSwResampleInterface
@@ -71,7 +71,7 @@ class DllSwResample : public DllDynamic, DllSwResampleInterface
// DLL faking.
virtual bool ResolveExports() { return true; }
virtual bool Load() {
-#if !defined(TARGET_DARWIN)
+#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG)
CLog::Log(LOGDEBUG, "DllAvFormat: Using libswresample system library");
#endif
return true;
View
4 lib/DllSwScale.h
@@ -87,7 +87,7 @@ class DllSwScaleInterface
virtual void sws_freeContext(struct SwsContext *context)=0;
};
-#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN) || (defined USE_STATIC_FFMPEG)
// We call into this library directly.
class DllSwScale : public DllDynamic, public DllSwScaleInterface
@@ -111,7 +111,7 @@ class DllSwScale : public DllDynamic, public DllSwScaleInterface
// DLL faking.
virtual bool ResolveExports() { return true; }
virtual bool Load() {
-#if !defined(TARGET_DARWIN)
+#if !defined(TARGET_DARWIN) && !defined(USE_STATIC_FFMPEG)
CLog::Log(LOGDEBUG, "DllSwScale: Using libswscale system library");
#endif
return true;
View
14 lib/Makefile.in
@@ -27,6 +27,7 @@ endif
LIBS=
ifneq (@USE_EXTERNAL_FFMPEG@,1)
+ifneq (@USE_STATIC_FFMPEG@,1)
LIBS+=$(AVUTIL_SO) \
$(AVCODEC_SO) \
$(AVFORMAT_SO) \
@@ -35,10 +36,12 @@ ifneq (@USE_EXTERNAL_FFMPEG@,1)
$(SWSCALE_SO) \
$(SWRESAMPLE_SO)
endif
+endif
.PHONY: $(DIRS) codecs
ifneq ($(findstring osx,$(ARCH)), osx)
+ifneq (@USE_STATIC_FFMPEG@,1)
codecs: $(addprefix $(SYSDIR)/, $(LIBS));
@@ -71,6 +74,17 @@ ffmpeg/libswscale/libswscale.so : ffmpeg;
ffmpeg/libpostproc/libpostproc.so : ffmpeg;
ffmpeg/libswresample/libswresample.so : ffmpeg;
endif
+endif
+
+ifeq (@USE_STATIC_FFMPEG@,1)
+ffmpeg/libavutil/libavutil.a : ffmpeg;
+ffmpeg/libavcodec/libavcodec.a : ffmpeg;
+ffmpeg/libavformat/libavformat.a : ffmpeg;
+ffmpeg/libavfilter/libavfilter.a : ffmpeg;
+ffmpeg/libswscale/libswscale.a : ffmpeg;
+ffmpeg/libpostproc/libpostproc.a : ffmpeg;
+ffmpeg/libswresample/libswresample.a : ffmpeg;
+endif
ffmpeg:
$(MAKE) -C $@

0 comments on commit 974a3c0

Please sign in to comment.
Something went wrong with that request. Please try again.