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