Makefile 8.96 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 \
11
       -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE -DHAVE_AV_CONFIG_H
12
LDFLAGS+= -g
13

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

Diego Biurrun's avatar
Diego Biurrun committed
18 19 20
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
21

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

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

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

INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
INSTALL_TARGETS-$(BUILD_DOC)    += install-man
Måns Rullgård's avatar
Måns Rullgård committed
38

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

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
52
LIBS_imlib2$(SLIBSUF)       = `imlib2-config --libs`
Måns Rullgård's avatar
Måns Rullgård committed
53 54

VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
Måns Rullgård's avatar
Måns Rullgård committed
55
LIBS_drawtext$(SLIBSUF)        = `freetype-config --libs`
Måns Rullgård's avatar
Måns Rullgård committed
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)
Zdenek Kabelac's avatar
Zdenek Kabelac committed
62

Luca Abeni's avatar
Luca Abeni committed
63
ifeq ($(CONFIG_SWSCALER),yes)
64
LDFLAGS+=-L$(BUILD_ROOT)/libswscale
Diego Biurrun's avatar
Diego Biurrun committed
65
EXTRALIBS+=-lswscale$(BUILDSUF)
Luca Abeni's avatar
Luca Abeni committed
66 67
endif

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

Fabrice Bellard's avatar
Fabrice Bellard committed
70
lib:
71 72
	$(MAKE) -C libavutil   all
	$(MAKE) -C libavcodec  all
Fabrice Bellard's avatar
Fabrice Bellard committed
73
	$(MAKE) -C libavformat all
74
ifeq ($(CONFIG_PP),yes)
75
	$(MAKE) -C libpostproc all
76
endif
Luca Abeni's avatar
Luca Abeni committed
77 78 79
ifeq ($(CONFIG_SWSCALER),yes)
	$(MAKE) -C libswscale  all
endif
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
80

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

Fabrice Bellard's avatar
Fabrice Bellard committed
84
ffserver$(EXESUF): ffserver.o .libs
Diego Biurrun's avatar
Diego Biurrun committed
85
	$(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ ffserver.o $(EXTRALIBS)
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
86

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

90
%$(EXESUF): %_g$(EXESUF)
Fabrice Bellard's avatar
Fabrice Bellard committed
91 92 93
	cp -p $< $@
	$(STRIP) $@

94 95 96 97 98
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
version.h: $(SVN_ENTRIES)
endif

99
version.h:
100
	$(SRC_PATH)/version.sh $(SRC_PATH)
101

Fabrice Bellard's avatar
Fabrice Bellard committed
102
output_example$(EXESUF): output_example.o .libs
103
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
104

105
tools/qt-faststart$(EXESUF): qt-faststart.c
Måns Rullgård's avatar
Måns Rullgård committed
106
	$(CC) $(CFLAGS) $< -o $@
107

108
tools/cws2fws$(EXESUF): cws2fws.c
109
	$(CC) $(CFLAGS) $< -o $@ -lz
110

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

113 114
ffmpeg.o ffplay.o ffserver.o: version.h

115 116 117
videohook: .libs $(HOOKS)

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

120 121 122 123 124
vhook/%.o: vhook/%.c
	$(CC) $(VHOOKCFLAGS) -c -o $@ $<

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

126 127 128 129 130 131 132 133 134 135 136 137
documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
                                 ffplay-doc.html hooks.html $(ALLMANPAGES))

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=" " $< > $@
138

Måns Rullgård's avatar
Måns Rullgård committed
139
install: install-progs install-libs install-headers $(INSTALL_TARGETS-yes)
140

141
ifeq ($(BUILD_SHARED),yes)
142
install-progs: $(PROGS) install-libs
143
else
144
install-progs: $(PROGS)
145
endif
Fabrice Bellard's avatar
Fabrice Bellard committed
146
	install -d "$(bindir)"
147
	install -c -m 755 $(PROGS) "$(bindir)"
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
148

Diego Biurrun's avatar
Diego Biurrun committed
149
# Create the Windows installer.
Fabrice Bellard's avatar
Fabrice Bellard committed
150 151 152
wininstaller: all install
	makensis ffinstall.nsi

153
install-man:
154 155
	install -d "$(mandir)/man1"
	install -m 644 $(MANPAGES) "$(mandir)/man1"
156

157 158 159
install-vhook: videohook
	install -d "$(shlibdir)/vhook"
	install -m 755 $(HOOKS) "$(shlibdir)/vhook"
160

161
install-libs:
162 163 164
	$(MAKE) -C libavutil   install-libs
	$(MAKE) -C libavcodec  install-libs
	$(MAKE) -C libavformat install-libs
165
ifeq ($(CONFIG_PP),yes)
166
	$(MAKE) -C libpostproc install-libs
167
endif
Luca Abeni's avatar
Luca Abeni committed
168 169 170 171
ifeq ($(CONFIG_SWSCALER),yes)
	$(MAKE) -C libswscale  install-libs
endif

