From 6ef79e607977fd4b652a75de832aee22b7f5233b Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Fri, 2 Feb 2024 11:55:39 +0100 Subject: [PATCH] fix cmd make linking + lv2 c++ --- templates/cmd-make/Makefile | 3 +-- templates/lv2-make/Makefile | 27 +++++++++++++++++++++------ templates/lv2-make/vars.mk | 6 ++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/templates/cmd-make/Makefile b/templates/cmd-make/Makefile index 964c430..fd200c2 100644 --- a/templates/cmd-make/Makefile +++ b/templates/cmd-make/Makefile @@ -46,7 +46,7 @@ build/${PROGRAM}: ${C_OBJS} | build ${CC} $^ -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} else build/${PROGRAM}: ${C_OBJS} ${CXX_OBJS} | build - ${CXX} $^ -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} + ${CXX} $^ -o $@ ${CFLAGS_ALL} ${CXXFLAGS_ALL} ${LDFLAGS_ALL} endif build build/obj: @@ -74,4 +74,3 @@ $(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$ $(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj ${CXX} $^ -o $@ -c ${CXXFLAGS_ALL} - diff --git a/templates/lv2-make/Makefile b/templates/lv2-make/Makefile index 5aed04d..aa1825b 100644 --- a/templates/lv2-make/Makefile +++ b/templates/lv2-make/Makefile @@ -31,9 +31,13 @@ CFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -fPIC ${CFLAGS} ${CFLAGS_EXTRA} LDFLAGS = LDFLAGS_ALL = -shared ${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}.lv2 @@ -43,19 +47,21 @@ DLL_FILE = ${BUNDLE_NAME}${DLL_SUFFIX} C_SRCS = ${COMMON_DIR}/src/lv2.c C_OBJS = $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o))) +CXX_SRCS = ${CXX_SRCS_EXTRA} +CXX_OBJS = $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o))) + all: build/${BUNDLE_DIR}/manifest.ttl build/${BUNDLE_DIR}/${DLL_FILE} build/${BUNDLE_DIR}/manifest.ttl: ${DATA_DIR}/data/manifest.ttl.in | build/${BUNDLE_DIR} cat $^ | sed s/@DLL_SUFFIX@/${DLL_SUFFIX}/g > $@ +ifeq ($(CXX_OBJS),) build/${BUNDLE_DIR}/${DLL_FILE}: ${C_OBJS} | build/${BUNDLE_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} + ${CXX} $^ -o $@ ${CFLAGS_ALL} ${CXXFLAGS_ALL} ${LDFLAGS_ALL} +endif build/${BUNDLE_DIR} build/obj: mkdir -p $@ @@ -74,3 +80,12 @@ install-user: all install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} "${LV2DIR_USER}/${BUNDLE_DIR}" .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/lv2-make/vars.mk b/templates/lv2-make/vars.mk index df24782..17629ac 100644 --- a/templates/lv2-make/vars.mk +++ b/templates/lv2-make/vars.mk @@ -1,6 +1,12 @@ BUNDLE_NAME := {{=it.product.bundleName}} + CFLAGS_EXTRA := {{=it.make && it.make.cflags ? it.make.cflags : ""}} {{=it.lv2_make && it.lv2_make.cflags ? it.lv2_make.cflags : ""}} LDFLAGS_EXTRA := {{=it.make && it.make.ldflags ? it.make.ldflags : ""}} {{=it.lv2_make && it.lv2_make.ldflags ? it.lv2_make.ldflags : ""}} +CXXFLAGS_EXTRA := {{=it.make && it.make.cxxflags ? it.make.cxxflags : ""}} {{=it.lv2_make && it.lv2_make.cxxflags ? it.lv2_make.cxxflags : ""}} + +C_SRCS_EXTRA := {{=it.make && it.make.cSrcs ? it.make.cSrcs : ""}} {{=it.lv2_make.cSrcs ? it.lv2_make.cSrcs : ""}} +CXX_SRCS_EXTRA := {{=it.make && it.make.cxxSrcs ? it.make.cxxSrcs : ""}} {{=it.lv2_make.cxxSrcs ? it.lv2_make.cxxSrcs : ""}} + COMMON_DIR := {{=it.lv2_make && it.lv2_make.commonDir ? it.lv2_make.commonDir : (it.make && it.make.commonDir ? it.make.commonDir : "")}} DATA_DIR := {{=it.lv2_make && it.lv2_make.dataDir ? it.lv2_make.dataDir : (it.make && it.make.dataDir ? it.make.dataDir : "")}} PLUGIN_DIR := {{=it.lv2_make && it.lv2_make.pluginDir ? it.lv2_make.pluginDir : (it.make && it.make.pluginDir ? it.make.pluginDir : "")}}