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