Simplify install-progs prerequisite declaration.
[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 endif
145 install-progs: $(PROGS)
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         $(MAKE) -C libswscale  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         $(MAKE) -C libswscale  uninstall-headers
210         -rmdir "$(INCDIR)"
211
212 depend dep: .depend .vhookdep
213         $(MAKE) -C libavutil   depend
214         $(MAKE) -C libavcodec  depend
215         $(MAKE) -C libavformat depend
216 ifeq ($(CONFIG_PP),yes)
217         $(MAKE) -C libpostproc depend
218 endif
219 ifeq ($(CONFIG_SWSCALER),yes)
220         $(MAKE) -C libswscale  depend
221 endif
222
223 .depend: $(SRCS) version.h
224         $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(filter-out %.h,$^) 1>.depend
225
226 # gcc stupidly only outputs the basename of targets
227 .vhookdep: $(ALLHOOKS_SRCS)
228         $(CC) $(VHOOKCFLAGS) -MM $^ | sed 's,^\([a-z]\),vhook/\1,' > $@
229
230 $(DEP_LIBS): lib
231
232 .libs: $(DEP_LIBS)
233         touch $@
234
235 clean:
236         $(MAKE) -C libavutil   clean
237         $(MAKE) -C libavcodec  clean
238         $(MAKE) -C libavformat clean
239         $(MAKE) -C libpostproc clean
240         $(MAKE) -C libswscale  clean
241         rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
242            output_example$(EXESUF) qt-faststart$(EXESUF) cws2fws$(EXESUF)
243         rm -f doc/*.html doc/*.pod doc/*.1
244         rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
245         rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
246         rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
247
248 distclean: clean
249         $(MAKE) -C libavutil   distclean
250         $(MAKE) -C libavcodec  distclean
251         $(MAKE) -C libavformat distclean
252         $(MAKE) -C libpostproc distclean
253         $(MAKE) -C libswscale  distclean
254         rm -f .depend .vhookdep version.h config.* *.pc
255
256 TAGS:
257         etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
258
259 # regression tests
260
261 fulltest test: codectest libavtest seektest
262
263 FFMPEG_REFFILE   = $(SRC_PATH)/tests/ffmpeg.regression.ref
264 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
265 LIBAV_REFFILE    = $(SRC_PATH)/tests/libav.regression.ref
266 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
267 SEEK_REFFILE     = $(SRC_PATH)/tests/seek.regression.ref
268
269 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
270         @echo
271         @echo "Unfortunately ffserver is broken and therefore its regression"
272         @echo "test fails randomly. Treat the results accordingly."
273         @echo
274         $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
275
276 codectest mpeg4 mpeg ac3 snow snowll: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw tests/tiny_psnr$(EXESUF)
277         $(SRC_PATH)/tests/regression.sh $@ $(FFMPEG_REFFILE)   tests/vsynth1
278         $(SRC_PATH)/tests/regression.sh $@ $(ROTOZOOM_REFFILE) tests/vsynth2
279
280 libavtest: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
281         $(SRC_PATH)/tests/regression.sh $@ $(LIBAV_REFFILE) tests/vsynth1
282
283 seektest: tests/seek_test$(EXESUF)
284         $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
285
286 ifeq ($(CONFIG_SWSCALER),yes)
287 test-server codectest mpeg4 mpeg ac3 snow snowll libavtest: swscale_error
288 swscale_error:
289         @echo
290         @echo "This regression test is incompatible with --enable-swscaler."
291         @echo
292         @exit 1
293 endif
294
295 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
296         mkdir -p tests/vsynth1
297         $(BUILD_ROOT)/$< 'tests/vsynth1/'
298
299 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
300         mkdir -p tests/vsynth2
301         $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
302
303 tests/asynth1.sw: tests/audiogen$(EXESUF)
304         $(BUILD_ROOT)/$< $@
305
306 %$(EXESUF): %.c
307         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
308
309 tests/seek_test$(EXESUF): tests/seek_test.c .libs
310         $(CC) $(LDFLAGS) $(CFLAGS) -DHAVE_AV_CONFIG_H -o $@ $< $(EXTRALIBS)
311
312
313 .PHONY: all lib videohook documentation install* wininstaller uninstall*
314 .PHONY: dep depend clean distclean TAGS
315 .PHONY: codectest libavtest seektest test-server fulltest test
316 .PHONY: mpeg4 mpeg ac3 snow snowll swscale-error
317
318 -include .depend
319 -include .vhookdep