From: Team LibreELEC - https://LibreELEC.tv
Subject: adjust Tvheadend ffmpeg build to work with LibreELEC (transcoding) 07.05.2016

---

diff --git a/Makefile.ffmpeg b/Makefile.ffmpeg
--- a/Makefile.ffmpeg
+++ b/Makefile.ffmpeg
@@ -24,6 +24,9 @@ FFMPEG_HOST   := $(ARCH)-linux-gnu
 FFMPEG_TARGET := x86-linux-gcc
 endif
 
+FFMPEG_HOST   := $(ARCH)-libreelec-linux-gnu
+FFMPEG_TARGET := $(ARCH)-libreelec-linux-gnu
+
 unexport CFLAGS
 unexport LDFLAGS
 
@@ -145,7 +148,7 @@ $(LIB_ROOT)/$(YASM)/.tvh_download:
 
 $(LIB_ROOT)/$(YASM)/.tvh_build: \
 		$(LIB_ROOT)/$(YASM)/.tvh_download
-	cd $(LIB_ROOT)/$(YASM) && $(CONFIGURE)
+	cd $(LIB_ROOT)/$(YASM) && $(CONFIGURE) CC=$(HOST_CC)
 	DESTDIR=$(EBUILDIR) \
 		$(MAKE) -C $(LIB_ROOT)/$(YASM) install
 	@touch $@
@@ -238,6 +241,7 @@ $(LIB_ROOT)/$(LIBX265)/.tvh_build: \
 	cd $(LIB_ROOT)/$(LIBX265)/build/linux && cmake -G "Unix Makefiles" \
 		-DCMAKE_INSTALL_PREFIX="/ffmpeg" \
 		-DENABLE_SHARED:BOOL=OFF \
+		-DEXTRA_LINK_FLAGS="-ldl" \
 		../../source
 	DESTDIR=$(EBUILDIR) \
 		$(MAKE) -C $(LIB_ROOT)/$(LIBX265)/build/linux install
@@ -271,7 +275,7 @@ endif
 ifeq (yes,$(CONFIG_LIBVPX_STATIC))
 
 ifneq (,$(FFMPEG_TARGET))
-LIBVPX_TARGET := --target=$(FFMPEG_TARGET)
+LIBVPX_TARGET := --target=generic-gnu
 endif
 
 $(LIB_ROOT)/$(LIBVPX)/.tvh_download:
@@ -283,7 +287,7 @@ $(LIB_ROOT)/$(LIBVPX)/.tvh_build: \
 		$(LIB_ROOT)/$(YASM)/.tvh_build \
 		$(LIB_ROOT)/$(LIBVPX)/.tvh_download
 	cd $(LIB_ROOT)/$(LIBVPX) && \
-		ASFLAGS="-DENABLE_PIC=1 -DPIC=1" $(CONFIGURE) \
+		ASFLAGS="-DENABLE_PIC=1 -DPIC=1" CROSS=$(FFMPEG_TARGET)- $(CONFIGURE) \
 		--extra-cflags="$(CFLAGS_PI)" \
 		--disable-examples \
 		--disable-docs \
@@ -359,7 +363,8 @@ $(LIB_ROOT)/$(LIBTHEORA)/.tvh_build: \
 		$(LIB_ROOT)/$(LIBTHEORA)/.tvh_download
 	cd $(LIB_ROOT)/$(LIBTHEORA) && \
 		CFLAGS="$(CFLAGS_PI)" $(CONFIGURE) \
-		--with-ogg=$(EPREFIX) \
+		OGG_CFLAGS=-I$(EPREFIX)/include \
+		OGG_LIBS=-L$(EPREFIX)/lib \
 		--disable-examples \
 		--disable-spec \
 		$(LIBTHEORA_HOST)
@@ -406,7 +411,8 @@ $(LIB_ROOT)/$(LIBVORBIS)/.tvh_build: \
 		$(LIB_ROOT)/$(LIBVORBIS)/.tvh_download
 	cd $(LIB_ROOT)/$(LIBVORBIS) && \
 		CFLAGS="$(CFLAGS_PI)" $(CONFIGURE) \
-		--with-ogg=$(EPREFIX)
+		OGG_CFLAGS=-I$(EPREFIX)/include \
+		OGG_LIBS=-L$(EPREFIX)/lib
 	DESTDIR=$(EBUILDIR) \
 		$(MAKE) -C $(LIB_ROOT)/$(LIBVORBIS) install
 	@touch $@
@@ -559,6 +565,8 @@ $(LIB_ROOT)/$(FFMPEG)/.tvh_build: \
 		$(LIB_ROOT)/$(LIBMFX)/.tvh_build \
 		$(LIB_ROOT)/$(FFMPEG)/.tvh_download
 	cd $(LIB_ROOT)/$(FFMPEG) && $(CONFIGURE) \
+		--cc=$(FFMPEG_HOST)-gcc \
+		--cxx=$(FFMPEG_HOST)-g++ \
 		--disable-all \
 		--enable-gpl \
 		--extra-cflags="$(ECFLAGS)" \
