d8ba2c44778339decd1d4191e275e9256c4cb3d3
[packages.git] / multimedia / ffmpeg / Makefile
1 #
2 # Copyright (C) 2006-2013 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:=0.11.2
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
15 PKG_SOURCE_URL:=http://ffmpeg.org/releases/
16 PKG_MD5SUM:=93c1908022567b321df74db7214da6ac
17
18 PKG_LICENSE:=LGPLv2.1+ GPLv2+ LGPLv3
19 PKG_LICENSE_FILES:=COPYING.GPLv2 COPYING.GPLv3 COPYING.LGPLv2.1 COPYING.LGPLv3
20
21 FFMPEG_CUSTOM_ENCODERS:= \
22         ac3 \
23         jpegls \
24         mpeg1video \
25         mpeg2video \
26         mpeg4 \
27         pcm_s16be \
28         pcm_s16le \
29         png \
30         vorbis \
31         zlib \
32
33 FFMPEG_CUSTOM_DECODERS:= \
34         aac \
35         ac3 \
36         atrac3 \
37         flac \
38         gif \
39         h264 \
40         jpegls \
41         mp2 \
42         mp3 \
43         mpeg1video \
44         mpeg2video \
45         mpeg4 \
46         mpegvideo \
47         pcm_s16be \
48         pcm_s16le \
49         png \
50         vorbis \
51         wmav1 \
52         wmav2 \
53         zlib \
54
55 FFMPEG_CUSTOM_MUXERS:= \
56         ac3 \
57         ffm \
58         h264 \
59         mp3 \
60         mp4 \
61         mpeg1video \
62         mpeg2video \
63         mpegts \
64         ogg \
65         rtp \
66
67 FFMPEG_CUSTOM_DEMUXERS:= \
68         aac \
69         ac3 \
70         avi \
71         flac \
72         ffm \
73         h264 \
74         matroska \
75         mov \
76         mp3 \
77         mpegps \
78         mpegts \
79         mpegvideo \
80         ogg \
81         rm \
82         rtsp \
83         sdp \
84         v4l2 \
85
86 FFMPEG_CUSTOM_PARSERS:= \
87         aac \
88         ac3 \
89         h264 \
90         mpegaudio \
91         mpeg4video \
92         mpegvideo \
93
94 FFMPEG_CUSTOM_PROTOCOLS:= \
95         file http pipe rtp tcp udp
96
97 FFMPEG_MINI_ENCODERS:= \
98
99 FFMPEG_MINI_DECODERS:= \
100         aac \
101         ac3 \
102         atrac3 \
103         flac \
104         h263 \
105         h264 \
106         jpegls \
107         mp3 \
108         mpeg1video \
109         mpeg2video \
110         mpeg4 \
111         mpegvideo \
112         png \
113         wmav1 \
114         wmav2 \
115
116 FFMPEG_MINI_MUXERS:= \
117         ffm \
118
119 FFMPEG_MINI_DEMUXERS := \
120         aac \
121         ac3 \
122         asf \
123         avi \
124         ffm \
125         flac \
126         h264 \
127         matroska \
128         mov \
129         mp3 \
130         mpegts \
131         mpegvideo \
132         rtsp \
133
134 FFMPEG_MINI_PARSERS:= \
135         ac3 \
136         flac \
137         h263 \
138         h264 \
139         mpeg4video \
140         mpegaudio \
141
142 FFMPEG_MINI_PROTOCOLS := \
143         file http rtp tcp udp \
144
145 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
146
147 PKG_CONFIG_DEPENDS:= \
148         $(patsubst %,CONFIG_FFMPEG_CUSTOM_ENCODER_%,$(FFMPEG_CUSTOM_ENCODERS)) \
149         $(patsubst %,CONFIG_FFMPEG_CUSTOM_DECODER_%,$(FFMPEG_CUSTOM_DECODERS)) \
150         $(patsubst %,CONFIG_FFMPEG_CUSTOM_MUXER_%,$(FFMPEG_CUSTOM_DEMUXERS)) \
151         $(patsubst %,CONFIG_FFMPEG_CUSTOM_DEMUXER_%,$(FFMPEG_CUSTOM_DEMUXERS)) \
152         $(patsubst %,CONFIG_FFMPEG_CUSTOM_PARSER_%,$(FFMPEG_CUSTOM_PARSERS)) \
153         $(patsubst %,CONFIG_FFMPEG_CUSTOM_PROTOCOL_%,$(FFMPEG_CUSTOM_PROTOCOLS))
154
155 include $(INCLUDE_DIR)/package.mk
156
157 define Package/ffmpeg/Default
158  TITLE:=FFmpeg
159  URL:=http://ffmpeg.mplayerhq.hu/
160 endef
161
162 define Package/ffmpeg/Default/description
163  FFmpeg is a a software package that can record, convert and stream digital 
164  audio and video in numerous formats.
165 endef
166
167
168 define Package/ffmpeg
169 $(call Package/ffmpeg/Default)
170  SECTION:=multimedia
171  CATEGORY:=Multimedia
172  TITLE+= program
173  DEPENDS+= +libpthread +libffmpeg-full
174  VARIANT:=full
175 endef
176
177 define Package/ffmpeg/description
178 $(call Package/ffmpeg/Default/description)
179  .
180  This package contains the FFmpeg command line tool.
181 endef
182
183
184 define Package/ffprobe
185 $(call Package/ffmpeg/Default)
186  SECTION:=multimedia
187  CATEGORY:=Multimedia
188  TITLE+= CLI media identifier
189  DEPENDS+= +libffmpeg-full
190  VARIANT:=full
191 endef
192
193 define Package/ffprobe/description
194 $(call Package/ffmpeg/Default/description)
195  .
196  This package contains the FFprobe command line tool.
197 endef
198
199
200 define Package/ffserver
201 $(call Package/ffserver/Default)
202  SECTION:=multimedia
203  CATEGORY:=Multimedia
204  TITLE+= streaming server
205  DEPENDS+= +libpthread +libffmpeg-full
206  VARIANT:=full
207 endef
208
209 define Package/ffserver/description
210 $(call Package/ffmpeg/Default/description)
211  .
212  This package contains the FFmpeg streaming server.
213 endef
214
215
216 define Package/libffmpeg/Default
217 $(call Package/ffmpeg/Default)
218  SECTION:=libs
219  CATEGORY:=Libraries
220  TITLE+= libraries
221  DEPENDS+= +libpthread +zlib +libbz2
222  PROVIDES:= libffmpeg
223 endef
224
225
226 define Package/libffmpeg-custom
227 $(call Package/libffmpeg/Default)
228  TITLE+= (mini)
229  DEPENDS+= @DEVEL
230  VARIANT:=custom
231  MENU:=1
232 endef
233
234 define Package/libffmpeg-custom/config
235 source "$(SOURCE)/Config.in"
236 endef
237
238 define Package/libffmpeg-custom/description
239 $(call Package/ffmpeg/Default/description)
240  .
241  This package contains customized FFmpeg shared libraries.
242 endef
243
244
245 define Package/libffmpeg-full
246 $(call Package/libffmpeg/Default)
247  TITLE+= (full)
248  DEPENDS+= @BUILD_PATENTED +alsa-lib
249  VARIANT:=full
250 endef
251
252 define Package/libffmpeg-full/description
253 $(call Package/ffmpeg/Default/description)
254  .
255  This package contains full-featured FFmpeg shared libraries.
256 endef
257
258
259 define Package/libffmpeg-mini
260 $(call Package/libffmpeg/Default)
261  TITLE+= (mini)
262  DEPENDS+= @BUILD_PATENTED
263  VARIANT:=mini
264 endef
265
266 define Package/libffmpeg-mini/description
267 $(call Package/ffmpeg/Default/description)
268  .
269  This package contains minimal-featured FFmpeg shared libraries.
270 endef
271
272
273 FFMPEG_CONFIGURE:= \
274         CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(FPIC)" \
275         LDFLAGS="$(TARGET_LDFLAGS)" \
276         ./configure \
277         --enable-cross-compile \
278         --cross-prefix="$(TARGET_CROSS)" \
279         --arch="$(ARCH)" \
280         --target-os=linux \
281         --prefix="/usr" \
282         --enable-shared \
283         --enable-static \
284         --disable-debug \
285         --pkg-config="pkg-config" \
286         \
287         --enable-gpl \
288         --enable-version3 \
289         \
290         --disable-asm \
291         --disable-doc \
292         --disable-dxva2 \
293         --enable-pthreads \
294         --disable-optimizations \
295         --enable-small \
296         --disable-stripping \
297         --enable-zlib \
298         --disable-outdevs
299
300 ifeq ($(BUILD_VARIANT),custom)
301
302   FFMPEG_ENABLE= \
303         $(foreach c, $(2), \
304                 $(if $($(3)_$(c)),--enable-$(1)="$(c)") \
305         )
306
307   FFMPEG_CONFIGURE+= \
308         --disable-ffmpeg \
309         --disable-ffplay \
310         --disable-ffprobe \
311         --disable-ffserver \
312         --disable-avfilter \
313         --disable-postproc \
314         --disable-swscale \
315         --disable-everything \
316         $(call FFMPEG_ENABLE,encoder,$(FFMPEG_CUSTOM_ENCODERS),CONFIG_FFMPEG_CUSTOM_ENCODER) \
317         $(call FFMPEG_ENABLE,decoder,$(FFMPEG_CUSTOM_DECODERS),CONFIG_FFMPEG_CUSTOM_DECODER) \
318         $(call FFMPEG_ENABLE,muxer,$(FFMPEG_CUSTOM_MUXERS),CONFIG_FFMPEG_CUSTOM_MUXER) \
319         $(call FFMPEG_ENABLE,demuxer,$(FFMPEG_CUSTOM_DEMUXERS),CONFIG_FFMPEG_CUSTOM_DEMUXER) \
320         $(call FFMPEG_ENABLE,parser,$(FFMPEG_CUSTOM_PARSERS),CONFIG_FFMPEG_CUSTOM_PARSER) \
321         $(call FFMPEG_ENABLE,protocol,$(FFMPEG_CUSTOM_PROTOCOLS),CONFIG_FFMPEG_CUSTOM_PROTOCOL) \
322
323 endif
324
325 ifeq ($(BUILD_VARIANT),mini)
326
327   FFMPEG_ENABLE= \
328         $(foreach c, $(2), \
329                 --enable-$(1)="$(c)" \
330         )
331
332   FFMPEG_CONFIGURE+= \
333         --disable-ffmpeg \
334         --disable-ffplay \
335         --disable-ffprobe \
336         --disable-ffserver \
337         --disable-avfilter \
338         --disable-postproc \
339         --disable-swscale \
340         --disable-everything \
341         $(call FFMPEG_ENABLE,encoder,$(FFMPEG_MINI_ENCODERS)) \
342         $(call FFMPEG_ENABLE,decoder,$(FFMPEG_MINI_DECODERS)) \
343         $(call FFMPEG_ENABLE,muxer,$(FFMPEG_MINI_MUXERS)) \
344         $(call FFMPEG_ENABLE,demuxer,$(FFMPEG_MINI_DEMUXERS)) \
345         $(call FFMPEG_ENABLE,parser,$(FFMPEG_MINI_PARSERS)) \
346         $(call FFMPEG_ENABLE,protocol,$(FFMPEG_MINI_PROTOCOLS)) \
347
348 endif
349
350 ifneq ($(CONFIG_TARGET_x86),)
351   TARGET_CFLAGS += -fomit-frame-pointer
352 endif
353
354 define Build/Configure
355         ( cd $(PKG_BUILD_DIR); $(FFMPEG_CONFIGURE) )
356 endef
357
358 define Build/Compile
359         $(MAKE) -C $(PKG_BUILD_DIR) \
360                 DESTDIR="$(PKG_INSTALL_DIR)" \
361                 all install
362 endef
363
364 define Build/InstallDev/custom
365         $(INSTALL_DIR) $(1)/usr/include
366         $(CP) $(PKG_INSTALL_DIR)/usr/include/lib{avcodec,avdevice,avformat,avutil} $(1)/usr/include/
367         $(INSTALL_DIR) $(1)/usr/lib
368         $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avformat,avutil}.{a,so*} $(1)/usr/lib/
369         $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
370         $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lib{avcodec,avdevice,avformat,avutil}.pc $(1)/usr/lib/pkgconfig/
371 endef
372
373 define Build/InstallDev/full
374         $(INSTALL_DIR) $(1)/usr/include
375         $(CP) $(PKG_INSTALL_DIR)/usr/include/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swscale} $(1)/usr/include/
376         $(INSTALL_DIR) $(1)/usr/lib
377         $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swscale}.{a,so*} $(1)/usr/lib/
378         $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
379         $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swscale}.pc $(1)/usr/lib/pkgconfig/
380 endef
381
382 Build/InstallDev/mini = $(Build/InstallDev/custom)
383
384 # XXX: attempt at installing "best" dev files available
385 ifeq ($(BUILD_VARIANT),custom)
386   # XXX: only install "custom" dev files if -full & -mini are not selected
387   ifeq ($(CONFIG_PACKAGE_libffmpeg-full)$(CONFIG_PACKAGE_libffmpeg-mini),)
388     Build/InstallDev = $(Build/InstallDev/custom)
389   endif
390 endif
391 ifeq ($(BUILD_VARIANT),full)
392   # XXX: always install "full" dev files if -full is selected
393   Build/InstallDev = $(Build/InstallDev/full)
394 endif
395 ifeq ($(BUILD_VARIANT),mini)
396   # XXX: only install "mini" dev files if -full is not selected
397   ifeq ($(CONFIG_PACKAGE_libffmpeg-full),)
398     Build/InstallDev = $(Build/InstallDev/mini)
399   endif
400 endif
401
402 define Package/ffmpeg/install
403         $(INSTALL_DIR) $(1)/usr/bin
404         $(CP) $(PKG_INSTALL_DIR)/usr/bin/ffmpeg $(1)/usr/bin/
405 endef
406
407 define Package/ffprobe/install
408         $(INSTALL_DIR) $(1)/usr/bin
409         $(CP) $(PKG_INSTALL_DIR)/usr/bin/ffprobe $(1)/usr/bin/
410 endef
411
412 define Package/ffserver/install
413         $(INSTALL_DIR) $(1)/usr/bin
414         $(CP) $(PKG_INSTALL_DIR)/usr/bin/ffserver $(1)/usr/bin/
415 endef
416
417 define Package/libffmpeg-custom/install
418         $(INSTALL_DIR) $(1)/usr/lib
419         $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avformat,avutil}.so.* $(1)/usr/lib/
420 endef
421
422 define Package/libffmpeg-full/install
423         $(INSTALL_DIR) $(1)/usr/lib
424         $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swscale}.so.* $(1)/usr/lib/
425 endef
426
427 Package/libffmpeg-mini/install = $(Package/libffmpeg-custom/install)
428
429 $(eval $(call BuildPackage,ffmpeg))
430 $(eval $(call BuildPackage,ffprobe))
431 $(eval $(call BuildPackage,ffserver))
432 $(eval $(call BuildPackage,libffmpeg-custom))
433 $(eval $(call BuildPackage,libffmpeg-full))
434 $(eval $(call BuildPackage,libffmpeg-mini))