remove some ifeq ($(CONFIG_FOO),yes)
[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 MAKE-yes = $(MAKE)
73 MAKE-    = : $(MAKE)
74
75 all: lib $(PROGS) $(ALL_TARGETS-yes)
76
77 lib:
78         $(MAKE) -C libavutil   all
79         $(MAKE) -C libavcodec  all
80         $(MAKE) -C libavformat all
81         $(MAKE) -C libavdevice all
82         $(MAKE-$(CONFIG_PP)) -C libpostproc all
83         $(MAKE-$(CONFIG_SWSCALER)) -C libswscale  all
84
85 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
86         $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(EXTRALIBS)
87
88 ffserver$(EXESUF): ffserver.o cmdutils.o .libs
89         $(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ ffserver.o cmdutils.o $(EXTRALIBS)
90
91 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
92         $(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(EXTRALIBS) $(SDL_LIBS)
93
94 %$(EXESUF): %_g$(EXESUF)
95         cp -p $< $@
96         $(STRIP) $@
97
98 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
99 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
100 version.h: $(SVN_ENTRIES)
101 endif
102
103 version.h:
104         $(SRC_PATH)/version.sh $(SRC_PATH)
105
106 output_example$(EXESUF): output_example.o .libs
107         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
108
109 tools/%$(EXESUF): tools/%.c
110         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
111
112 ffplay.o: CFLAGS += $(SDL_CFLAGS)
113
114 ffmpeg.o ffplay.o ffserver.o: version.h
115
116 videohook: .libs $(HOOKS)
117
118 vhook/%$(SLIBSUF): vhook/%.o
119         $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
120
121 vhook/%.o: vhook/%.c
122         $(CC) $(VHOOKCFLAGS) -c -o $@ $<
123
124 %.o: %.c
125         $(CC) $(CFLAGS) -c -o $@ $<
126
127 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
128                                  ffplay-doc.html general.html hooks.html \
129                                  $(ALLMANPAGES))
130
131 doc/%.html: doc/%.texi
132         texi2html -monolithic -number $<
133         mv $(@F) $@
134
135 doc/%.pod: doc/%-doc.texi
136         doc/texi2pod.pl $< $@
137
138 doc/%.1: doc/%.pod
139         pod2man --section=1 --center=" " --release=" " $< > $@
140
141 install: install-libs install-headers $(INSTALL_TARGETS-yes)
142
143 ifeq ($(BUILD_SHARED),yes)
144 install-progs: install-libs
145 endif
146 install-progs: $(PROGS)
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         $(MAKE) -C libavdevice install-libs
167         $(MAKE-$(CONFIG_PP)) -C libpostproc install-libs
168         $(MAKE-$(CONFIG_SWSCALER)) -C libswscale  install-libs
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         $(MAKE) -C libavdevice install-headers
179         $(MAKE-$(CONFIG_PP)) -C libpostproc install-headers
180         $(MAKE) -C libswscale  install-headers
181
182 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
183
184 uninstall-progs:
185         rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
186
187 uninstall-man:
188         rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
189
190 uninstall-vhook:
191         rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
192         -rmdir "$(SHLIBDIR)/vhook/"
193
194 uninstall-libs:
195         $(MAKE) -C libavutil   uninstall-libs
196         $(MAKE) -C libavcodec  uninstall-libs
197         $(MAKE) -C libavformat uninstall-libs
198         $(MAKE) -C libavdevice uninstall-libs
199         $(MAKE) -C libpostproc uninstall-libs
200         $(MAKE) -C libswscale  uninstall-libs
201
202 uninstall-headers:
203         $(MAKE) -C libavutil   uninstall-headers
204         $(MAKE) -C libavcodec  uninstall-headers
205         $(MAKE) -C libavformat uninstall-headers
206         $(MAKE) -C libavdevice uninstall-headers
207         $(MAKE) -C libpostproc uninstall-headers
208         $(MAKE) -C libswscale  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         $(MAKE) -C libavdevice depend
216         $(MAKE-$(CONFIG_PP)) -C libpostproc depend
217         $(MAKE-$(CONFIG_SWSCALER)) -C libswscale  depend
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 with -MM
223 .vhookdep: $(ALLHOOKS_SRCS) version.h
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 libavdevice clean
236         $(MAKE) -C libpostproc clean
237         $(MAKE) -C libswscale  clean
238         rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
239            output_example$(EXESUF)
240         rm -f doc/*.html doc/*.pod doc/*.1
241         rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
242         rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
243         rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
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 libavdevice distclean
251         $(MAKE) -C libpostproc distclean
252         $(MAKE) -C libswscale  distclean
253         rm -f .depend .vhookdep 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) -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