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