73c564244d7ecf7b0b0986bde35e5a3c89b1390f
[libav.git] / Makefile
1 #
2 # Main ffmpeg Makefile
3 # (c) 2000-2004 Fabrice Bellard
4 #
5 include config.mak
6
7 VPATH=$(SRC_PATH_BARE)
8
9 CFLAGS=$(OPTFLAGS) -I$(BUILD_ROOT) -I$(SRC_PATH) -I$(SRC_PATH)/libavutil \
10 -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat -I$(SRC_PATH)/libswscale \
11 -I$(SRC_PATH)/libavdevice \
12 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE -DHAVE_AV_CONFIG_H
13 LDFLAGS+= -g
14
15 PROGS-$(CONFIG_FFMPEG) += ffmpeg
16 PROGS-$(CONFIG_FFPLAY) += ffplay
17 PROGS-$(CONFIG_FFSERVER) += ffserver
18
19 PROGS = $(addsuffix $(EXESUF), $(PROGS-yes))
20 PROGS_G = $(addsuffix _g$(EXESUF), $(PROGS-yes))
21 MANPAGES = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
22
23 BASENAMES = ffmpeg ffplay ffserver
24 ALLPROGS = $(addsuffix $(EXESUF), $(BASENAMES))
25 ALLPROGS_G = $(addsuffix _g$(EXESUF), $(BASENAMES))
26 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
27
28 ifeq ($(BUILD_SHARED),yes)
29 DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavdevice/$(SLIBPREF)avdevice$(SLIBSUF)
30 else
31 DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavdevice/$(LIBPREF)avdevice$(LIBSUF)
32 endif
33
34 ALL_TARGETS-$(CONFIG_VHOOK) += videohook
35 ALL_TARGETS-$(BUILD_DOC) += documentation
36
37 INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
38 ifneq ($(PROGS),)
39 INSTALL_TARGETS-yes += install-progs
40 INSTALL_TARGETS-$(BUILD_DOC) += install-man
41 endif
42
43 VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
44
45 BASEHOOKS = fish null watermark
46 ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
47 ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
48
49 HOOKS-$(HAVE_FORK) += ppm
50 HOOKS-$(HAVE_IMLIB2) += imlib2
51 HOOKS-$(HAVE_FREETYPE2) += drawtext
52
53 HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
54
55 VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
56 LIBS_imlib2$(SLIBSUF) = `imlib2-config --libs`
57
58 VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
59 LIBS_drawtext$(SLIBSUF) = `freetype-config --libs`
60
61 VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
62
63 SRCS = $(addsuffix .c, $(PROGS-yes)) cmdutils.c
64 LDFLAGS := -L$(BUILD_ROOT)/libavdevice -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil $(LDFLAGS)
65 EXTRALIBS := -lavdevice$(BUILDSUF) -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
66
67 ifeq ($(CONFIG_SWSCALER),yes)
68 LDFLAGS+=-L$(BUILD_ROOT)/libswscale
69 EXTRALIBS+=-lswscale$(BUILDSUF)
70 endif
71
72 all: lib $(PROGS) $(ALL_TARGETS-yes)
73
74 lib:
75 $(MAKE) -C libavutil all
76 $(MAKE) -C libavcodec all
77 $(MAKE) -C libavformat all
78 $(MAKE) -C libavdevice all
79 ifeq ($(CONFIG_PP),yes)
80 $(MAKE) -C libpostproc all
81 endif
82 ifeq ($(CONFIG_SWSCALER),yes)
83 $(MAKE) -C libswscale all
84 endif
85
86 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
87 $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(EXTRALIBS)
88
89 ffserver$(EXESUF): ffserver.o cmdutils.o .libs
90 $(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ ffserver.o cmdutils.o $(EXTRALIBS)
91
92 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
93 $(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(EXTRALIBS) $(SDL_LIBS)
94
95 %$(EXESUF): %_g$(EXESUF)
96 cp -p $< $@
97 $(STRIP) $@
98
99 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
100 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
101 version.h: $(SVN_ENTRIES)
102 endif
103
104 version.h:
105 $(SRC_PATH)/version.sh $(SRC_PATH)
106
107 output_example$(EXESUF): output_example.o .libs
108 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
109
110 tools/qt-faststart$(EXESUF): tools/qt-faststart.c
111 $(CC) $(CFLAGS) $< -o $@
112
113 tools/cws2fws$(EXESUF): tools/cws2fws.c
114 $(CC) $(CFLAGS) $< -o $@ -lz
115
116 ffplay.o: CFLAGS += $(SDL_CFLAGS)
117
118 ffmpeg.o ffplay.o ffserver.o: version.h
119
120 videohook: .libs $(HOOKS)
121
122 vhook/%$(SLIBSUF): vhook/%.o
123 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
124
125 vhook/%.o: vhook/%.c
126 $(CC) $(VHOOKCFLAGS) -c -o $@ $<
127
128 %.o: %.c
129 $(CC) $(CFLAGS) -c -o $@ $<
130
131 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
132 ffplay-doc.html general.html hooks.html \
133 $(ALLMANPAGES))
134
135 doc/%.html: doc/%.texi
136 texi2html -monolithic -number $<
137 mv $(@F) $@
138
139 doc/%.pod: doc/%-doc.texi
140 doc/texi2pod.pl $< $@
141
142 doc/%.1: doc/%.pod
143 pod2man --section=1 --center=" " --release=" " $< > $@
144
145 install: install-libs install-headers $(INSTALL_TARGETS-yes)
146
147 ifeq ($(BUILD_SHARED),yes)
148 install-progs: install-libs
149 endif
150 install-progs: $(PROGS)
151 install -d "$(BINDIR)"
152 install -c -m 755 $(PROGS) "$(BINDIR)"
153
154 # Create the Windows installer.
155 wininstaller: all install
156 makensis ffinstall.nsi
157
158 install-man:
159 install -d "$(MANDIR)/man1"
160 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
161
162 install-vhook: videohook
163 install -d "$(SHLIBDIR)/vhook"
164 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
165
166 install-libs:
167 $(MAKE) -C libavutil install-libs
168 $(MAKE) -C libavcodec install-libs
169 $(MAKE) -C libavformat install-libs
170 $(MAKE) -C libavdevice install-libs
171 ifeq ($(CONFIG_PP),yes)
172 $(MAKE) -C libpostproc install-libs
173 endif
174 ifeq ($(CONFIG_SWSCALER),yes)
175 $(MAKE) -C libswscale install-libs
176 endif
177
178 ifeq ($(BUILD_SHARED),yes)
179 -$(LDCONFIG)
180 endif
181
182 install-headers:
183 $(MAKE) -C libavutil install-headers
184 $(MAKE) -C libavcodec install-headers
185 $(MAKE) -C libavformat install-headers
186 $(MAKE) -C libavdevice install-headers
187 ifeq ($(CONFIG_PP),yes)
188 $(MAKE) -C libpostproc install-headers
189 endif
190 $(MAKE) -C libswscale install-headers
191
192 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
193
194 uninstall-progs:
195 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
196
197 uninstall-man:
198 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
199
200 uninstall-vhook:
201 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
202 -rmdir "$(SHLIBDIR)/vhook/"
203
204 uninstall-libs:
205 $(MAKE) -C libavutil uninstall-libs
206 $(MAKE) -C libavcodec uninstall-libs
207 $(MAKE) -C libavformat uninstall-libs
208 $(MAKE) -C libavdevice uninstall-libs
209 $(MAKE) -C libpostproc uninstall-libs
210 $(MAKE) -C libswscale uninstall-libs
211
212 uninstall-headers:
213 $(MAKE) -C libavutil uninstall-headers
214 $(MAKE) -C libavcodec uninstall-headers
215 $(MAKE) -C libavformat uninstall-headers
216 $(MAKE) -C libavdevice uninstall-headers
217 $(MAKE) -C libpostproc uninstall-headers
218 $(MAKE) -C libswscale uninstall-headers
219 -rmdir "$(INCDIR)"
220
221 depend dep: .depend .vhookdep
222 $(MAKE) -C libavutil depend
223 $(MAKE) -C libavcodec depend
224 $(MAKE) -C libavformat depend
225 $(MAKE) -C libavdevice depend
226 ifeq ($(CONFIG_PP),yes)
227 $(MAKE) -C libpostproc depend
228 endif
229 ifeq ($(CONFIG_SWSCALER),yes)
230 $(MAKE) -C libswscale depend
231 endif
232
233 .depend: $(SRCS) version.h
234 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(filter-out %.h,$^) 1>.depend
235
236 # gcc stupidly only outputs the basename of targets with -MM
237 .vhookdep: $(ALLHOOKS_SRCS)
238 $(CC) $(VHOOKCFLAGS) -MM $^ | sed 's,^\([a-z]\),vhook/\1,' > $@
239
240 $(DEP_LIBS): lib
241
242 .libs: $(DEP_LIBS)
243 touch $@
244
245 clean:
246 $(MAKE) -C libavutil clean
247 $(MAKE) -C libavcodec clean
248 $(MAKE) -C libavformat clean
249 $(MAKE) -C libavdevice clean
250 $(MAKE) -C libpostproc clean
251 $(MAKE) -C libswscale clean
252 rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
253 output_example$(EXESUF) qt-faststart$(EXESUF) cws2fws$(EXESUF)
254 rm -f doc/*.html doc/*.pod doc/*.1
255 rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
256 rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
257 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
258
259 distclean: clean
260 $(MAKE) -C libavutil distclean
261 $(MAKE) -C libavcodec distclean
262 $(MAKE) -C libavformat distclean
263 $(MAKE) -C libavdevice distclean
264 $(MAKE) -C libpostproc distclean
265 $(MAKE) -C libswscale distclean
266 rm -f .depend .vhookdep version.h config.* *.pc
267
268 TAGS:
269 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
270
271 # regression tests
272
273 fulltest test: codectest libavtest seektest
274
275 FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
276 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
277 LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
278 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
279 SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
280
281 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
282 @echo
283 @echo "Unfortunately ffserver is broken and therefore its regression"
284 @echo "test fails randomly. Treat the results accordingly."
285 @echo
286 $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
287
288 codectest mpeg4 mpeg ac3 snow snowll: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw tests/tiny_psnr$(EXESUF)
289 $(SRC_PATH)/tests/regression.sh $@ $(FFMPEG_REFFILE) tests/vsynth1
290 $(SRC_PATH)/tests/regression.sh $@ $(ROTOZOOM_REFFILE) tests/vsynth2
291
292 libavtest: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
293 $(SRC_PATH)/tests/regression.sh $@ $(LIBAV_REFFILE) tests/vsynth1
294
295 seektest: tests/seek_test$(EXESUF)
296 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
297
298 ifeq ($(CONFIG_SWSCALER),yes)
299 test-server codectest mpeg4 mpeg ac3 snow snowll libavtest: swscale_error
300 swscale_error:
301 @echo
302 @echo "This regression test is incompatible with --enable-swscaler."
303 @echo
304 @exit 1
305 endif
306
307 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
308 mkdir -p tests/vsynth1
309 $(BUILD_ROOT)/$< 'tests/vsynth1/'
310
311 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
312 mkdir -p tests/vsynth2
313 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
314
315 tests/asynth1.sw: tests/audiogen$(EXESUF)
316 $(BUILD_ROOT)/$< $@
317
318 %$(EXESUF): %.c
319 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
320
321 tests/seek_test$(EXESUF): tests/seek_test.c .libs
322 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
323
324
325 .PHONY: all lib videohook documentation install* wininstaller uninstall*
326 .PHONY: dep depend clean distclean TAGS
327 .PHONY: codectest libavtest seektest test-server fulltest test
328 .PHONY: mpeg4 mpeg ac3 snow snowll swscale-error
329
330 -include .depend
331 -include .vhookdep