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