Cross-Platform build scripts for audio plugins
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
4.8KB

  1. #!/bin/bash
  2. # ---------------------------------------------------------------------------------------------------------------------
  3. # OS setup
  4. if [ "${LINUX}" -eq 1 ]; then
  5. CMAKE_SYSTEM_NAME="Linux"
  6. PAWPAW_TARGET="linux"
  7. elif [ "${MACOS}" -eq 1 ]; then
  8. CMAKE_SYSTEM_NAME="Darwin"
  9. if [ "${MACOS_OLD}" -eq 1 ]; then
  10. PAWPAW_TARGET="macos-old"
  11. elif [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  12. PAWPAW_TARGET="macos-universal"
  13. else
  14. PAWPAW_TARGET="macos"
  15. fi
  16. elif [ "${WIN32}" -eq 1 ]; then
  17. CMAKE_SYSTEM_NAME="Windows"
  18. if [ "${WIN64}" -eq 1 ]; then
  19. PAWPAW_TARGET="win64"
  20. else
  21. PAWPAW_TARGET="win32"
  22. fi
  23. else
  24. echo "Unknown target '${target}'"
  25. exit 4
  26. fi
  27. # ---------------------------------------------------------------------------------------------------------------------
  28. # PawPaw setup
  29. PAWPAW_DIR="${HOME}/PawPawBuilds"
  30. PAWPAW_DOWNLOADDIR="${PAWPAW_DIR}/downloads"
  31. PAWPAW_BUILDDIR="${PAWPAW_DIR}/builds/${PAWPAW_TARGET}"
  32. PAWPAW_PREFIX="${PAWPAW_DIR}/targets/${PAWPAW_TARGET}"
  33. PAWPAW_TMPDIR="/tmp"
  34. # ---------------------------------------------------------------------------------------------------------------------
  35. # build environment
  36. ## build flags
  37. BUILD_FLAGS="-O2 -pipe -I${PAWPAW_PREFIX}/include"
  38. BUILD_FLAGS+=" -mtune=generic -msse -msse2 -ffast-math"
  39. BUILD_FLAGS+=" -fPIC -DPIC -DNDEBUG -D_FORTIFY_SOURCE=2"
  40. BUILD_FLAGS+=" -fdata-sections -ffunction-sections -fno-common -fstack-protector -fvisibility=hidden"
  41. if [ "${MACOS_UNIVERSAL}" -eq 0 ]; then
  42. BUILD_FLAGS+=" -mfpmath=sse"
  43. fi
  44. if [ "${MACOS}" -eq 1 ]; then
  45. if [ "${MACOS_OLD}" -eq 1 ]; then
  46. BUILD_FLAGS+=" -DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_5 -mmacosx-version-min=10.5"
  47. elif [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  48. BUILD_FLAGS+=" -DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_12 -mmacosx-version-min=10.12 -arch x86_64 -arch arm64"
  49. else
  50. BUILD_FLAGS+=" -DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_8 -mmacosx-version-min=10.8 -stdlib=libc++ -Wno-deprecated-declarations"
  51. fi
  52. elif [ "${WIN32}" -eq 1 ]; then
  53. BUILD_FLAGS+=" -DFLUIDSYNTH_NOT_A_DLL -DPTW32_STATIC_LIB -mstackrealign"
  54. fi
  55. # anything that talks to db should have this
  56. BUILD_FLAGS+=" -DHAVE_MIXED_SIZE_ADDRESSING"
  57. TARGET_CFLAGS="${BUILD_FLAGS}"
  58. TARGET_CXXFLAGS="${BUILD_FLAGS} -fvisibility-inlines-hidden"
  59. ## link flags
  60. LINK_FLAGS="-L${PAWPAW_PREFIX}/lib"
  61. LINK_FLAGS+=" -fdata-sections -ffunction-sections -fstack-protector"
  62. if [ "${MACOS}" -eq 1 ]; then
  63. LINK_FLAGS+=" -Wl,-dead_strip -Wl,-dead_strip_dylibs"
  64. if [ "${MACOS_OLD}" -eq 1 ]; then
  65. LINK_FLAGS+=" -mmacosx-version-min=10.5"
  66. elif [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  67. LINK_FLAGS+=" -mmacosx-version-min=10.12 -arch x86_64 -arch arm64"
  68. else
  69. LINK_FLAGS+=" -mmacosx-version-min=10.8 -stdlib=libc++"
  70. fi
  71. else
  72. LINK_FLAGS+=" -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined -Wl,--strip-all"
  73. if [ "${WIN32}" -eq 1 ]; then
  74. LINK_FLAGS+=" -static -lssp_nonshared -Wl,-Bstatic"
  75. fi
  76. fi
  77. TARGET_LDFLAGS="${LINK_FLAGS}"
  78. ## toolchain
  79. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  80. if [ "${MACOS}" -eq 1 ]; then
  81. TOOLCHAIN_PREFIX="i686-apple-darwin10"
  82. TOOLCHAIN_PREFIX_="${TOOLCHAIN_PREFIX}-"
  83. elif [ "${WIN64}" -eq 1 ]; then
  84. TOOLCHAIN_PREFIX="x86_64-w64-mingw32"
  85. TOOLCHAIN_PREFIX_="${TOOLCHAIN_PREFIX}-"
  86. elif [ "${WIN32}" -eq 1 ]; then
  87. TOOLCHAIN_PREFIX="i686-w64-mingw32"
  88. TOOLCHAIN_PREFIX_="${TOOLCHAIN_PREFIX}-"
  89. fi
  90. fi
  91. TARGET_AR="${TOOLCHAIN_PREFIX_}ar"
  92. TARGET_CC="${TOOLCHAIN_PREFIX_}gcc"
  93. TARGET_CXX="${TOOLCHAIN_PREFIX_}g++"
  94. TARGET_LD="${TOOLCHAIN_PREFIX_}ld"
  95. TARGET_STRIP="${TOOLCHAIN_PREFIX_}strip"
  96. TARGET_PATH="${PAWPAW_PREFIX}/bin:/usr/${TOOLCHAIN_PREFIX}/bin:${PATH}"
  97. TARGET_PKG_CONFIG="${PAWPAW_PREFIX}/bin/pkg-config --static"
  98. TARGET_PKG_CONFIG_PATH="${PAWPAW_PREFIX}/lib/pkgconfig"
  99. # ---------------------------------------------------------------------------------------------------------------------
  100. # other
  101. MAKE_ARGS=""
  102. WAF_ARGS=""
  103. if which nproc > /dev/null; then
  104. MAKE_ARGS+="-j $(nproc)"
  105. WAF_ARGS+="-j $(nproc)"
  106. elif [ "${MACOS}" -eq 1 ]; then
  107. MAKE_ARGS+="-j $(sysctl -n hw.logicalcpu)"
  108. WAF_ARGS+="-j $(sysctl -n hw.logicalcpu)"
  109. fi
  110. if [ "${CROSS_COMPILING}" -eq 1 ]; then
  111. MAKE_ARGS+=" CROSS_COMPILING=true"
  112. fi
  113. if [ "${MACOS}" -eq 1 ]; then
  114. MAKE_ARGS+=" MACOS=true"
  115. if [ "${MACOS_OLD}" -eq 1 ]; then
  116. MAKE_ARGS+=" MACOS_OLD=true"
  117. elif [ "${MACOS_UNIVERSAL}" -eq 1 ]; then
  118. MAKE_ARGS+=" MACOS_UNIVERSAL=true"
  119. fi
  120. elif [ "${WIN32}" -eq 1 ]; then
  121. MAKE_ARGS+=" WINDOWS=true WIN32=true"
  122. if [ "${WIN64}" -eq 1 ]; then
  123. MAKE_ARGS+=" WIN64=true"
  124. fi
  125. export EXE_WRAPPER="wine"
  126. fi
  127. # ---------------------------------------------------------------------------------------------------------------------