Fix previously broken x86_64 check, simplifying it in the process.
[libav.git] / Makefile
CommitLineData
a1b63811 1#
85f07f22 2# Main ffmpeg Makefile
38100e8c 3# (c) 2000-2004 Fabrice Bellard
85f07f22 4#
980fc7b8 5include config.mak
85f07f22 6
a426bbfc
MR
7SRC_DIR = $(SRC_PATH_BARE)
8
de2f77d8
MR
9vpath %.c $(SRC_PATH_BARE)
10vpath %.h $(SRC_PATH_BARE)
11vpath %.texi $(SRC_PATH_BARE)
dd9ca370 12
cbeee4d8 13CFLAGS=$(OPTFLAGS) -I$(BUILD_ROOT) -I$(SRC_PATH) -I$(SRC_PATH)/libavutil \
a163ed1a 14 -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat -I$(SRC_PATH)/libswscale \
f7679c54 15 -I$(SRC_PATH)/libavdevice -I$(SRC_PATH)/libavfilter \
364a9607 16 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE -DHAVE_AV_CONFIG_H
115329f1 17LDFLAGS+= -g
37736979 18
0cb8579a
MR
19PROGS-$(CONFIG_FFMPEG) += ffmpeg
20PROGS-$(CONFIG_FFPLAY) += ffplay
21PROGS-$(CONFIG_FFSERVER) += ffserver
01310af2 22
bb8fe69a
DB
23PROGS = $(addsuffix $(EXESUF), $(PROGS-yes))
24PROGS_G = $(addsuffix _g$(EXESUF), $(PROGS-yes))
25MANPAGES = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
85f07f22 26
bb8fe69a
DB
27BASENAMES = ffmpeg ffplay ffserver
28ALLPROGS = $(addsuffix $(EXESUF), $(BASENAMES))
29ALLPROGS_G = $(addsuffix _g$(EXESUF), $(BASENAMES))
30ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
6b991cb2 31
0fd94442 32ifeq ($(BUILD_SHARED),yes)
c721d803 33DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavdevice/$(SLIBPREF)avdevice$(SLIBSUF)
0fd94442 34else
c721d803 35DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavdevice/$(LIBPREF)avdevice$(LIBSUF)
f02be79d
RS
36endif
37
7d6ac9a3
MR
38ALL_TARGETS-$(CONFIG_VHOOK) += videohook
39ALL_TARGETS-$(BUILD_DOC) += documentation
40
41INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
1217916b
DB
42ifneq ($(PROGS),)
43INSTALL_TARGETS-yes += install-progs
282db5fd 44INSTALL_TARGETS-$(BUILD_DOC) += install-man
1217916b 45endif
dd9f3d97 46
3b26ee47 47VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
dd9f3d97
MR
48
49BASEHOOKS = fish null watermark
50ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
51ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
52
53HOOKS-$(HAVE_FORK) += ppm
54HOOKS-$(HAVE_IMLIB2) += imlib2
55HOOKS-$(HAVE_FREETYPE2) += drawtext
56
57HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
58
59VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
cbefadbd 60LIBS_imlib2$(SLIBSUF) = `imlib2-config --libs`
dd9f3d97
MR
61
62VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
cbefadbd 63LIBS_drawtext$(SLIBSUF) = `freetype-config --libs`
dd9f3d97
MR
64
65VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
142fc6b9 66
7f0f6e13 67SRCS = $(addsuffix .c, $(PROGS-yes)) cmdutils.c
c721d803
LA
68LDFLAGS := -L$(BUILD_ROOT)/libavdevice -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil $(LDFLAGS)
69EXTRALIBS := -lavdevice$(BUILDSUF) -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
57514323 70
13ca50f3 71ifeq ($(CONFIG_SWSCALE),yes)
06694949 72LDFLAGS+=-L$(BUILD_ROOT)/libswscale
6de9e506 73EXTRALIBS+=-lswscale$(BUILDSUF)
790c9ca7
LA
74endif
75
f7679c54
VS
76ifeq ($(CONFIG_AVFILTER),yes)
77LDFLAGS+=-L$(BUILD_ROOT)/libavfilter
78EXTRALIBS := -lavfilter$(BUILDSUF) $(EXTRALIBS)
79endif
80
a11f43a4
MR
81MAKE-yes = $(MAKE)
82MAKE- = : $(MAKE)
83
b1b18481 84all: lib $(PROGS_G) $(PROGS) $(ALL_TARGETS-yes)
85f07f22 85
951bf3e6 86lib:
20963a71
MR
87 $(MAKE) -C libavutil all
88 $(MAKE) -C libavcodec all
89 $(MAKE) -C libavformat all
90 $(MAKE) -C libavdevice all
4a24ab64 91 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc all
13ca50f3 92 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale all
f7679c54 93 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter all
85f07f22 94
b1b18481
DB
95ffplay_g$(EXESUF): EXTRALIBS += $(SDL_LIBS)
96ffserver_g$(EXESUF): LDFLAGS += $(FFSERVERLDFLAGS)
85f07f22 97
b1b18481
DB
98%_g$(EXESUF): %.o cmdutils.o .libs
99 $(CC) $(LDFLAGS) -o $@ $< cmdutils.o $(EXTRALIBS)
01310af2 100
0cfd96cc 101%$(EXESUF): %_g$(EXESUF)
01310af2
FB
102 cp -p $< $@
103 $(STRIP) $@
104
a4da50e1
MR
105SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
106ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
107version.h: $(SVN_ENTRIES)
108endif
109
f1cc88a5 110version.h:
997baf01 111 $(SRC_PATH)/version.sh $(SRC_PATH)
f1cc88a5 112
951bf3e6 113output_example$(EXESUF): output_example.o .libs
18caf192 114 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
8de65d4f 115
1521c500
DB
116tools/%$(EXESUF): tools/%.c
117 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
6da7cc81 118
3c889b5c 119ffplay.o .depend: CFLAGS += $(SDL_CFLAGS)
2744a37f 120
496cfa3c
MR
121ffmpeg.o ffplay.o ffserver.o: version.h
122
bab785a5
DB
123# vhooks compile fine without libav*, but need them nonetheless.
124videohook: .libs $(HOOKS)
ed5614eb
DB
125
126vhook/%$(SLIBSUF): vhook/%.o
3b26ee47 127 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
ed5614eb 128
3b26ee47
MR
129vhook/%.o: vhook/%.c
130 $(CC) $(VHOOKCFLAGS) -c -o $@ $<
131
132%.o: %.c
133 $(CC) $(CFLAGS) -c -o $@ $<
142fc6b9 134
e9b19db8 135documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
d0e1cd3d
DB
136 ffplay-doc.html general.html hooks.html \
137 $(ALLMANPAGES))
e9b19db8
DB
138
139doc/%.html: doc/%.texi
140 texi2html -monolithic -number $<
141 mv $(@F) $@
142
143doc/%.pod: doc/%-doc.texi
144 doc/texi2pod.pl $< $@
145
146doc/%.1: doc/%.pod
147 pod2man --section=1 --center=" " --release=" " $< > $@
146ea952 148
1217916b 149install: install-libs install-headers $(INSTALL_TARGETS-yes)
81dcdc53 150
a4848db6 151ifeq ($(BUILD_SHARED),yes)
e1a3a63f 152install-progs: install-libs
a4848db6 153endif
c4fa7ebc 154install-progs: $(PROGS)
22a324da
DB
155 install -d "$(BINDIR)"
156 install -c -m 755 $(PROGS) "$(BINDIR)"
85f07f22 157
23a65308 158install-man:
22a324da
DB
159 install -d "$(MANDIR)/man1"
160 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
23a65308 161
ed5614eb 162install-vhook: videohook
22a324da
DB
163 install -d "$(SHLIBDIR)/vhook"
164 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
142fc6b9 165
b12f8273 166install-libs:
20963a71
MR
167 $(MAKE) -C libavutil install-libs
168 $(MAKE) -C libavcodec install-libs
169 $(MAKE) -C libavformat install-libs
170 $(MAKE) -C libavdevice install-libs
4a24ab64 171 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-libs
13ca50f3 172 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale install-libs
3d323571 173 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-libs
37736979 174
f29f3b5d 175install-headers:
61c51088
DB
176 $(MAKE) -C libavutil install-headers
177 $(MAKE) -C libavcodec install-headers
178 $(MAKE) -C libavformat install-headers
179 $(MAKE) -C libavdevice install-headers
4a24ab64 180 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-headers
61c51088 181 $(MAKE) -C libswscale install-headers
f7679c54 182 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-headers
f29f3b5d 183
f9edb717
DB
184uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
185
f9edb717 186uninstall-progs:
1c2211bd 187 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
f9edb717 188
f9edb717 189uninstall-man:
1c2211bd 190 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
f9edb717
DB
191
192uninstall-vhook:
1c2211bd 193 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
22a324da 194 -rmdir "$(SHLIBDIR)/vhook/"
f9edb717
DB
195
196uninstall-libs:
197 $(MAKE) -C libavutil uninstall-libs
198 $(MAKE) -C libavcodec uninstall-libs
199 $(MAKE) -C libavformat uninstall-libs
c721d803 200 $(MAKE) -C libavdevice uninstall-libs
6d9a2421 201 $(MAKE) -C libpostproc uninstall-libs
65f37992 202 $(MAKE) -C libswscale uninstall-libs
f7679c54 203 $(MAKE) -C libavfilter uninstall-libs
f9edb717
DB
204
205uninstall-headers:
206 $(MAKE) -C libavutil uninstall-headers
207 $(MAKE) -C libavcodec uninstall-headers
208 $(MAKE) -C libavformat uninstall-headers
c721d803 209 $(MAKE) -C libavdevice uninstall-headers
6d9a2421 210 $(MAKE) -C libpostproc uninstall-headers
65f37992 211 $(MAKE) -C libswscale uninstall-headers
f7679c54 212 $(MAKE) -C libavfilter uninstall-headers
22a324da 213 -rmdir "$(INCDIR)"
f9edb717 214
3b26ee47 215depend dep: .depend .vhookdep
20963a71
MR
216 $(MAKE) -C libavutil depend
217 $(MAKE) -C libavcodec depend
218 $(MAKE) -C libavformat depend
219 $(MAKE) -C libavdevice depend
4a24ab64 220 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc depend
13ca50f3 221 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale depend
f7679c54 222 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter depend
4b8b2edb 223
fd071c26 224.depend: $(SRCS) version.h
315c741d 225 $(DEPEND_CMD) > $@
3b26ee47 226
fc900b7b 227.vhookdep: $(ALLHOOKS_SRCS) version.h
315c741d 228 $(VHOOK_DEPEND_CMD) > $@
57514323 229
da34f7ac
MR
230$(DEP_LIBS): lib
231
232.libs: $(DEP_LIBS)
233 touch $@
cf2818b0 234
98013cc1 235clean:
5d22ccf7
DB
236 $(MAKE) -C libavutil clean
237 $(MAKE) -C libavcodec clean
abac6175 238 $(MAKE) -C libavformat clean
c721d803 239 $(MAKE) -C libavdevice clean
6d9a2421 240 $(MAKE) -C libpostproc clean
790c9ca7 241 $(MAKE) -C libswscale clean
f7679c54 242 $(MAKE) -C libavfilter clean
b8d40825 243 rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
2b258bba 244 output_example$(EXESUF)
e9b19db8 245 rm -f doc/*.html doc/*.pod doc/*.1
4fbd52f0
DB
246 rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
247 rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
2b258bba 248 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
ed5614eb 249 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
142fc6b9 250
85f07f22 251distclean: clean
98013cc1
DB
252 $(MAKE) -C libavutil distclean
253 $(MAKE) -C libavcodec distclean
254 $(MAKE) -C libavformat distclean
c721d803 255 $(MAKE) -C libavdevice distclean
6d9a2421 256 $(MAKE) -C libpostproc distclean
790c9ca7 257 $(MAKE) -C libswscale distclean
f7679c54 258 $(MAKE) -C libavfilter distclean
2c8c5021 259 rm -f .depend .vhookdep version.h config.* *.pc
85f07f22
FB
260
261TAGS:
abac6175 262 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
57514323 263
dd9ca370
FB
264# regression tests
265
4fbd52f0 266fulltest test: codectest libavtest seektest
4fbd52f0
DB
267
268FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
269FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
270LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
271ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
272SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
273
4383ed5c
MR
274CODEC_TESTS = $(addprefix regtest-, \
275 mpeg \
276 mpeg2 \
277 mpeg2thread \
278 msmpeg4v2 \
279 msmpeg4 \
280 wmv1 \
281 wmv2 \
282 h261 \
283 h263 \
284 h263p \
285 mpeg4 \
286 huffyuv \
287 rc \
288 mpeg4adv \
289 mpeg4thread \
4383ed5c
MR
290 error \
291 mpeg4nr \
292 mpeg1b \
293 mjpeg \
294 ljpeg \
295 jpegls \
296 rv10 \
297 rv20 \
298 asv1 \
299 asv2 \
300 flv \
301 ffv1 \
302 snow \
303 snowll \
304 dv \
305 dv50 \
306 svq1 \
307 flashsv \
308 mp2 \
309 ac3 \
310 g726 \
311 adpcm_ima_wav \
9dc92a38 312 adpcm_ima_qt \
4383ed5c
MR
313 adpcm_ms \
314 adpcm_yam \
315 adpcm_swf \
316 flac \
317 wma \
318 )
319
2009721d
MR
320LAVF_TESTS = $(addprefix regtest-, \
321 avi \
322 asf \
323 rm \
324 mpg \
325 ts \
326 swf \
327 ffm \
328 flv_fmt \
329 mov \
330 dv_fmt \
331 gxf \
332 nut \
333 mkv \
334 pbmpipe \
335 pgmpipe \
336 ppmpipe \
337 gif \
338 yuv4mpeg \
339 pgm \
340 ppm \
341 bmp \
342 tga \
343 tiff \
344 sgi \
345 jpg \
346 wav \
347 alaw \
348 mulaw \
349 au \
350 mmf \
351 aiff \
352 voc \
353 ogg \
354 pixfmt \
355 )
4383ed5c
MR
356
357REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
358
359CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
360CODEC_VSYNTH = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
361
362LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
363
364LAVF_REG = tests/data/lavf.regression
365ROTOZOOM_REG = tests/data/rotozoom.regression
366VSYNTH_REG = tests/data/vsynth.regression
367
368codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
4411cb11
MR
369 diff -u -w $(FFMPEG_REFFILE) $(VSYNTH_REG)
370 diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
4383ed5c
MR
371
372libavtest: $(LAVF_REG)
373 diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
374
375$(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
376 cat $^ > $@
377
378$(LAVF_REG): $(LAVF_REGFILES)
379$(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
380$(VSYNTH_REG): $(CODEC_VSYNTH)
381
382$(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
383
384$(LAVF_REGFILES): $(LAVF_TESTS)
385
386$(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
387
388regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
389
390$(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
2009721d
MR
391 $(SRC_PATH)/tests/regression.sh $@ vsynth tests/vsynth1 a
392 $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
4383ed5c
MR
393
394$(LAVF_TESTS):
2009721d 395 $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
4383ed5c
MR
396
397seektest: codectest libavtest tests/seek_test$(EXESUF)
398 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
399
b13cdd33 400test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
4fbd52f0
DB
401 @echo
402 @echo "Unfortunately ffserver is broken and therefore its regression"
403 @echo "test fails randomly. Treat the results accordingly."
404 @echo
405 $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
406
13ca50f3 407ifeq ($(CONFIG_SWSCALE),yes)
4383ed5c 408test-server codectest $(CODEC_TESTS) libavtest: swscale_error
4fbd52f0
DB
409swscale_error:
410 @echo
13ca50f3 411 @echo "This regression test is incompatible with --enable-swscale."
4fbd52f0
DB
412 @echo
413 @exit 1
414endif
415
416tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
417 mkdir -p tests/vsynth1
418 $(BUILD_ROOT)/$< 'tests/vsynth1/'
419
420tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
421 mkdir -p tests/vsynth2
422 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
423
424tests/asynth1.sw: tests/audiogen$(EXESUF)
425 $(BUILD_ROOT)/$< $@
426
427%$(EXESUF): %.c
428 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
429
06396e11 430tests/seek_test$(EXESUF): tests/seek_test.c .libs
ff21c1b0 431 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
4fbd52f0 432
dd9ca370 433
1b9cec96 434.PHONY: all lib videohook documentation install* uninstall*
bedb3550 435.PHONY: dep depend clean distclean TAGS
5e2dfd39 436.PHONY: codectest libavtest seektest test-server fulltest test
4383ed5c 437.PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error
cf2818b0 438
6ca0c110 439-include .depend
3b26ee47 440-include .vhookdep