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