From 42782ee6eac6d3b3c5b456e41edc03baede5a4a7 Mon Sep 17 00:00:00 2001 From: casey langen Date: Wed, 9 Feb 2022 15:20:57 -0800 Subject: [PATCH] Minor script updates. --- .cmake/ConfigureRpath.cmake | 2 +- .cmake/ConfigureStandalone.cmake | 4 +- CMakeLists.txt | 4 + script/bootstrap-static-vendors.sh | 223 +++++++++++++------ script/stage-static-vendor-libraries.sh | 28 ++- src/plugins/libopenmptdecoder/CMakeLists.txt | 3 + src/plugins/server/CMakeLists.txt | 2 +- 7 files changed, 197 insertions(+), 69 deletions(-) diff --git a/.cmake/ConfigureRpath.cmake b/.cmake/ConfigureRpath.cmake index 2f4fba06a..67c794058 100644 --- a/.cmake/ConfigureRpath.cmake +++ b/.cmake/ConfigureRpath.cmake @@ -7,4 +7,4 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") # note: macOS does not use $ORIGIN, and uses @executable_path/ instead. we # add a custom post build step at the bottom of this file to add this value # to macOS binaries. -endif() \ No newline at end of file +endif() diff --git a/.cmake/ConfigureStandalone.cmake b/.cmake/ConfigureStandalone.cmake index 44e221c95..eedb8aa21 100644 --- a/.cmake/ConfigureStandalone.cmake +++ b/.cmake/ConfigureStandalone.cmake @@ -13,7 +13,7 @@ if (${BUILD_STANDALONE} MATCHES "true") "${CMAKE_CURRENT_SOURCE_DIR}/vendor/ffmpeg-bin/include" "${CMAKE_CURRENT_SOURCE_DIR}/vendor/lame-bin/include" "${CMAKE_CURRENT_SOURCE_DIR}/vendor/libmicrohttpd-bin/include" - "${CMAKE_CURRENT_SOURCE_DIR}/vendor/zlib-bin/include" + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/openssl-bin/include" "${CMAKE_CURRENT_SOURCE_DIR}/vendor/curl-bin/include") list( @@ -22,7 +22,7 @@ if (${BUILD_STANDALONE} MATCHES "true") "${CMAKE_CURRENT_SOURCE_DIR}/vendor/ffmpeg-bin/lib" "${CMAKE_CURRENT_SOURCE_DIR}/vendor/lame-bin/lib" "${CMAKE_CURRENT_SOURCE_DIR}/vendor/libmicrohttpd-bin/lib" - "${CMAKE_CURRENT_SOURCE_DIR}/vendor/zlib-bin/lib" + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/openssl-bin/lib" "${CMAKE_CURRENT_SOURCE_DIR}/vendor/curl-bin/lib") else() message(STATUS "[standalone-build] *NOT* enabled!") diff --git a/CMakeLists.txt b/CMakeLists.txt index 023046221..4720a8ce9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,8 +45,12 @@ message(STATUS "[boost] includes: " ${Boost_INCLUDE_DIRS}) if (${BUILD_STANDALONE} MATCHES "true") find_library(LIBCURL NAMES curl PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH) + find_library(LIBSSL NAMES ssl PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH) + find_library(LIBCRYPTO NAMES crypto PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH) else() find_library(LIBCURL NAMES curl) + find_library(LIBSSL NAMES ssl) + find_library(LIBCRYPTO NAMES crypto) endif() find_library(LIBSSL NAMES ssl PATHS ${VENDOR_LINK_DIRECTORIES}) diff --git a/script/bootstrap-static-vendors.sh b/script/bootstrap-static-vendors.sh index 0c2b1df31..43b9dee92 100755 --- a/script/bootstrap-static-vendors.sh +++ b/script/bootstrap-static-vendors.sh @@ -1,39 +1,161 @@ #!/bin/bash +set -x + rm -rf vendor mkdir vendor cd vendor -PLATFORM=$(uname) -if [[ "$PLATFORM" == 'Darwin' ]]; then - export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/opt/homebrew/opt/openssl/lib/pkgconfig/" -fi +# +# vars +# export CFLAGS="-fPIC" export CXXFLAGS="-fPIC" +ARCH=$(uname -m) +BOOST_VERSION="1_76_0" +OPENSSL_VERSION="1.1.1m" +OPENSSL_LIB_PATH="$(pwd)/openssl-${OPENSSL_VERSION}/output/lib" +CURL_VERSION="7.81.0" +LIBMICROHTTPD_VERSION="0.9.75" +FFMPEG_VERSION="5.0" +LAME_VERSION="3.100" + +# +# download deps +# + +wget https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_${BOOST_VERSION}.tar.bz2 +wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz +wget https://curl.se/download/${CURL_VERSION}.tar.gz +wget https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-${LIBMICROHTTPD_VERSION}.tar.gz +wget https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 +wget https://downloads.sourceforge.net/project/lame/lame/3.100/lame-${LAME_VERSION}.tar.gz + # # boost # -wget https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_76_0.tar.bz2 -tar xvfj boost_1_76_0.tar.bz2 -cd boost_1_76_0/ +tar xvfj boost_${BOOST_VERSION}.tar.bz2 +cd boost_${BOOST_VERSION} ./bootstrap.sh ./b2 headers ./b2 -d -j8 -sNO_LZMA=1 -sNO_ZSTD=1 threading=multi link=shared,static cxxflags="-fPIC -std=c++14 -stdlib=libc++" --prefix=../boost-bin/ install || exit $? cd .. +# +# openssl +# + +rm -rf openssl-bin +tar xvfz openssl-${OPENSSL_VERSION}.tar.gz +cd openssl-${OPENSSL_VERSION} +perl ./Configure --prefix=`pwd`/output no-ssl3 no-ssl3-method no-zlib "darwin64-${ARCH}-cc" +make +make install +mkdir ../openssl-bin +cp -rfp output/* ../openssl-bin +cd .. + +if [ $OS == "Darwin" ]; then + cd openssl-bin/lib + install_name_tool -id "@rpath/libcrypto.1.1.dylib" libcrypto.1.1.dylib + install_name_tool -id "@rpath/libcrypto.dylib" libcrypto.dylib + install_name_tool -id "@rpath/libssl.1.1.dylib" libssl.1.1.dylib + install_name_tool -id "@rpath/libssl.dylib" libssl.dylib + install_name_tool -change "${OPENSSL_LIB_PATH}/libcrypto.1.1.dylib" "@rpath/libcrypto.1.1.dylib" libssl.1.1.dylib + install_name_tool -change "${OPENSSL_LIB_PATH}/libcrypto.1.1.dylib" "@rpath/libcrypto.dylib" libssl.dylib + cd ../../ +fi + +# +# curl +# + +rm -rf curl-${CURL_VERSION} +rm -rf curl-bin +tar xvfz curl-${CURL_VERSION}.tar.gz +cd curl-${CURL_VERSION} +./configure --enable-shared \ + --enable-static \ + --with-pic \ + --with-openssl="../openssl-bin/" \ + --enable-optimize \ + --enable-http \ + --enable-proxy \ + --enable-ipv6 \ + --disable-rtsp \ + --disable-ftp \ + --disable-ftps \ + --disable-gopher \ + --disable-gophers \ + --disable-pop3 \ + --disable-pop3s \ + --disable-smb \ + --disable-smbs \ + --disable-smtp \ + --disable-telnet \ + --disable-tftp \ + --disable-hsts \ + --disable-imap \ + --disable-mqtt \ + --disable-dict \ + --disable-ldap \ + --without-brotli \ + --without-libidn2 \ + --without-nghttp2 \ + --prefix=`pwd`/output/ +make -j8 +make install +mkdir ../curl-bin +cp -rfp output/* ../curl-bin +cd .. + +if [ $OS == "Darwin" ]; then + cd curl-bin/lib + install_name_tool -id "@rpath/libcurl.dylib" libcurl.dylib + install_name_tool -id "@rpath/libcurl.4.dylib" libcurl.4.dylib + install_name_tool -change "${OPENSSL_LIB_PATH}/libcrypto.1.1.dylib" "@rpath/libcrypto.1.1.dylib" libcurl.dylib + install_name_tool -change "${OPENSSL_LIB_PATH}/libcrypto.1.1.dylib" "@rpath/libcrypto.1.1.dylib" libcurl.4.dylib + install_name_tool -change "${OPENSSL_LIB_PATH}/libssl.1.1.dylib" "@rpath/libssl.1.1.dylib" libcurl.dylib + install_name_tool -change "${OPENSSL_LIB_PATH}/libssl.1.1.dylib" "@rpath/libssl.1.1.dylib" libcurl.4.dylib + cd ../../ +fi + +# +# libmicrohttpd +# + +rm -rf libmicrohttpd-${LIBMICROHTTPD_VERSION} +rm -rf libmicrohttpd-bin +tar xvfz libmicrohttpd-${LIBMICROHTTPD_VERSION}.tar.gz +cd libmicrohttpd-${LIBMICROHTTPD_VERSION} +./configure --enable-shared --enable-static --with-pic --enable-https=no --disable-curl --prefix=`pwd`/output +make -j8 || exit $? +make install +mkdir ../libmicrohttpd-bin +cp -rfp output/* ../libmicrohttpd-bin/ +cd .. + +if [ $OS == "Darwin" ]; then + cd libmicrohttpd-bin/lib/ + install_name_tool -id "@rpath/libmicrohttpd.dylib" libmicrohttpd.dylib + install_name_tool -id "@rpath/libmicrohttpd.12.dylib" libmicrohttpd.12.dylib + cd ../../ +fi + # # ffmpeg # -wget https://ffmpeg.org/releases/ffmpeg-5.0.tar.bz2 -tar xvfj ffmpeg-5.0.tar.bz2 -cd ffmpeg-5.0 +rm -rf ffmpeg-${FFMPEG_VERSION} ffmpeg-bin +tar xvfj ffmpeg-${FFMPEG_VERSION}.tar.bz2 +cd ffmpeg-${FFMPEG_VERSION} ./configure \ --pkg-config-flags="--static" \ - --prefix="../ffmpeg-bin/" \ + --prefix="@rpath" \ + --enable-rpath \ --disable-asm \ --enable-pic \ --enable-static \ @@ -66,6 +188,14 @@ cd ffmpeg-5.0 --disable-videotoolbox \ --disable-audiotoolbox \ --disable-filters \ + --disable-libxcb \ + --disable-libxcb-shm \ + --disable-libxcb-xfixes \ + --disable-libxcb-shape \ + --disable-sdl2 \ + --disable-securetransport \ + --disable-vaapi \ + --disable-xlib \ --enable-demuxer=aac \ --enable-demuxer=ac3 \ --enable-demuxer=aiff \ @@ -165,7 +295,6 @@ cd ffmpeg-5.0 --enable-decoder=pcm_u24le \ --enable-decoder=pcm_u32be \ --enable-decoder=pcm_u32le \ - --enable-decoder=pcm_zork \ --enable-decoder=dsd_lsbf \ --enable-decoder=dsd_msbf \ --enable-decoder=dsd_lsbf_planar \ @@ -195,62 +324,32 @@ cd ffmpeg-5.0 --enable-encoder=wmav1 \ --enable-encoder=wmav2 \ --disable-pthreads \ - --build-suffix=-musikcube || exit $? -make -j8 || exit $? + --build-suffix=-musikcube +make -j8 make install +mkdir ../ffmpeg-bin +cp -rfp \@rpath/* ../ffmpeg-bin cd .. # -# libmicrohttpd +# lame # -wget https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.75.tar.gz -tar xvfz libmicrohttpd-0.9.75.tar.gz -cd libmicrohttpd-0.9.75 -./configure --enable-shared --enable-static --with-pic --enable-https=no --disable-curl --prefix=`pwd`/output -make -j8 || exit $? +rm -rf lame-${LAME_VERSION} lame-bin +tar xvfz lame-${LAME_VERSION}.tar.gz +cd lame-${LAME_VERSION} +# https://sourceforge.net/p/lame/mailman/message/36081038/ +perl -i.bak -0pe "s|lame_init_old\n||" include/libmp3lame.sym +./configure --disable-dependency-tracking --disable-debug --enable-nasm --prefix=$(pwd)/output +make -j8 make install -mv output ../libmicrohttpd-bin +mkdir ../lame-bin +cp -rfp output/* ../lame-bin cd .. -# -# curl -# - -wget https://curl.se/download/curl-7.81.0.tar.gz -tar xvfz curl-7.81.0.tar.gz -cd curl-7.81.0 -./configure \ - --enable-shared \ - --enable-static \ - --with-pic \ - --with-openssl \ - --enable-optimize \ - --enable-http \ - --enable-proxy \ - --enable-ipv6 \ - --disable-rtsp \ - --disable-ftp \ - --disable-ftps \ - --disable-gopher \ - --disable-gophers \ - --disable-pop3 \ - --disable-pop3s \ - --disable-smb \ - --disable-smbs \ - --disable-smtp \ - --disable-telnet \ - --disable-tftp \ - --disable-hsts \ - --disable-imap \ - --disable-mqtt \ - --disable-dict \ - --disable-ldap \ - --without-brotli \ - --without-libidn2 \ - --without-nghttp2 \ - --prefix=`pwd`/output -make -j8 || exit $? -make install -mv output ../curl-bin -cd .. \ No newline at end of file +if [ $OS == "Darwin" ]; then + cd lame-bin/lib/ + install_name_tool -id "@rpath/libmp3lame.dylib" libmp3lame.dylib + install_name_tool -id "@rpath/libmp3lame.0.dylib" libmp3lame.0.dylib + cd ../../ +fi \ No newline at end of file diff --git a/script/stage-static-vendor-libraries.sh b/script/stage-static-vendor-libraries.sh index ff64cdcd8..83b5386a1 100755 --- a/script/stage-static-vendor-libraries.sh +++ b/script/stage-static-vendor-libraries.sh @@ -9,16 +9,38 @@ popd PLATFORM=$(uname) if [[ "$PLATFORM" == 'Darwin' ]]; then - echo "[stage-static-vendor-libraries] no-op on darwin. not required." - exit 0 + echo "[stage-static-vendor-libraries] staging macOS .dylib files..." + + cp vendor/ffmpeg-bin/lib/libavcodec-musikcube.59.dylib ./bin/lib + cp vendor/ffmpeg-bin/lib/libavformat-musikcube.59.dylib ./bin/lib + cp vendor/ffmpeg-bin/lib/libavutil-musikcube.57.dylib ./bin/lib + cp vendor/ffmpeg-bin/lib/libswresample-musikcube.4.dylib ./bin/lib + + cp vendor/boost-bin/lib/libboost_atomic.dylib ./bin/lib + cp vendor/boost-bin/lib/libboost_chrono.dylib ./bin/lib + cp vendor/boost-bin/lib/libboost_date_time.dylib ./bin/lib + cp vendor/boost-bin/lib/libboost_filesystem.dylib ./bin/lib + cp vendor/boost-bin/lib/libboost_system.dylib ./bin/lib + cp vendor/boost-bin/lib/libboost_thread.dylib ./bin/lib + + cp vendor/openssl-bin/lib/libcrypto.dylib ./bin/lib + cp vendor/openssl-bin/lib/libssl.dylib ./bin/lib + + cp vendor/curl-bin/lib/libcurl.dylib ./bin/lib + + cp vendor/libmicrohttpd-bin/lib/libmicrohttpd.dylib ./bin/lib + elif [[ "$PLATFORM" == 'Linux' ]]; then - echo "[stage-static-vendor-libraries] staging linux libraries..." + echo "[stage-static-vendor-libraries] staging Linux .so files..." + cp vendor/boost-bin/lib/libboost_filesystem.so.1.78.0 ./bin/lib/ cp vendor/boost-bin/lib/libboost_thread.so.1.78.0 ./bin/lib/ + cp vendor/ffmpeg-bin/lib/libavcodec-musikcube.so.59 ./bin/lib/ cp vendor/ffmpeg-bin/lib/libavformat-musikcube.so.59 ./bin/lib/ cp vendor/ffmpeg-bin/lib/libavutil-musikcube.so.57 ./bin/lib/ cp vendor/ffmpeg-bin/lib/libswresample-musikcube.so.4 ./bin/lib/ + cp vendor/curl-bin/lib/libcurl.so.4 ./bin/lib/ cp /lib/x86_64-linux-gnu/libssl.so.1.1 ./bin/lib/ diff --git a/src/plugins/libopenmptdecoder/CMakeLists.txt b/src/plugins/libopenmptdecoder/CMakeLists.txt index 8d7b3544f..1cb650dc9 100644 --- a/src/plugins/libopenmptdecoder/CMakeLists.txt +++ b/src/plugins/libopenmptdecoder/CMakeLists.txt @@ -8,6 +8,9 @@ set (openmptdecoder_SOURCES add_library(openmptdecoder SHARED ${openmptdecoder_SOURCES}) +# ensure vendor'd headers take priority over our local ones. +target_include_directories(openmptdecoder BEFORE PRIVATE ${VENDOR_INCLUDE_DIRECTORIES}) + find_library(OPENMPTLIB NAMES openmpt) find_library(MPG123LIB NAMES mpg123) find_library(ZLIB NAMES z) diff --git a/src/plugins/server/CMakeLists.txt b/src/plugins/server/CMakeLists.txt index 5bd3f19dc..3bdc3eaec 100644 --- a/src/plugins/server/CMakeLists.txt +++ b/src/plugins/server/CMakeLists.txt @@ -14,7 +14,7 @@ target_include_directories(server BEFORE PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/3r target_include_directories(server BEFORE PRIVATE ${VENDOR_INCLUDE_DIRECTORIES}) if (${BUILD_STANDALONE} MATCHES "true") - find_library(LIBMICROHTTPD NAMES libmicrohttpd.a PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH NO_CACHE) + find_library(LIBMICROHTTPD NAMES microhttpd PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH NO_CACHE) else() if (APPLE) find_library(LIBGNUTLS NAMES gnutls)