commit d3ad4d606d0752c274f117cd33a9913887e3fcb9 Author: falkTX Date: Tue May 26 04:42:10 2020 +0100 Initial commit Signed-off-by: falkTX diff --git a/README.md b/README.md new file mode 100644 index 0000000..5f162c6 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# PawPaw + +PawPaw is a Cross-Platform build scripts setup for static libraries and audio plugins + +It was created out of the need of many open-source developers to easily build their stuff for macOS and Windows, +where usually dependencies are involved which need to be built manually. +In order to make audio plugins self-contained, these dependencies/libraries need to be built statically, +which most packaging projects do not do. +Also, most open-source audio plugin projects to do have binaries for macOS or Windows, +making it very difficult for users in these platforms to enjoy them. + +PawPaw has the following goals: + + - Single script to build most common plugin dependencies statically, both natively and cross-compiling + - Clean and simple code, easy to maintain and add new libraries to build + - Statically build LV2 plugins for (at least) macOS and Windows + - Define each plugin to build in its own file, to make it easy to support new plugins via pull-request + - Package the entire collection as an installer + +Additonally, PawPaw will be used to build library dependencies for Carla and JACK2. diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..15493bc --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,134 @@ +#!/bin/bash + +set -e + +cd $(dirname ${0}) + +# --------------------------------------------------------------------------------------------------------------------- + +# TODO CLI args + +# NOTE all of these need to be defined. either 0 or 1 +CROSS_COMPILING=1 +MACOS=0 +MACOS_OLD=0 +WIN32=1 +WIN64=1 + +# --------------------------------------------------------------------------------------------------------------------- + +# TODO check for depedencies: +# - curl +# - cmake +# - make +# - jq +# - python (waf, meson) +# - sed +# - tar + +source setup/env.sh +source setup/functions.sh +source setup/versions.sh + +mkdir -p ${PAWPAW_BUILDDIR} +mkdir -p ${PAWPAW_DOWNLOADDIR} +mkdir -p ${PAWPAW_PREFIX} +mkdir -p ${PAWPAW_TMPDIR} + +# --------------------------------------------------------------------------------------------------------------------- +# pkgconfig + +download pkg-config "${PKG_CONFIG_VERSION}" "https://pkg-config.freedesktop.org/releases" +build_host_autoconf pkg-config "${PKG_CONFIG_VERSION}" "--enable-indirect-deps --with-internal-glib --with-pc-path=${TARGET_PKG_CONFIG_PATH}" + +# --------------------------------------------------------------------------------------------------------------------- +# liblo + +download liblo "${LIBLO_VERSION}" "http://download.sourceforge.net/liblo" +build_autoconf liblo "${LIBLO_VERSION}" "--enable-threads --disable-examples --disable-tools" + +# --------------------------------------------------------------------------------------------------------------------- +# zlib + +download zlib "${ZLIB_VERSION}" "https://github.com/madler/zlib/archive" +build_conf zlib "${ZLIB_VERSION}" "--static --prefix=${PAWPAW_PREFIX}" + +# --------------------------------------------------------------------------------------------------------------------- +# libogg + +download libogg "${LIBOGG_VERSION}" "https://ftp.osuosl.org/pub/xiph/releases/ogg" +patch_file libogg "${LIBOGG_VERSION}" "include/ogg/os_types.h" 's/__MACH__/__MACH_SKIP__/' +build_autoconf libogg "${LIBOGG_VERSION}" + +# --------------------------------------------------------------------------------------------------------------------- +# file/magic + +# download file "${FILE_VERSION}" "ftp://ftp.astron.com/pub/file" +# build_autoconf file "${FILE_VERSION}" + +# --------------------------------------------------------------------------------------------------------------------- +# libvorbis + +download libvorbis "${LIBVORBIS_VERSION}" "https://ftp.osuosl.org/pub/xiph/releases/vorbis" +build_autoconf libvorbis "${LIBVORBIS_VERSION}" + +# --------------------------------------------------------------------------------------------------------------------- +# flac + +download flac "${FLAC_VERSION}" "https://ftp.osuosl.org/pub/xiph/releases/flac" "tar.xz" +build_autoconf flac "${FLAC_VERSION}" + +# --------------------------------------------------------------------------------------------------------------------- +# libsndfile + +download libsndfile "${LIBSNDFILE_VERSION}" "http://www.mega-nerd.com/libsndfile/files" +patch_file libsndfile "${LIBSNDFILE_VERSION}" "configure" 's/ -Wvla//' +build_autoconf libsndfile "${LIBSNDFILE_VERSION}" "--disable-full-suite --disable-alsa --disable-sqlite" + +# --------------------------------------------------------------------------------------------------------------------- +# lv2 + +download lv2 "${LV2_VERSION}" "http://lv2plug.in/spec" "tar.bz2" +build_waf lv2 "${LV2_VERSION}" "--lv2dir=${PAWPAW_PREFIX}/lib/lv2" + +# --------------------------------------------------------------------------------------------------------------------- +# now the fun: plugins! + +for p in $(ls plugins); do + name=$(jq -crM .name plugins/${p}) + version=$(jq -crM .version plugins/${p}) + buildtype=$(jq -crM .buildtype plugins/${p}) + dlbaseurl=$(jq -crM .dlbaseurl plugins/${p}) + + # optional args + buildargs=$(echo -e $(jq -ecrM .buildargs plugins/${p} || echo '\n\n') | tail -n 1) + dlext=$(echo -e $(jq -ecrM .dlext plugins/${p} || echo '\n\n') | tail -n 1) + dlmethod=$(echo -e $(jq -ecrM .dlmethod plugins/${p} || echo '\n\n') | tail -n 1) + + download "${name}" "${version}" "${dlbaseurl}" "${dlext}" "${dlmethod}" + + # TODO patch_file support? + + case ${buildtype} in + "autoconf") + build_autoconf "${name}" "${version}" "${buildargs}" + ;; + "conf") + build_conf "${name}" "${version}" "${buildargs}" + ;; + "cmake") + build_cmake "${name}" "${version}" "${buildargs}" + ;; + "make") + build_make "${name}" "${version}" "${buildargs}" + ;; + "meson") + build_meson "${name}" "${version}" "${buildargs}" + ;; + "waf") + build_waf "${name}" "${version}" "${buildargs}" + ;; + esac +done + +# --------------------------------------------------------------------------------------------------------------------- diff --git a/plugins-todo/mod-utilities.json b/plugins-todo/mod-utilities.json new file mode 100644 index 0000000..3f20f53 --- /dev/null +++ b/plugins-todo/mod-utilities.json @@ -0,0 +1,7 @@ +{ + "name": "mod-utilities", + "version": "4a92aa81351c5c95fefa0505fafad5fbea494dd0", + "dlbaseurl": "https://github.com/moddevices/mod-utilities.git", + "dlmethod": "git", + "buildtype": "make" +} diff --git a/plugins-todo/noise-repellent.json b/plugins-todo/noise-repellent.json new file mode 100644 index 0000000..fcb810a --- /dev/null +++ b/plugins-todo/noise-repellent.json @@ -0,0 +1,7 @@ +{ + "name": "noise-repellent", + "version": "87b4380eae2b69b09bba8a8b181f24153079100d", + "dlbaseurl": "https://github.com/lucianodato/noise-repellent.git", + "dlmethod": "git", + "buildtype": "meson" +} diff --git a/plugins/artyfx.json b/plugins/artyfx.json new file mode 100644 index 0000000..aea7498 --- /dev/null +++ b/plugins/artyfx.json @@ -0,0 +1,8 @@ +{ + "name": "artyfx", + "version": "6010d1a6034ea684cc2edb22021f034122ccf814", + "dlbaseurl": "https://github.com/openAVproductions/openAV-ArtyFX.git", + "dlmethod": "git", + "buildtype": "cmake", + "buildargs": "-DBUILD_GUI=OFF" +} diff --git a/plugins/dpf-plugins.json b/plugins/dpf-plugins.json new file mode 100644 index 0000000..f535177 --- /dev/null +++ b/plugins/dpf-plugins.json @@ -0,0 +1,6 @@ +{ + "name": "dpf-plugins", + "version": "1.3", + "dlbaseurl": "https://github.com/DISTRHO/DPF-Plugins/archive", + "buildtype": "make" +} diff --git a/plugins/regrader.json b/plugins/regrader.json new file mode 100644 index 0000000..6f71345 --- /dev/null +++ b/plugins/regrader.json @@ -0,0 +1,7 @@ +{ + "name": "regrader-port", + "version": "412e475cef1025d955fae4229b6bc94596f36fd4", + "dlbaseurl": "https://github.com/linuxmao-org/regrader-port.git", + "dlmethod": "git", + "buildtype": "make" +} diff --git a/setup/env.sh b/setup/env.sh new file mode 100644 index 0000000..ac9d3fc --- /dev/null +++ b/setup/env.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +# --------------------------------------------------------------------------------------------------------------------- +# pawpaw setup + +PAWPAW_DIR="$(realpath ~/PawPawBuilds)" +PAWPAW_BUILDDIR="${PAWPAW_DIR}/builds" +PAWPAW_DOWNLOADDIR="${PAWPAW_DIR}/downloads" +PAWPAW_PREFIX="${PAWPAW_DIR}/target" +PAWPAW_TMPDIR="/tmp" + +# --------------------------------------------------------------------------------------------------------------------- +# OS setup + +if [ "${MACOS}" -eq 1 ]; then + CMAKE_SYSTEM_NAME="Darwin" +elif [ "${WIN32}" -eq 1 ]; then + CMAKE_SYSTEM_NAME="Windows" +fi + +# --------------------------------------------------------------------------------------------------------------------- +# build environment + +## build flags + +BUILD_FLAGS="-O2 -pipe -I${PAWPAW_PREFIX}/include" +BUILD_FLAGS="${BUILD_FLAGS} -mtune=generic -msse -msse2 -mfpmath=sse" +# -ffast-math +BUILD_FLAGS="${BUILD_FLAGS} -fPIC -DPIC -DNDEBUG" +BUILD_FLAGS="${BUILD_FLAGS} -fdata-sections -ffunction-sections -fno-common -fvisibility=hidden" +if [ "${MACOS}" -eq 1 ]; then + if [ "${MACOS_OLD}" -eq 1 ]; then + BUILD_FLAGS="${BUILD_FLAGS} -mmacosx-version-min=10.5" + else + BUILD_FLAGS="${BUILD_FLAGS} -mmacosx-version-min=10.8 -stdlib=libc++ -Wno-deprecated-declarations" + fi +elif [ "${WIN32}" -eq 1 ]; then + BUILD_FLAGS="${BUILD_FLAGS} -DPTW32_STATIC_LIB -mstackrealign" +fi +# -DFLUIDSYNTH_NOT_A_DLL +TARGET_CFLAGS="${BUILD_FLAGS}" +TARGET_CXXFLAGS="${BUILD_FLAGS} -fvisibility-inlines-hidden" + +## link flags + +LINK_FLAGS="-fdata-sections -ffunction-sections -L${PAWPAW_PREFIX}/lib" +if [ "${MACOS}" -eq 1 ]; then + LINK_FLAGS="${LINK_FLAGS} -Wl,-dead_strip -Wl,-dead_strip_dylibs" + if [ "${MACOS_OLD}" -ne 1 ]; then + LINK_FLAGS="${LINK_FLAGS} -stdlib=libc++" + fi +else + LINK_FLAGS="${LINK_FLAGS} -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined -Wl,--strip-all" + if [ "${WIN32}" -eq 1 ]; then + LINK_FLAGS="${LINK_FLAGS} -static" + fi +fi +TARGET_LDFLAGS="${LINK_FLAGS}" + +## toolchain + +if [ "${MACOS}" -eq 1 ]; then + TOOLCHAIN_PREFIX="i686-apple-darwin10" + TOOLCHAIN_PREFIX_="${TOOLCHAIN_PREFIX}-" +elif [ "${WIN64}" -eq 1 ]; then + TOOLCHAIN_PREFIX="x86_64-w64-mingw32" + TOOLCHAIN_PREFIX_="${TOOLCHAIN_PREFIX}-" +elif [ "${WIN32}" -eq 1 ]; then + TOOLCHAIN_PREFIX="i686-w64-mingw32" + TOOLCHAIN_PREFIX_="${TOOLCHAIN_PREFIX}-" +fi +TARGET_AR="${TOOLCHAIN_PREFIX_}ar" +TARGET_CC="${TOOLCHAIN_PREFIX_}gcc" +TARGET_CXX="${TOOLCHAIN_PREFIX_}g++" +TARGET_LD="${TOOLCHAIN_PREFIX_}ld" +TARGET_STRIP="${TOOLCHAIN_PREFIX_}strip" +TARGET_PATH="${PAWPAW_PREFIX}/bin:/usr/${TOOLCHAIN_PREFIX}/bin:${PATH}" +TARGET_PKG_CONFIG_PATH="${PAWPAW_PREFIX}/lib/pkgconfig" + +# --------------------------------------------------------------------------------------------------------------------- +# other + +# "-j 2" +MAKE_ARGS="" + +if [ "${CROSS_COMPILING}" -eq 1 ]; then + MAKE_ARGS="${MAKE_ARGS} CROSS_COMPILING=true" +fi + +if [ "${MACOS}" -eq 1 ]; then + MAKE_ARGS="${MAKE_ARGS} MACOS=true" + if [ "${MACOS_OLD}" -eq 1 ]; then + MAKE_ARGS="${MAKE_ARGS} MACOS_OLD=true" + fi +elif [ "${WIN32}" -eq 1 ]; then + MAKE_ARGS="${MAKE_ARGS} WIN32=true WINDOWS=true" +fi + +# --------------------------------------------------------------------------------------------------------------------- diff --git a/setup/functions.sh b/setup/functions.sh new file mode 100644 index 0000000..f1b0551 --- /dev/null +++ b/setup/functions.sh @@ -0,0 +1,340 @@ +#!/bin/bash + +# --------------------------------------------------------------------------------------------------------------------- + +function download() { + local name="${1}" + local version="${2}" + local dlbaseurl="${3}" + local dlext="${4}" + local dlmethod="${5}" + + if [ -z "${dlext}" ]; then + dlext="tar.gz" + fi + + local dlfile="${PAWPAW_DOWNLOADDIR}/${name}-${version}.${dlext}" + local dlfolder="${PAWPAW_BUILDDIR}/${name}-${version}" + + if [ ! -f "${dlfile}" ]; then + if [ -n "${dlmethod}" ] && [ "${dlmethod}" = "git" ]; then + local tmprepodir="${PAWPAW_TMPDIR}/${name}-${version}" + rm -rf "${tmprepodir}" + git clone --recursive "${dlbaseurl}" "${tmprepodir}" + git -C "${tmprepodir}" checkout "${version}" + git -C "${tmprepodir}" submodule update + tar --exclude=".git" -czf "${dlfile}" -C "${PAWPAW_TMPDIR}" "${name}-${version}" + rm -rf "${tmprepodir}" + else + local dlurl + if echo ${dlbaseurl} | grep -q github.com; then + dlurl="${dlbaseurl}/v${version}.${dlext}" + else + dlurl="${dlbaseurl}/${name}-${version}.${dlext}" + fi + curl -L "${dlurl}" -o "${dlfile}" + fi + fi + + if [ ! -d "${dlfolder}" ]; then + mkdir "${dlfolder}" + tar -xf "${dlfile}" -C "${dlfolder}" --strip-components=1 + fi +} + +# --------------------------------------------------------------------------------------------------------------------- + +function _prebuild() { + local pkgdir="${1}" + + export AR="${TARGET_AR}" + export CC="${TARGET_CC}" + export CXX="${TARGET_CXX}" + export LD="${TARGET_LD}" + export STRIP="${TARGET_STRIP}" + export CFLAGS="${TARGET_CFLAGS}" + export CXXFLAGS="${TARGET_CXXFLAGS}" + export LDFLAGS="${TARGET_LDFLAGS}" + export PKG_CONFIG_PATH="${TARGET_PKG_CONFIG_PATH}" + + unset CPPFLAGS + export OLD_PATH="${PATH}" + export PATH="${TARGET_PATH}" + + if [ ! -f "${pkgdir}/.stamp_configured" ]; then + rm -f "${pkgdir}/.stamp_built" + rm -f "${pkgdir}/.stamp_installed" + + elif [ ! -f "${pkgdir}/.stamp_built" ]; then + rm -f "${pkgdir}/.stamp_installed" + + fi +} + +function _postbuild() { + unset AR + unset CC + unset CXX + unset LD + unset STRIP + unset CFLAGS + unset CPPFLAGS + unset CXXFLAGS + unset LDFLAGS + unset PKG_CONFIG_PATH + + export PATH="${OLD_PATH}" +} + +# --------------------------------------------------------------------------------------------------------------------- + +function build_autoconf() { + local name="${1}" + local version="${2}" + local extraconfrules="${3}" + + local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}" + + _prebuild "${pkgdir}" + + if [ ! -f "${pkgdir}/.stamp_configured" ]; then + pushd "${pkgdir}" + ./configure --enable-static --disable-shared --prefix="${PAWPAW_PREFIX}" --host=${TOOLCHAIN_PREFIX} ${extraconfrules} + touch .stamp_configured + popd + fi + + if [ ! -f "${pkgdir}/.stamp_built" ]; then + pushd "${pkgdir}" + make ${MAKE_ARGS} + touch .stamp_built + popd + fi + + if [ ! -f "${pkgdir}/.stamp_installed" ]; then + pushd "${pkgdir}" + make ${MAKE_ARGS} install + touch .stamp_installed + popd + fi + + _postbuild +} + +function build_conf() { + local name="${1}" + local version="${2}" + local extraconfrules="${3}" + + local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}" + + _prebuild "${pkgdir}" + + if [ ! -f "${pkgdir}/.stamp_configured" ]; then + pushd "${pkgdir}" + ./configure ${extraconfrules} + touch .stamp_configured + popd + fi + + if [ ! -f "${pkgdir}/.stamp_built" ]; then + pushd "${pkgdir}" + make ${MAKE_ARGS} + touch .stamp_built + popd + fi + + if [ ! -f "${pkgdir}/.stamp_installed" ]; then + pushd "${pkgdir}" + make ${MAKE_ARGS} install + touch .stamp_installed + popd + fi + + _postbuild +} + +function build_cmake() { + local name="${1}" + local version="${2}" + local extraconfrules="${3}" + + local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}" + + _prebuild "${pkgdir}" + + if [ ! -f "${pkgdir}/.stamp_configured" ]; then + pushd "${pkgdir}" + # FIXME put this as a patch file + sed -i -e 's/ -Wl,--no-undefined//' CMakeLists.txt + cmake -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_PREFIX="${PAWPAW_PREFIX}" -DCMAKE_SYSTEM_NAME="${CMAKE_SYSTEM_NAME}" ${extraconfrules} + touch .stamp_configured + popd + fi + + if [ ! -f "${pkgdir}/.stamp_built" ]; then + pushd "${pkgdir}" + make ${MAKE_ARGS} + touch .stamp_built + popd + fi + + if [ ! -f "${pkgdir}/.stamp_installed" ]; then + pushd "${pkgdir}" + make ${MAKE_ARGS} install + touch .stamp_installed + popd + fi + + _postbuild +} + +function build_make() { + local name="${1}" + local version="${2}" + local extraconfrules="${3}" + + local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}" + + _prebuild "${pkgdir}" + + touch "${pkgdir}/.stamp_configured" + + if [ ! -f "${pkgdir}/.stamp_built" ]; then + pushd "${pkgdir}" + make PREFIX="${PAWPAW_PREFIX}" ${MAKE_ARGS} ${extraconfrules} + touch .stamp_built + popd + fi + + if [ ! -f "${pkgdir}/.stamp_installed" ]; then + pushd "${pkgdir}" + make PREFIX="${PAWPAW_PREFIX}" ${MAKE_ARGS} install + touch .stamp_installed + popd + fi + + _postbuild +} + +function build_meson() { + local name="${1}" + local version="${2}" + local extraconfrules="${3}" + + local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}" + + _prebuild "${pkgdir}" + + if [ ! -f "${pkgdir}/.stamp_configured" ]; then + pushd "${pkgdir}" + meson build --buildtype release --prefix "${PAWPAW_PREFIX}" ${extraconfrules} + touch .stamp_configured + popd + fi + + if [ ! -f "${pkgdir}/.stamp_built" ]; then + pushd "${pkgdir}" + ninja -v -C build + touch .stamp_built + popd + fi + + if [ ! -f "${pkgdir}/.stamp_installed" ]; then + pushd "${pkgdir}" + ninja -C build install + touch .stamp_installed + popd + fi + + _postbuild +} + +function build_waf() { + local name="${1}" + local version="${2}" + local extraconfrules="${3}" + + local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}" + + _prebuild "${pkgdir}" + + if [ ! -f "${pkgdir}/.stamp_configured" ]; then + pushd "${pkgdir}" + ./waf configure --prefix="${PAWPAW_PREFIX}" ${extraconfrules} + touch .stamp_configured + popd + fi + + if [ ! -f "${pkgdir}/.stamp_built" ]; then + pushd "${pkgdir}" + ./waf build + touch .stamp_built + popd + fi + + if [ ! -f "${pkgdir}/.stamp_installed" ]; then + pushd "${pkgdir}" + ./waf install + touch .stamp_installed + popd + fi + + _postbuild +} + +# --------------------------------------------------------------------------------------------------------------------- + +function build_host_autoconf() { + local name="${1}" + local version="${2}" + local extraconfrules="${3}" + + local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}" + + unset AR + unset CC + unset CXX + unset LD + unset STRIP + unset CFLAGS + unset CPPFLAGS + unset CXXFLAGS + unset LDFLAGS + + if [ ! -f "${pkgdir}/.stamp_configured" ]; then + pushd "${pkgdir}" + ./configure --enable-static --disable-shared --prefix="${PAWPAW_PREFIX}" ${extraconfrules} + touch .stamp_configured + popd + fi + + if [ ! -f "${pkgdir}/.stamp_built" ]; then + pushd "${pkgdir}" + make ${MAKE_ARGS} + touch .stamp_built + popd + fi + + if [ ! -f "${pkgdir}/.stamp_installed" ]; then + pushd "${pkgdir}" + make install + touch .stamp_installed + popd + fi +} + +# --------------------------------------------------------------------------------------------------------------------- + +function patch_file() { + local name="${1}" + local version="${2}" + local file="${3}" + local rule="${4}" + + local pkgdir="${PAWPAW_BUILDDIR}/${name}-${version}" + + sed -i -e "${rule}" "${pkgdir}/${file}" +} + +# --------------------------------------------------------------------------------------------------------------------- diff --git a/setup/versions.sh b/setup/versions.sh new file mode 100644 index 0000000..8e473c8 --- /dev/null +++ b/setup/versions.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +PKG_CONFIG_VERSION=0.28 +LIBLO_VERSION=0.30 +ZLIB_VERSION=1.2.11 +FILE_VERSION=5.34 +LIBOGG_VERSION=1.3.4 +LIBVORBIS_VERSION=1.3.6 +FLAC_VERSION=1.3.2 +LIBSNDFILE_VERSION=1.0.28 +LV2_VERSION=1.18.0 + +# GLIB_VERSION=2.44.1 +# GLIB_MVERSION=2.44 +# FLUIDSYNTH_VERSION=1.1.11 +# MXML_VERSION=2.12 +# FFTW3_VERSION=3.3.8 +# PYTHON_VERSION=3.7.4 +# PYLIBLO_VERSION=0.9.2 +# CXFREEZE_VERSION=6.1