Makefile 9.78 KB
Newer Older
1
#
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
2
# Main ffmpeg Makefile
3
# (c) 2000-2004 Fabrice Bellard
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
4
#
5
include config.mak
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
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 \
Luca Abeni's avatar
Luca Abeni committed
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

Måns Rullgård's avatar
Måns Rullgård committed
15 16 17
PROGS-$(CONFIG_FFMPEG)   += ffmpeg
PROGS-$(CONFIG_FFPLAY)   += ffplay
PROGS-$(CONFIG_FFSERVER) += ffserver
Fabrice Bellard's avatar
Fabrice Bellard committed
18

Diego Biurrun's avatar
Diego Biurrun committed
19 20 21
PROGS       = $(addsuffix   $(EXESUF), $(PROGS-yes))
PROGS_G     = $(addsuffix _g$(EXESUF), $(PROGS-yes))
MANPAGES    = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
22

Diego Biurrun's avatar
Diego Biurrun committed
23 24 25 26
BASENAMES   = ffmpeg ffplay ffserver
ALLPROGS    = $(addsuffix   $(EXESUF), $(BASENAMES))
ALLPROGS_G  = $(addsuffix _g$(EXESUF), $(BASENAMES))
ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
27

Nick Kurshev's avatar
Nick Kurshev committed
28
ifeq ($(BUILD_SHARED),yes)
Luca Abeni's avatar
Luca Abeni committed
29
DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavdevice/$(SLIBPREF)avdevice$(SLIBSUF)
Nick Kurshev's avatar
Nick Kurshev committed
30
else
Luca Abeni's avatar
Luca Abeni committed
31
DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavdevice/$(LIBPREF)avdevice$(LIBSUF)
32 33
endif

Måns Rullgård's avatar
Måns Rullgård committed
34 35 36 37
ALL_TARGETS-$(CONFIG_VHOOK) += videohook
ALL_TARGETS-$(BUILD_DOC)    += documentation

INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
38 39
ifneq ($(PROGS),)
INSTALL_TARGETS-yes             += install-progs
40
INSTALL_TARGETS-$(BUILD_DOC)    += install-man
41
endif
Måns Rullgård's avatar
Måns Rullgård committed
42

43
VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
Måns Rullgård's avatar
Måns Rullgård committed
44 45 46 47 48 49 50 51 52 53 54 55

BASEHOOKS = fish null watermark
ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))

HOOKS-$(HAVE_FORK)      += ppm
HOOKS-$(HAVE_IMLIB2)    += imlib2
HOOKS-$(HAVE_FREETYPE2) += drawtext

HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))

VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
Måns Rullgård's avatar
Måns Rullgård committed
56
LIBS_imlib2$(SLIBSUF)       = `imlib2-config --libs`
Måns Rullgård's avatar
Måns Rullgård committed
57 58

VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
Måns Rullgård's avatar
Måns Rullgård committed
59
LIBS_drawtext$(SLIBSUF)        = `freetype-config --libs`
Måns Rullgård's avatar
Måns Rullgård committed
60 61

VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
62

63
SRCS = $(addsuffix .c, $(PROGS-yes)) cmdutils.c
Luca Abeni's avatar
Luca Abeni committed
64 65
LDFLAGS := -L$(BUILD_ROOT)/libavdevice -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil $(LDFLAGS)
EXTRALIBS := -lavdevice$(BUILDSUF) -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
Zdenek Kabelac's avatar
Zdenek Kabelac committed
66

Luca Abeni's avatar
Luca Abeni committed
67
ifeq ($(CONFIG_SWSCALER),yes)
68
LDFLAGS+=-L$(BUILD_ROOT)/libswscale
Diego Biurrun's avatar
Diego Biurrun committed
69
EXTRALIBS+=-lswscale$(BUILDSUF)
Luca Abeni's avatar
Luca Abeni committed
70 71
endif

Måns Rullgård's avatar
Måns Rullgård committed
72
all: lib $(PROGS) $(ALL_TARGETS-yes)
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
73

Fabrice Bellard's avatar
Fabrice Bellard committed
74
lib:
75 76
	$(MAKE) -C libavutil   all
	$(MAKE) -C libavcodec  all
Fabrice Bellard's avatar
Fabrice Bellard committed
77
	$(MAKE) -C libavformat all
Luca Abeni's avatar
Luca Abeni committed
78
	$(MAKE) -C libavdevice all
79
ifeq ($(CONFIG_PP),yes)
80
	$(MAKE) -C libpostproc all
81
endif
Luca Abeni's avatar
Luca Abeni committed
82 83 84
ifeq ($(CONFIG_SWSCALER),yes)
	$(MAKE) -C libswscale  all
endif
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
85

