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