Merge rules for tools/* into a generic rule.
[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/%$(EXESUF): tools/%.c
111 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
112
113 ffplay.o: CFLAGS += $(SDL_CFLAGS)
114
115 ffmpeg.o ffplay.o ffserver.o: version.h
116
117 videohook: .libs $(HOOKS)
118
119 vhook/%$(SLIBSUF): vhook/%.o
120 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
121
122 vhook/%.o: vhook/%.c
123 $(CC) $(VHOOKCFLAGS) -c -o $@ $<
124
125 %.o: %.c
126 $(CC) $(CFLAGS) -c -o $@ $<
127
128 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
129 ffplay-doc.html general.html hooks.html \
130 $(ALLMANPAGES))
131
132 doc/%.html: doc/%.texi
133 texi2html -monolithic -number $<
134 mv $(@F) $@
135
136 doc/%.pod: doc/%-doc.texi
137 doc/texi2pod.pl $< $@
138
139 doc/%.1: doc/%.pod
140 pod2man --section=1 --center=" " --release=" " $< > $@
141
142 install: install-libs install-headers $(INSTALL_TARGETS-yes)
143
144 ifeq ($(BUILD_SHARED),yes)
145 install-progs: install-libs
146 endif
147 install-progs: $(PROGS)
148 install -d "$(BINDIR)"
149 install -c -m 755 $(PROGS) "$(BINDIR)"
150
151 # Create the Windows installer.
152 wininstaller: all install
153 makensis ffinstall.nsi
154
155 install-man:
156 install -d "$(MANDIR)/man1"
157 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
158
159 install-vhook: videohook
160 install -d "$(SHLIBDIR)/vhook"
161 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
162
163 install-libs:
164 $(MAKE) -C libavutil install-libs
165 $(MAKE) -C libavcodec install-libs
166 $(MAKE) -C libavformat install-libs
167 $(MAKE) -C libavdevice 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 $(MAKE) -C libavdevice install-headers
184 ifeq ($(CONFIG_PP),yes)
185 $(MAKE) -C libpostproc install-headers
186 endif
187 $(MAKE) -C libswscale install-headers
188
189 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
190
191 uninstall-progs:
192 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
193
194 uninstall-man:
195 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
196
197 uninstall-vhook:
198 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
199 -rmdir "$(SHLIBDIR)/vhook/"
200
201 uninstall-libs:
202 $(MAKE) -C libavutil uninstall-libs
203 $(MAKE) -C libavcodec uninstall-libs
204 $(MAKE) -C libavformat uninstall-libs
205 $(MAKE) -C libavdevice uninstall-libs
206 $(MAKE) -C libpostproc uninstall-libs
207 $(MAKE) -C libswscale uninstall-libs
208
209 uninstall-headers:
210 $(MAKE) -C libavutil uninstall-headers
211 $(MAKE) -C libavcodec uninstall-headers
212 $(MAKE) -C libavformat uninstall-headers
213 $(MAKE) -C libavdevice uninstall-headers
214 $(MAKE) -C libpostproc uninstall-headers
215 $(MAKE) -C libswscale uninstall-headers
216 -rmdir "$(INCDIR)"
217
218 depend dep: .depend .vhookdep
219 $(MAKE) -C libavutil depend
220 $(MAKE) -C libavcodec depend
221 $(MAKE) -C libavformat depend
222 $(MAKE) -C libavdevice depend
223 ifeq ($(CONFIG_PP),yes)
224 $(MAKE) -C libpostproc depend
225 endif
226 ifeq ($(CONFIG_SWSCALER),yes)
227 $(MAKE) -C libswscale depend
228 endif
229
230 .depend: $(SRCS) version.h
231 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(filter-out %.h,$^) 1>.depend
232
233 # gcc stupidly only outputs the basename of targets with -MM
234 .vhookdep: $(ALLHOOKS_SRCS) version.h
235 $(CC) $(VHOOKCFLAGS) -MM $^ | sed 's,^\([a-z]\),vhook/\1,' > $@
236
237 $(DEP_LIBS): lib
238
239 .libs: $(DEP_LIBS)
240 touch $@
241
242 clean:
243 $(MAKE) -C libavutil clean
244 $(MAKE) -C libavcodec clean
245 $(MAKE) -C libavformat clean
246 $(MAKE) -C libavdevice clean
247 $(MAKE) -C libpostproc clean
248 $(MAKE) -C libswscale clean
249 rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
250 output_example$(EXESUF)
251 rm -f doc/*.html doc/*.pod doc/*.1
252 rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
253 rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
254 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
255 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
256
257 distclean: clean
258 $(MAKE) -C libavutil distclean
259 $(MAKE) -C libavcodec distclean
260 $(MAKE) -C libavformat distclean
261 $(MAKE) -C libavdevice distclean
262 $(MAKE) -C libpostproc distclean
263 $(MAKE) -C libswscale distclean
264 rm -f .depend .vhookdep version.h config.* *.pc
265
266 TAGS:
267 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
268
269 # regression tests
270
271 fulltest test: codectest libavtest seektest
272
273 FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
274 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
275 LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
276 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
277 SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
278
279 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
280 @echo
281 @echo "Unfortunately ffserver is broken and therefore its regression"
282 @echo "test fails randomly. Treat the results accordingly."
283 @echo
284 $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
285
286 codectest mpeg4 mpeg ac3 snow snowll: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw tests/tiny_psnr$(EXESUF)
287 $(SRC_PATH)/tests/regression.sh $@ $(FFMPEG_REFFILE) tests/vsynth1
288 $(SRC_PATH)/tests/regression.sh $@ $(ROTOZOOM_REFFILE) tests/vsynth2
289
290 libavtest: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
291 $(SRC_PATH)/tests/regression.sh $@ $(LIBAV_REFFILE) tests/vsynth1
292
293 seektest: tests/seek_test$(EXESUF)
294 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
295
296 ifeq ($(CONFIG_SWSCALER),yes)
297 test-server codectest mpeg4 mpeg ac3 snow snowll libavtest: swscale_error
298 swscale_error:
299 @echo
300 @echo "This regression test is incompatible with --enable-swscaler."
301 @echo
302 @exit 1
303 endif
304
305 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
306 mkdir -p tests/vsynth1
307 $(BUILD_ROOT)/$< 'tests/vsynth1/'
308
309 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
310 mkdir -p tests/vsynth2
311 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
312
313 tests/asynth1.sw: tests/audiogen$(EXESUF)
314 $(BUILD_ROOT)/$< $@
315
316 %$(EXESUF): %.c
317 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
318
319 tests/seek_test$(EXESUF): tests/seek_test.c .libs
320 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
321
322
323 .PHONY: all lib videohook documentation install* wininstaller uninstall*
324 .PHONY: dep depend clean distclean TAGS
325 .PHONY: codectest libavtest seektest test-server fulltest test
326 .PHONY: mpeg4 mpeg ac3 snow snowll swscale-error
327
328 -include .depend
329 -include .vhookdep