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