|
| 1 | +#! /usr/bin/env bash |
| 2 | +# |
| 3 | +# Copyright (C) 2021 Matt Reach<qianlongxu@gmail.com> |
| 4 | + |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | + |
| 18 | +# This script is based on projects below |
| 19 | +# https://github.com/bilibili/ijkplayer |
| 20 | + |
| 21 | +set -e |
| 22 | + |
| 23 | +error_handler() { |
| 24 | + echo "An error occurred!" |
| 25 | + tail -n20 ${MR_BUILD_SOURCE}/ffbuild/config.log |
| 26 | +} |
| 27 | + |
| 28 | +trap 'error_handler' ERR |
| 29 | + |
| 30 | +THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd) |
| 31 | +cd "$THIS_DIR" |
| 32 | + |
| 33 | +# ffmpeg config options |
| 34 | +source $MR_SHELL_CONFIGS_DIR/ffconfig/module.sh |
| 35 | +source $MR_SHELL_CONFIGS_DIR/ffconfig/auto-detect-third-libs.sh |
| 36 | + |
| 37 | +CFG_FLAGS= |
| 38 | +CFG_FLAGS="$CFG_FLAGS $COMMON_FF_CFG_FLAGS" |
| 39 | +CFG_FLAGS="$CFG_FLAGS $THIRD_CFG_FLAGS" |
| 40 | +CFG_FLAGS="$CFG_FLAGS --disable-avfilter" |
| 41 | +CFG_FLAGS="$CFG_FLAGS --disable-avdevice" |
| 42 | + |
| 43 | +C_FLAGS="$MR_DEFAULT_CFLAGS" |
| 44 | +EXTRA_LDFLAGS= |
| 45 | +LDFLAGS="$C_FLAGS $EXTRA_LDFLAGS" |
| 46 | +# C_FLAGS="$C_FLAGS -I/Users/matt/GitWorkspace/MoltenVK/Package/Release/MoltenVK/include" |
| 47 | +# use system xml2 lib |
| 48 | +# C_FLAGS="$C_FLAGS $(xml2-config --prefix=${MR_SYS_ROOT}/usr --cflags)" |
| 49 | +# LDFLAGS="$C_FLAGS $(xml2-config --prefix=${MR_SYS_ROOT}/usr --libs)" |
| 50 | + |
| 51 | +# LDFLAGS="$LDFLAGS -framework IOKit -framework Metal -framework IOSurface -framework CoreGraphics -framework QuartzCore -framework AppKit -framework Foundation -lc++ /Users/matt/GitWorkspace/MoltenVK/Package/Release/MoltenVK/static/MoltenVK.xcframework/macos-arm64_x86_64/libMoltenVK.a" |
| 52 | +echo "----------------------" |
| 53 | +echo "[*] configure" |
| 54 | + |
| 55 | +if [[ ! -d $MR_BUILD_SOURCE ]]; then |
| 56 | + echo "" |
| 57 | + echo "!! ERROR" |
| 58 | + echo "!! Can not find $MR_BUILD_SOURCE directory for $MR_BUILD_NAME" |
| 59 | + echo "!! Run 'init-*.sh' first" |
| 60 | + echo "" |
| 61 | + exit 1 |
| 62 | +fi |
| 63 | + |
| 64 | +cd $MR_BUILD_SOURCE |
| 65 | +if [[ -f "./config.h" ]]; then |
| 66 | + echo 'reuse configure' |
| 67 | +else |
| 68 | + echo |
| 69 | + echo "CC: $MR_CC" |
| 70 | + echo "CFLAGS: $C_FLAGS" |
| 71 | + echo "LDFLAG:$LDFLAGS" |
| 72 | + echo "FF_CFG_FLAGS: $CFG_FLAGS" |
| 73 | + echo |
| 74 | + ./configure \ |
| 75 | + $CFG_FLAGS \ |
| 76 | + --cc="$MR_CC" \ |
| 77 | + --as="perl ${MR_GAS_PERL} -arch ${MR_ARCH} -- $MR_CC" \ |
| 78 | + --extra-cflags="$C_FLAGS" \ |
| 79 | + --extra-cxxflags="$C_FLAGS" \ |
| 80 | + --extra-ldflags="$LDFLAGS" |
| 81 | +fi |
| 82 | + |
| 83 | +#---------------------- |
| 84 | +echo "----------------------" |
| 85 | +echo "[*] compile" |
| 86 | + |
| 87 | +make -j$MR_HOST_NPROC >/dev/null |
| 88 | + |
| 89 | +cp config.* $MR_BUILD_PREFIX |
| 90 | +make install >/dev/null |
| 91 | +mkdir -p $MR_BUILD_PREFIX/include/libffmpeg |
| 92 | +cp -f config.h $MR_BUILD_PREFIX/include/libffmpeg/ |
| 93 | +[ -e config_components.h ] && cp -f config_components.h $MR_BUILD_PREFIX/include/libffmpeg/ |
| 94 | +# copy private header for ffmpeg-kit. |
| 95 | +[ -e $MR_BUILD_SOURCE/libavutil/getenv_utf8.h ] && cp -f $MR_BUILD_SOURCE/libavutil/getenv_utf8.h $MR_BUILD_PREFIX/include/libavutil/ |
| 96 | +cp -f $MR_BUILD_SOURCE/libavutil/internal.h $MR_BUILD_PREFIX/include/libavutil/ |
| 97 | +cp -f $MR_BUILD_SOURCE/libavutil/libm.h $MR_BUILD_PREFIX/include/libavutil/ |
| 98 | +[ -e $MR_BUILD_SOURCE/libavutil/attributes_internal.h ] && cp -f $MR_BUILD_SOURCE/libavutil/attributes_internal.h $MR_BUILD_PREFIX/include/libavutil/ |
| 99 | +cp -f $MR_BUILD_SOURCE/libavcodec/mathops.h $MR_BUILD_PREFIX/include/libavcodec/ |
| 100 | + |
| 101 | +mkdir -p $MR_BUILD_PREFIX/include/libavcodec/x86/ |
| 102 | +cp -f $MR_BUILD_SOURCE/libavcodec/x86/mathops.h $MR_BUILD_PREFIX/include/libavcodec/x86/ |
| 103 | +mkdir -p $MR_BUILD_PREFIX/include/libavutil/x86/ |
| 104 | +cp -f $MR_BUILD_SOURCE/libavutil/x86/asm.h $MR_BUILD_PREFIX/include/libavutil/x86/ |
| 105 | +#copy private header for hls.c |
| 106 | +cp -f $MR_BUILD_SOURCE/libavformat/demux.h $MR_BUILD_PREFIX/include/libavformat/ |
| 107 | +cp -f $MR_BUILD_SOURCE/libavformat/http.h $MR_BUILD_PREFIX/include/libavformat/ |
| 108 | +cp -f $MR_BUILD_SOURCE/libavformat/hls_sample_encryption.h $MR_BUILD_PREFIX/include/libavformat/ |
0 commit comments