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