8d85a0ed6791f41d9be915c1d6c64eca943eda42
[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 %.c    $(SRC_PATH_BARE)
10 vpath %.h    $(SRC_PATH_BARE)
11 vpath %.texi $(SRC_PATH_BARE)
12
13 PROGS-$(CONFIG_FFMPEG)   += ffmpeg
14 PROGS-$(CONFIG_FFPLAY)   += ffplay
15 PROGS-$(CONFIG_FFSERVER) += ffserver
16
17 PROGS       = $(addsuffix   $(EXESUF), $(PROGS-yes))
18 PROGS_G     = $(addsuffix _g$(EXESUF), $(PROGS-yes))
19 PROGS_SRCS  = $(addsuffix .c,          $(PROGS-yes)) cmdutils.c
20 MANPAGES    = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
21
22 BASENAMES   = ffmpeg ffplay ffserver
23 ALLPROGS    = $(addsuffix   $(EXESUF), $(BASENAMES))
24 ALLPROGS_G  = $(addsuffix _g$(EXESUF), $(BASENAMES))
25 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
26
27 ifeq ($(BUILD_SHARED),yes)
28 DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavdevice/$(SLIBPREF)avdevice$(SLIBSUF)
29 else
30 DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavdevice/$(LIBPREF)avdevice$(LIBSUF)
31 endif
32
33 ALL_TARGETS-$(CONFIG_VHOOK) += videohook
34 ALL_TARGETS-$(BUILD_DOC)    += documentation
35
36 INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
37 ifneq ($(PROGS),)
38 INSTALL_TARGETS-yes             += install-progs
39 INSTALL_TARGETS-$(BUILD_DOC)    += install-man
40 endif
41
42 main: lib $(PROGS_G) $(PROGS) $(ALL_TARGETS-yes)
43
44 %$(EXESUF): %_g$(EXESUF)
45         cp -p $< $@
46         $(STRIP) $@
47
48 vhook/%.o: vhook/%.c
49         $(CC) $(VHOOKCFLAGS) -c -o $@ $<
50
51 .depend: version.h $(PROGS_SRCS)
52
53 include common.mak
54
55 VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
56
57 BASEHOOKS = fish null watermark
58 ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
59 ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
60
61 HOOKS-$(HAVE_FORK)      += ppm
62 HOOKS-$(HAVE_IMLIB2)    += imlib2
63 HOOKS-$(HAVE_FREETYPE2) += drawtext
64
65 HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
66
67 VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
68 LIBS_imlib2$(SLIBSUF)       = `imlib2-config --libs`
69
70 VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
71 LIBS_drawtext$(SLIBSUF)        = `freetype-config --libs`
72
73 VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
74
75 LDFLAGS := -L$(BUILD_ROOT)/libavdevice -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil -g $(LDFLAGS)
76 EXTRALIBS := -lavdevice$(BUILDSUF) -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
77
78 ifeq ($(CONFIG_SWSCALE),yes)
79 LDFLAGS+=-L$(BUILD_ROOT)/libswscale
80 EXTRALIBS+=-lswscale$(BUILDSUF)
81 endif
82
83 ifeq ($(CONFIG_AVFILTER),yes)
84 LDFLAGS+=-L$(BUILD_ROOT)/libavfilter
85 EXTRALIBS := -lavfilter$(BUILDSUF) $(EXTRALIBS)
86 endif
87
88 MAKE-yes = $(MAKE)
89 MAKE-    = : $(MAKE)
90
91 lib:
92         $(MAKE)                    -C libavutil   all
93         $(MAKE)                    -C libavcodec  all
94         $(MAKE)                    -C libavformat all
95         $(MAKE)                    -C libavdevice all
96         $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc all
97         $(MAKE-$(CONFIG_SWSCALE))  -C libswscale  all
98         $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter all
99
100 ffplay_g$(EXESUF): EXTRALIBS += $(SDL_LIBS)
101 ffserver_g$(EXESUF): LDFLAGS += $(FFSERVERLDFLAGS)
102
103 %_g$(EXESUF): %.o cmdutils.o .libs
104         $(CC) $(LDFLAGS) -o $@ $< cmdutils.o $(EXTRALIBS)
105
106 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
107 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
108 version.h: $(SVN_ENTRIES)
109 endif
110
111 version.h:
112         $(SRC_PATH)/version.sh $(SRC_PATH)
113
114 output_example$(EXESUF): output_example.o .libs
115         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
116
117 tools/%$(EXESUF): tools/%.c
118         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
119
120 ffplay.o .depend: CFLAGS += $(SDL_CFLAGS)
121
122 ffmpeg.o ffplay.o ffserver.o: version.h
123
124 # vhooks compile fine without libav*, but need them nonetheless.
125 videohook: .libs $(HOOKS)
126
127 vhook/%$(SLIBSUF): vhook/%.o
128         $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
129
130 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
131                                  ffplay-doc.html general.html hooks.html \
132                                  $(ALLMANPAGES))
133
134 doc/%.html: doc/%.texi
135         texi2html -monolithic -number $<
136         mv $(@F) $@
137
138 doc/%.pod: doc/%-doc.texi
139         doc/texi2pod.pl $< $@
140
141 doc/%.1: doc/%.pod
142         pod2man --section=1 --center=" " --release=" " $< > $@
143
144 ifeq ($(BUILD_SHARED),yes)
145 install-progs: install-libs
146 endif
147 install-progs: $(PROGS)
148         install -d "$(BINDIR)"
149         install -c -m 755 $(PROGS) "$(BINDIR)"
150
151 install-man:
152         install -d "$(MANDIR)/man1"
153         install -m 644 $(MANPAGES) "$(MANDIR)/man1"
154
155 install-vhook: videohook
156         install -d "$(SHLIBDIR)/vhook"
157         install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
158
159 install-libs:
160         $(MAKE)                    -C libavutil   install-libs
161         $(MAKE)                    -C libavcodec  install-libs
162         $(MAKE)                    -C libavformat install-libs
163         $(MAKE)                    -C libavdevice install-libs
164         $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-libs
165         $(MAKE-$(CONFIG_SWSCALE))  -C libswscale  install-libs
166         $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-libs
167
168 install-headers::
169         $(MAKE)                    -C libavutil   install-headers
170         $(MAKE)                    -C libavcodec  install-headers
171         $(MAKE)                    -C libavformat install-headers
172         $(MAKE)                    -C libavdevice install-headers
173         $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-headers
174         $(MAKE)                    -C libswscale  install-headers
175         $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-headers
176
177 uninstall: uninstall-progs uninstall-man uninstall-vhook
178
179 uninstall-progs:
180         rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
181
182 uninstall-man:
183         rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
184
185 uninstall-vhook:
186         rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
187         -rmdir "$(SHLIBDIR)/vhook/"
188
189 uninstall-libs::
190         $(MAKE) -C libavutil   uninstall-libs
191         $(MAKE) -C libavcodec  uninstall-libs
192         $(MAKE) -C libavformat uninstall-libs
193         $(MAKE) -C libavdevice uninstall-libs
194         $(MAKE) -C libpostproc uninstall-libs
195         $(MAKE) -C libswscale  uninstall-libs
196         $(MAKE) -C libavfilter uninstall-libs
197
198 uninstall-headers::
199         $(MAKE) -C libavutil   uninstall-headers
200         $(MAKE) -C libavcodec  uninstall-headers
201         $(MAKE) -C libavformat uninstall-headers
202         $(MAKE) -C libavdevice uninstall-headers
203         $(MAKE) -C libpostproc uninstall-headers
204         $(MAKE) -C libswscale  uninstall-headers
205         $(MAKE) -C libavfilter uninstall-headers
206         -rmdir "$(INCDIR)"
207
208 depend dep: .vhookdep
209         $(MAKE)                    -C libavutil   depend
210         $(MAKE)                    -C libavcodec  depend
211         $(MAKE)                    -C libavformat depend
212         $(MAKE)                    -C libavdevice depend
213         $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc depend
214         $(MAKE-$(CONFIG_SWSCALE))  -C libswscale  depend
215         $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter depend
216
217 .vhookdep: $(ALLHOOKS_SRCS) version.h
218         $(VHOOK_DEPEND_CMD) > $@
219
220 $(DEP_LIBS): lib
221
222 .libs: $(DEP_LIBS)
223         touch $@
224
225 clean::
226         $(MAKE) -C libavutil   clean
227         $(MAKE) -C libavcodec  clean
228         $(MAKE) -C libavformat clean
229         $(MAKE) -C libavdevice clean
230         $(MAKE) -C libpostproc clean
231         $(MAKE) -C libswscale  clean
232         $(MAKE) -C libavfilter clean
233         rm -f .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
234            output_example$(EXESUF)
235         rm -f doc/*.html doc/*.pod doc/*.1
236         rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
237         rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
238         rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
239         rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
240
241 distclean::
242         $(MAKE) -C libavutil   distclean
243         $(MAKE) -C libavcodec  distclean
244         $(MAKE) -C libavformat distclean
245         $(MAKE) -C libavdevice distclean
246         $(MAKE) -C libpostproc distclean
247         $(MAKE) -C libswscale  distclean
248         $(MAKE) -C libavfilter distclean
249         rm -f .vhookdep version.h config.* *.pc
250
251 # regression tests
252
253 fulltest test: codectest libavtest seektest
254
255 FFMPEG_REFFILE   = $(SRC_PATH)/tests/ffmpeg.regression.ref
256 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
257 LIBAV_REFFILE    = $(SRC_PATH)/tests/libav.regression.ref
258 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
259 SEEK_REFFILE     = $(SRC_PATH)/tests/seek.regression.ref
260
261 CODEC_TESTS = $(addprefix regtest-,             \
262         mpeg                                    \
263         mpeg2                                   \
264         mpeg2thread                             \
265         msmpeg4v2                               \
266         msmpeg4                                 \
267         wmv1                                    \
268         wmv2                                    \
269         h261                                    \
270         h263                                    \
271         h263p                                   \
272         mpeg4                                   \
273         huffyuv                                 \
274         rc                                      \
275         mpeg4adv                                \
276         mpeg4thread                             \
277         error                                   \
278         mpeg4nr                                 \
279         mpeg1b                                  \
280         mjpeg                                   \
281         ljpeg                                   \
282         jpegls                                  \
283         rv10                                    \
284         rv20                                    \
285         asv1                                    \
286         asv2                                    \
287         flv                                     \
288         ffv1                                    \
289         snow                                    \
290         snowll                                  \
291         dv                                      \
292         dv50                                    \
293         svq1                                    \
294         flashsv                                 \
295         mp2                                     \
296         ac3                                     \
297         g726                                    \
298         adpcm_ima_wav                           \
299         adpcm_ima_qt                            \
300         adpcm_ms                                \
301         adpcm_yam                               \
302         adpcm_swf                               \
303         flac                                    \
304         wma                                     \
305     )
306
307 LAVF_TESTS = $(addprefix regtest-,              \
308         avi                                     \
309         asf                                     \
310         rm                                      \
311         mpg                                     \
312         ts                                      \
313         swf                                     \
314         ffm                                     \
315         flv_fmt                                 \
316         mov                                     \
317         dv_fmt                                  \
318         gxf                                     \
319         nut                                     \
320         mkv                                     \
321         pbmpipe                                 \
322         pgmpipe                                 \
323         ppmpipe                                 \
324         gif                                     \
325         yuv4mpeg                                \
326         pgm                                     \
327         ppm                                     \
328         bmp                                     \
329         tga                                     \
330         tiff                                    \
331         sgi                                     \
332         jpg                                     \
333         wav                                     \
334         alaw                                    \
335         mulaw                                   \
336         au                                      \
337         mmf                                     \
338         aiff                                    \
339         voc                                     \
340         ogg                                     \
341         pixfmt                                  \
342     )
343
344 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
345
346 CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
347 CODEC_VSYNTH   = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
348
349 LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
350
351 LAVF_REG     = tests/data/lavf.regression
352 ROTOZOOM_REG = tests/data/rotozoom.regression
353 VSYNTH_REG   = tests/data/vsynth.regression
354
355 codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
356         diff -u -w $(FFMPEG_REFFILE)   $(VSYNTH_REG)
357         diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
358
359 libavtest: $(LAVF_REG)
360         diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
361
362 $(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
363         cat $^ > $@
364
365 $(LAVF_REG):     $(LAVF_REGFILES)
366 $(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
367 $(VSYNTH_REG):   $(CODEC_VSYNTH)
368
369 $(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
370
371 $(LAVF_REGFILES): $(LAVF_TESTS)
372
373 $(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
374
375 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
376
377 $(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
378         $(SRC_PATH)/tests/regression.sh $@ vsynth   tests/vsynth1 a
379         $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
380
381 $(LAVF_TESTS):
382         $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
383
384 seektest: codectest libavtest tests/seek_test$(EXESUF)
385         $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
386
387 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
388         @echo
389         @echo "Unfortunately ffserver is broken and therefore its regression"
390         @echo "test fails randomly. Treat the results accordingly."
391         @echo
392         $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
393
394 ifeq ($(CONFIG_SWSCALE),yes)
395 test-server codectest $(CODEC_TESTS) libavtest: swscale_error
396 swscale_error:
397         @echo
398         @echo "This regression test is incompatible with --enable-swscale."
399         @echo
400         @exit 1
401 endif
402
403 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
404         mkdir -p tests/vsynth1
405         $(BUILD_ROOT)/$< 'tests/vsynth1/'
406
407 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
408         mkdir -p tests/vsynth2
409         $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
410
411 tests/asynth1.sw: tests/audiogen$(EXESUF)
412         $(BUILD_ROOT)/$< $@
413
414 %$(EXESUF): %.c
415         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
416
417 tests/seek_test$(EXESUF): tests/seek_test.c .libs
418         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
419
420
421 .PHONY: lib videohook documentation TAGS
422 .PHONY: codectest libavtest seektest test-server fulltest test
423 .PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error
424
425 -include .vhookdep