1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
#
# This Makefile provides automatic build environment for FFmpeg
#
####################################################################################################
# Configuration
# commands
JOBS ?= $(shell expr $(shell cat /proc/cpuinfo | grep processor | wc -l) + 2)
MAKE = make -j$(JOBS)
RM = rm -rf
CD = cd
TOUCH = touch
QUILT = quilt
GIT = git
BZR = bzr
APT_GET ?= @echo "W: Skipping apt-get... (set APT_GET=\"sudo apt-get\" to enable automatic installation)" && true
CHECKINSTALL = sudo checkinstall --backup=no --default
# version suffix (.deb)
VERSION_SUFFIX = $(shell date +%Y%m%d)
# Required packages to run this script
ALL_DEPS := build-essential bzr subversion git-core checkinstall
# libx264 configure script options
X264_OPTS ?= --enable-pic --enable-shared
# Required packages to build libx264
X264_DEPS ?= yasm
# FFmpeg configure script options
FFMPEG_OPTS ?= \
--enable-gpl --enable-version3 --enable-nonfree \
--enable-postproc --enable-pthreads --enable-runtime-cpudetect --enable-pic \
--enable-avfilter --enable-vdpau --enable-bzlib --enable-zlib --enable-vaapi --enable-x11grab \
--enable-libfaac --enable-libmp3lame \
--enable-libopencore-amrnb --enable-libopencore-amrwb \
--enable-libx264 --enable-libxvid --enable-libtheora --enable-libvorbis \
--enable-libdirac --enable-libschroedinger --enable-libvpx \
--enable-libopenjpeg --enable-libgsm --enable-libspeex --enable-libdc1394
# Required packages to build ffmpeg
FFMPEG_DEPS ?= \
yasm pkg-config libva-dev libvdpau-dev \
libdirac-dev libfaac-dev libgsm1-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libvpx-dev \
libopenjpeg-dev libschroedinger-dev libspeex-dev libtheora-dev libvorbis-dev libxvidcore-dev libdc1394-22-dev
# ffpreset deps
FFPRESET_DEPS = autoconf automake
# FFmpeg repository root
FFMPEG_REPOS_ROOT = git://git.videolan.org/ffmpeg.git
# libx264 repository root
X264_REPOS_ROOT = git://git.videolan.org/x264.git
# FFmpeg repository directory
FFMPEG_REPOS_DIR = ffmpeg_repos
# libx264 repository directory
X264_REPOS_DIR = x264_repos
# ffpreset directory
FFPRESET_DIR = ffpreset
# suite
SUITE = $(shell lsb_release --codename --short)
# all extra tools (or, more precisely targets) that should be run
FFMPEG_CONFIGURE_EXTRA_DEPENDS_ALL =
####################################################################################################
# PHONY targets
.PHONY: all clean
all: ffmpeg-all
all-deps: all-deps-stamp
all-deps-stamp:
$(APT_GET) install $(ALL_DEPS)
$(TOUCH) $@
clean: ffmpeg-clean x264-clean
$(RM) *-stamp
####################################################################################################
# Suit specific rules
ffmpeg-configure-extra-depends-stamp: $(FFMPEG_CONFIGURE_EXTRA_DEPENDS_ALL)
$(TOUCH) $@
####################################################################################################
# FFmpeg
.PHONY: ffmpeg-all ffmpeg-clean ffmpeg-repos ffmpeg-update ffmpeg-configure ffmpeg-build ffmpeg-install
ffmpeg-all: ffmpeg-install-stamp
ffmpeg-clean:
-sudo $(RM) $(FFMPEG_REPOS_DIR)/doc-pak $(FFMPEG_REPOS_DIR)/*.deb $(FFMPEG_REPOS_DIR)/description-pak
-$(CD) $(FFMPEG_REPOS_DIR) && $(MAKE) clean
ffmpeg-repos: ffmpeg-repos-stamp
ffmpeg-repos-stamp: all-deps-stamp
if [ ! -d $(FFMPEG_REPOS_DIR) ]; then \
$(GIT) clone $(FFMPEG_REPOS_ROOT) $(FFMPEG_REPOS_DIR); \
fi
$(TOUCH) $@
ffmpeg-update: ffmpeg-update-stamp
ffmpeg-update-stamp: ffmpeg-repos-stamp
$(CD) $(FFMPEG_REPOS_DIR) && $(GIT) pull
$(TOUCH) $@
ffmpeg-deps: ffmpeg-deps-stamp
ffmpeg-deps-stamp:
$(APT_GET) install $(FFMPEG_DEPS)
$(TOUCH) $@
ffmpeg-configure: ffmpeg-configure-stamp
ffmpeg-configure-stamp: ffmpeg-update-stamp ffmpeg-deps-stamp ffmpeg-configure-extra-depends-stamp
$(CD) $(FFMPEG_REPOS_DIR) && LDFLAGS=-L/usr/local/lib ./configure $(FFMPEG_OPTS)
$(TOUCH) $@
ffmpeg-build: ffmpeg-build-stamp
ffmpeg-build-stamp: ffmpeg-configure-stamp
$(CD) $(FFMPEG_REPOS_DIR) && $(MAKE) all
$(TOUCH) $@
ffmpeg-install: ffmpeg-install-stamp
ffmpeg-install-stamp: ffmpeg-build-stamp
$(CD) $(FFMPEG_REPOS_DIR) && $(CHECKINSTALL) --pkgname ffmpeg --pkgversion "4:0.8.2+git$(VERSION_SUFFIX)"
sudo ldconfig
$(TOUCH) $@
####################################################################################################
# ffpreset
.PHONY: ffpreset-all ffpreset-clean ffpreset-configure ffpreset-build ffpreset-install
ffpreset-all: ffpreset-install-stamp
ffpreset-clean:
-sudo $(RM) $(FFPRESED_DIR)/doc-pak $(FFPRESET_DIR)/*.deb $(FFPRESET_DIR)/description-pak
-$(CD) $(FFPRESET_DIR) && $(MAKE) clean
ffpreset-deps: ffpreset-deps-stamp
ffpreset-deps-stamp:
$(APT_GET) install $(FFPRESET_DEPS)
$(TOUCH) $@
ffpreset-configure: ffpreset-configure-stamp
ffpreset-configure-stamp: ffpreset-deps-stamp
$(CD) $(FFPRESET_DIR) && autoreconf --install
$(CD) $(FFPRESET_DIR) && ./configure
$(TOUCH) $@
ffpreset-build: ffpreset-build-stamp
ffpreset-build-stamp: ffpreset-configure-stamp
$(CD) $(FFPRESET_DIR) && $(MAKE) all
$(TOUCH) $@
ffpreset-install: ffpreset-install-stamp
ffpreset-install-stamp: ffpreset-build-stamp
$(CD) $(FFPRESET_DIR) && $(CHECKINSTALL) --pkgname ffpreset --pkgversion "0.1"
$(TOUCH) $@
####################################################################################################
# x264
.PHONY: x264-all x264-clean x264-repos x264-update x264-configure x264-build x264-install
x264-all: x264-install-stamp
x264-clean:
-sudo $(RM) $(X264_REPOS_DIR)/doc-pak $(X264_REPOS_DIR)/*.deb $(X264_REPOS_DIR)/description-pak
-$(CD) $(X264_REPOS_DIR) && $(MAKE) clean
x264-repos: x264-repos-stamp
x264-repos-stamp: all-deps-stamp
if [ ! -d $(X264_REPOS_DIR) ]; then \
$(GIT) clone $(X264_REPOS_ROOT) $(X264_REPOS_DIR); \
fi
$(TOUCH) $@
x264-update: x264-update-stamp
x264-update-stamp: x264-repos-stamp
$(CD) $(X264_REPOS_DIR) && $(GIT) pull
$(TOUCH) $@
x264-configure: x264-configure-stamp
x264-configure-stamp: x264-update-stamp
$(CD) $(X264_REPOS_DIR) && ./configure $(X264_OPTS)
$(TOUCH) $@
x264-build: x264-build-stamp
x264-build-stamp: x264-configure-stamp
$(CD) $(X264_REPOS_DIR) && $(MAKE)
$(TOUCH) $@
x264-install: x264-install-stamp
x264-install-stamp: x264-build-stamp
$(CD) $(X264_REPOS_DIR) && $(CHECKINSTALL) --pkgname x264 --pkgversion "2:1+git$(VERSION_SUFFIX)"
$(TOUCH) $@
|