You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.9KB

  1. ifndef RACK_DIR
  2. $(error RACK_DIR is not defined)
  3. endif
  4. SLUG := $(shell jq -r .slug plugin.json)
  5. VERSION := $(shell jq -r .version plugin.json)
  6. ifndef SLUG
  7. $(error SLUG could not be found in manifest)
  8. endif
  9. ifndef VERSION
  10. $(error VERSION could not be found in manifest)
  11. endif
  12. DISTRIBUTABLES += plugin.json
  13. FLAGS += -fPIC
  14. FLAGS += -I$(RACK_DIR)/include -I$(RACK_DIR)/dep/include
  15. LDFLAGS += -shared
  16. LDFLAGS += -L$(RACK_DIR) -lRack
  17. # Since the compiler we're using could have a newer version than the minimum supported libstdc++ version, link it statically.
  18. LDFLAGS += -static-libstdc++
  19. include $(RACK_DIR)/arch.mk
  20. ifdef ARCH_LIN
  21. TARGET := plugin.so
  22. # This prevents static variables in the DSO (dynamic shared object) from being preserved after dlclose().
  23. # I don't really understand the side effects (see GCC manual), but so far tests are positive.
  24. FLAGS += -fno-gnu-unique
  25. LDFLAGS += -Wl,-rpath=.
  26. RACK_USER_DIR ?= $(HOME)/.Rack
  27. endif
  28. ifdef ARCH_MAC
  29. TARGET := plugin.dylib
  30. LDFLAGS += -undefined dynamic_lookup
  31. RACK_USER_DIR ?= $(HOME)/Documents/Rack
  32. endif
  33. ifdef ARCH_WIN
  34. TARGET := plugin.dll
  35. RACK_USER_DIR ?= "$(USERPROFILE)"/Documents/Rack
  36. endif
  37. DEP_FLAGS += -fPIC
  38. include $(RACK_DIR)/dep.mk
  39. all: $(TARGET)
  40. include $(RACK_DIR)/compile.mk
  41. clean:
  42. rm -rfv build $(TARGET) dist
  43. dist: all
  44. rm -rf dist
  45. mkdir -p dist/"$(SLUG)"
  46. @# Strip and copy plugin binary
  47. cp $(TARGET) dist/"$(SLUG)"/
  48. ifdef ARCH_MAC
  49. $(STRIP) -S dist/"$(SLUG)"/$(TARGET)
  50. else
  51. $(STRIP) -s dist/"$(SLUG)"/$(TARGET)
  52. endif
  53. @# Copy distributables
  54. ifdef ARCH_MAC
  55. rsync -rR $(DISTRIBUTABLES) dist/"$(SLUG)"/
  56. else
  57. cp -r --parents $(DISTRIBUTABLES) dist/"$(SLUG)"/
  58. endif
  59. @# Create ZIP package
  60. cd dist && ZSTD_CLEVEL=19 tar -cf "$(SLUG)"-"$(VERSION)"-$(ARCH).vcvplugin --zstd "$(SLUG)"
  61. install: dist
  62. cp dist/"$(SLUG)"-"$(VERSION)"-$(ARCH).vcvplugin $(RACK_USER_DIR)/plugins-v2/
  63. .PHONY: clean dist
  64. .DEFAULT_GOAL := all