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