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