From c4d48f9089cd21366fb77b2c2f78d8b4b7b8e38e Mon Sep 17 00:00:00 2001 From: Andre Abrantes Date: Fri, 5 Apr 2019 02:32:10 -0300 Subject: [PATCH] [fix][ffmpeg] fixing linux build (#5917) * limit windows dep libs to windows * fixing configure patch * fixing detect-openssl.patch * adapting portfile to linux * adding a linux-specific build sh * add missing endif() * bumping version * adding extra check for windows environment --- ports/ffmpeg/CONTROL | 2 +- ports/ffmpeg/FindFFMPEG.cmake | 4 ++- ports/ffmpeg/build_linux.sh | 23 +++++++++++++++++ ports/ffmpeg/configure_opencv.patch | 14 +++++------ ports/ffmpeg/detect-openssl.patch | 17 ++++++------- ports/ffmpeg/portfile.cmake | 38 +++++++++++++++++++---------- 6 files changed, 66 insertions(+), 32 deletions(-) create mode 100644 ports/ffmpeg/build_linux.sh diff --git a/ports/ffmpeg/CONTROL b/ports/ffmpeg/CONTROL index ce69402dc..0fb3df0a7 100644 --- a/ports/ffmpeg/CONTROL +++ b/ports/ffmpeg/CONTROL @@ -1,5 +1,5 @@ Source: ffmpeg -Version: 4.1-1 +Version: 4.1-2 Description: a library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation. It is also highly portable: FFmpeg compiles, runs, and passes our testing infrastructure FATE across Linux, Mac OS X, Microsoft Windows, the BSDs, Solaris, etc. under a wide variety of build environments, machine architectures, and configurations. diff --git a/ports/ffmpeg/FindFFMPEG.cmake b/ports/ffmpeg/FindFFMPEG.cmake index bd373bfae..f8e65f53a 100644 --- a/ports/ffmpeg/FindFFMPEG.cmake +++ b/ports/ffmpeg/FindFFMPEG.cmake @@ -6,6 +6,8 @@ foreach(FFMPEG_SUBLIBRARY avformat avdevice avcodec avutil swscale) find_library(FFMPEG_lib${FFMPEG_SUBLIBRARY}_LIBRARY NAMES ${FFMPEG_SUBLIBRARY}) list(APPEND FFMPEG_LIBRARIES ${FFMPEG_lib${FFMPEG_SUBLIBRARY}_LIBRARY}) endforeach() -list(APPEND FFMPEG_LIBRARIES wsock32 ws2_32 Secur32) +if(WIN32) + list(APPEND FFMPEG_LIBRARIES wsock32 ws2_32 Secur32) +endif() find_package_handle_standard_args(FFMPEG REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS) diff --git a/ports/ffmpeg/build_linux.sh b/ports/ffmpeg/build_linux.sh new file mode 100644 index 000000000..b24be1346 --- /dev/null +++ b/ports/ffmpeg/build_linux.sh @@ -0,0 +1,23 @@ +#!/usr/bin/bash +set -e +export PATH=/usr/bin:$PATH +# Export HTTP(S)_PROXY as http(s)_proxy: +if [ "$HTTP_PROXY" ]; then + export http_proxy=$HTTP_PROXY +fi +if [ "$HTTPS_PROXY" ]; then + export https_proxy=$HTTPS_PROXY +fi + +PATH_TO_BUILD_DIR=$1 +PATH_TO_SRC_DIR=$2 +PATH_TO_PACKAGE_DIR=$3 +# Note: $4 is extra configure options + +cd "$PATH_TO_BUILD_DIR" +echo "=== CONFIGURING ===" +"$PATH_TO_SRC_DIR/configure" "--prefix=$PATH_TO_PACKAGE_DIR" $4 +echo "=== BUILDING ===" +make -j6 +echo "=== INSTALLING ===" +make install diff --git a/ports/ffmpeg/configure_opencv.patch b/ports/ffmpeg/configure_opencv.patch index 66678661e..ac5c82797 100644 --- a/ports/ffmpeg/configure_opencv.patch +++ b/ports/ffmpeg/configure_opencv.patch @@ -1,11 +1,11 @@ --- a/configure +++ b/configure -@@ -5804,7 +5804,7 @@ +@@ -6110,7 +6110,7 @@ enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb - enabled libopencv && { check_header opencv2/core/core_c.h && - { use_pkg_config opencv opencv2/core/core_c.h cvCreateImageHeader || -- require opencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core -lopencv_imgproc; } || + enabled libopencv && { check_headers opencv2/core/core_c.h && + { check_pkg_config libopencv opencv opencv2/core/core_c.h cvCreateImageHeader || +- require libopencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core -lopencv_imgproc; } || + require opencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core341 -lopencv_imgproc341; } || - require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader; } - enabled libopenh264 && require_pkg_config openh264 wels/codec_api.h WelsGetCodecVersion - enabled libopenjpeg && { { check_lib openjpeg-2.1/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } || + require_pkg_config libopencv opencv opencv/cxcore.h cvCreateImageHeader; } + enabled libopenh264 && require_pkg_config libopenh264 openh264 wels/codec_api.h WelsGetCodecVersion + enabled libopenjpeg && { check_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version || diff --git a/ports/ffmpeg/detect-openssl.patch b/ports/ffmpeg/detect-openssl.patch index cb8a77e0a..affd37d15 100644 --- a/ports/ffmpeg/detect-openssl.patch +++ b/ports/ffmpeg/detect-openssl.patch @@ -12,14 +12,11 @@ diff --git a/configure b/configure index a1818dc..1cf2a7c 100755 --- a/configure +++ b/configure -@@ -5836,6 +5836,7 @@ enabled openssl && { use_pkg_config openssl openssl/ssl.h OPENSSL_init - check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto || - check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 || - check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 || -+ check_lib openssl/ssl.h SSL_library_init -llibeay32 -lssleay32 || +@@ -6127,6 +6127,7 @@ + check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto || + check_lib openssl openssl/ssl.h SSL_library_init -lssl32 -leay32 || + check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 || ++ check_lib openssl openssl/ssl.h SSL_library_init -llibeay32 -lssleay32 || die "ERROR: openssl not found"; } - enabled qtkit_indev && { check_header_objcc QTKit/QTKit.h || disable qtkit_indev; } - --- -2.10.1.windows.1 - + enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/rk_mpi.h mpp_create && + require_pkg_config rockchip_mpp "rockchip_mpp >= 1.3.7" rockchip/rk_mpi.h mpp_create && diff --git a/ports/ffmpeg/portfile.cmake b/ports/ffmpeg/portfile.cmake index f8c0c9f38..262867d84 100644 --- a/ports/ffmpeg/portfile.cmake +++ b/ports/ffmpeg/portfile.cmake @@ -23,12 +23,22 @@ vcpkg_find_acquire_program(YASM) get_filename_component(YASM_EXE_PATH ${YASM} DIRECTORY) set(ENV{PATH} "$ENV{PATH};${YASM_EXE_PATH}") -if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") - vcpkg_acquire_msys(MSYS_ROOT PACKAGES perl gcc diffutils make) -else() - vcpkg_acquire_msys(MSYS_ROOT PACKAGES diffutils make) +if (WIN32) + if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") + vcpkg_acquire_msys(MSYS_ROOT PACKAGES perl gcc diffutils make) + else() + vcpkg_acquire_msys(MSYS_ROOT PACKAGES diffutils make) + endif() endif() -set(BASH ${MSYS_ROOT}/usr/bin/bash.exe) + +if (WIN32) + set(BASH ${MSYS_ROOT}/usr/bin/bash.exe) + set(BUILD_SCRIPT ${CMAKE_CURRENT_LIST_DIR}\\build.sh) +else() + set(BASH bash) + set(BUILD_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/build_linux.sh) +endif() + set(ENV{INCLUDE} "${CURRENT_INSTALLED_DIR}/include;$ENV{INCLUDE}") set(ENV{LIB} "${CURRENT_INSTALLED_DIR}/lib;$ENV{LIB}") @@ -122,18 +132,20 @@ endif() message(STATUS "Building Options: ${OPTIONS}") -if(VCPKG_CRT_LINKAGE STREQUAL "dynamic") - set(OPTIONS_DEBUG "${OPTIONS_DEBUG} --extra-cflags=-MDd --extra-cxxflags=-MDd") - set(OPTIONS_RELEASE "${OPTIONS_RELEASE} --extra-cflags=-MD --extra-cxxflags=-MD") -else() - set(OPTIONS_DEBUG "${OPTIONS_DEBUG} --extra-cflags=-MTd --extra-cxxflags=-MTd") - set(OPTIONS_RELEASE "${OPTIONS_RELEASE} --extra-cflags=-MT --extra-cxxflags=-MT") +if(WIN32) + if(VCPKG_CRT_LINKAGE STREQUAL "dynamic") + set(OPTIONS_DEBUG "${OPTIONS_DEBUG} --extra-cflags=-MDd --extra-cxxflags=-MDd") + set(OPTIONS_RELEASE "${OPTIONS_RELEASE} --extra-cflags=-MD --extra-cxxflags=-MD") + else() + set(OPTIONS_DEBUG "${OPTIONS_DEBUG} --extra-cflags=-MTd --extra-cxxflags=-MTd") + set(OPTIONS_RELEASE "${OPTIONS_RELEASE} --extra-cflags=-MT --extra-cxxflags=-MT") + endif() endif() message(STATUS "Building ${_csc_PROJECT_PATH} for Release") file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) vcpkg_execute_required_process( - COMMAND ${BASH} --noprofile --norc "${CMAKE_CURRENT_LIST_DIR}\\build.sh" + COMMAND ${BASH} --noprofile --norc "${BUILD_SCRIPT}" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" # BUILD DIR "${SOURCE_PATH}" # SOURCE DIR "${CURRENT_PACKAGES_DIR}" # PACKAGE DIR @@ -145,7 +157,7 @@ vcpkg_execute_required_process( message(STATUS "Building ${_csc_PROJECT_PATH} for Debug") file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) vcpkg_execute_required_process( - COMMAND ${BASH} --noprofile --norc "${CMAKE_CURRENT_LIST_DIR}\\build.sh" + COMMAND ${BASH} --noprofile --norc "${BUILD_SCRIPT}" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" # BUILD DIR "${SOURCE_PATH}" # SOURCE DIR "${CURRENT_PACKAGES_DIR}/debug" # PACKAGE DIR