Use $< to simplify a few lines.
[platform/upstream/libav.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 $@ $< cmdutils.o $(EXTRALIBS)
95
96 ffserver_g$(EXESUF): ffserver.o cmdutils.o .libs
97         $(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ $< cmdutils.o $(EXTRALIBS)
98
99 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
100         $(CC) $(LDFLAGS) -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 install-man:
160         install -d "$(MANDIR)/man1"
161         install -m 644 $(MANPAGES) "$(MANDIR)/man1"
162
163 install-vhook: videohook
164         install -d "$(SHLIBDIR)/vhook"
165         install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
166
167 install-libs:
168         $(MAKE)                    -C libavutil   install-libs
169         $(MAKE)                    -C libavcodec  install-libs
170         $(MAKE)                    -C libavformat install-libs
171         $(MAKE)                    -C libavdevice install-libs
172         $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-libs
173         $(MAKE-$(CONFIG_SWSCALE))  -C libswscale  install-libs
174         $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-libs
175
176 install-headers:
177         $(MAKE)                    -C libavutil   install-headers
178         $(MAKE)                    -C libavcodec  install-headers
179         $(MAKE)                    -C libavformat install-headers
180         $(MAKE)                    -C libavdevice install-headers
181         $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-headers
182         $(MAKE)                    -C libswscale  install-headers
183         $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-headers
184
185 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
186
187 uninstall-progs:
188         rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
189
190 uninstall-man:
191         rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
192
193 uninstall-vhook:
194         rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
195         -rmdir "$(SHLIBDIR)/vhook/"
196
197 uninstall-libs:
198         $(MAKE) -C libavutil   uninstall-libs
199         $(MAKE) -C libavcodec  uninstall-libs
200         $(MAKE) -C libavformat uninstall-libs
201         $(MAKE) -C libavdevice uninstall-libs
202         $(MAKE) -C libpostproc uninstall-libs
203         $(MAKE) -C libswscale  uninstall-libs
204         $(MAKE) -C libavfilter uninstall-libs
205
206 uninstall-headers:
207         $(MAKE) -C libavutil   uninstall-headers
208         $(MAKE) -C libavcodec  uninstall-headers
209         $(MAKE) -C libavformat uninstall-headers
210         $(MAKE) -C libavdevice uninstall-headers
211         $(MAKE) -C libpostproc uninstall-headers
212         $(MAKE) -C libswscale  uninstall-headers
213         $(MAKE) -C libavfilter uninstall-headers
214         -rmdir "$(INCDIR)"
215
216 depend dep: .depend .vhookdep
217         $(MAKE)                    -C libavutil   depend
218         $(MAKE)                    -C libavcodec  depend
219         $(MAKE)                    -C libavformat depend
220         $(MAKE)                    -C libavdevice depend
221         $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc depend
222         $(MAKE-$(CONFIG_SWSCALE))  -C libswscale  depend
223         $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter depend
224
225 .depend: $(SRCS) version.h
226         $(DEPEND_CMD) > $@
227
228 .vhookdep: $(ALLHOOKS_SRCS) version.h
229         $(VHOOK_DEPEND_CMD) > $@
230
231 $(DEP_LIBS): lib
232
233 .libs: $(DEP_LIBS)
234         touch $@
235
236 clean:
237         $(MAKE) -C libavutil   clean
238         $(MAKE) -C libavcodec  clean
239         $(MAKE) -C libavformat clean
240         $(MAKE) -C libavdevice clean
241         $(MAKE) -C libpostproc clean
242         $(MAKE) -C libswscale  clean
243         $(MAKE) -C libavfilter clean
244         rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
245            output_example$(EXESUF)
246         rm -f doc/*.html doc/*.pod doc/*.1
247         rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
248         rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
249         rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
250         rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
251
252 distclean: clean
253         $(MAKE) -C libavutil   distclean
254         $(MAKE) -C libavcodec  distclean
255         $(MAKE) -C libavformat distclean
256         $(MAKE) -C libavdevice distclean
257         $(MAKE) -C libpostproc distclean
258         $(MAKE) -C libswscale  distclean
259         $(MAKE) -C libavfilter distclean
260         rm -f .depend .vhookdep version.h config.* *.pc
261
262 TAGS:
263         etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
264
265 # regression tests
266
267 fulltest test: codectest libavtest seektest
268
269 FFMPEG_REFFILE   = $(SRC_PATH)/tests/ffmpeg.regression.ref
270 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
271 LIBAV_REFFILE    = $(SRC_PATH)/tests/libav.regression.ref
272 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
273 SEEK_REFFILE     = $(SRC_PATH)/tests/seek.regression.ref
274
275 CODEC_TESTS = $(addprefix regtest-,             \
276         mpeg                                    \
277         mpeg2                                   \
278         mpeg2thread                             \
279         msmpeg4v2                               \
280         msmpeg4                                 \
281         wmv1                                    \
282         wmv2                                    \
283         h261                                    \
284         h263                                    \
285         h263p                                   \
286         mpeg4                                   \
287         huffyuv                                 \
288         rc                                      \
289         mpeg4adv                                \
290         mpeg4thread                             \
291         error                                   \
292         mpeg4nr                                 \
293         mpeg1b                                  \
294         mjpeg                                   \
295         ljpeg                                   \
296         jpegls                                  \
297         rv10                                    \
298         rv20                                    \
299         asv1                                    \
300         asv2                                    \
301         flv                                     \
302         ffv1                                    \
303         snow                                    \
304         snowll                                  \
305         dv                                      \
306         dv50                                    \
307         svq1                                    \
308         flashsv                                 \
309         mp2                                     \
310         ac3                                     \
311         g726                                    \
312         adpcm_ima_wav                           \
313         adpcm_ima_qt                            \
314         adpcm_ms                                \
315         adpcm_yam                               \
316         adpcm_swf                               \
317         flac                                    \
318         wma                                     \
319     )
320
321 LAVF_TESTS = $(addprefix regtest-,              \
322         avi                                     \
323         asf                                     \
324         rm                                      \
325         mpg                                     \
326         ts                                      \
327         swf                                     \
328         ffm                                     \
329         flv_fmt                                 \
330         mov                                     \
331         dv_fmt                                  \
332         gxf                                     \
333         nut                                     \
334         mkv                                     \
335         pbmpipe                                 \
336         pgmpipe                                 \
337         ppmpipe                                 \
338         gif                                     \
339         yuv4mpeg                                \
340         pgm                                     \
341         ppm                                     \
342         bmp                                     \
343         tga                                     \
344         tiff                                    \
345         sgi                                     \
346         jpg                                     \
347         wav                                     \
348         alaw                                    \
349         mulaw                                   \
350         au                                      \
351         mmf                                     \
352         aiff                                    \
353         voc                                     \
354         ogg                                     \
355         pixfmt                                  \
356     )
357
358 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
359
360 CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
361 CODEC_VSYNTH   = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
362
363 LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
364
365 LAVF_REG     = tests/data/lavf.regression
366 ROTOZOOM_REG = tests/data/rotozoom.regression
367 VSYNTH_REG   = tests/data/vsynth.regression
368
369 codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
370         diff -u -w $(FFMPEG_REFFILE)   $(VSYNTH_REG)
371         diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
372
373 libavtest: $(LAVF_REG)
374         diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
375
376 $(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
377         cat $^ > $@
378
379 $(LAVF_REG):     $(LAVF_REGFILES)
380 $(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
381 $(VSYNTH_REG):   $(CODEC_VSYNTH)
382
383 $(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
384
385 $(LAVF_REGFILES): $(LAVF_TESTS)
386
387 $(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
388
389 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
390
391 $(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
392         $(SRC_PATH)/tests/regression.sh $@ vsynth   tests/vsynth1 a
393         $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
394
395 $(LAVF_TESTS):
396         $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
397
398 seektest: codectest libavtest tests/seek_test$(EXESUF)
399         $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
400
401 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
402         @echo
403         @echo "Unfortunately ffserver is broken and therefore its regression"
404         @echo "test fails randomly. Treat the results accordingly."
405         @echo
406         $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
407
408 ifeq ($(CONFIG_SWSCALE),yes)
409 test-server codectest $(CODEC_TESTS) libavtest: swscale_error
410 swscale_error:
411         @echo
412         @echo "This regression test is incompatible with --enable-swscale."
413         @echo
414         @exit 1
415 endif
416
417 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
418         mkdir -p tests/vsynth1
419         $(BUILD_ROOT)/$< 'tests/vsynth1/'
420
421 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
422         mkdir -p tests/vsynth2
423         $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
424
425 tests/asynth1.sw: tests/audiogen$(EXESUF)
426         $(BUILD_ROOT)/$< $@
427
428 %$(EXESUF): %.c
429         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
430
431 tests/seek_test$(EXESUF): tests/seek_test.c .libs
432         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
433
434
435 .PHONY: all lib videohook documentation install* uninstall*
436 .PHONY: dep depend clean distclean TAGS
437 .PHONY: codectest libavtest seektest test-server fulltest test
438 .PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error
439
440 -include .depend
441 -include .vhookdep