172
ifeq ($(BUILD_SHARED),yes)
173
	-$(LDCONFIG)
174
endif
175

176 177 178 179
install-headers:
	$(MAKE) -C libavutil   install-headers
	$(MAKE) -C libavcodec  install-headers
	$(MAKE) -C libavformat install-headers
180
ifeq ($(CONFIG_PP),yes)
181
	$(MAKE) -C libpostproc install-headers
182
endif
Luca Abeni's avatar
Luca Abeni committed
183
	$(MAKE) -C libswscale  install-headers
184

Diego Biurrun's avatar
Diego Biurrun committed
185 186 187 188 189 190 191 192 193
uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook

uninstall-progs:
	rm -f $(addprefix $(bindir)/, $(ALLPROGS))

uninstall-man:
	rm -f $(addprefix $(mandir)/man1/,$(ALLMANPAGES))

uninstall-vhook:
194 195
	rm -f $(addprefix $(shlibdir)/vhook/,$(ALLHOOKS))
	-rmdir "$(shlibdir)/vhook/"
Diego Biurrun's avatar
Diego Biurrun committed
196 197 198 199 200

uninstall-libs:
	$(MAKE) -C libavutil   uninstall-libs
	$(MAKE) -C libavcodec  uninstall-libs
	$(MAKE) -C libavformat uninstall-libs
201
	$(MAKE) -C libpostproc uninstall-libs
Diego Biurrun's avatar
Diego Biurrun committed
202 203 204 205 206

uninstall-headers:
	$(MAKE) -C libavutil   uninstall-headers
	$(MAKE) -C libavcodec  uninstall-headers
	$(MAKE) -C libavformat uninstall-headers
207
	$(MAKE) -C libpostproc uninstall-headers
Diego Biurrun's avatar
Diego Biurrun committed
208 209
	-rmdir "$(incdir)"

210
depend dep: .depend .vhookdep
211
	$(MAKE) -C libavutil   depend
212
	$(MAKE) -C libavcodec  depend
213
	$(MAKE) -C libavformat depend
214 215 216
ifeq ($(CONFIG_PP),yes)
	$(MAKE) -C libpostproc depend
endif
217 218 219
ifeq ($(CONFIG_SWSCALER),yes)
	$(MAKE) -C libswscale  depend
endif
220

221
.depend: $(SRCS) version.h
222
	$(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(filter-out %.h,$^) 1>.depend
223 224 225 226

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

228 229 230 231
$(DEP_LIBS): lib

.libs: $(DEP_LIBS)
	touch $@
232

233
clean:
234 235
	$(MAKE) -C libavutil   clean
	$(MAKE) -C libavcodec  clean
Fabrice Bellard's avatar
Fabrice Bellard committed
236
	$(MAKE) -C libavformat clean
237
	$(MAKE) -C libpostproc clean
Luca Abeni's avatar
Luca Abeni committed
238
	$(MAKE) -C libswscale  clean
239
	rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
Diego Biurrun's avatar
Diego Biurrun committed
240
	   output_example$(EXESUF) qt-faststart$(EXESUF) cws2fws$(EXESUF)
241
	rm -f doc/*.html doc/*.pod doc/*.1
242 243
	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))
244
	rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
245

Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
246
distclean: clean
247 248 249
	$(MAKE) -C libavutil   distclean
	$(MAKE) -C libavcodec  distclean
	$(MAKE) -C libavformat distclean
250
	$(MAKE) -C libpostproc distclean
Luca Abeni's avatar
Luca Abeni committed
251
	$(MAKE) -C libswscale  distclean
Diego Biurrun's avatar
Diego Biurrun committed
252
	rm -f .depend version.h config.* *.pc
Fabrice Bellard's avatar
merge  
Fabrice Bellard committed
253 254

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

257 258
# regression tests

259 260 261 262 263 264 265 266
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

267
test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
268 269 270 271 272 273
	@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

274
codectest mpeg4 mpeg ac3 snow snowll: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw tests/tiny_psnr$(EXESUF)
275 276 277
	$(SRC_PATH)/tests/regression.sh $@ $(FFMPEG_REFFILE)   tests/vsynth1
	$(SRC_PATH)/tests/regression.sh $@ $(ROTOZOOM_REFFILE) tests/vsynth2

278
libavtest: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
	$(SRC_PATH)/tests/regression.sh $@ $(LIBAV_REFFILE) tests/vsynth1
seektest: tests/seek_test$(EXESUF)
	$(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 $@ $<

tests/seek_test$(EXESUF): tests/seek_test.c
	$(CC) $(LDFLAGS) $(CFLAGS) -DHAVE_AV_CONFIG_H -o $@ $< $(EXTRALIBS)

309

310
.PHONY: all lib videohook documentation install* wininstaller uninstall*
311
.PHONY: dep depend clean distclean TAGS
312
.PHONY: codectest libavtest seektest test-server fulltest test
313
.PHONY: mpeg4 mpeg ac3 snow snowll swscale-error
314

315
-include .depend
316
-include .vhookdep