]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
build: add libffmpeg_static=yes and Makefile.ffmpeg
authorJaroslav Kysela <perex@perex.cz>
Mon, 13 Oct 2014 07:55:17 +0000 (09:55 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 13 Oct 2014 07:55:17 +0000 (09:55 +0200)
.gitignore
Makefile
Makefile.ffmpeg [new file with mode: 0644]
configure

index 77a330519ba7c6b8d5f8f7155dcb5b7c334d35da..191c2fee7db8c5f50a62e688bb07d9dab62606cf 100644 (file)
@@ -5,6 +5,8 @@ src/version.c
 
 data/dvb-scan
 
+libav_static
+
 .cproject
 .project
 nbproject
index 830f62c2f76267ad54e51903d40582c00434592b..e917d12117b35ac82df857f609c5b7984203504c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -49,6 +49,14 @@ LDFLAGS += -lrt
 endif
 endif
 
+ifeq ($(CONFIG_LIBFFMPEG_STATIC),yes)
+CFLAGS  += -I${ROOTDIR}/libav_static/build/ffmpeg/include
+LDFLAGS += -L${ROOTDIR}/libav_static/build/ffmpeg/lib -Wl,-Bstatic \
+           -lavresample -lswresample -lswscale -lavformat -lavcodec -lavutil \
+           -lvorbisenc -lvorbis -logg -lx264 -lvpx \
+           -Wl,-Bdynamic
+endif
+
 ifeq ($(COMPILER), clang)
 CFLAGS  += -Wno-microsoft -Qunused-arguments -Wno-unused-function
 CFLAGS  += -Wno-unused-value -Wno-tautological-constant-out-of-range-compare
@@ -332,6 +340,9 @@ BUNDLES-${CONFIG_DVBSCAN} += data/dvb-scan
 BUNDLES                    = $(BUNDLES-yes)
 ALL-$(CONFIG_DVBSCAN)     += check_dvb_scan
 
+# Static libav
+ALL-$(CONFIG_LIBFFMPEG_STATIC) += ${ROOTDIR}/libav_static/build/ffmpeg/lib/libavcodec.a
+
 #
 # Add-on modules
 #
@@ -387,6 +398,7 @@ clean:
        find . -name "*~" | xargs rm -f
 
 distclean: clean
+       rm -rf ${ROOTDIR}/libav_static
        rm -rf ${ROOTDIR}/build.*
        rm -f ${ROOTDIR}/.config.mk
 
@@ -411,12 +423,16 @@ $(BUILDDIR)/bundle.c: check_dvb_scan
        @mkdir -p $(dir $@)
        $(MKBUNDLE) -o $@ -d ${BUILDDIR}/bundle.d $(BUNDLE_FLAGS) $(BUNDLES:%=$(ROOTDIR)/%)
 
+# Static FFMPEG
+${ROOTDIR}/libav_static/build/ffmpeg/lib/libavcodec.a:
+       $(MAKE) -f Makefile.ffmpeg build
+
 # linuxdvb git tree
 $(ROOTDIR)/data/dvb-scan/.stamp:
        @echo "Receiving data/dvb-scan/dvb-t from http://linuxtv.org/git/dtv-scan-tables.git"
        @rm -rf $(ROOTDIR)/data/dvb-scan/*
        @$(ROOTDIR)/support/getmuxlist $(ROOTDIR)/data/dvb-scan
-       @touch $(ROOTDIR)/data/dvb-scan/.stamp
+       @touch $@
 
 .PHONY: check_dvb_scan
 check_dvb_scan: $(ROOTDIR)/data/dvb-scan/.stamp
diff --git a/Makefile.ffmpeg b/Makefile.ffmpeg
new file mode 100644 (file)
index 0000000..1521bc4
--- /dev/null
@@ -0,0 +1,177 @@
+#
+#  Static Audio/Video libs (ffmpeg version) build
+#  Copyright (C) 2014 Jaroslav Kysela
+#
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+include $(dir $(lastword $(MAKEFILE_LIST))).config.mk
+
+define DOWNLOAD
+       @mkdir -p $(LIBAVDIR)/build
+       wget -O $(2) $(1)
+endef
+
+define UNTAR
+       tar x -C $(LIBAVDIR) -$(2)f $(LIBAVDIR)/$(1)
+endef
+
+LIBAVDIR = $(ROOTDIR)/libav_static
+
+ECFLAGS         = -I$(LIBAVDIR)/build/ffmpeg/include
+ELIBS           = -L$(LIBAVDIR)/build/ffmpeg/lib -ldl
+
+FFMPEG          = ffmpeg-2.4.2
+FFMPEG_TB       = $(FFMPEG).tar.bz2
+FFMPEG_URL      = http://ffmpeg.org/releases/$(FFMPEG_TB)
+
+EXTLIBS         = libx264 libvorbis libvpx
+COMPONENTS      = avutil avformat avcodec swresample swscale avresample
+DECODERS        = mpeg2video mp2 h264 h264_vdpau aac aac_latm vorbis libvorbis
+ENCODERS        = mpeg2video mp2 libx264 libvpx_vp8 libvpx_vp9 aac libaacplus vorbis libvorbis
+MUXERS          = mpegts mpeg2dvd
+
+LIBOGG          = libogg-1.3.2
+LIBOGG_TB       = $(LIBOGG).tar.gz
+LIBOGG_URL      = http://downloads.xiph.org/releases/ogg/$(LIBOGG_TB)
+
+LIBVORBIS       = libvorbis-1.3.4
+LIBVORBIS_TB    = $(LIBVORBIS).tar.gz
+LIBVORBIS_URL   = http://downloads.xiph.org/releases/vorbis/$(LIBVORBIS_TB)
+
+LIBX264         = last_x264
+LIBX264_TB      = $(LIBX264).tar.bz2
+LIBX264_URL     = ftp://ftp.videolan.org/pub/x264/snapshots/$(LIBX264_TB)
+
+LIBVPX          = libvpx-v1.3.0
+LIBVPX_TB       = $(LIBVPX).tar.bz2
+LIBVPX_URL      = https://webm.googlecode.com/files/$(LIBVPX_TB)
+
+.PHONY: build
+build: $(LIBAVDIR)/$(FFMPEG)/.tvh_build
+
+#
+# libogg & libvorbis
+#
+
+$(LIBAVDIR)/$(LIBOGG)/.tvh_download:
+       $(call DOWNLOAD,$(LIBOGG_URL),$(LIBAVDIR)/$(LIBOGG_TB))
+       $(call UNTAR,$(LIBOGG_TB),z)
+       @touch $@
+
+$(LIBAVDIR)/$(LIBOGG)/.tvh_build: \
+               $(LIBAVDIR)/$(LIBOGG)/.tvh_download
+       cd $(LIBAVDIR)/$(LIBOGG) && ./configure \
+                --prefix=/ffmpeg \
+               --enable-static \
+               --disable-shared
+       DESTDIR=$(LIBAVDIR)/build make -C $(LIBAVDIR)/$(LIBOGG) install
+       @touch $@
+
+$(LIBAVDIR)/$(LIBVORBIS)/.tvh_download: \
+               $(LIBAVDIR)/$(LIBOGG)/.tvh_download
+       $(call DOWNLOAD,$(LIBVORBIS_URL),$(LIBAVDIR)/$(LIBVORBIS_TB))
+       $(call UNTAR,$(LIBVORBIS_TB),z)
+       @touch $@
+
+$(LIBAVDIR)/$(LIBVORBIS)/.tvh_build: \
+               $(LIBAVDIR)/$(LIBVORBIS)/.tvh_download \
+               $(LIBAVDIR)/$(LIBOGG)/.tvh_build
+       cd $(LIBAVDIR)/$(LIBVORBIS) && ./configure \
+               --prefix=/ffmpeg \
+               --enable-static \
+               --disable-shared \
+               --with-ogg=$(LIBAVDIR)/build/ffmpeg
+       DESTDIR=$(LIBAVDIR)/build make -C $(LIBAVDIR)/$(LIBVORBIS) install
+       @touch $@
+
+#
+# libx264
+#
+
+$(LIBAVDIR)/$(LIBX264)/.tvh_download:
+       $(call DOWNLOAD,$(LIBX264_URL),$(LIBAVDIR)/$(LIBX264_TB))
+       rm -rf $(LIBAVDIR)/x264-snapshot-*
+       $(call UNTAR,$(LIBX264_TB),j)
+       { ln -sf $$(basename $(LIBAVDIR)/x264-snapshot-*) $(LIBAVDIR)/$(LIBX264); }
+       @touch $@
+
+$(LIBAVDIR)/$(LIBX264)/.tvh_build: \
+               $(LIBAVDIR)/$(LIBX264)/.tvh_download
+       cd $(LIBAVDIR)/$(LIBX264) && ./configure \
+               --prefix=/ffmpeg \
+               --enable-static \
+               --disable-shared \
+               --disable-avs \
+               --disable-swscale \
+               --disable-lavf \
+               --disable-ffms \
+               --disable-gpac \
+               --disable-lsmash
+       DESTDIR=$(LIBAVDIR)/build make -C $(LIBAVDIR)/$(LIBX264) install
+       @touch $@
+
+#
+# libvpx (VP8)
+#
+
+$(LIBAVDIR)/$(LIBVPX)/.tvh_download:
+       @mkdir -p $(LIBAVDIR)
+       $(call DOWNLOAD,$(LIBVPX_URL),$(LIBAVDIR)/$(LIBVPX_TB))
+       $(call UNTAR,$(LIBVPX_TB),j)
+       @touch $@
+
+$(LIBAVDIR)/$(LIBVPX)/.tvh_build: \
+               $(LIBAVDIR)/$(LIBVPX)/.tvh_download
+       cd $(LIBAVDIR)/$(LIBVPX) && ./configure \
+               --prefix=/ffmpeg \
+               --enable-static \
+               --disable-shared
+       DIST_DIR=$(LIBAVDIR)/build/ffmpeg make -C $(LIBAVDIR)/$(LIBVPX) install
+       @touch $@
+
+#
+# FFMPEG
+#
+
+$(LIBAVDIR)/$(FFMPEG)/.tvh_download:
+       @mkdir -p $(LIBAVDIR)/build
+       $(call DOWNLOAD,$(FFMPEG_URL),$(LIBAVDIR)/$(FFMPEG_TB))
+       $(call UNTAR,$(FFMPEG_TB),j)
+       @touch $@
+
+$(LIBAVDIR)/$(FFMPEG)/.tvh_build: \
+               $(LIBAVDIR)/$(LIBVORBIS)/.tvh_build \
+               $(LIBAVDIR)/$(LIBX264)/.tvh_build \
+               $(LIBAVDIR)/$(LIBVPX)/.tvh_build \
+               $(LIBAVDIR)/$(FFMPEG)/.tvh_download
+       cd $(LIBAVDIR)/$(FFMPEG) && ./configure \
+                --prefix=/ffmpeg \
+               --disable-all \
+               --enable-static \
+               --disable-shared \
+               --enable-gpl \
+               --extra-cflags="$(ECFLAGS)" \
+               --extra-libs="$(ELIBS)" \
+               $(foreach extlib,$(EXTLIBS),--enable-$(extlib)) \
+               $(foreach component,$(COMPONENTS),--enable-$(component)) \
+               $(foreach decoder,$(DECODERS),--enable-decoder=$(decoder)) \
+               $(foreach encoder,$(ENCODERS),--enable-encoder=$(encoder)) \
+               $(foreach muxer,$(MUXERS),--enable-muxer=$(muxer))
+       DESTDIR=$(LIBAVDIR)/build make -C $(LIBAVDIR)/$(FFMPEG) install
+       @touch $@
+
+.PHONY: static_libav_clean
+static_libav_clean:
+       @rm -rf $(LIBAVDIR)
index b4bd5f72988e3b4a483283d85430e007e8c193c9..a0dd0b3768a434d2cbc5a2749f1b23a0fedacf5d 100755 (executable)
--- a/configure
+++ b/configure
@@ -31,6 +31,7 @@ OPTIONS=(
   "avahi:auto"
   "zlib:auto"
   "libav:auto"
+  "libffmpeg_static:yes"
   "inotify:auto"
   "epoll:auto"
   "uriparser:auto"
@@ -276,34 +277,43 @@ fi
 #
 # libav
 #
-if enabled_or_auto libav; then
+if enabled libffmpeg_static; then
+
+  enable libav
   has_libav=true
 
-  if $has_libav && ! check_pkg libavcodec ">=52.96.0"; then
-    has_libav=false
-  fi
+else
 
-  if $has_libav && ! check_pkg libavutil ">=50.43.0"; then
-    has_libav=false
-  fi
+  if enabled_or_auto libav; then
+    has_libav=true
 
-  if $has_libav && ! check_pkg libavformat ">=53.10.0"; then
-    has_libav=false
-  fi
+    if $has_libav && ! check_pkg libavcodec ">=52.96.0"; then
+      has_libav=false
+    fi
 
-  if $has_libav && ! check_pkg libswscale ">=0.13.0"; then
-    has_libav=false
-  fi
+    if $has_libav && ! check_pkg libavutil ">=50.43.0"; then
+      has_libav=false
+    fi
 
-  if $has_libav && ! check_pkg libavresample ">=1.1.0"; then
-    has_libav=false
-  fi
+    if $has_libav && ! check_pkg libavformat ">=53.10.0"; then
+      has_libav=false
+    fi
+
+    if $has_libav && ! check_pkg libswscale ">=0.13.0"; then
+      has_libav=false
+    fi
 
-  if $has_libav; then
-    enable libav
-  elif enabled libav; then
-    die "libav development support not found (use --disable-libav)"
+    if $has_libav && ! check_pkg libavresample ">=1.1.0"; then
+      has_libav=false
+    fi
+
+    if $has_libav; then
+      enable libav
+    elif enabled libav; then
+      die "libav development support not found (use --disable-libav)"
+    fi
   fi
+
 fi
 
 #