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