88 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
if [ $# -eq 0 ]; then
echo "No command line parameters are provided. Please enter '$0 -h' to view usage instructions."
exit 1
fi
if test x"$1" = x"-h" -o x"$1" = x"--help"; then
cat <<EOF
Usage: ./configure [options]
Help:
-h, --help print this message
Standard options:
-x86_64 编译x86_64平台的库文件
-arm 编译arm32平台的库文件
-aarch64 编译aarch64平台的库文件
EOF
exit 1
fi
OPENCV_BUILD_DIR=$(pwd)
PROJECT_ROOT_DIR="${OPENCV_BUILD_DIR}/../.."
# configure
if [[ x"$1" = x"-x86_64" ]];then
if [ -d x86_64 ]; then
rm -rf x86_64
fi
mkdir -p x86_64/install
cd x86_64
# 导出 x264 pkg-config 查找文件的环境变量
export PKG_CONFIG_PATH=${PROJECT_ROOT_DIR}/thirdparty/x264_build/x86_64/install/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=${PROJECT_ROOT_DIR}/thirdparty/ffmpeg_build/x86_64/install/lib/pkgconfig:$PKG_CONFIG_PATH
cmake -DCMAKE_INSTALL_PREFIX=${OPENCV_BUILD_DIR}/x86_64/install \
-DWITH_FFMPEG=ON \
-DFFMPEG_INCLUDE_DIRS=${PROJECT_ROOT_DIR}/thirdparty/ffmpeg_build/x86_64/install/include \
-DFFMPEG_LIBRARIES="${PROJECT_ROOT_DIR}/thirdparty/ffmpeg_build/x86_64/install/lib/libavcodec.a;${PROJECT_ROOT_DIR}/thirdparty/ffmpeg_build/x86_64/install/lib/libavformat.a;${PROJECT_ROOT_DIR}/thirdparty/ffmpeg_build/x86_64/install/lib/libavutil.a;${PROJECT_ROOT_DIR}/thirdparty/ffmpeg_build/x86_64/install/lib/libswscale.a" \
-DWITH_X264=ON \
-DX264_INCLUDE_DIR=${PROJECT_ROOT_DIR}/thirdparty/x264_build/x86_64/install/include \
-DX264_LIBRARY=${PROJECT_ROOT_DIR}/thirdparty/x264_build/x86_64/install/lib/libx264.a \
-DBUILD_SHARED_LIBS=OFF \
-DOPENCV_FFMPEG_SKIP_BUILD_CHECK=ON \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_opencv_python2=OFF \
-DBUILD_opencv_python3=OFF \
-DBUILD_opencv_java=OFF \
-DWITH_GTK=ON \
../opencv/
if [ $? -ne 0 ]; then
echo "ffmpeg configure failed!"
exit 1
fi
make -j8
if [ $? -ne 0 ]; then
echo "ffmpeg make failed!"
exit 1
fi
make install
if [ $? -ne 0 ]; then
echo "ffmpeg make install failed!"
exit 1
fi
elif [[ x"$1" = x"-arm" ]];then
echo "compile arm32"
elif [[ x"$1" = x"-aarch64" ]];then
echo "compile arm64"
else
echo "parameters error"
fi
if [ $? -ne 0 ];then
echo "Exec configure failed!"
exit 1
fi