ffmpeg: Build without altivec on powerpc hfp platforms
[feed/packages.git] / multimedia / ffmpeg / Makefile
1 #
2 # Copyright (C) 2006-2016 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=ffmpeg
11 PKG_VERSION:=2.8.8
12 PKG_RELEASE:=2
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15 PKG_SOURCE_URL:=http://ffmpeg.org/releases/
16 PKG_MD5SUM:=5fae1ba5a5d37a2d0de750479b7270d4
17 PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net>
18
19 PKG_LICENSE:=LGPL-2.1+ GPL-2+ LGPL-3
20 PKG_LICENSE_FILES:=COPYING.GPLv2 COPYING.GPLv3 COPYING.LGPLv2.1 COPYING.LGPLv3
21
22 FFMPEG_CUSTOM_ENCODERS:= \
23 ac3 \
24 jpegls \
25 mpeg1video \
26 mpeg2video \
27 mpeg4 \
28 pcm_s16be \
29 pcm_s16le \
30 png \
31 vorbis \
32 zlib \
33
34 FFMPEG_CUSTOM_DECODERS:= \
35 aac \
36 ac3 \
37 alac \
38 amrnb \
39 amrwb \
40 ape \
41 atrac3 \
42 flac \
43 gif \
44 h264 \
45 hevc \
46 jpegls \
47 mp2 \
48 mp3 \
49 mpeg1video \
50 mpeg2video \
51 mpeg4 \
52 mpegvideo \
53 mpc7 \
54 mpc8 \
55 pcm_s16be \
56 pcm_s16le \
57 png \
58 vc1 \
59 vorbis \
60 wavpack \
61 wmav1 \
62 wmav2 \
63 zlib \
64
65 FFMPEG_CUSTOM_MUXERS:= \
66 ac3 \
67 ffm \
68 h264 \
69 hevc \
70 mp3 \
71 mp4 \
72 mpeg1video \
73 mpeg2video \
74 mpegts \
75 ogg \
76 rtp \
77
78 FFMPEG_CUSTOM_DEMUXERS:= \
79 aac \
80 ac3 \
81 amr \
82 ape \
83 avi \
84 flac \
85 ffm \
86 h264 \
87 hevc \
88 matroska \
89 mov \
90 mp3 \
91 mpegps \
92 mpegts \
93 mpegvideo \
94 mpc \
95 mpc8 \
96 ogg \
97 rm \
98 rtsp \
99 rtp \
100 sdp \
101 v4l2 \
102 vc1 \
103 wav \
104 wv \
105
106 FFMPEG_CUSTOM_PARSERS:= \
107 aac \
108 flac \
109 ac3 \
110 h264 \
111 hevc \
112 mpegaudio \
113 mpeg4video \
114 mpegvideo \
115 vc1 \
116
117 FFMPEG_CUSTOM_PROTOCOLS:= \
118 file http icecast pipe rtp tcp udp
119
120 FFMPEG_MINI_DECODERS:= \
121 aac \
122 ac3 \
123 flac \
124 h264 \
125 hevc \
126 jpegls \
127 mp3 \
128 mpeg1video \
129 mpeg2video \
130 mpeg4 \
131 mpegvideo \
132 opus \
133 png \
134 vc1 \
135 vorbis \
136 wmav1 \
137 wmav2 \
138
139 FFMPEG_MINI_DEMUXERS:= \
140 avi \
141 flac \
142 matroska \
143 mov \
144 mp3 \
145 mpegts \
146 mpegvideo \
147 ogg \
148
149 FFMPEG_MINI_PROTOCOLS:= \
150 file \
151
152 FFMPEG_AUDIO_DECODERS:= \
153 aac \
154 aac_latm \
155 ac3 \
156 adpcm_* \
157 alac \
158 amrnb \
159 amrwb \
160 ape \
161 atrac3 \
162 flac \
163 mp2 \
164 mp3* \
165 mpc7 \
166 mpc8 \
167 opus \
168 pcm_* \
169 vorbis \
170 wavpack \
171 wmav1 \
172 wmav2 \
173 wmalossless \
174 wmapro \
175 zlib \
176
177 FFMPEG_AUDIO_DEMUXERS:= \
178 aac \
179 ac3 \
180 aiff \
181 amr \
182 ape \
183 avi \
184 flac \
185 ffm \
186 matroska \
187 mp3 \
188 mov \
189 mpc \
190 mpc8 \
191 mpegts \
192 ogg \
193 rm \
194 rtsp \
195 rtp \
196 sdp \
197 wav \
198 wv \
199
200 FFMPEG_AUDIO_PARSERS:= \
201 aac \
202 aac_latm \
203 ac3 \
204 flac \
205 mpegaudio \
206 opus \
207
208 FFMPEG_AUDIO_PROTOCOLS:= \
209 file http icecast rtp tcp udp
210
211
212 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
213
214 PKG_CONFIG_DEPENDS:= \
215 $(patsubst %,CONFIG_FFMPEG_CUSTOM_ENCODER_%,$(FFMPEG_CUSTOM_ENCODERS)) \
216 $(patsubst %,CONFIG_FFMPEG_CUSTOM_DECODER_%,$(FFMPEG_CUSTOM_DECODERS)) \
217 $(patsubst %,CONFIG_FFMPEG_CUSTOM_MUXER_%,$(FFMPEG_CUSTOM_DEMUXERS)) \
218 $(patsubst %,CONFIG_FFMPEG_CUSTOM_DEMUXER_%,$(FFMPEG_CUSTOM_DEMUXERS)) \
219 $(patsubst %,CONFIG_FFMPEG_CUSTOM_PARSER_%,$(FFMPEG_CUSTOM_PARSERS)) \
220 $(patsubst %,CONFIG_FFMPEG_CUSTOM_PROTOCOL_%,$(FFMPEG_CUSTOM_PROTOCOLS))
221
222 include $(INCLUDE_DIR)/package.mk
223
224 define Package/ffmpeg/Default
225 TITLE:=FFmpeg
226 URL:=http://ffmpeg.mplayerhq.hu/
227 endef
228
229 define Package/ffmpeg/Default/description
230 FFmpeg is a a software package that can record, convert and stream digital
231 audio and video in numerous formats.
232 endef
233
234
235 define Package/ffmpeg
236 $(call Package/ffmpeg/Default)
237 SECTION:=multimedia
238 CATEGORY:=Multimedia
239 TITLE+= program
240 DEPENDS+= +libpthread +libffmpeg-full
241 VARIANT:=full
242 endef
243
244 define Package/ffmpeg/description
245 $(call Package/ffmpeg/Default/description)
246 .
247 This package contains the FFmpeg command line tool.
248 endef
249
250
251 define Package/ffprobe
252 $(call Package/ffmpeg/Default)
253 SECTION:=multimedia
254 CATEGORY:=Multimedia
255 TITLE+= CLI media identifier
256 DEPENDS+= +libffmpeg-full
257 VARIANT:=full
258 endef
259
260 define Package/ffprobe/description
261 $(call Package/ffmpeg/Default/description)
262 .
263 This package contains the FFprobe command line tool.
264 endef
265
266
267 define Package/ffserver
268 $(call Package/ffserver/Default)
269 SECTION:=multimedia
270 CATEGORY:=Multimedia
271 TITLE+= streaming server
272 DEPENDS+= +libpthread +libffmpeg-full
273 VARIANT:=full
274 endef
275
276 define Package/ffserver/description
277 $(call Package/ffmpeg/Default/description)
278 .
279 This package contains the FFmpeg streaming server.
280 endef
281
282 define Package/libffmpeg/Default
283 $(call Package/ffmpeg/Default)
284 SECTION:=libs
285 CATEGORY:=Libraries
286 TITLE+= libraries
287 DEPENDS+= @BUILD_PATENTED +libpthread +zlib +libbz2
288 PROVIDES:= libffmpeg
289 endef
290
291
292 define Package/libffmpeg-custom
293 $(call Package/libffmpeg/Default)
294 TITLE+= (custom)
295 DEPENDS+= +FFMPEG_CUSTOM_SELECT_libopus:libopus +FFMPEG_CUSTOM_SELECT_speex:libspeex \
296 +PACKAGE_libx264:libx264 +PACKAGE_lame-lib:lame-lib
297
298 VARIANT:=custom
299 MENU:=1
300 endef
301
302 define Package/libffmpeg-custom/config
303 source "$(SOURCE)/Config.in"
304 endef
305
306 define Package/libffmpeg-custom/description
307 $(call Package/ffmpeg/Default/description)
308 .
309 This package contains customized FFmpeg shared libraries.
310 endef
311
312
313 define Package/libffmpeg-audio-dec
314 $(call Package/libffmpeg/Default)
315 TITLE+= (audio)
316 DEPENDS+= +libspeex
317 VARIANT:=audio-dec
318 endef
319
320 define Package/libffmpeg-audio-dec/description
321 $(call Package/ffmpeg/Default/description)
322 .
323 This package contains FFmpeg shared libraries for audio decoding
324 endef
325
326
327 define Package/libffmpeg-full
328 $(call Package/libffmpeg/Default)
329 TITLE+= (full)
330 DEPENDS+= +alsa-lib +PACKAGE_libx264:libx264 +PACKAGE_lame-lib:lame-lib +libopus +libspeex
331 VARIANT:=full
332 endef
333
334 define Package/libffmpeg-full/description
335 $(call Package/ffmpeg/Default/description)
336 .
337 This package contains full-featured FFmpeg shared libraries.
338 endef
339
340
341 define Package/libffmpeg-mini
342 $(call Package/libffmpeg/Default)
343 TITLE+= (mini)
344 VARIANT:=mini
345 endef
346
347 define Package/libffmpeg-mini/description
348 $(call Package/ffmpeg/Default/description)
349 .
350 This package contains minimal-featured FFmpeg shared libraries.
351 endef
352
353
354 FFMPEG_CONFIGURE:= \
355 CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(FPIC)" \
356 LDFLAGS="$(TARGET_LDFLAGS)" \
357 ./configure \
358 --enable-cross-compile \
359 --cross-prefix="$(TARGET_CROSS)" \
360 --arch="$(ARCH)" \
361 --target-os=linux \
362 --prefix="/usr" \
363 --pkg-config="pkg-config" \
364 --enable-shared \
365 --enable-static \
366 --enable-small \
367 --enable-pthreads \
368 --enable-zlib \
369 --disable-doc \
370 --disable-debug \
371 \
372 --enable-gpl \
373 --enable-version3 \
374 \
375 --disable-dxva2 \
376 --disable-lzma \
377 --disable-vaapi \
378 --disable-vda \
379 --disable-vdpau \
380 --disable-outdevs
381
382 ifeq ($(CONFIG_SOFT_FLOAT),y)
383 FFMPEG_CONFIGURE += \
384 --disable-altivec \
385 --disable-amd3dnow \
386 --disable-amd3dnowext \
387 --disable-mmx \
388 --disable-mmxext \
389 --disable-sse \
390 --disable-sse2 \
391 --disable-sse3 \
392 --disable-ssse3 \
393 --disable-sse4 \
394 --disable-sse42 \
395 --disable-avx \
396 --disable-xop \
397 --disable-fma3 \
398 --disable-fma4 \
399 --disable-avx2 \
400 --disable-inline-asm \
401 --disable-mips32r2 \
402 --disable-mipsdspr1 \
403 --disable-mipsdspr2 \
404 --disable-mipsfpu \
405 --disable-runtime-cpudetect
406
407 else ifneq ($(findstring arm,$(CONFIG_ARCH)),)
408 FFMPEG_CONFIGURE += \
409 --disable-runtime-cpudetect
410 else ifneq ($(findstring powerpc,$(CONFIG_ARCH)),)
411 FFMPEG_CONFIGURE += \
412 --disable-altivec
413 endif
414
415 ifneq ($(CONFIG_YASM),y)
416 FFMPEG_CONFIGURE += \
417 --disable-yasm
418
419 endif
420
421 #selectibly disable optimizations according to arch/cpu type
422 ifneq ($(findstring arm,$(CONFIG_ARCH)),)
423 ifeq (,$(findstring vfp,$(CONFIG_TARGET_OPTIMIZATION)))
424 FFMPEG_CONFIGURE+= \
425 --disable-vfp
426 endif
427 ifeq (,$(findstring neon,$(CONFIG_TARGET_OPTIMIZATION)))
428 FFMPEG_CONFIGURE+= \
429 --disable-neon
430 endif
431
432 endif
433
434 ifeq ($(BUILD_VARIANT),full)
435 FFMPEG_CONFIGURE+= \
436 --enable-libopus --enable-decoder=libopus \
437 --enable-libspeex --enable-decoder=libspeex \
438 $(if $(CONFIG_PACKAGE_libx264),--enable-libx264) \
439 $(if $(CONFIG_PACKAGE_lame-lib),--enable-libmp3lame)
440 endif
441
442 ifeq ($(BUILD_VARIANT),custom)
443
444 FFMPEG_ENABLE= \
445 $(foreach c, $(2), \
446 $(if $($(3)_$(c)),--enable-$(1)="$(c)") \
447 )
448
449 FFMPEG_CONFIGURE+= \
450 --disable-programs \
451 --disable-avfilter \
452 --disable-postproc \
453 --disable-swresample \
454 --disable-swscale \
455 --disable-everything \
456 $(call FFMPEG_ENABLE,encoder,$(FFMPEG_CUSTOM_ENCODERS),CONFIG_FFMPEG_CUSTOM_ENCODER) \
457 $(call FFMPEG_ENABLE,decoder,$(FFMPEG_CUSTOM_DECODERS),CONFIG_FFMPEG_CUSTOM_DECODER) \
458 $(call FFMPEG_ENABLE,muxer,$(FFMPEG_CUSTOM_MUXERS),CONFIG_FFMPEG_CUSTOM_MUXER) \
459 $(call FFMPEG_ENABLE,demuxer,$(FFMPEG_CUSTOM_DEMUXERS),CONFIG_FFMPEG_CUSTOM_DEMUXER) \
460 $(call FFMPEG_ENABLE,parser,$(FFMPEG_CUSTOM_PARSERS),CONFIG_FFMPEG_CUSTOM_PARSER) \
461 $(call FFMPEG_ENABLE,protocol,$(FFMPEG_CUSTOM_PROTOCOLS),CONFIG_FFMPEG_CUSTOM_PROTOCOL) \
462
463 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_adpcm),y)
464 FFMPEG_CONFIGURE+= \
465 --enable-decoder=adpcm_ima_wav \
466 --enable-decoder=adpcm_ima_qt \
467 --enable-decoder=adpcm_ms \
468
469 endif
470
471 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libopus),y)
472 FFMPEG_CONFIGURE+= \
473 --enable-libopus --enable-decoder=libopus
474 endif
475
476 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_speex),y)
477 FFMPEG_CONFIGURE+= \
478 --enable-libspeex --enable-decoder=libspeex
479 endif
480
481 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_x264),y)
482 FFMPEG_CONFIGURE+= \
483 --enable-libx264
484 endif
485
486 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_mp3lame),y)
487 FFMPEG_CONFIGURE+= \
488 --enable-libmp3lame
489 endif
490
491 endif
492
493 ifeq ($(BUILD_VARIANT),audio-dec)
494
495 FFMPEG_ENABLE= \
496 $(foreach c, $(2), \
497 --enable-$(1)="$(c)" \
498 )
499
500 FFMPEG_CONFIGURE+= \
501 --disable-programs \
502 --disable-avfilter \
503 --disable-postproc \
504 --disable-swresample \
505 --disable-swscale \
506 --disable-everything \
507 $(call FFMPEG_ENABLE,decoder,$(FFMPEG_AUDIO_DECODERS)) \
508 $(call FFMPEG_ENABLE,demuxer,$(FFMPEG_AUDIO_DEMUXERS)) \
509 $(call FFMPEG_ENABLE,parser,$(FFMPEG_AUDIO_PARSERS)) \
510 $(call FFMPEG_ENABLE,protocol,$(FFMPEG_AUDIO_PROTOCOLS)) \
511 --enable-libspeex --enable-decoder=libspeex \
512 --disable-decoder=pcm_bluray,pcm_dvd \
513
514 endif
515
516 ifeq ($(BUILD_VARIANT),mini)
517
518 FFMPEG_ENABLE= \
519 $(foreach c, $(2), \
520 --enable-$(1)="$(c)" \
521 )
522
523 FFMPEG_CONFIGURE+= \
524 --disable-programs \
525 --disable-avdevice \
526 --disable-avfilter \
527 --disable-postproc \
528 --disable-swresample \
529 --disable-swscale \
530 --disable-everything \
531 $(call FFMPEG_ENABLE,decoder,$(FFMPEG_MINI_DECODERS)) \
532 $(call FFMPEG_ENABLE,demuxer,$(FFMPEG_MINI_DEMUXERS)) \
533 $(call FFMPEG_ENABLE,protocol,$(FFMPEG_MINI_PROTOCOLS)) \
534
535 endif
536
537 ifneq ($(CONFIG_TARGET_x86),)
538 TARGET_CFLAGS += -fomit-frame-pointer
539 endif
540
541 define Build/Configure
542 ( cd $(PKG_BUILD_DIR); $(FFMPEG_CONFIGURE) )
543 endef
544
545 define Build/Compile
546 $(MAKE) -C $(PKG_BUILD_DIR) \
547 DESTDIR="$(PKG_INSTALL_DIR)" \
548 all install
549 endef
550
551 define Build/InstallDev/custom
552 $(INSTALL_DIR) $(1)/usr/include
553 $(CP) $(PKG_INSTALL_DIR)/usr/include/lib{avcodec,avdevice,avformat,avutil} $(1)/usr/include/
554 $(INSTALL_DIR) $(1)/usr/lib
555 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avformat,avutil}.{a,so*} $(1)/usr/lib/
556 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
557 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lib{avcodec,avdevice,avformat,avutil}.pc $(1)/usr/lib/pkgconfig/
558 endef
559
560 define Build/InstallDev/full
561 $(INSTALL_DIR) $(1)/usr/include
562 $(CP) $(PKG_INSTALL_DIR)/usr/include/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale} $(1)/usr/include/
563 $(INSTALL_DIR) $(1)/usr/lib
564 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale}.{a,so*} $(1)/usr/lib/
565 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
566 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale}.pc $(1)/usr/lib/pkgconfig/
567 endef
568
569 define Build/InstallDev/mini
570 $(INSTALL_DIR) $(1)/usr/include
571 $(CP) $(PKG_INSTALL_DIR)/usr/include/lib{avcodec,avformat,avutil} $(1)/usr/include/
572 $(INSTALL_DIR) $(1)/usr/lib
573 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avformat,avutil}.{a,so*} $(1)/usr/lib/
574 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
575 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lib{avcodec,avformat,avutil}.pc $(1)/usr/lib/pkgconfig/
576 endef
577
578 Build/InstallDev/audio-dec = $(Build/InstallDev/custom)
579
580 # XXX: attempt at installing "best" dev files available
581 ifeq ($(BUILD_VARIANT),custom)
582 # XXX: only install "custom" dev files if -full & -mini are not selected
583 ifeq ($(CONFIG_PACKAGE_libffmpeg-full)$(CONFIG_PACKAGE_libffmpeg-mini),)
584 Build/InstallDev = $(Build/InstallDev/custom)
585 endif
586 endif
587 ifeq ($(BUILD_VARIANT),audio-dec)
588 # XXX: only install "audio-dec" dev files if -full & -mini are not selected
589 ifeq ($(CONFIG_PACKAGE_libffmpeg-full)$(CONFIG_PACKAGE_libffmpeg-mini),)
590 Build/InstallDev = $(Build/InstallDev/audio-dec)
591 endif
592 endif
593 ifeq ($(BUILD_VARIANT),full)
594 # XXX: always install "full" dev files if -full is selected
595 Build/InstallDev = $(Build/InstallDev/full)
596 endif
597 ifeq ($(BUILD_VARIANT),mini)
598 # XXX: only install "mini" dev files if -full is not selected
599 ifeq ($(CONFIG_PACKAGE_libffmpeg-full),)
600 Build/InstallDev = $(Build/InstallDev/mini)
601 endif
602 endif
603
604 define Package/ffmpeg/install
605 $(INSTALL_DIR) $(1)/usr/bin
606 $(CP) $(PKG_INSTALL_DIR)/usr/bin/ffmpeg $(1)/usr/bin/
607 endef
608
609 define Package/ffprobe/install
610 $(INSTALL_DIR) $(1)/usr/bin
611 $(CP) $(PKG_INSTALL_DIR)/usr/bin/ffprobe $(1)/usr/bin/
612 endef
613
614 define Package/ffserver/install
615 $(INSTALL_DIR) $(1)/usr/bin
616 $(CP) $(PKG_INSTALL_DIR)/usr/bin/ffserver $(1)/usr/bin/
617 endef
618
619 define Package/libffmpeg-custom/install
620 $(INSTALL_DIR) $(1)/usr/lib
621 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avformat,avutil}.so.* $(1)/usr/lib/
622 endef
623
624 define Package/libffmpeg-full/install
625 $(INSTALL_DIR) $(1)/usr/lib
626 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale}.so.* $(1)/usr/lib/
627 endef
628
629 define Package/libffmpeg-mini/install
630 $(INSTALL_DIR) $(1)/usr/lib
631 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avformat,avutil}.so.* $(1)/usr/lib/
632 endef
633
634 Package/libffmpeg-audio-dec/install = $(Package/libffmpeg-custom/install)
635
636 $(eval $(call BuildPackage,ffmpeg))
637 $(eval $(call BuildPackage,ffprobe))
638 $(eval $(call BuildPackage,ffserver))
639 $(eval $(call BuildPackage,libffmpeg-audio-dec))
640 $(eval $(call BuildPackage,libffmpeg-full))
641 $(eval $(call BuildPackage,libffmpeg-mini))
642 ifneq ($(CONFIG_ALL),y)
643 $(eval $(call BuildPackage,libffmpeg-custom))
644 endif