sm-26/Makefile

104 lines
3.7 KiB
Makefile
Raw Permalink Normal View History

SHELL := /bin/sh
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
BUILD_DIR ?= build
JUCE_ROOT ?= $(BUILD_DIR)/juce
CONFIG := Release
JOBS := $(shell sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 4)
BUNDLE := SM-26
ifeq ($(UNAME_S),Darwin)
OSX_ARCH := arm64
FOLLOW_BRANCH := 1
endif
.PHONY: all deps configure build install uninstall clean distclean
all: build
deps:
@if [ ! -f "$(JUCE_ROOT)/CMakeLists.txt" ]; then \
echo ">> Cloning JUCE into $(JUCE_ROOT) ..."; \
mkdir -p "$(JUCE_ROOT)"; \
git clone --depth 1 https://github.com/juce-framework/JUCE.git "$(JUCE_ROOT)"; \
fi
@echo ">> JUCE present."
configure: deps
@mkdir -p "$(BUILD_DIR)"
@if [ "$(UNAME_S)" = "Darwin" ]; then \
cmake -S . -B "$(BUILD_DIR)" \
-DCMAKE_BUILD_TYPE="$(CONFIG)" \
-DCMAKE_OSX_ARCHITECTURES="$(OSX_ARCH)" \
-DJUCE_ROOT="$(abspath $(JUCE_ROOT))"; \
else \
cmake -S . -B "$(BUILD_DIR)" \
-DCMAKE_BUILD_TYPE="$(CONFIG)" \
-DJUCE_ROOT="$(abspath $(JUCE_ROOT))"; \
fi
build: configure
cmake --build "$(BUILD_DIR)" --config "$(CONFIG)" -j "$(JOBS)"
# After install the plugin gets ad-hoc code-signed (required for AU hosts and
# VST3 sandboxing on macOS) and any quarantine xattr is stripped.
DEST_VST3 ?=
DEST_AU ?=
ifeq ($(UNAME_S),Darwin)
DEST_VST3 := "$(HOME)/Library/Audio/Plug-Ins/VST3/$(BUNDLE).vst3"
DEST_AU := "$(HOME)/Library/Audio/Plug-Ins/Components/$(BUNDLE).component"
else ifeq ($(UNAME_S),Linux)
DEST_VST3 := "$(HOME)/.vst3/$(BUNDLE).vst3"
endif
help_install_sources := $(shell find "$(BUILD_DIR)" -type d -name "*.vst3" 2>/dev/null; find "$(BUILD_DIR)" -type d -name "*.component" 2>/dev/null)
install: build
@if [ "$(UNAME_S)" = "Darwin" ]; then \
mkdir -p "$(HOME)/Library/Audio/Plug-Ins/VST3" "$(HOME)/Library/Audio/Plug-Ins/Components"; \
VST3=$$(find "$(BUILD_DIR)" -type d -name "$(BUNDLE).vst3" | head -n1); \
AU=$$(find "$(BUILD_DIR)" -type d -name "$(BUNDLE).component" | head -n1); \
if [ -n "$$VST3" ]; then \
echo ">> Installing VST3"; \
rm -rf "$(DEST_VST3)"; cp -R "$$VST3" "$(HOME)/Library/Audio/Plug-Ins/VST3/"; \
codesign --force --deep --sign - "$(DEST_VST3)" && echo ">> Signed VST3 (ad-hoc)"; \
codesign --verify --deep "$(DEST_VST3)" 2>/dev/null && echo ">> VST3 signature verified"; \
xattr -dr com.apple.quarantine "$(DEST_VST3)" 2>/dev/null || true; \
echo ">> Quarantine removed."; \
fi; \
if [ -n "$$AU" ]; then \
echo ">> Installing AU"; \
rm -rf "$(DEST_AU)"; cp -R "$$AU" "$(HOME)/Library/Audio/Plug-Ins/Components/"; \
codesign --force --deep --sign - "$(DEST_AU)" && echo ">> Signed AU (ad-hoc)"; \
codesign --verify --deep "$(DEST_AU)" 2>/dev/null && echo ">> AU signature verified"; \
xattr -dr com.apple.quarantine "$(DEST_AU)" 2>/dev/null || true; \
echo ">> Quarantine removed."; \
fi; \
elif [ "$(UNAME_S)" = "Linux" ]; then \
echo ">> Installing VST3"; \
mkdir -p "$(HOME)/.vst3"; \
VST3=$$(find "$(BUILD_DIR)" -type d -name "$(BUNDLE).vst3" | head -n1); \
if [ -n "$$VST3" ]; then rm -rf "$(DEST_VST3)"; cp -R "$$VST3" "$(HOME)/.vst3/"; else echo "!! VST3 not found in build dir"; exit 1; fi; \
fi
@echo ">> SM-26 installed."
@echo ""
@echo ">> To make newly-installed AUs visible to macOS immediately, run:"
@echo ">> sudo killall -HUP coreaudiod"
@echo ">> (or simply restart your audio host / DAW)"
uninstall:
@if [ "$(UNAME_S)" = "Darwin" ]; then \
rm -rf "$(DEST_VST3)" "$(DEST_AU)"; \
echo ">> Removed $(BUNDLE) AU + VST3"; \
elif [ "$(UNAME_S)" = "Linux" ]; then \
rm -rf "$(DEST_VST3)"; \
echo ">> Removed $(BUNDLE) VST3"; \
fi
clean:
rm -rf "$(BUILD_DIR)"/SM-26_artefacts
distclean:
rm -rf "$(BUILD_DIR)"