Dynamically configure job count based on available logical CPUs on Darwin.

This commit is contained in:
casey langen 2022-02-10 22:16:38 -08:00
parent 1a068f1bae
commit 1be4750631

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -x # set -x
# #
# vars # vars
@ -19,6 +19,11 @@ LIBMICROHTTPD_VERSION="0.9.75"
FFMPEG_VERSION="5.0" FFMPEG_VERSION="5.0"
LAME_VERSION="3.100" LAME_VERSION="3.100"
JOBS="-j8"
if [ $OS == "Darwin" ]; then
JOBS="-j$(sysctl -n hw.ncpu)"
fi
function clean() { function clean() {
rm -rf vendor rm -rf vendor
mkdir vendor mkdir vendor
@ -51,7 +56,7 @@ function build_boost() {
cd boost_${BOOST_VERSION} cd boost_${BOOST_VERSION}
./bootstrap.sh --without-libraries=python,mpi,log ./bootstrap.sh --without-libraries=python,mpi,log
./b2 headers ./b2 headers
./b2 -d -j8 -sNO_LZMA=1 -sNO_ZSTD=1 threading=multi link=shared,static cxxflags=${BOOST_CXX_FLAGS} --prefix=../boost-bin/ install || exit $? ./b2 -d ${JOBS} -sNO_LZMA=1 -sNO_ZSTD=1 threading=multi link=shared,static cxxflags=${BOOST_CXX_FLAGS} --prefix=../boost-bin/ install || exit $?
cd .. cd ..
} }
@ -125,7 +130,7 @@ function build_curl() {
--without-libidn2 \ --without-libidn2 \
--without-nghttp2 \ --without-nghttp2 \
--prefix=`pwd`/output/ --prefix=`pwd`/output/
make -j8 make ${JOBS} || exit $?
make install make install
mkdir ../curl-bin mkdir ../curl-bin
cp -rfp output/* ../curl-bin cp -rfp output/* ../curl-bin
@ -183,11 +188,13 @@ function stage_opus_ogg_vorbis() {
cd opus-ogg-vorbis cd opus-ogg-vorbis
export PKG_CONFIG_PATH=$(pwd) export PKG_CONFIG_PATH=$(pwd)
BREW=$(brew --prefix)
# create pkg-config files to point towards this dir # create pkg-config files to point towards this dir
cp /opt/homebrew/opt/opus/lib/pkgconfig/opus.pc . cp $BREW/opt/opus/lib/pkgconfig/opus.pc .
cp /opt/homebrew/opt/libogg/lib/pkgconfig/ogg.pc . cp $BREW/opt/libogg/lib/pkgconfig/ogg.pc .
cp /opt/homebrew/opt/libvorbis/lib/pkgconfig/vorbis.pc . cp $BREW/opt/libvorbis/lib/pkgconfig/vorbis.pc .
cp /opt/homebrew/opt/libvorbis/lib/pkgconfig/vorbisenc.pc . cp $BREW/opt/libvorbis/lib/pkgconfig/vorbisenc.pc .
chmod 644 *.pc chmod 644 *.pc
perl -i.bak -0pe "s|libdir.*\n|libdir=$(pwd)\n|" opus.pc perl -i.bak -0pe "s|libdir.*\n|libdir=$(pwd)\n|" opus.pc
perl -i.bak -0pe "s|libdir.*\n|libdir=$(pwd)\n|" ogg.pc perl -i.bak -0pe "s|libdir.*\n|libdir=$(pwd)\n|" ogg.pc
@ -196,10 +203,10 @@ function stage_opus_ogg_vorbis() {
rm *.bak rm *.bak
# copy libs, update their ids, then resign # copy libs, update their ids, then resign
LIBOPUS="/opt/homebrew/opt/opus/lib/libopus.0.dylib" LIBOPUS="$BREW/opt/opus/lib/libopus.0.dylib"
LIBOGG="/opt/homebrew/opt/libogg/lib/libogg.0.dylib" LIBOGG="$BREW/opt/libogg/lib/libogg.0.dylib"
LIBVORBIS="/opt/homebrew/opt/libvorbis/lib/libvorbis.0.dylib" LIBVORBIS="$BREW/opt/libvorbis/lib/libvorbis.0.dylib"
LIBVORBISENC="/opt/homebrew/opt/libvorbis/lib/libvorbisenc.2.dylib" LIBVORBISENC="$BREW/opt/libvorbis/lib/libvorbisenc.2.dylib"
cp ${LIBOPUS} ${LIBOGG} ${LIBVORBIS} ${LIBVORBISENC} . cp ${LIBOPUS} ${LIBOGG} ${LIBVORBIS} ${LIBVORBISENC} .
chmod 755 *.dylib chmod 755 *.dylib
install_name_tool -id "@rpath/libopus.0.dylib" ./libopus.0.dylib install_name_tool -id "@rpath/libopus.0.dylib" ./libopus.0.dylib
@ -406,7 +413,7 @@ function build_ffmpeg() {
--enable-encoder=wmav2 \ --enable-encoder=wmav2 \
--enable-encoder=libvorbis \ --enable-encoder=libvorbis \
--build-suffix=-musikcube --build-suffix=-musikcube
make -j8 make ${JOBS} || exit $?
make install make install
mkdir ../ffmpeg-bin mkdir ../ffmpeg-bin
cp -rfp \@rpath/* ../ffmpeg-bin cp -rfp \@rpath/* ../ffmpeg-bin
@ -437,7 +444,7 @@ function build_lame() {
# https://sourceforge.net/p/lame/mailman/message/36081038/ # https://sourceforge.net/p/lame/mailman/message/36081038/
perl -i.bak -0pe "s|lame_init_old\n||" include/libmp3lame.sym perl -i.bak -0pe "s|lame_init_old\n||" include/libmp3lame.sym
./configure --disable-dependency-tracking --disable-debug --enable-nasm --prefix=$(pwd)/output ./configure --disable-dependency-tracking --disable-debug --enable-nasm --prefix=$(pwd)/output
make -j8 make ${JOBS} || exit $?
make install make install
mkdir ../lame-bin mkdir ../lame-bin
cp -rfp output/* ../lame-bin cp -rfp output/* ../lame-bin