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