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