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

---

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -97,50 +97,65 @@ FFMPEG_CONFIG := \
     PKG_CONFIG_LIBDIR=$(FFMPEG_LIBDIR)/pkgconfig $(PKG_CONFIG) \
     --define-variable=prefix=$(FFMPEG_PREFIX) --static
 
+CFLAGS  += -I${FFMPEG_PREFIX}/include
+LDFLAGS += ${FFMPEG_LIBDIR}/libavfilter.a
+LDFLAGS += ${FFMPEG_LIBDIR}/libswresample.a
+LDFLAGS += ${FFMPEG_LIBDIR}/libavresample.a
+LDFLAGS += ${FFMPEG_LIBDIR}/libswscale.a
+LDFLAGS += ${FFMPEG_LIBDIR}/libavformat.a
+LDFLAGS += ${FFMPEG_LIBDIR}/libavcodec.a
+LDFLAGS += ${FFMPEG_LIBDIR}/libavutil.a
+
 ifeq ($(CONFIG_LIBX264_STATIC),yes)
 FFMPEG_DEPS += libx264
+LDFLAGS += ${FFMPEG_LIBDIR}/libx264.a
 endif
 
 ifeq ($(CONFIG_LIBX265_STATIC),yes)
 FFMPEG_DEPS += libx265
+LDFLAGS += ${FFMPEG_LIBDIR}/libx265.a
 endif
 
 ifeq ($(CONFIG_LIBVPX_STATIC),yes)
 FFMPEG_DEPS += libvpx
+LDFLAGS += ${FFMPEG_LIBDIR}/libvpx.a
 endif
 
 ifeq ($(CONFIG_LIBOGG_STATIC),yes)
 FFMPEG_DEPS += libogg
+LDFLAGS += ${FFMPEG_LIBDIR}/libogg.a
 endif
 
 ifeq ($(CONFIG_LIBTHEORA_STATIC),yes)
 FFMPEG_DEPS += libtheoraenc libtheoradec libtheora
+LDFLAGS += ${FFMPEG_LIBDIR}/libtheora.a
+LDFLAGS += ${FFMPEG_LIBDIR}/libtheoradec.a
+LDFLAGS += ${FFMPEG_LIBDIR}/libtheoraenc.a
 endif
 
 ifeq ($(CONFIG_LIBVORBIS_STATIC),yes)
 FFMPEG_DEPS += libvorbisfile libvorbisenc libvorbis
+LDFLAGS += ${FFMPEG_LIBDIR}/libvorbis.a
+LDFLAGS += ${FFMPEG_LIBDIR}/libvorbisenc.a
+LDFLAGS += ${FFMPEG_LIBDIR}/libvorbisfile.a
 endif
 
 ifeq ($(CONFIG_LIBFDKAAC_STATIC),yes)
 FFMPEG_DEPS += libfdk-aac
+LDFLAGS += ${FFMPEG_LIBDIR}/libfdk-aac.a
 endif
 
 ifeq ($(CONFIG_LIBMFX_STATIC),yes)
 FFMPEG_DEPS += libmfx
+LDFLAGS += ${FFMPEG_LIBDIR}/libmfx.a
 endif
 
-LDFLAGS += $(foreach lib,$(FFMPEG_LIBS),$(FFMPEG_LIBDIR)/$(lib).a)
-LDFLAGS += $(foreach lib,$(FFMPEG_DEPS),$(FFMPEG_LIBDIR)/$(lib).a)
-
 else # !FFMPEG_STATIC
 
 FFMPEG_CONFIG := $(PKG_CONFIG)
 
 endif # FFMPEG_STATIC
 
-CFLAGS  += `$(FFMPEG_CONFIG) --cflags $(FFMPEG_LIBS)`
-LDFLAGS += `$(FFMPEG_CONFIG) --libs $(FFMPEG_LIBS)`
-
 endif
 
 # LIBAV ########################################################################
@@ -613,7 +628,7 @@ reconfigure:
 
 # Binary
 ${PROG}: .config.mk make_webui $(OBJS)
-	$(pCC) -o $@ $(OBJS) $(CFLAGS) $(LDFLAGS)
+	$(CXX) -o $@ $(OBJS) $(CFLAGS) $(LDFLAGS)
 
 # Object
 ${BUILDDIR}/%.o: %.c
