2020-08-05 03:26:42 +03:00
#!/bin/bash
if [ [ -z ${ ARCH } ] ] ; then
2020-08-05 03:53:02 +03:00
echo -e "\n(*) ARCH not defined\n"
exit 1
2020-08-05 03:26:42 +03:00
fi
if [ [ -z ${ IOS_MIN_VERSION } ] ] ; then
2020-08-05 03:53:02 +03:00
echo -e "\n(*) IOS_MIN_VERSION not defined\n"
exit 1
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
if [ [ -z ${ BASEDIR } ] ] ; then
echo -e "\n(*) BASEDIR not defined\n"
exit 1
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
if [ [ -z ${ SDK_PATH } ] ] ; then
echo -e "\n(*) SDK_PATH not defined\n"
exit 1
2020-08-05 03:26:42 +03:00
fi
# ENABLE COMMON FUNCTIONS
2020-11-23 00:51:45 +02:00
source " ${ BASEDIR } " /scripts/function-" ${ FFMPEG_KIT_BUILD_TYPE } " .sh 1>>" ${ BASEDIR } " /build.log 2>& 1 || exit 1
2020-08-05 03:26:42 +03:00
2021-10-09 17:14:44 +03:00
echo -e " \nBuilding ${ ARCH } platform targeting iOS SDK ${ IOS_MIN_VERSION } and Mac Catalyst ${ MAC_CATALYST_MIN_VERSION } \n "
echo -e " \nINFO: Starting new build for ${ ARCH } targeting iOS SDK ${ IOS_MIN_VERSION } and Mac Catalyst ${ MAC_CATALYST_MIN_VERSION } at $( date) \n " 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:53:02 +03:00
# SET BASE INSTALLATION DIRECTORY FOR THIS ARCHITECTURE
2020-11-23 00:51:45 +02:00
export LIB_INSTALL_BASE = " ${ BASEDIR } /prebuilt/ $( get_build_directory) "
2020-08-05 03:26:42 +03:00
2020-08-05 03:53:02 +03:00
# CREATE PACKAGE CONFIG DIRECTORY FOR THIS ARCHITECTURE
2020-11-23 00:51:45 +02:00
PKG_CONFIG_DIRECTORY = " ${ LIB_INSTALL_BASE } /pkgconfig "
2020-08-05 03:53:02 +03:00
if [ ! -d " ${ PKG_CONFIG_DIRECTORY } " ] ; then
mkdir -p " ${ PKG_CONFIG_DIRECTORY } " || exit 1
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
# FILTER WHICH EXTERNAL LIBRARIES WILL BE BUILT
2020-08-05 03:26:42 +03:00
# NOTE THAT BUILT-IN LIBRARIES ARE FORWARDED TO FFMPEG SCRIPT WITHOUT ANY PROCESSING
enabled_library_list = ( )
2020-11-23 00:51:45 +02:00
for library in { 1..47} ; do
2020-08-05 03:53:02 +03:00
if [ [ ${ !library } -eq 1 ] ] ; then
ENABLED_LIBRARY = $( get_library_name $(( library - 1 )) )
enabled_library_list += ( ${ ENABLED_LIBRARY } )
2020-08-05 03:26:42 +03:00
2020-08-05 03:53:02 +03:00
echo -e " INFO: Enabled library ${ ENABLED_LIBRARY } will be built\n " 1>>" ${ BASEDIR } " /build.log 2>& 1
fi
2020-08-05 03:26:42 +03:00
done
2020-08-05 03:53:02 +03:00
# BUILD ENABLED LIBRARIES AND THEIR DEPENDENCIES
2020-08-05 03:26:42 +03:00
let completed = 0
while [ ${# enabled_library_list [@] } -gt $completed ] ; do
2020-08-05 03:53:02 +03:00
for library in " ${ enabled_library_list [@] } " ; do
let run = 0
case $library in
fontconfig)
2020-11-23 00:51:45 +02:00
if [ [ $OK_expat -eq 1 ] ] && [ [ $OK_freetype -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
freetype)
2020-11-23 00:51:45 +02:00
if [ [ $OK_libpng -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
gnutls)
2020-11-23 00:51:45 +02:00
if [ [ $OK_nettle -eq 1 ] ] && [ [ $OK_gmp -eq 1 ] ] ; then
run = 1
fi
; ;
harfbuzz)
if [ [ $OK_fontconfig -eq 1 ] ] && [ [ $OK_freetype -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
leptonica)
2020-11-23 00:51:45 +02:00
if [ [ $OK_giflib -eq 1 ] ] && [ [ $OK_jpeg -eq 1 ] ] && [ [ $OK_libpng -eq 1 ] ] && [ [ $OK_tiff -eq 1 ] ] && [ [ $OK_libwebp -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
libass)
2020-11-23 00:51:45 +02:00
if [ [ $OK_expat -eq 1 ] ] && [ [ $OK_freetype -eq 1 ] ] && [ [ $OK_fribidi -eq 1 ] ] && [ [ $OK_fontconfig -eq 1 ] ] && [ [ $OK_libpng -eq 1 ] ] && [ [ $OK_harfbuzz -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
libtheora)
2020-11-23 00:51:45 +02:00
if [ [ $OK_libvorbis -eq 1 ] ] && [ [ $OK_libogg -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
libvorbis)
2020-11-23 00:51:45 +02:00
if [ [ $OK_libogg -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
libwebp)
2020-11-23 00:51:45 +02:00
if [ [ $OK_giflib -eq 1 ] ] && [ [ $OK_jpeg -eq 1 ] ] && [ [ $OK_libpng -eq 1 ] ] && [ [ $OK_tiff -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
nettle)
2020-11-23 00:51:45 +02:00
if [ [ $OK_gmp -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
rubberband)
2020-11-23 00:51:45 +02:00
if [ [ $OK_libsndfile -eq 1 ] ] && [ [ $OK_libsamplerate -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
tesseract)
2020-11-23 00:51:45 +02:00
if [ [ $OK_leptonica -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
tiff)
2020-11-23 00:51:45 +02:00
if [ [ $OK_jpeg -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
twolame)
2020-11-23 00:51:45 +02:00
if [ [ $OK_libsndfile -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
*)
run = 1
; ;
esac
2020-08-05 03:26:42 +03:00
2020-08-05 03:53:02 +03:00
# DEFINE SOME FLAGS TO MANAGE DEPENDENCIES AND REBUILD OPTIONS
BUILD_COMPLETED_FLAG = $( echo " OK_ ${ library } " | sed "s/\-/\_/g" )
REBUILD_FLAG = $( echo " REBUILD_ ${ library } " | sed "s/\-/\_/g" )
DEPENDENCY_REBUILT_FLAG = $( echo " DEPENDENCY_REBUILT_ ${ library } " | sed "s/\-/\_/g" )
2020-08-05 03:26:42 +03:00
2020-11-23 00:51:45 +02:00
if [ [ $run -eq 1 ] ] && [ [ " ${ !BUILD_COMPLETED_FLAG } " != "1" ] ] ; then
LIBRARY_IS_INSTALLED = $( library_is_installed " ${ LIB_INSTALL_BASE } " " ${ library } " )
2020-08-05 03:26:42 +03:00
2020-11-23 00:51:45 +02:00
echo -e " INFO: Flags detected for ${ library } : already installed= ${ LIBRARY_IS_INSTALLED } , rebuild requested by user= ${ !REBUILD_FLAG } , will be rebuilt due to dependency update= ${ !DEPENDENCY_REBUILT_FLAG } \n " 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:26:42 +03:00
2020-08-05 03:53:02 +03:00
# CHECK IF BUILD IS NECESSARY OR NOT
2020-11-23 00:51:45 +02:00
if [ [ ${ LIBRARY_IS_INSTALLED } -ne 1 ] ] || [ [ ${ !REBUILD_FLAG } -eq 1 ] ] || [ [ ${ !DEPENDENCY_REBUILT_FLAG } -eq 1 ] ] ; then
2020-08-05 03:26:42 +03:00
2020-08-05 03:53:02 +03:00
echo -n " ${ library } : "
2020-08-05 03:26:42 +03:00
2020-11-23 00:51:45 +02:00
" ${ BASEDIR } " /scripts/run-apple.sh " ${ library } " 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:26:42 +03:00
2020-11-23 00:51:45 +02:00
# SET SOME FLAGS AFTER THE BUILD
2020-08-05 03:53:02 +03:00
if [ $? -eq 0 ] ; then
( ( completed += 1) )
declare " $BUILD_COMPLETED_FLAG =1 "
check_if_dependency_rebuilt " ${ library } "
echo "ok"
2020-08-05 03:26:42 +03:00
else
2020-11-23 00:51:45 +02:00
echo -e "failed\n\nSee build.log for details\n"
2020-08-05 03:53:02 +03:00
exit 1
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
else
( ( completed += 1) )
declare " $BUILD_COMPLETED_FLAG =1 "
echo " ${ library } : already built "
fi
else
2020-11-23 00:51:45 +02:00
echo -e " INFO: Skipping $library , dependencies built= $run , already built= ${ !BUILD_COMPLETED_FLAG } \n " 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:53:02 +03:00
fi
done
2020-08-05 03:26:42 +03:00
done
2020-08-05 03:53:02 +03:00
# SKIP TO SPEED UP THE BUILD
2020-08-05 03:26:42 +03:00
if [ [ ${ SKIP_ffmpeg } -ne 1 ] ] ; then
2020-11-23 00:51:45 +02:00
# PREPARE PATHS & DEFINE ${INSTALL_PKG_CONFIG_DIR}
LIB_NAME = "ffmpeg"
set_toolchain_paths " ${ LIB_NAME } "
# SET BUILD FLAGS
HOST = $( get_host)
export CFLAGS = $( get_cflags " ${ LIB_NAME } " )
export CXXFLAGS = $( get_cxxflags " ${ LIB_NAME } " )
export LDFLAGS = $( get_ldflags " ${ LIB_NAME } " )
export PKG_CONFIG_LIBDIR = " ${ INSTALL_PKG_CONFIG_DIR } "
cd " ${ BASEDIR } " /src/" ${ LIB_NAME } " 1>>" ${ BASEDIR } " /build.log 2>& 1 || exit 1
LIB_INSTALL_PREFIX = " ${ LIB_INSTALL_BASE } " /" ${ LIB_NAME } "
2020-08-05 03:53:02 +03:00
# BUILD FFMPEG
2020-11-23 00:51:45 +02:00
source " ${ BASEDIR } " /scripts/apple/ffmpeg.sh " $@ "
if [ [ $? -ne 0 ] ] ; then
exit 1
fi
2020-08-05 03:26:42 +03:00
else
2020-08-05 03:53:02 +03:00
echo -e "\nffmpeg: skipped"
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
# SKIP TO SPEED UP THE BUILD
2020-08-05 03:26:42 +03:00
if [ [ ${ SKIP_ffmpeg_kit } -ne 1 ] ] ; then
2020-08-05 03:53:02 +03:00
# BUILD FFMPEG KIT
2020-11-23 00:51:45 +02:00
. " ${ BASEDIR } " /scripts/apple/ffmpeg-kit.sh " $@ " || exit 1
2020-08-05 03:26:42 +03:00
else
2020-08-05 03:53:02 +03:00
echo -e "\nffmpeg-kit: skipped"
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
echo -e " \nINFO: Completed build for ${ ARCH } at $( date) \n " 1>>" ${ BASEDIR } " /build.log 2>& 1