# Generic Mcaster1AMP plugin build.
#   make SRC=/path/to/myplugin.c OUT=/path/to/myplugin
# Produces a .so (Linux), .dylib (macOS) or .dll (Windows/MinGW).
SRC ?= ../templates/dsp-plugin-template.c
OUT ?= myplugin
INC ?= ../include
CXX ?= g++
CXXFLAGS ?= -std=c++17 -O2 -fvisibility=hidden -I$(INC)

UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
  EXT := dylib
  LDFLAGS := -dynamiclib
else ifneq (,$(findstring MINGW,$(UNAME)))
  EXT := dll
  LDFLAGS := -shared
else
  EXT := so
  LDFLAGS := -shared -fPIC
endif

all:
	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(OUT).$(EXT) $(SRC) -lm
	@echo "Built $(OUT).$(EXT) — copy it to your Mcaster1AMP plugins folder."

clean:
	rm -f $(OUT).so $(OUT).dylib $(OUT).dll $(OUT).lib
