From f6e53d8e9bffd67f97c31c647cb245dc92b72731 Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Fri, 2 Feb 2024 12:02:42 +0100 Subject: [PATCH] fix lv2-make + vst3 c++ --- templates/lv2-make/Makefile | 3 ++- templates/vst3-make/Makefile | 34 +++++++++++++++++++++++----------- templates/vst3-make/vars.mk | 6 ++++++ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/templates/lv2-make/Makefile b/templates/lv2-make/Makefile index aa1825b..29b03d0 100644 --- a/templates/lv2-make/Makefile +++ b/templates/lv2-make/Makefile @@ -44,7 +44,7 @@ BUNDLE_DIR = ${BUNDLE_NAME}.lv2 DLL_FILE = ${BUNDLE_NAME}${DLL_SUFFIX} -C_SRCS = ${COMMON_DIR}/src/lv2.c +C_SRCS = ${COMMON_DIR}/src/lv2.c ${C_SRCS_EXTRA} C_OBJS = $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o))) CXX_SRCS = ${CXX_SRCS_EXTRA} @@ -84,6 +84,7 @@ install-user: all .SECONDEXPANSION: PERCENT := % + $(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$(C_SRCS)) | build/obj ${CC} $^ -o $@ -c ${CFLAGS_ALL} diff --git a/templates/vst3-make/Makefile b/templates/vst3-make/Makefile index ffc828d..8b6aad5 100644 --- a/templates/vst3-make/Makefile +++ b/templates/vst3-make/Makefile @@ -33,9 +33,13 @@ CFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -fPIC ${CFLAGS} ${CFLAGS_EXTRA} LDFLAGS = LDFLAGS_ALL = -shared -lm ${LDFLAGS} ${LDFLAGS_EXTRA} +CXXFLAGS = ${CFLAGS} +CXXFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -fPIC ${CXXFLAGS} ${CXXFLAGS_EXTRA} + ifeq ($(UNAME_S), Darwin) CFLAGS_ALL := ${CFLAGS_ALL} -arch arm64 -arch x86_64 LDFLAGS_ALL := ${LDFLAGS_ALL} -arch arm64 -arch x86_64 +CXXFLAGS_ALL := ${CXXFLAGS_ALL} -arch arm64 -arch x86_64 endif BUNDLE_DIR = ${BUNDLE_NAME}.vst3 @@ -43,30 +47,28 @@ BUNDLE_DIR = ${BUNDLE_NAME}.vst3 DLL_DIR = Contents/${PLATFORM} DLL_FILE = ${DLL_DIR}/${BUNDLE_NAME}${DLL_SUFFIX} -C_SRCS = ${COMMON_DIR}/src/vst3.c +C_SRCS = ${COMMON_DIR}/src/vst3.c ${C_SRCS_EXTRA} C_OBJS = $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o))) -ifeq ($(UNAME_S), Darwin) +CXX_SRCS = ${CXX_SRCS_EXTRA} +CXX_OBJS = $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o))) +ifeq ($(UNAME_S), Darwin) all: build/${BUNDLE_DIR}/${DLL_FILE} build/${BUNDLE_DIR}/Contents/Info.plist build/${BUNDLE_DIR}/Contents/Info.plist: ${DATA_DIR}/data/Info.plist | build/${BUNDLE_DIR}/Contents cp $^ $@ - else - all: build/${BUNDLE_DIR}/${DLL_FILE} - endif +ifeq ($(CXX_OBJS),) build/${BUNDLE_DIR}/${DLL_FILE}: ${C_OBJS} | build/${BUNDLE_DIR}/${DLL_DIR} ${CC} $^ -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} - -.SECONDEXPANSION: - -PERCENT := % -$(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$(C_SRCS)) | build/obj - ${CC} $^ -o $@ -c ${CFLAGS_ALL} +else +build/${BUNDLE_DIR}/${DLL_FILE}: ${C_OBJS} ${CXX_OBJS} | build/${BUNDLE_DIR}/${DLL_DIR} + ${CXX} $^ -o $@ ${CFLAGS_ALL} ${CXXFLAGS_ALL} ${LDFLAGS_ALL} +endif build/${BUNDLE_DIR}/${DLL_DIR} build/obj: mkdir -p $@ @@ -99,3 +101,13 @@ install-user: all endif .PHONY: all clean install install-user + +.SECONDEXPANSION: + +PERCENT := % + +$(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$(C_SRCS)) | build/obj + ${CC} $^ -o $@ -c ${CFLAGS_ALL} + +$(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj + ${CXX} $^ -o $@ -c ${CXXFLAGS_ALL} diff --git a/templates/vst3-make/vars.mk b/templates/vst3-make/vars.mk index ad08a2b..612bb58 100644 --- a/templates/vst3-make/vars.mk +++ b/templates/vst3-make/vars.mk @@ -1,6 +1,12 @@ BUNDLE_NAME := {{=it.product.bundleName}} + CFLAGS_EXTRA := {{=it.make && it.make.cflags ? it.make.cflags : ""}} {{=it.vst3_make && it.vst3_make.cflags ? it.vst3_make.cflags : ""}} LDFLAGS_EXTRA := {{=it.make && it.make.ldflags ? it.make.ldflags : ""}} {{=it.vst3_make && it.vst3_make.ldflags ? it.vst3_make.ldflags : ""}} +CXXFLAGS_EXTRA := {{=it.make && it.make.cxxflags ? it.make.cxxflags : ""}} {{=it.vst3_make && it.vst3_make.cxxflags ? it.vst3_make.cxxflags : ""}} + +C_SRCS_EXTRA := {{=it.make && it.make.cSrcs ? it.make.cSrcs : ""}} {{=it.vst3_make.cSrcs ? it.vst3_make.cSrcs : ""}} +CXX_SRCS_EXTRA := {{=it.make && it.make.cxxSrcs ? it.make.cxxSrcs : ""}} {{=it.vst3_make.cxxSrcs ? it.vst3_make.cxxSrcs : ""}} + COMMON_DIR := {{=it.vst3_make && it.vst3_make.commonDir ? it.vst3_make.commonDir : (it.make && it.make.commonDir ? it.make.commonDir : "")}} DATA_DIR := {{=it.vst3_make && it.vst3_make.dataDir ? it.vst3_make.dataDir : (it.make && it.make.dataDir ? it.make.dataDir : "")}} PLUGIN_DIR := {{=it.vst3_make && it.vst3_make.pluginDir ? it.vst3_make.pluginDir : (it.make && it.make.pluginDir ? it.make.pluginDir : "")}}