Simplify rotate_block()
[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 %.texi $(SRC_PATH_BARE)
10
11 PROGS-$(CONFIG_FFMPEG)   += ffmpeg
12 PROGS-$(CONFIG_FFPLAY)   += ffplay
13 PROGS-$(CONFIG_FFSERVER) += ffserver
14
15 PROGS       = $(addsuffix   $(EXESUF), $(PROGS-yes))
16 PROGS_G     = $(addsuffix _g$(EXESUF), $(PROGS-yes))
17 OBJS        = $(addsuffix .o,          $(PROGS-yes)) cmdutils.o
18 MANPAGES    = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
19
20 BASENAMES   = ffmpeg ffplay ffserver
21 ALLPROGS    = $(addsuffix   $(EXESUF), $(BASENAMES))
22 ALLPROGS_G  = $(addsuffix _g$(EXESUF), $(BASENAMES))
23 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
24
25 FFLIBS-$(CONFIG_AVFILTER) += avfilter
26 FFLIBS-$(CONFIG_POSTPROC) += postproc
27 FFLIBS-$(CONFIG_SWSCALE)  += swscale
28
29 FFLIBS := avdevice avformat avcodec avutil
30
31 include common.mak
32
33 FF_LDFLAGS   := $(FFLDFLAGS)
34 FF_EXTRALIBS := $(FFEXTRALIBS)
35 FF_DEP_LIBS  := $(DEP_LIBS)
36
37 ALL_TARGETS-$(CONFIG_VHOOK) += videohook
38 ALL_TARGETS-$(BUILD_DOC)    += documentation
39
40 INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
41 ifneq ($(PROGS),)
42 INSTALL_TARGETS-yes             += install-progs
43 INSTALL_TARGETS-$(BUILD_DOC)    += install-man
44 endif
45 INSTALL_PROGS_TARGETS-$(BUILD_SHARED) = install-libs
46
47 all: $(FF_DEP_LIBS) $(PROGS) $(ALL_TARGETS-yes)
48
49 $(PROGS): %$(EXESUF): %_g$(EXESUF)
50         cp -p $< $@
51         $(STRIP) $@
52
53 SUBDIR_VARS := OBJS ASM_OBJS CPP_OBJS FFLIBS CLEANFILES DIRS TESTS
54
55 define RESET
56 $(1) :=
57 $(1)-yes :=
58 endef
59
60 define DOSUBDIR
61 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
62 SUBDIR := $(1)/
63 include $(1)/Makefile
64 endef
65
66 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
67
68 ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
69 ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
70
71 %_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
72         $(CC) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
73
74 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
75 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
76 version.h: $(SVN_ENTRIES)
77 endif
78
79 version.h:
80         $(SRC_PATH)/version.sh $(SRC_PATH)
81
82 output_example$(EXESUF): output_example.o $(FF_DEP_LIBS)
83         $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
84
85 tools/%$(EXESUF): tools/%.c
86         $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
87
88 ffplay.o ffplay.d: CFLAGS += $(SDL_CFLAGS)
89
90 VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
91
92 BASEHOOKS = fish null watermark
93 ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
94 ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
95
96 HOOKS-$(HAVE_FORK)      += ppm
97 HOOKS-$(HAVE_IMLIB2)    += imlib2
98 HOOKS-$(HAVE_FREETYPE2) += drawtext
99
100 HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
101
102 VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
103 LIBS_imlib2$(SLIBSUF)       = `imlib2-config --libs`
104
105 VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
106 LIBS_drawtext$(SLIBSUF)        = `freetype-config --libs`
107
108 VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
109
110 vhook/%.o vhook/%.d: CFLAGS:=$(VHOOKCFLAGS)
111
112 # vhooks compile fine without libav*, but need them nonetheless.
113 videohook: $(FF_DEP_LIBS) $(HOOKS)
114
115 $(eval VHOOKSHFLAGS=$(VHOOKSHFLAGS))
116 vhook/%$(SLIBSUF): vhook/%.o
117         $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
118
119 VHOOK_DEPS = $(HOOKS:$(SLIBSUF)=.d)
120 depend dep: $(VHOOK_DEPS)
121
122 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
123                                  ffplay-doc.html general.html hooks.html \
124                                  $(ALLMANPAGES))
125
126 doc/%.html: doc/%.texi
127         texi2html -monolithic -number $<
128         mv $(@F) $@
129
130 doc/%.pod: doc/%-doc.texi
131         doc/texi2pod.pl $< $@
132
133 doc/%.1: doc/%.pod
134         pod2man --section=1 --center=" " --release=" " $< > $@
135
136 install: $(INSTALL_TARGETS-yes)
137
138 install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
139         install -d "$(BINDIR)"
140         install -c -m 755 $(PROGS) "$(BINDIR)"
141
142 install-man: $(MANPAGES)
143         install -d "$(MANDIR)/man1"
144         install -m 644 $(MANPAGES) "$(MANDIR)/man1"
145
146 install-vhook: videohook
147         install -d "$(SHLIBDIR)/vhook"
148         install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
149
150 uninstall: uninstall-progs uninstall-man uninstall-vhook
151
152 uninstall-progs:
153         rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
154
155 uninstall-man:
156         rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
157
158 uninstall-vhook:
159         rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
160         -rmdir "$(SHLIBDIR)/vhook/"
161
162 clean::
163         rm -f gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
164            output_example$(EXESUF)
165         rm -f doc/*.html doc/*.pod doc/*.1
166         rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
167         rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
168         rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
169         rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
170
171 distclean::
172         rm -f version.h config.* *.pc vhook/*.d
173
174 # regression tests
175
176 fulltest test: codectest libavtest seektest
177
178 FFMPEG_REFFILE   = $(SRC_PATH)/tests/ffmpeg.regression.ref
179 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
180 LIBAV_REFFILE    = $(SRC_PATH)/tests/libav.regression.ref
181 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
182 SEEK_REFFILE     = $(SRC_PATH)/tests/seek.regression.ref
183
184 CODEC_TESTS = $(addprefix regtest-,             \
185         mpeg                                    \
186         mpeg2                                   \
187         mpeg2thread                             \
188         msmpeg4v2                               \
189         msmpeg4                                 \
190         wmv1                                    \
191         wmv2                                    \
192         h261                                    \
193         h263                                    \
194         h263p                                   \
195         mpeg4                                   \
196         huffyuv                                 \
197         rc                                      \
198         mpeg4adv                                \
199         mpeg4thread                             \
200         error                                   \
201         mpeg4nr                                 \
202         mpeg1b                                  \
203         mjpeg                                   \
204         ljpeg                                   \
205         jpegls                                  \
206         rv10                                    \
207         rv20                                    \
208         asv1                                    \
209         asv2                                    \
210         flv                                     \
211         ffv1                                    \
212         snow                                    \
213         snowll                                  \
214         dv                                      \
215         dv50                                    \
216         svq1                                    \
217         flashsv                                 \
218         mp2                                     \
219         ac3                                     \
220         g726                                    \
221         adpcm_ima_wav                           \
222         adpcm_ima_qt                            \
223         adpcm_ms                                \
224         adpcm_yam                               \
225         adpcm_swf                               \
226         flac                                    \
227         wma                                     \
228     )
229
230 LAVF_TESTS = $(addprefix regtest-,              \
231         avi                                     \
232         asf                                     \
233         rm                                      \
234         mpg                                     \
235         ts                                      \
236         swf                                     \
237         ffm                                     \
238         flv_fmt                                 \
239         mov                                     \
240         dv_fmt                                  \
241         gxf                                     \
242         nut                                     \
243         mkv                                     \
244         pbmpipe                                 \
245         pgmpipe                                 \
246         ppmpipe                                 \
247         gif                                     \
248         yuv4mpeg                                \
249         pgm                                     \
250         ppm                                     \
251         bmp                                     \
252         tga                                     \
253         tiff                                    \
254         sgi                                     \
255         jpg                                     \
256         wav                                     \
257         alaw                                    \
258         mulaw                                   \
259         au                                      \
260         mmf                                     \
261         aiff                                    \
262         voc                                     \
263         ogg                                     \
264         pixfmt                                  \
265     )
266
267 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
268
269 CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
270 CODEC_VSYNTH   = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
271
272 LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
273
274 LAVF_REG     = tests/data/lavf.regression
275 ROTOZOOM_REG = tests/data/rotozoom.regression
276 VSYNTH_REG   = tests/data/vsynth.regression
277
278 codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
279         diff -u -w $(FFMPEG_REFFILE)   $(VSYNTH_REG)
280         diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
281
282 libavtest: $(LAVF_REG)
283         diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
284
285 $(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
286         cat $^ > $@
287
288 $(LAVF_REG):     $(LAVF_REGFILES)
289 $(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
290 $(VSYNTH_REG):   $(CODEC_VSYNTH)
291
292 $(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
293
294 $(LAVF_REGFILES): $(LAVF_TESTS)
295
296 $(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
297
298 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
299
300 $(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
301         $(SRC_PATH)/tests/regression.sh $@ vsynth   tests/vsynth1 a
302         $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
303
304 $(LAVF_TESTS):
305         $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
306
307 seektest: codectest libavtest tests/seek_test$(EXESUF)
308         $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
309
310 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
311         @echo
312         @echo "Unfortunately ffserver is broken and therefore its regression"
313         @echo "test fails randomly. Treat the results accordingly."
314         @echo
315         $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
316
317 ifeq ($(CONFIG_SWSCALE),yes)
318 test-server codectest $(CODEC_TESTS) libavtest: swscale_error
319 swscale_error:
320         @echo
321         @echo "This regression test is incompatible with --enable-swscale."
322         @echo
323         @exit 1
324 endif
325
326 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
327         mkdir -p tests/vsynth1
328         $(BUILD_ROOT)/$< 'tests/vsynth1/'
329
330 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
331         mkdir -p tests/vsynth2
332         $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
333
334 tests/asynth1.sw: tests/audiogen$(EXESUF)
335         $(BUILD_ROOT)/$< $@
336
337 %$(EXESUF): %.c
338         $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $<
339
340 tests/seek_test$(EXESUF): tests/seek_test.c $(FF_DEP_LIBS)
341         $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $< $(FF_EXTRALIBS)
342
343
344 .PHONY: lib videohook documentation TAGS
345 .PHONY: codectest libavtest seektest test-server fulltest test
346 .PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error
347
348 -include $(VHOOK_DEPS)