cosmetics: Remove useless empty line.
[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 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 cmdutils.o .libs
85         $(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ ffserver.o cmdutils.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 general.html hooks.html \
128                                  $(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 $(INSTALL_TARGETS-yes)
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 libavtest: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
280         $(SRC_PATH)/tests/regression.sh $@ $(LIBAV_REFFILE) tests/vsynth1
281
282 seektest: tests/seek_test$(EXESUF)
283         $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
284
285 ifeq ($(CONFIG_SWSCALER),yes)
286 test-server codectest mpeg4 mpeg ac3 snow snowll libavtest: swscale_error
287 swscale_error:
288         @echo
289         @echo "This regression test is incompatible with --enable-swscaler."
290         @echo
291         @exit 1
292 endif
293
294 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
295         mkdir -p tests/vsynth1
296         $(BUILD_ROOT)/$< 'tests/vsynth1/'
297
298 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
299         mkdir -p tests/vsynth2
300         $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
301
302 tests/asynth1.sw: tests/audiogen$(EXESUF)
303         $(BUILD_ROOT)/$< $@
304
305 %$(EXESUF): %.c
306         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
307
308 tests/seek_test$(EXESUF): tests/seek_test.c .libs
309         $(CC) $(LDFLAGS) $(CFLAGS) -DHAVE_AV_CONFIG_H -o $@ $< $(EXTRALIBS)
310
311
312 .PHONY: all lib videohook documentation install* wininstaller uninstall*
313 .PHONY: dep depend clean distclean TAGS
314 .PHONY: codectest libavtest seektest test-server fulltest test
315 .PHONY: mpeg4 mpeg ac3 snow snowll swscale-error
316
317 -include .depend
318 -include .vhookdep