rules.mak 4.67 KB
Newer Older
1
FFMPEG_HASH := f7e9275f83ec116fc859367d61998eae8af438fc
2
FFMPEG_URL := https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/$(FFMPEG_HASH).tar.gz
Edric Milaret's avatar
Edric Milaret committed
3 4 5 6 7

ifdef HAVE_WIN32
PKGS += ffmpeg
endif

Alexandre Lision's avatar
Alexandre Lision committed
8 9 10 11
ifdef HAVE_MACOSX
PKGS += ffmpeg
endif

Philippe Gorley's avatar
Philippe Gorley committed
12 13 14 15
ifdef HAVE_LINUX
PKGS += ffmpeg
endif

Edric Milaret's avatar
Edric Milaret committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
FFMPEGCONF = \
		--cc="$(CC)" \
		--pkg-config="$(PKG_CONFIG)"

#disable everything
FFMPEGCONF += \
		--disable-everything \
		--enable-zlib \
		--enable-gpl \
		--enable-swscale \
		--enable-protocols \
		--disable-programs \
		--disable-sdl

#enable muxers/demuxers
FFMPEGCONF += \
		--enable-demuxers \
		--enable-muxers

#enable parsers
FFMPEGCONF += \
		--enable-parser=h263 \
		--enable-parser=h264 \
		--enable-parser=mpeg4video \
		--enable-parser=vp8

#librairies
43
ifndef HAVE_ANDROID
Adrien Béraud's avatar
Adrien Béraud committed
44
FFMPEGCONF += --enable-libx264
45
endif
Edric Milaret's avatar
Edric Milaret committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

#encoders/decoders
FFMPEGCONF += \
		--enable-encoder=adpcm_g722 \
		--enable-decoder=adpcm_g722 \
		--enable-encoder=rawvideo \
		--enable-decoder=rawvideo \
		--enable-encoder=libx264 \
		--enable-decoder=h264 \
		--enable-encoder=pcm_alaw \
		--enable-decoder=pcm_alaw \
		--enable-encoder=pcm_mulaw \
		--enable-decoder=pcm_mulaw \
		--enable-encoder=mpeg4 \
		--enable-decoder=mpeg4 \
		--enable-encoder=libvpx_vp8 \
		--enable-decoder=vp8 \
		--enable-encoder=h263 \
Éloi Bail's avatar
Éloi Bail committed
64
		--enable-encoder=h263p \
Edric Milaret's avatar
Edric Milaret committed
65 66 67 68
		--enable-decoder=h263 \
		--enable-encoder=mjpeg \
		--enable-decoder=mjpeg \
		--enable-decoder=mjpegb \
Edric Milaret's avatar
Edric Milaret committed
69 70
		--enable-libspeex \
		--enable-libopus \
Adrien Béraud's avatar
Adrien Béraud committed
71
		--enable-libvpx \
Edric Milaret's avatar
Edric Milaret committed
72
		--enable-encoder=libspeex \
Edric Milaret's avatar
Edric Milaret committed
73 74 75
		--enable-decoder=libspeex \
		--enable-encoder=libopus \
		--enable-decoder=libopus
Edric Milaret's avatar
Edric Milaret committed
76

77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
#encoders/decoders for images
FFMPEGCONF += \
		--enable-encoder=gif \
		--enable-decoder=gif \
		--enable-encoder=jpegls \
		--enable-decoder=jpegls \
		--enable-encoder=ljpeg \
		--enable-decoder=jpeg2000 \
		--enable-encoder=png \
		--enable-decoder=png \
		--enable-encoder=bmp \
		--enable-decoder=bmp \
		--enable-encoder=tiff \
		--enable-decoder=tiff

Alexandre Lision's avatar
Alexandre Lision committed
92 93
DEPS_ffmpeg = iconv zlib x264 vpx opus speex $(DEPS_vpx)

94
ifdef HAVE_WIN32
Edric Milaret's avatar
Edric Milaret committed
95 96
FFMPEGCONF += \
	--enable-indev=dshow \
97
	--enable-indev=gdigrab \
Edric Milaret's avatar
Edric Milaret committed
98
	--enable-dxva2
99
endif
Edric Milaret's avatar
Edric Milaret committed
100

Philippe Gorley's avatar
Philippe Gorley committed
101
ifdef HAVE_LINUX
102
ifndef HAVE_ANDROID
Philippe Gorley's avatar
Philippe Gorley committed
103
FFMPEGCONF += \
104 105 106
	--enable-vdpau \
	--enable-hwaccel=h264_vdpau \
	--enable-hwaccel=mpeg4_vdpau \
Philippe Gorley's avatar
Philippe Gorley committed
107 108 109 110 111
	--enable-vaapi \
	--enable-hwaccel=h264_vaapi \
	--enable-hwaccel=mpeg4_vaapi \
	--enable-hwaccel=h263_vaapi
endif
112
endif
Philippe Gorley's avatar
Philippe Gorley committed
113 114 115 116 117 118

ifdef HAVE_MACOSX
FFMPEGCONF += \
	--enable-indev=avfcapture \
	--enable-indev=avfgrab
