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