Fabrice Bellard's avatar
Fabrice Bellard committed
86
ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
Diego Biurrun's avatar
Diego Biurrun committed
87
	$(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(EXTRALIBS)
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
88

89 90
ffserver$(EXESUF): ffserver.o cmdutils.o .libs
	$(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ ffserver.o cmdutils.o $(EXTRALIBS)
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
91

Fabrice Bellard's avatar
Fabrice Bellard committed
92
ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
Diego Biurrun's avatar
Diego Biurrun committed
93
	$(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(EXTRALIBS) $(SDL_LIBS)
Fabrice Bellard's avatar
Fabrice Bellard committed
94

95
%$(EXESUF): %_g$(EXESUF)
Fabrice Bellard's avatar
Fabrice Bellard committed
96 97 98
	cp -p $< $@
	$(STRIP) $@

99 100 101 102 103
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
version.h: $(SVN_ENTRIES)
endif

104
version.h:
105
	$(SRC_PATH)/version.sh $(SRC_PATH)
106

Fabrice Bellard's avatar
Fabrice Bellard committed
107
output_example$(EXESUF): output_example.o .libs
108
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
109

110 111 112
tools/pktdumper$(EXESUF): tools/pktdumper.c
	$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(EXTRALIBS)

Benoit Fouet's avatar
Benoit Fouet committed
113
tools/qt-faststart$(EXESUF): tools/qt-faststart.c
Måns Rullgård's avatar
Måns Rullgård committed
114
	$(CC) $(CFLAGS) $< -o $@
115

Benoit Fouet's avatar
Benoit Fouet committed
116
tools/cws2fws$(EXESUF): tools/cws2fws.c
117
	$(CC) $(CFLAGS) $< -o $@ -lz
118

119 120 121
tools/trasher$(EXESUF): tools/trasher.c
	$(CC) $(CFLAGS) $< -o $@

122
ffplay.o: CFLAGS += $(SDL_CFLAGS)
Fabrice Bellard's avatar
Fabrice Bellard committed
123

124 125
ffmpeg.o ffplay.o ffserver.o: version.h

126 127 128
videohook: .libs $(HOOKS)

vhook/%$(SLIBSUF): vhook/%.o
129
	$(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
130

131 132 133 134 135
vhook/%.o: vhook/%.c
	$(CC) $(VHOOKCFLAGS) -c -o $@ $<

%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<
136

137
documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
138 139
                                 ffplay-doc.html general.html hooks.html \
                                 $(ALLMANPAGES))
140 141 142 143 144 145 146 147 148 149

doc/%.html: doc/%.texi
	texi2html -monolithic -number $<
	mv $(@F) $@

doc/%.pod: doc/%-doc.texi
	doc/texi2pod.pl $< $@

doc/%.1: doc/%.pod
	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 158
	install -d "$(BINDIR)"
	install -c -m 755 $(PROGS) "$(BINDIR)"
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
159

Diego Biurrun's avatar
Diego Biurrun committed
160
# Create the Windows installer.
Fabrice Bellard's avatar
Fabrice Bellard committed
161 162 163
wininstaller: all install
	makensis ffinstall.nsi

164
install-man:
165 166
	install -d "$(MANDIR)/man1"
	install -m 644 $(MANPAGES) "$(MANDIR)/man1"
167

168
install-vhook: videohook
169 170
	install -d "$(SHLIBDIR)/vhook"
	install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
171

172
install-libs:
173 174 175
	$(MAKE) -C libavutil   install-libs
	$(MAKE) -C libavcodec  install-libs
	$(MAKE) -C libavformat install-libs
Luca Abeni's avatar
Luca Abeni committed
176
	$(MAKE) -C libavdevice install-libs
177
ifeq ($(CONFIG_PP),yes)
178
	$(MAKE) -C libpostproc install-libs
179
endif
Luca Abeni's avatar
Luca Abeni committed
180 181 182 183
ifeq ($(CONFIG_SWSCALER),yes)
	$(MAKE) -C libswscale  install-libs
endif

184
ifeq ($(BUILD_SHARED),yes)
185
	-$(LDCONFIG)
186
endif
187

188 189 190 191
install-headers:
	$(MAKE) -C libavutil   install-headers
	$(MAKE) -C libavcodec  install-headers
	$(MAKE) -C libavformat install-headers
Luca Abeni's avatar
Luca Abeni committed
192
	$(MAKE) -C libavdevice install-headers
193
ifeq ($(CONFIG_PP),yes)
194
	$(MAKE) -C libpostproc install-headers
195
endif
Luca Abeni's avatar
Luca Abeni committed
196
	$(MAKE) -C libswscale  install-headers
197

Diego Biurrun's avatar
Diego Biurrun committed
198 199 200
uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook

uninstall-progs:
201
	rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
Diego Biurrun's avatar
Diego Biurrun committed
202 203

uninstall-man:
204
	rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
Diego Biurrun's avatar
Diego Biurrun committed
205 206

uninstall-vhook:
207
	rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
208
	-rmdir "$(SHLIBDIR)/vhook/"
Diego Biurrun's avatar
Diego Biurrun committed
209 210 211 212 213

uninstall-libs:
	$(MAKE) -C libavutil   uninstall-libs
	$(MAKE) -C libavcodec  uninstall-libs
	$(MAKE) -C libavformat uninstall-libs
Luca Abeni's avatar
Luca Abeni committed
214
	$(MAKE) -C libavdevice uninstall-libs
215
	$(MAKE) -C libpostproc uninstall-libs
216
	$(MAKE) -C libswscale  uninstall-libs
Diego Biurrun's avatar
Diego Biurrun committed
217 218 219 220 221

uninstall-headers:
	$(MAKE) -C libavutil   uninstall-headers
	$(MAKE) -C libavcodec  uninstall-headers
	$(MAKE) -C libavformat uninstall-headers
Luca Abeni's avatar
Luca Abeni committed
222
	$(MAKE) -C libavdevice uninstall-headers
223
	$(MAKE) -C libpostproc uninstall-headers
224
	$(MAKE) -C libswscale  uninstall-headers
225
	-rmdir "$(INCDIR)"
Diego Biurrun's avatar
Diego Biurrun committed
226

227
depend dep: .depend .vhookdep
228
	$(MAKE) -C libavutil   depend
229
	$(MAKE) -C libavcodec  depend
230
	$(MAKE) -C libavformat depend
Luca Abeni's avatar
Luca Abeni committed
231
	$(MAKE) -C libavdevice depend
232 233 234
ifeq ($(CONFIG_PP),yes)
	$(MAKE) -C libpostproc depend
endif
235 236 237
ifeq ($(CONFIG_SWSCALER),yes)
	$(MAKE) -C libswscale  depend
endif
238

239
.depend: $(SRCS) version.h
240
	$(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(filter-out %.h,$^) 1>.depend
241

Diego Biurrun's avatar
Diego Biurrun committed
242
# gcc stupidly only outputs the basename of targets with -MM
243 244
.vhookdep: $(ALLHOOKS_SRCS)
	$(CC) $(VHOOKCFLAGS) -MM $^ | sed 's,^\([a-z]\),vhook/\1,' > $@
Zdenek Kabelac's avatar
Zdenek Kabelac committed
245

246 247 248 249
$(DEP_LIBS): lib

.libs: $(DEP_LIBS)
	touch $@
250

251
clean:
252 253
	$(MAKE) -C libavutil   clean
	$(MAKE) -C libavcodec  clean
Fabrice Bellard's avatar
Fabrice Bellard committed
254
	$(MAKE) -C libavformat clean
Luca Abeni's avatar
Luca Abeni committed
255
	$(MAKE) -C libavdevice clean
256
	$(MAKE) -C libpostproc clean
Luca Abeni's avatar
Luca Abeni committed
257
	$(MAKE) -C libswscale  clean
258
	rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
Diego Biurrun's avatar
Diego Biurrun committed
259
	   output_example$(EXESUF) qt-faststart$(EXESUF) cws2fws$(EXESUF)
260
	rm -f doc/*.html doc/*.pod doc/*.1
261 262
	rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
	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

Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
265
distclean: clean
266 267 268
	$(MAKE) -C libavutil   distclean
	$(MAKE) -C libavcodec  distclean
	$(MAKE) -C libavformat distclean
Luca Abeni's avatar
Luca Abeni committed
269
	$(MAKE) -C libavdevice distclean
270
	$(MAKE) -C libpostproc distclean
Luca Abeni's avatar
Luca Abeni committed
271
	$(MAKE) -C libswscale  distclean
272
	rm -f .depend .vhookdep version.h config.* *.pc
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
273 274

TAGS:
Fabrice Bellard's avatar
Fabrice Bellard committed
275
	etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
Zdenek Kabelac's avatar
Zdenek Kabelac committed
276

277 278
# regression tests

279 280 281 282 283 284 285 286
fulltest test: codectest libavtest seektest

FFMPEG_REFFILE   = $(SRC_PATH)/tests/ffmpeg.regression.ref
FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
LIBAV_REFFILE    = $(SRC_PATH)/tests/libav.regression.ref
ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
SEEK_REFFILE     = $(SRC_PATH)/tests/seek.regression.ref

287
test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
288 289 290 291 292 293
	@echo
	@echo "Unfortunately ffserver is broken and therefore its regression"
	@echo "test fails randomly. Treat the results accordingly."
	@echo
	$(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf

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 296 297
	$(SRC_PATH)/tests/regression.sh $@ $(FFMPEG_REFFILE)   tests/vsynth1
	$(SRC_PATH)/tests/regression.sh $@ $(ROTOZOOM_REFFILE) tests/vsynth2

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 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
	$(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)

ifeq ($(CONFIG_SWSCALER),yes)
test-server codectest mpeg4 mpeg ac3 snow snowll libavtest: swscale_error
swscale_error:
	@echo
	@echo "This regression test is incompatible with --enable-swscaler."
	@echo
	@exit 1
endif

tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
	mkdir -p tests/vsynth1
	$(BUILD_ROOT)/$< 'tests/vsynth1/'

tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
	mkdir -p tests/vsynth2
	$(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm

tests/asynth1.sw: tests/audiogen$(EXESUF)
	$(BUILD_ROOT)/$< $@

%$(EXESUF): %.c
	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<

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