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