rules.mak 4.77 KB
Newer Older
Philippe Gorley's avatar
Philippe Gorley committed
1 2 3
ifndef HAVE_MACOSX
FFMPEG_HASH := 18516d3e695980525bd9758dc7b8a8e36cd3f09e
else
Adrien Béraud's avatar
Adrien Béraud committed
4
FFMPEG_HASH := n3.3.3
Philippe Gorley's avatar
Philippe Gorley committed
5
endif
6
FFMPEG_URL := https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/$(FFMPEG_HASH).tar.gz
Edric Milaret's avatar
Edric Milaret committed
7

8
PKGS+=ffmpeg
Philippe Gorley's avatar
Philippe Gorley committed
9

Philippe Gorley's avatar
Philippe Gorley committed
10
ifeq ($(call need_pkg,"libavutil >= 55.75.100 libavcodec >= 57.106.101 libavformat >= 57.82.100 libavdevice >= 57.8.101 libswscale >= 4.7.103"),)
11 12 13 14 15
PKGS_FOUND += ffmpeg
endif

DEPS_ffmpeg = iconv zlib x264 vpx opus speex $(DEPS_vpx)

Edric Milaret's avatar
Edric Milaret committed
16
FFMPEGCONF = \
17 18
	--cc="$(CC)" \
	--pkg-config="$(PKG_CONFIG)"
Edric Milaret's avatar
Edric Milaret committed
19 20 21

#disable everything
FFMPEGCONF += \
22 23 24 25 26
	--disable-everything \
	--enable-zlib \
	--enable-gpl \
	--enable-swscale \
	--enable-protocols \
Philippe Gorley's avatar
Philippe Gorley committed
27
	--disable-programs
Edric Milaret's avatar
Edric Milaret committed
28 29 30

#enable muxers/demuxers
FFMPEGCONF += \
31 32
	--enable-demuxers \
	--enable-muxers
Edric Milaret's avatar
Edric Milaret committed
33 34 35

#enable parsers
FFMPEGCONF += \
36 37 38 39
	--enable-parser=h263 \
	--enable-parser=h264 \
	--enable-parser=mpeg4video \
	--enable-parser=vp8
Edric Milaret's avatar
Edric Milaret committed
40 41 42

#encoders/decoders
FFMPEGCONF += \
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
	--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 \
	--enable-encoder=h263p \
	--enable-decoder=h263 \
	--enable-encoder=mjpeg \
	--enable-decoder=mjpeg \
	--enable-decoder=mjpegb \
	--enable-libspeex \
	--enable-libopus \
	--enable-libvpx \
	--enable-encoder=libspeex \
	--enable-decoder=libspeex \
	--enable-encoder=libopus \
	--enable-decoder=libopus
Edric Milaret's avatar
Edric Milaret committed
70

71 72
#encoders/decoders for images
FFMPEGCONF += \
73 74 75 76 77 78 79 80 81 82 83 84 85 86
	--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

#platform specific options
Alexandre Lision's avatar
Alexandre Lision committed
87

88
ifdef HAVE_WIN32
Edric Milaret's avatar
Edric Milaret committed
89 90
FFMPEGCONF += \
	--enable-indev=dshow \
91
	--enable-indev=gdigrab \
Edric Milaret's avatar
Edric Milaret committed
92
	--enable-dxva2
93
endif
Edric Milaret's avatar
Edric Milaret committed
94

Philippe Gorley's avatar
Philippe Gorley committed
95
ifdef HAVE_LINUX
96 97 98 99 100 101
FFMPEGCONF += --enable-pic
FFMPEGCONF += --extra-cxxflags=-fPIC --extra-cflags=-fPIC
ifdef HAVE_ANDROID
# Android Linux
FFMPEGCONF += \
	--target-os=android \
102
	--enable-jni \
103 104
	--enable-mediacodec \
	--enable-hwaccel=vp8_mediacodec \
105
	--enable-hwaccel=h264_mediacodec \
106 107
	--enable-hwaccel=mpeg4_mediacodec \
	--enable-decoder=vp8_mediacodec \
108
	--enable-decoder=h264_mediacodec \
109 110 111 112 113
	--enable-decoder=mpeg4_mediacodec
# ASM not working on Android x86 https://trac.ffmpeg.org/ticket/4928
ifeq ($(ARCH),i386)
FFMPEGCONF += --disable-asm
endif
114 115 116
ifeq ($(ARCH),x86_64)
FFMPEGCONF += --disable-asm
endif
117 118
else
# Desktop Linux
Philippe Gorley's avatar
Philippe Gorley committed
119
FFMPEGCONF += \
120 121 122
	--target-os=linux \
	--enable-indev=v4l2 \
	--enable-indev=xcbgrab \