endif
Edric Milaret's avatar
Edric Milaret committed
119

120 121 122 123 124 125 126 127 128
ifdef HAVE_IOS
FFMPEGCONF += \
	--target-os=darwin \
	--enable-cross-compile \
	--arch=$(ARCH) \
	--enable-pic \
        --enable-indev=avfoundation
endif

Philippe Gorley's avatar
Philippe Gorley committed
129 130
DEPS_ffmpeg = iconv zlib x264 vpx opus speex $(DEPS_vpx)

131 132 133 134
# Linux
ifdef HAVE_LINUX
FFMPEGCONF += --target-os=linux --enable-pic
ifndef HAVE_ANDROID
135
FFMPEGCONF += --enable-indev=v4l2 --enable-indev=x11grab_xcb --enable-indev=x11grab --enable-x11grab
136 137 138 139 140 141 142
else
# used to avoid Text Relocations
FFMPEGCONF += --extra-cxxflags=-fPIC --extra-cflags=-fPIC
FFMPEGCONF += --disable-asm
endif
endif

143
ifndef HAVE_IOS
Edric Milaret's avatar
Edric Milaret committed
144 145 146
ifdef HAVE_CROSS_COMPILE
FFMPEGCONF += --cross-prefix=$(HOST)-
endif
147
endif
Edric Milaret's avatar
Edric Milaret committed
148 149 150 151 152 153 154 155 156 157

# x86 stuff
ifeq ($(ARCH),i386)
FFMPEGCONF += --arch=x86
endif

ifeq ($(ARCH),x86_64)
FFMPEGCONF += --arch=x86_64
endif

158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
# ARM stuff
ifeq ($(ARCH),arm)
FFMPEGCONF += --arch=arm
ifdef HAVE_NEON
FFMPEGCONF += --enable-neon
endif
ifdef HAVE_ARMV7A
FFMPEGCONF += --cpu=cortex-a8
endif
ifdef HAVE_ARMV6
FFMPEGCONF += --cpu=armv6 --disable-neon
endif
endif

# ARM64 stuff
ifeq ($(ARCH),aarch64)
FFMPEGCONF += --arch=aarch64
endif
Adrien Béraud's avatar
Adrien Béraud committed
176 177 178
ifeq ($(ARCH),arm64)
FFMPEGCONF += --arch=aarch64
endif
179

Edric Milaret's avatar
Edric Milaret committed
180 181 182 183 184 185
# Windows
ifdef HAVE_WIN32
FFMPEGCONF += --target-os=mingw32 --enable-memalign-hack
FFMPEGCONF += --enable-w32threads --disable-decoder=dca
endif

186
ifeq ($(call need_pkg,"libavcodec >= 57.89.100 libavformat >= 57.71.100 libswscale >= 4.6.100 libavdevice >= 57.6.100 libavutil >= 55.58.100"),)
187
PKGS_FOUND += ffmpeg
Edric Milaret's avatar
Edric Milaret committed
188 189 190
endif

$(TARBALLS)/ffmpeg-$(FFMPEG_HASH).tar.xz:
191
	$(call download,$(FFMPEG_URL))
Edric Milaret's avatar
Edric Milaret committed
192 193

.sum-ffmpeg: ffmpeg-$(FFMPEG_HASH).tar.xz
194
	$(warning $@ is not implemented.)
Edric Milaret's avatar
Edric Milaret committed
195 196 197 198 199
	touch $@

ffmpeg: ffmpeg-$(FFMPEG_HASH).tar.xz .sum-ffmpeg
	rm -Rf $@ $@-$(FFMPEG_HASH)
	mkdir -p $@-$(FFMPEG_HASH)
200
	(cd $@-$(FFMPEG_HASH) && tar x $(if ${BATCH_MODE},,-v) --strip-components=1 -f ../$<)
Edric Milaret's avatar
Edric Milaret committed
201
	$(UPDATE_AUTOCONFIG)
202 203 204 205 206
ifdef HAVE_IOS
	$(APPLY) $(SRC)/ffmpeg/clock_gettime.patch
endif
ifdef HAVE_MACOSX
	$(APPLY) $(SRC)/ffmpeg/clock_gettime.patch
Alexandre Lision's avatar
Alexandre Lision committed
207 208
	$(APPLY) $(SRC)/ffmpeg/0004-add-avfcapture-device.patch
	$(APPLY) $(SRC)/ffmpeg/0005-add-avfgrab-device.patch
209
endif
Edric Milaret's avatar
Edric Milaret committed
210 211 212 213
	$(MOVE)

.ffmpeg: ffmpeg
	cd $< && $(HOSTVARS) ./configure \
214
		--extra-cflags="$(CFLAGS)" \
Edric Milaret's avatar
Edric Milaret committed
215
		--extra-ldflags="$(LDFLAGS)" $(FFMPEGCONF) \
216
                --prefix="$(PREFIX)" --enable-static --disable-shared
Edric Milaret's avatar
Edric Milaret committed
217 218
	cd $< && $(MAKE) install-libs install-headers
	touch $@