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