blob: 586efb74fddec17e476a0d568e2c388435da5541 (
plain)
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
|
#!/bin/sh
echo "$(pwd)" | grep -q '[[:blank:]]' &&
echo "Out of tree builds are impossible with whitespace in source path." && exit 1
if [ "${1}" == "x64" ]; then
arch=x86_64
archdir=x64
cross_prefix=x86_64-w64-mingw32-
lav_folder=LAVFilters64
mpc_hc_folder=mpc-hc_x64
else
arch=x86
archdir=Win32
cross_prefix=
lav_folder=LAVFilters
mpc_hc_folder=mpc-hc_x86
fi
if [ "${2}" == "Debug" ]; then
FFMPEG_DLL_PATH=$(readlink -f ../../..)/bin/${mpc_hc_folder}_Debug/${lav_folder}
BASEDIR=$(pwd)/src/bin_${archdir}d
else
FFMPEG_DLL_PATH=$(readlink -f ../../..)/bin/${mpc_hc_folder}/${lav_folder}
BASEDIR=$(pwd)/src/bin_${archdir}
fi
THIRDPARTYPREFIX=${BASEDIR}/thirdparty
FFMPEG_BUILD_PATH=${THIRDPARTYPREFIX}/ffmpeg
FFMPEG_LIB_PATH=${BASEDIR}/lib
DCADEC_SOURCE_PATH=$(pwd)/src/thirdparty/dcadec
DCADEC_BUILD_PATH=${THIRDPARTYPREFIX}/dcadec
export PKG_CONFIG_PATH="${DCADEC_BUILD_PATH}"
make_dirs() {
mkdir -p ${FFMPEG_LIB_PATH}
mkdir -p ${FFMPEG_BUILD_PATH}
mkdir -p ${DCADEC_BUILD_PATH}
mkdir -p ${FFMPEG_DLL_PATH}
}
copy_libs() {
# install -s --strip-program=${cross_prefix}strip lib*/*-lav-*.dll ${FFMPEG_DLL_PATH}
cp lib*/*-lav-*.dll ${FFMPEG_DLL_PATH}
${cross_prefix}strip ${FFMPEG_DLL_PATH}/*-lav-*.dll
cp -u lib*/*.lib ${FFMPEG_LIB_PATH}
}
clean() {
cd ${FFMPEG_BUILD_PATH}
echo Cleaning...
if [ -f config.mak ]; then
make distclean > /dev/null 2>&1
fi
cd ${BASEDIR}
}
configure() {
OPTIONS="
--enable-shared \
--disable-static \
--enable-version3 \
--enable-w32threads \
--disable-demuxer=asf \
--disable-demuxer=matroska \
--disable-filters \
--enable-filter=yadif \
--enable-filter=scale \
--disable-protocols \
--enable-protocol=file \
--enable-protocol=pipe \
--enable-protocol=mmsh \
--enable-protocol=mmst \
--enable-protocol=rtp \
--enable-protocol=http \
--enable-protocol=crypto \
--enable-protocol=rtmp \
--enable-protocol=rtmpt \
--disable-muxers \
--enable-muxer=spdif \
--disable-hwaccels \
--enable-hwaccel=h264_dxva2 \
--enable-hwaccel=hevc_dxva2 \
--enable-hwaccel=vc1_dxva2 \
--enable-hwaccel=wmv3_dxva2 \
--enable-hwaccel=mpeg2_dxva2 \
--disable-decoder=dca \
--enable-libdcadec \
--enable-libspeex \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-avresample \
--enable-avisynth \
--disable-avdevice \
--disable-postproc \
--disable-swresample \
--disable-encoders \
--disable-bsfs \
--disable-devices \
--disable-programs \
--disable-debug \
--disable-doc \
--build-suffix=-lav \
--arch=${arch}"
EXTRA_CFLAGS="-D_WIN32_WINNT=0x0502 -DWINVER=0x0502 -I../../../thirdparty/include"
EXTRA_LDFLAGS=""
if [ "${arch}" == "x86_64" ]; then
OPTIONS="${OPTIONS} --enable-cross-compile --cross-prefix=${cross_prefix} --target-os=mingw32 --pkg-config=pkg-config"
EXTRA_LDFLAGS="${EXTRA_LDFLAGS} -L../../../thirdparty/lib64"
else
OPTIONS="${OPTIONS} --cpu=i686"
EXTRA_CFLAGS="${EXTRA_CFLAGS} -mmmx -msse -mfpmath=sse"
EXTRA_LDFLAGS="${EXTRA_LDFLAGS} -L../../../thirdparty/lib32"
fi
sh ../../../ffmpeg/configure --extra-ldflags="${EXTRA_LDFLAGS}" --extra-cflags="${EXTRA_CFLAGS}" ${OPTIONS}
}
build() {
echo Building...
make -j$NUMBER_OF_PROCESSORS 2>&1 | tee make.log
## Check the return status and the log to detect possible errors
[ ${PIPESTATUS[0]} -eq 0 ] && ! grep -q -F "rerun configure" make.log
}
configureAndBuild() {
cd ${FFMPEG_BUILD_PATH}
## Don't run configure again if it was previously run
if [ ../../../ffmpeg/configure -ot config.mak ] &&
[ ../../../../build_ffmpeg.sh -ot config.mak ]; then
echo Skipping configure...
else
echo Configuring...
## run configure, redirect to file because of a msys bug
configure > config.out 2>&1
CONFIGRETVAL=$?
## show configure output
cat config.out
fi
## Only if configure succeeded, actually build
if [ ${CONFIGRETVAL} -eq 0 ]; then
build &&
copy_libs
CONFIGRETVAL=$?
fi
cd ${BASEDIR}
}
build_dcadec() {
cd ${DCADEC_BUILD_PATH}
make -f "${DCADEC_SOURCE_PATH}/Makefile" -j$NUMBER_OF_PROCESSORS CONFIG_WINDOWS=1 CONFIG_SMALL=1 CC=${cross_prefix}gcc AR=${cross_prefix}ar lib
make -f "${DCADEC_SOURCE_PATH}/Makefile" PREFIX="${THIRDPARTYPREFIX}" LIBDIR="${DCADEC_BUILD_PATH}/libdcadec" INCLUDEDIR="${DCADEC_SOURCE_PATH}" dcadec.pc
cd ${BASEDIR}
}
clean_dcadec() {
cd ${DCADEC_BUILD_PATH}
make -f "${DCADEC_SOURCE_PATH}/Makefile" CONFIG_WINDOWS=1 clean
cd ${BASEDIR}
}
echo Building ffmpeg in GCC ${arch} Release config...
make_dirs
CONFIGRETVAL=0
if [ "${3}" == "Clean" ]; then
clean_dcadec
clean
CONFIGRETVAL=$?
else
## Check if configure was previously run
if [ -f config.mak ]; then
CLEANBUILD=0
else
CLEANBUILD=1
fi
build_dcadec
configureAndBuild
## In case of error and only if we didn't start with a clean build,
## we try to rebuild from scratch including a full reconfigure
if [ ! ${CONFIGRETVAL} -eq 0 ] && [ ${CLEANBUILD} -eq 0 ]; then
echo Trying again with forced reconfigure...
clean_dcadec && build_dcadec
clean && configureAndBuild
fi
fi
exit ${CONFIGRETVAL}
|