improved vst3 makefile

This commit is contained in:
Stefano D'Angelo 2024-06-16 11:18:29 +02:00
parent 90a739181e
commit 62767a4397

View File

@ -21,28 +21,28 @@
include vars.mk include vars.mk
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
DLL_SUFFIX = .vst3 DLL_SUFFIX := .vst3
PLATFORM = x86_64-win PLATFORM := x86_64-win
VST3DIR = $(shell echo '${COMMONPROGRAMFILES}' | sed 's:\\:/:g')/VST3 VST3DIR := $(shell echo '$(COMMONPROGRAMFILES)' | sed 's:\\:/:g')/VST3
VST3DIR_USER = $(shell echo '${LOCALAPPDATA}' | sed 's:\\:/:g')/Programs/Common/VST3 VST3DIR_USER := $(shell echo '$(LOCALAPPDATA)' | sed 's:\\:/:g')/Programs/Common/VST3
CC = gcc CC := gcc
CXX = g++ CXX := g++
else else
UNAME_S = $(shell uname -s) UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Darwin) ifeq ($(UNAME_S), Darwin)
DLL_SUFFIX = DLL_SUFFIX :=
PLATFORM = MacOS PLATFORM := MacOS
VST3DIR = /Library/Audio/Plug-Ins/VST3 VST3DIR := /Library/Audio/Plug-Ins/VST3
VST3DIR_USER = ${HOME}/Library/Audio/Plug-Ins/VST3 VST3DIR_USER := $(HOME)/Library/Audio/Plug-Ins/VST3
CC = clang CC := clang
CXX = clang++ CXX := clang++
else else
DLL_SUFFIX = .so DLL_SUFFIX := .so
PLATFORM = $(shell uname -m)-linux PLATFORM := $(shell uname -m)-linux
VST3DIR = /usr/local/lib/vst3 VST3DIR := /usr/local/lib/vst3
VST3DIR_USER = ${HOME}/.vst3 VST3DIR_USER := $(HOME)/.vst3
CC = gcc CC := gcc
CXX = g++ CXX := g++
endif endif
endif endif
@ -50,91 +50,89 @@ COMMON_DIR := $(or $(COMMON_DIR),.)
DATA_DIR := $(or $(DATA_DIR),.) DATA_DIR := $(or $(DATA_DIR),.)
PLUGIN_DIR := $(or $(PLUGIN_DIR),src) PLUGIN_DIR := $(or $(PLUGIN_DIR),src)
CFLAGS = -O3 -Wall -Wpedantic -Wextra CFLAGS := -O3 -Wall -Wpedantic -Wextra
CFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -fPIC ${CFLAGS} ${CFLAGS_EXTRA} CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -fPIC $(CFLAGS) $(CFLAGS_EXTRA)
LDFLAGS = LDFLAGS :=
LDFLAGS_ALL = -shared -lm ${LDFLAGS} ${LDFLAGS_EXTRA} LDFLAGS_ALL := -shared -lm $(LDFLAGS) $(LDFLAGS_EXTRA)
CXXFLAGS = ${CFLAGS} CXXFLAGS := $(CFLAGS)
CXXFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -fPIC ${CXXFLAGS} ${CXXFLAGS_EXTRA} CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -fPIC $(CXXFLAGS) $(CXXFLAGS_EXTRA)
ifeq ($(UNAME_S), Darwin) ifeq ($(UNAME_S), Darwin)
CFLAGS_ALL := ${CFLAGS_ALL} -arch arm64 -arch x86_64 CFLAGS_ALL := $(CFLAGS_ALL) -arch arm64 -arch x86_64
LDFLAGS_ALL := ${LDFLAGS_ALL} -arch arm64 -arch x86_64 LDFLAGS_ALL := $(LDFLAGS_ALL) -arch arm64 -arch x86_64
CXXFLAGS_ALL := ${CXXFLAGS_ALL} -arch arm64 -arch x86_64 CXXFLAGS_ALL := $(CXXFLAGS_ALL) -arch arm64 -arch x86_64
ifeq (${HAS_UI}, yes) ifeq ($(HAS_UI), yes)
LDFLAGS_ALL := ${LDFLAGS_ALL} -Wl,-framework,Foundation -Wl,-framework,Cocoa -Wl,-framework,Corevideo LDFLAGS_ALL := $(LDFLAGS_ALL) -Wl,-framework,Foundation -Wl,-framework,Cocoa -Wl,-framework,Corevideo
endif endif
endif endif
ifeq ($(UNAME_S), Linux) ifeq ($(UNAME_S), Linux)
ifeq (${HAS_UI}, yes) ifeq ($(HAS_UI), yes)
CFLAGS_ALL := ${CFLAGS_ALL} $(shell pkg-config --cflags x11) CFLAGS_ALL := $(CFLAGS_ALL) $(shell pkg-config --cflags x11)
LDFLAGS_ALL := ${LDFLAGS_ALL} $(shell pkg-config --libs x11) LDFLAGS_ALL := $(LDFLAGS_ALL) $(shell pkg-config --libs x11)
CXXFLAGS_ALL := ${CXXFLAGS_ALL} $(shell pkg-config --cflags x11) CXXFLAGS_ALL := $(CXXFLAGS_ALL) $(shell pkg-config --cflags x11)
endif endif
endif endif
BUNDLE_DIR = ${BUNDLE_NAME}.vst3 BUNDLE_DIR := $(BUNDLE_NAME).vst3
DLL_DIR = Contents/${PLATFORM} DLL_DIR := Contents/$(PLATFORM)
DLL_FILE = ${DLL_DIR}/${BUNDLE_NAME}${DLL_SUFFIX} DLL_FILE := $(DLL_DIR)/$(BUNDLE_NAME)$(DLL_SUFFIX)
C_SRCS = ${COMMON_DIR}/src/vst3.c ${C_SRCS_EXTRA} C_SRCS := $(COMMON_DIR)/src/vst3.c $(C_SRCS_EXTRA)
C_OBJS = $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o))) C_OBJS := $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o)))
CXX_SRCS = ${CXX_SRCS_EXTRA} CXX_SRCS := $(CXX_SRCS_EXTRA)
CXX_OBJS = $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o))) CXX_OBJS := $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o)))
ALL := build/$(BUNDLE_DIR)/$(DLL_FILE)
ifeq ($(UNAME_S), Darwin) ifeq ($(UNAME_S), Darwin)
all: build/${BUNDLE_DIR}/${DLL_FILE} build/${BUNDLE_DIR}/Contents/Info.plist build/${BUNDLE_DIR}/Contents/PkgInfo ALL := $(ALL) build/$(BUNDLE_DIR)/Contents/Info.plist build/$(BUNDLE_DIR)/Contents/PkgInfo
build/${BUNDLE_DIR}/Contents/%: ${DATA_DIR}/data/% | build/${BUNDLE_DIR}/Contents
cp $^ $@
else
all: build/${BUNDLE_DIR}/${DLL_FILE}
endif endif
all: $(ALL)
ifeq ($(CXX_OBJS),) ifeq ($(CXX_OBJS),)
build/${BUNDLE_DIR}/${DLL_FILE}: ${C_OBJS} | build/${BUNDLE_DIR}/${DLL_DIR} build/$(BUNDLE_DIR)/$(DLL_FILE): $(C_OBJS) | build/$(BUNDLE_DIR)/$(DLL_DIR)
${CC} $^ -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} $(CC) $^ -o $@ $(CFLAGS_ALL) $(LDFLAGS_ALL)
else else
build/${BUNDLE_DIR}/${DLL_FILE}: ${C_OBJS} ${CXX_OBJS} | build/${BUNDLE_DIR}/${DLL_DIR} build/$(BUNDLE_DIR)/$(DLL_FILE): $(C_OBJS) $(CXX_OBJS) | build/$(BUNDLE_DIR)/$(DLL_DIR)
${CXX} $^ -o $@ ${CFLAGS_ALL} ${CXXFLAGS_ALL} ${LDFLAGS_ALL} $(CXX) $^ -o $@ $(CFLAGS_ALL) $(CXXFLAGS_ALL) $(LDFLAGS_ALL)
endif endif
build/${BUNDLE_DIR}/${DLL_DIR} build/obj: ifeq ($(UNAME_S), Darwin)
build/$(BUNDLE_DIR)/Contents/%: $(DATA_DIR)/data/% | build/$(BUNDLE_DIR)/Contents
cp $^ $@
endif
build/$(BUNDLE_DIR)/Contents build/$(BUNDLE_DIR)/$(DLL_DIR) build/obj:
mkdir -p $@ mkdir -p $@
clean: clean:
rm -fr build rm -fr build
ifeq ($(UNAME_S), Darwin)
install: all install: all
mkdir -p -m 0755 "${VST3DIR}/${BUNDLE_DIR}/${DLL_DIR}" @for f in `find build/$(BUNDLE_DIR) -type f`; do \
install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} "${VST3DIR}/${BUNDLE_DIR}/${DLL_DIR}" m=`[ -x $$f ] && echo 0755 || echo 0644`; \
install -m 0644 build/${BUNDLE_DIR}/Contents/Info.plist "${VST3DIR}/${BUNDLE_DIR}/Contents/Info.plist" d=`echo $$f | sed 's:^build/::'` ; \
install -m 0644 build/${BUNDLE_DIR}/Contents/PkgInfo "${VST3DIR}/${BUNDLE_DIR}/Contents/PkgInfo" d=`dirname $$d`; \
echo install -m $$m -t "$(VST3DIR)/$$d" -D $$f; \
install -m $$m -t "$(VST3DIR)/$$d" -D $$f; \
done
install-user: all install-user: all
mkdir -p -m 0755 "${VST3DIR_USER}/${BUNDLE_DIR}/${DLL_DIR}" @for f in `find build/$(BUNDLE_DIR) -type f`; do \
install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} "${VST3DIR_USER}/${BUNDLE_DIR}/${DLL_DIR}" m=`[ -x $$f ] && echo 0755 || echo 0644`; \
install -m 0644 build/${BUNDLE_DIR}/Contents/Info.plist "${VST3DIR_USER}/${BUNDLE_DIR}/Contents/Info.plist" d=`echo $$f | sed 's:^build/::'` ; \
install -m 0644 build/${BUNDLE_DIR}/Contents/PkgInfo "${VST3DIR_USER}/${BUNDLE_DIR}/Contents/PkgInfo" d=`dirname $$d`; \
echo install -m $$m -t "$(VST3DIR_USER)/$$d" -D $$f; \
install -m $$m -t "$(VST3DIR_USER)/$$d" -D $$f; \
done
else -include rules-extra.mk
install: all
mkdir -p -m 0755 "${VST3DIR}/${BUNDLE_DIR}/${DLL_DIR}"
install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} "${VST3DIR}/${BUNDLE_DIR}/${DLL_DIR}"
install-user: all
mkdir -p -m 0755 "${VST3DIR_USER}/${BUNDLE_DIR}/${DLL_DIR}"
install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} "${VST3DIR_USER}/${BUNDLE_DIR}/${DLL_DIR}"
endif
.PHONY: all clean install install-user .PHONY: all clean install install-user
@ -143,7 +141,9 @@ endif
PERCENT := % PERCENT := %
$(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$(C_SRCS)) | build/obj $(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$(C_SRCS)) | build/obj
${CC} $^ -o $@ -c ${CFLAGS_ALL} $(CC) $^ -o $@ -c $(CFLAGS_ALL)
$(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj $(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj
${CXX} $^ -o $@ -c ${CXXFLAGS_ALL} $(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
-include rules-secondexp-extra.mk