]> git.sesse.net Git - vlc/blob - contrib/src/ffmpeg/rules.mak
15aabafbc1ce17ca4422da0649cf4ee2add775af
[vlc] / contrib / src / ffmpeg / rules.mak
1 # FFmpeg
2
3 #FFMPEG_SNAPURL := http://git.videolan.org/?p=ffmpeg.git;a=snapshot;h=HEAD;sf=tgz
4 FFMPEG_SNAPURL := http://git.libav.org/?p=libav.git;a=snapshot;h=HEAD;sf=tgz
5
6 FFMPEGCONF = \
7         --cc="$(CC)" \
8         --disable-doc \
9         --disable-decoder=libvpx \
10         --disable-decoder=bink \
11         --enable-libgsm \
12         --enable-libopenjpeg \
13         --disable-debug \
14         --disable-avdevice \
15         --disable-devices \
16         --disable-avfilter \
17         --disable-filters
18
19 # Those tools are named differently in FFmpeg and Libav
20 #       --disable-ffserver \
21 #       --disable-ffplay \
22 #       --disable-ffprobe
23 DEPS_ffmpeg = zlib gsm openjpeg
24
25 # Optional dependencies
26 ifdef BUILD_ENCODERS
27 FFMPEGCONF += --enable-libmp3lame --enable-libvpx
28 DEPS_ffmpeg += lame $(DEPS_lame) vpx $(DEPS_vpx)
29 else
30 FFMPEGCONF += --disable-encoders --disable-muxers
31 endif
32
33 ifdef ENABLE_SMALL
34 FFMPEGCONF += --enable-small --optflags=-O2
35 ifeq ($(ARCH),arm)
36 ifdef HAVE_NEON
37 # XXX: assumes CPU >= cortex-a8, and thus thumb2 able
38 FFMPEGCONF += --enable-thumb
39 endif
40 endif
41 endif
42
43 # XXX: REVISIT
44 #ifndef HAVE_FPU
45 #FFMPEGCONF += --disable-mpegaudio-hp
46 #endif
47
48 ifdef HAVE_CROSS_COMPILE
49 FFMPEGCONF += --enable-cross-compile
50 ifndef HAVE_IOS
51 FFMPEGCONF += --cross-prefix=$(HOST)-
52 endif
53 endif
54
55 # ARM stuff
56 ifeq ($(ARCH),arm)
57 FFMPEGCONF += --disable-runtime-cpudetect --arch=arm
58 ifdef HAVE_NEON
59 FFMPEGCONF += --cpu=cortex-a8 --enable-neon
60 FFMPEG_CFLAGS +=-mfloat-abi=softfp -mfpu=neon
61 endif
62 endif
63
64 # x86 stuff
65 ifeq ($(ARCH),i386)
66 FFMPEGCONF += --arch=x86
67 endif
68
69 # Darwin
70 ifdef HAVE_DARWIN_OS
71 FFMPEGCONF += --arch=$(ARCH) --target-os=darwin
72 FFMPEG_CFLAGS += -DHAVE_LRINTF
73 ifneq ($(findstring $(ARCH),i386 x86_64),)
74 FFMPEGCONF += --enable-memalign-hack
75 endif
76 ifeq ($(ARCH),x86_64)
77 FFMPEGCONF += --cpu=core2
78 endif
79 endif
80 ifdef HAVE_IOS
81 FFMPEGCONF += --enable-pic --as="$(AS)" --disable-decoder=snow
82 endif
83
84 # Linux
85 ifdef HAVE_LINUX
86 FFMPEGCONF += --target-os=linux --enable-pic
87
88 ifeq ($(ANDROID_ABI), x86)
89 ifdef HAVE_ANDROID
90 # Android-x86 gcc doesn't guarantee an aligned stack, but this is
91 # handled by __attribute__((force_align_arg_pointer)) in libavcodec
92 # already, so we tell gcc to assume this alignment, so we don't need
93 # to waste a precious register in assembly functions to realign it.
94 FFMPEG_CFLAGS += -mincoming-stack-boundary=4
95 endif # HAVE_ANDROID
96 endif # x86
97
98 endif
99
100 # Windows
101 ifdef HAVE_WIN32
102 ifndef HAVE_MINGW_W64
103 DEPS_ffmpeg += directx
104 endif
105 FFMPEGCONF += --target-os=mingw32 --enable-memalign-hack
106 FFMPEGCONF += --enable-w32threads \
107         --disable-bzlib --disable-bsfs \
108         --disable-decoder=dca --disable-encoder=vorbis \
109         --enable-dxva2
110
111 ifdef HAVE_WIN64
112 FFMPEGCONF += --cpu=athlon64 --arch=x86_64
113 else # !WIN64
114 FFMPEGCONF+= --cpu=i686 --arch=x86
115 endif
116 else
117 FFMPEGCONF += --enable-pthreads
118 endif
119
120 ifdef HAVE_WINCE
121 FFMPEGCONF += --target-os=mingw32ce --arch=armv4l --cpu=armv4t \
122         --disable-decoder=snow --disable-decoder=vc9 \
123         --disable-decoder=wmv3 --disable-decoder=vorbis \
124         --disable-decoder=dvdsub --disable-decoder=dvbsub
125 endif
126
127 FFMPEG_CFLAGS += --std=gnu99
128
129 # Build
130
131 PKGS += ffmpeg
132 ifeq ($(call need_pkg,"libavcodec >= 52.25.0 libavformat >= 52.30.0 libswscale"),)
133 PKGS_FOUND += ffmpeg
134 endif
135
136 $(TARBALLS)/ffmpeg-git.tar.gz:
137         $(call download,$(FFMPEG_SNAPURL))
138
139 FFMPEG_VERSION := git
140
141 .sum-ffmpeg: $(TARBALLS)/ffmpeg-$(FFMPEG_VERSION).tar.gz
142         $(warning Not implemented.)
143         touch $@
144
145 ffmpeg: ffmpeg-$(FFMPEG_VERSION).tar.gz .sum-ffmpeg
146         rm -Rf $@ $@-git
147         mkdir -p $@-git
148         $(ZCAT) "$<" | (cd $@-git && tar xv --strip-components=1)
149 ifdef HAVE_WIN32
150         sed -i "s/std=c99/std=gnu99/" $@-$(FFMPEG_VERSION)/configure
151 endif
152         $(MOVE)
153
154 .ffmpeg: ffmpeg
155         cd $< && $(HOSTVARS) ./configure \
156                 --extra-cflags="$(FFMPEG_CFLAGS) -DHAVE_STDINT_H"  \
157                 --extra-ldflags="$(LDFLAGS)" $(FFMPEGCONF) \
158                 --prefix="$(PREFIX)" --enable-static --disable-shared
159         cd $< && $(MAKE) install-libs install-headers
160         touch $@