flvenc.o depends on avc.o (for H.264 support functions).
[ffmpeg.git] / Makefile
1 #
2 # Main ffmpeg Makefile
3 # (c) 2000-2004 Fabrice Bellard
4 #
5 include config.mak
6
7 SRC_DIR = $(SRC_PATH_BARE)
8
9 vpath %.texi $(SRC_PATH_BARE)
10
11 PROGS-$(CONFIG_FFMPEG)   += ffmpeg
12 PROGS-$(CONFIG_FFPLAY)   += ffplay
13 PROGS-$(CONFIG_FFSERVER) += ffserver
14
15 PROGS       = $(addsuffix   $(EXESUF), $(PROGS-yes))
16 PROGS_G     = $(addsuffix _g$(EXESUF), $(PROGS-yes))
17 OBJS        = $(addsuffix .o,          $(PROGS-yes)) cmdutils.o
18 MANPAGES    = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
19
20 BASENAMES   = ffmpeg ffplay ffserver
21 ALLPROGS    = $(addsuffix   $(EXESUF), $(BASENAMES))
22 ALLPROGS_G  = $(addsuffix _g$(EXESUF), $(BASENAMES))
23 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
24
25 FFLIBS-$(CONFIG_AVFILTER) += avfilter
26 FFLIBS-$(CONFIG_POSTPROC) += postproc
27 FFLIBS-$(CONFIG_SWSCALE)  += swscale
28
29 FFLIBS := avdevice avformat avcodec avutil
30
31 include common.mak
32
33 FF_LDFLAGS   := $(FFLDFLAGS)
34 FF_EXTRALIBS := $(FFEXTRALIBS)
35 FF_DEP_LIBS  := $(DEP_LIBS)
36
37 ALL_TARGETS-$(CONFIG_VHOOK) += videohook
38 ALL_TARGETS-$(BUILD_DOC)    += documentation
39
40 INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
41 ifneq ($(PROGS),)
42 INSTALL_TARGETS-yes             += install-progs
43 INSTALL_TARGETS-$(BUILD_DOC)    += install-man
44 endif
45 INSTALL_PROGS_TARGETS-$(BUILD_SHARED) = install-libs
46
47 all: $(FF_DEP_LIBS) $(PROGS) $(ALL_TARGETS-yes)
48
49 $(PROGS): %$(EXESUF): %_g$(EXESUF)
50         cp -p $< $@
51         $(STRIP) $@
52
53 SUBDIR_VARS := OBJS ASM_OBJS CPP_OBJS FFLIBS CLEANFILES DIRS TESTS
54
55 define RESET
56 $(1) :=
57 $(1)-yes :=
58 endef
59
60 define DOSUBDIR
61 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
62 SUBDIR := $(1)/
63 include $(1)/Makefile
64 endef
65
66 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
67
68 ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
69 ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
70
71 %_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
72         $(CC) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
73
74 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
75 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
76 version.h: $(SVN_ENTRIES)
77 endif
78
79 version.h:
80         $(SRC_PATH)/version.sh $(SRC_PATH)
81
82 output_example$(EXESUF): output_example.o $(FF_DEP_LIBS)
83         $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
84
85 tools/%$(EXESUF): tools/%.c
86         $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
87
88 ffplay.o ffplay.d: CFLAGS += $(SDL_CFLAGS)
89
90 VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
91
92 BASEHOOKS = fish null watermark
93 ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
94 ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
95
96 HOOKS-$(HAVE_FORK)      += ppm
97 HOOKS-$(HAVE_IMLIB2)    += imlib2
98 HOOKS-$(HAVE_FREETYPE2) += drawtext
99
100 HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
101
102 VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
103 LIBS_imlib2$(SLIBSUF)       = `imlib2-config --libs`
104
105 VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
106 LIBS_drawtext$(SLIBSUF)        = `freetype-config --libs`
107
108 VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
109
110 vhook/%.o vhook/%.d: CFLAGS:=$(VHOOKCFLAGS)
111
112 # vhooks compile fine without libav*, but need them nonetheless.
113 videohook: $(FF_DEP_LIBS) $(HOOKS)
114
115 $(eval VHOOKSHFLAGS=$(VHOOKSHFLAGS))
116 vhook/%$(SLIBSUF): vhook/%.o
117         $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
118
119 VHOOK_DEPS = $(HOOKS:$(SLIBSUF)=.d)
120 depend dep: $(VHOOK_DEPS)
121
122 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
123                                  ffplay-doc.html general.html hooks.html \
124                                  $(ALLMANPAGES))
125
126 doc/%.html: doc/%.texi
127         texi2html -monolithic -number $<
128         mv $(@F) $@
129
130 doc/%.pod: doc/%-doc.texi
131         doc/texi2pod.pl $< $@
132
133 doc/%.1: doc/%.pod
134         pod2man --section=1 --center=" " --release=" " $< > $@
135
136 install: $(INSTALL_TARGETS-yes)
137
138 install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
139         install -d "$(BINDIR)"
140         install -c -m 755 $(PROGS) "$(BINDIR)"
141
142 install-man: $(MANPAGES)
143         install -d "$(MANDIR)/man1"
144         install -m 644 $(MANPAGES) "$(MANDIR)/man1"
145
146 install-vhook: videohook
147         install -d "$(SHLIBDIR)/vhook"
148         install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
149
150 uninstall: uninstall-progs uninstall-man uninstall-vhook
151
152 uninstall-progs:
153         rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
154
155 uninstall-man:
156         rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
157
158 uninstall-vhook:
159         rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
160         -rmdir "$(SHLIBDIR)/vhook/"
161
162 clean::
163         rm -f $(ALLPROGS) $(ALLPROGS_G) output_example$(EXESUF)
164         rm -f doc/*.html doc/*.pod doc/*.1
165         rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
166         rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
167         rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
168         rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
169
170 distclean::
171         rm -f version.h config.* *.pc vhook/*.d
172
173 # regression tests
174
175 fulltest test: codectest libavtest seektest
176
177 FFMPEG_REFFILE   = $(SRC_PATH)/tests/ffmpeg.regression.ref
178 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
179 LIBAV_REFFILE    = $(SRC_PATH)/tests/libav.regression.ref
180 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
181 SEEK_REFFILE     = $(SRC_PATH)/tests/seek.regression.ref
182
183 CODEC_TESTS = $(addprefix regtest-,             \
184         mpeg                                    \
185         mpeg2                                   \
186         mpeg2thread                             \
187         msmpeg4v2                               \
188         msmpeg4                                 \
189         wmv1                                    \
190         wmv2                                    \
191         h261                                    \
192         h263                                    \
193         h263p                                   \
194         mpeg4                                   \
195         huffyuv                                 \
196         rc                                      \
197         mpeg4adv                                \
198         mpeg4thread                             \
199         error                                   \
200         mpeg4nr                                 \
201         mpeg1b                                  \
202         mjpeg                                   \
203         ljpeg                                   \
204         jpegls                                  \
205         rv10                                    \
206         rv20                                    \
207         asv1                                    \
208         asv2                                    \
209         flv                                     \
210         ffv1                                    \
211         snow                                    \
212         snowll                                  \
213         dv                                      \
214         dv50                                    \
215         svq1                                    \
216         flashsv                                 \
217         mp2                                     \
218         ac3                                     \
219         g726                                    \
220         adpcm_ima_wav                           \
221         adpcm_ima_qt                            \
222         adpcm_ms                                \
223         adpcm_yam                               \
224         adpcm_swf                               \
225         flac                                    \
226         wma                                     \
227     )
228
229 LAVF_TESTS = $(addprefix regtest-,              \
230         avi                                     \
231         asf                                     \
232         rm                                      \
233         mpg                                     \
234         ts                                      \
235         swf                                     \
236         ffm                                     \
237         flv_fmt                                 \
238         mov                                     \
239         dv_fmt                                  \
240         gxf                                     \
241         nut                                     \
242         mkv                                     \
243         pbmpipe                                 \
244         pgmpipe                                 \
245         ppmpipe                                 \
246         gif                                     \
247         yuv4mpeg                                \
248         pgm                                     \
249         ppm                                     \
250         bmp                                     \
251         tga                                     \
252         tiff                                    \
253         sgi                                     \
254         jpg                                     \
255         wav                                     \
256         alaw                                    \
257         mulaw                                   \
258         au                                      \
259         mmf                                     \
260         aiff                                    \
261         voc                                     \
262         ogg                                     \
263         pixfmt                                  \
264     )
265
266 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
267
268 CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
269 CODEC_VSYNTH   = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
270
271 LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
272
273 LAVF_REG     = tests/data/lavf.regression
274 ROTOZOOM_REG = tests/data/rotozoom.regression
275 VSYNTH_REG   = tests/data/vsynth.regression
276
277 codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
278         diff -u -w $(FFMPEG_REFFILE)   $(VSYNTH_REG)
279         diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
280
281 libavtest: $(LAVF_REG)
282         diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
283
284 $(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
285         cat $^ > $@
286
287 $(LAVF_REG):     $(LAVF_REGFILES)
288 $(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
289 $(VSYNTH_REG):   $(CODEC_VSYNTH)
290
291 $(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
292
293 $(LAVF_REGFILES): $(LAVF_TESTS)
294
295 $(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
296
297 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
298
299 $(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
300         $(SRC_PATH)/tests/regression.sh $@ vsynth   tests/vsynth1 a
301         $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
302
303 $(LAVF_TESTS):
304         $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
305
306 seektest: codectest libavtest tests/seek_test$(EXESUF)
307         $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
308
309 servertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
310         @echo
311         @echo "Unfortunately ffserver is broken and therefore its regression"
312         @echo "test fails randomly. Treat the results accordingly."
313         @echo
314         $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
315
316 ifeq ($(CONFIG_SWSCALE),yes)
317 servertest codectest $(CODEC_TESTS) libavtest: swscale_error
318 swscale_error:
319         @echo
320         @echo "This regression test is incompatible with --enable-swscale."
321         @echo
322         @exit 1
323 endif
324
325 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
326         mkdir -p tests/vsynth1
327         $(BUILD_ROOT)/$< 'tests/vsynth1/'
328
329 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
330         mkdir -p tests/vsynth2
331         $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
332
333 tests/asynth1.sw: tests/audiogen$(EXESUF)
334         $(BUILD_ROOT)/$< $@
335
336 %$(EXESUF): %.c
337         $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $<
338
339 tests/seek_test$(EXESUF): tests/seek_test.c $(FF_DEP_LIBS)
340         $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $< $(FF_EXTRALIBS)
341
342
343 .PHONY: lib videohook documentation *test regtest-* swscale-error
344
345 -include $(VHOOK_DEPS)