123 124 125
	--enable-vdpau \
	--enable-hwaccel=h264_vdpau \
	--enable-hwaccel=mpeg4_vdpau \
Philippe Gorley's avatar
Philippe Gorley committed
126 127 128 129 130
	--enable-vaapi \
	--enable-hwaccel=h264_vaapi \
	--enable-hwaccel=mpeg4_vaapi \
	--enable-hwaccel=h263_vaapi
endif
131
endif
Philippe Gorley's avatar
Philippe Gorley committed
132

133 134 135 136
ifndef HAVE_ANDROID
FFMPEGCONF += --enable-libx264
endif

Philippe Gorley's avatar
Philippe Gorley committed
137 138
ifdef HAVE_MACOSX
FFMPEGCONF += \
Philippe Gorley's avatar
Philippe Gorley committed
139
	--disable-sdl \
140
	--enable-indev=avfoundation \
141 142 143
	--enable-videotoolbox \
	--enable-hwaccel=h263_videotoolbox \
	--enable-hwaccel=h264_videotoolbox \
Philippe Gorley's avatar
Philippe Gorley committed
144
	--enable-hwaccel=mpeg4_videotoolbox
Philippe Gorley's avatar
Philippe Gorley committed
145
endif
Edric Milaret's avatar
Edric Milaret committed
146

147 148 149 150 151
ifdef HAVE_IOS
FFMPEGCONF += \
	--target-os=darwin \
	--enable-cross-compile \
	--arch=$(ARCH) \
Philippe Gorley's avatar
Philippe Gorley committed
152
	--enable-pic
153 154
endif

155
ifndef HAVE_IOS
Edric Milaret's avatar
Edric Milaret committed
156 157 158
ifdef HAVE_CROSS_COMPILE
FFMPEGCONF += --cross-prefix=$(HOST)-
endif
159
endif
Edric Milaret's avatar
Edric Milaret committed
160 161 162 163 164 165 166 167 168 169

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

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

170 171 172 173 174 175 176
# ARM stuff
ifeq ($(ARCH),arm)
FFMPEGCONF += --arch=arm
ifdef HAVE_ARMV7A
FFMPEGCONF += --cpu=cortex-a8
endif
ifdef HAVE_ARMV6
177
FFMPEGCONF += --cpu=armv6 --disable-neon
178 179 180 181 182 183 184
endif
endif

# ARM64 stuff
ifeq ($(ARCH),aarch64)
FFMPEGCONF += --arch=aarch64
endif
Adrien Béraud's avatar
Adrien Béraud committed
185 186 187
ifeq ($(ARCH),arm64)
FFMPEGCONF += --arch=aarch64
endif
188

Edric Milaret's avatar
Edric Milaret committed
189 190
# Windows
ifdef HAVE_WIN32
191
FFMPEGCONF += --target-os=mingw32
Edric Milaret's avatar
Edric Milaret committed
192 193 194
FFMPEGCONF += --enable-w32threads --disable-decoder=dca
endif

195
$(TARBALLS)/ffmpeg-$(FFMPEG_HASH).tar.gz:
196
	$(call download,$(FFMPEG_URL))
Edric Milaret's avatar
Edric Milaret committed
197

198
.sum-ffmpeg: ffmpeg-$(FFMPEG_HASH).tar.gz
199
	$(warning $@ is not implemented.)
Edric Milaret's avatar
Edric Milaret committed
200 201
	touch $@

202
ffmpeg: ffmpeg-$(FFMPEG_HASH).tar.gz .sum-ffmpeg
Edric Milaret's avatar
Edric Milaret committed
203 204
	rm -Rf $@ $@-$(FFMPEG_HASH)
	mkdir -p $@-$(FFMPEG_HASH)
205
	(cd $@-$(FFMPEG_HASH) && tar x $(if ${BATCH_MODE},,-v) --strip-components=1 -f ../$<)
Edric Milaret's avatar
Edric Milaret committed
206
	$(UPDATE_AUTOCONFIG)
Philippe Gorley's avatar
Philippe Gorley committed
207 208
ifdef HAVE_ANDROID
ifeq ($(ARCH),arm)
209
	$(APPLY) $(SRC)/ffmpeg/android_file_offset.patch
Philippe Gorley's avatar
Philippe Gorley committed
210 211
endif
ifeq ($(ARCH),i386)
212
	$(APPLY) $(SRC)/ffmpeg/android_file_offset.patch
Philippe Gorley's avatar
Philippe Gorley committed
213
endif
214
endif
Edric Milaret's avatar
Edric Milaret committed
215 216 217 218
	$(MOVE)

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