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.

plugin.mk 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. include $(RACK_DIR)/arch.mk
  18. ifdef ARCH_LIN
  19. TARGET := plugin.so
  20. # This prevents static variables in the DSO (dynamic shared object) from being preserved after dlclose().
  21. # I don't really understand the side effects (see GCC manual), but so far tests are positive.
  22. FLAGS += -fno-gnu-unique
  23. LDFLAGS += -Wl,-rpath=.
  24. # Since the compiler we're using could have a newer version than the minimum supported libstdc++ version, link it statically.
  25. LDFLAGS += -static-libstdc++
  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. LDFLAGS += -static-libstdc++
  36. RACK_USER_DIR ?= $(USERPROFILE)/Documents/Rack
  37. endif
  38. DEP_FLAGS += -fPIC
  39. include $(RACK_DIR)/dep.mk
  40. all: $(TARGET)
  41. include $(RACK_DIR)/compile.mk
  42. clean:
  43. rm -rfv build $(TARGET) dist
  44. ZSTD_COMPRESSION_LEVEL ?= 19
  45. dist: all
  46. rm -rf dist
  47. mkdir -p dist/$(SLUG)
  48. @# Strip and copy plugin binary
  49. cp $(TARGET) dist/$(SLUG)/
  50. ifdef ARCH_MAC
  51. $(STRIP) -S dist/$(SLUG)/$(TARGET)
  52. install_name_tool -change libRack.dylib @rpath/libRack.dylib dist/$(SLUG)/$(TARGET)
  53. install_name_tool -add_rpath . dist/$(SLUG)/$(TARGET)
  54. otool -L dist/$(SLUG)/$(TARGET)
  55. else
  56. $(STRIP) -s dist/$(SLUG)/$(TARGET)
  57. endif
  58. @# Copy distributables
  59. ifdef ARCH_MAC
  60. rsync -rR $(DISTRIBUTABLES) dist/$(SLUG)/
  61. else
  62. cp -r --parents $(DISTRIBUTABLES) dist/$(SLUG)/
  63. endif
  64. @# Create ZIP package
  65. cd dist && tar -c $(SLUG) | zstd -$(ZSTD_COMPRESSION_LEVEL) -o $(SLUG)-"$(VERSION)"-$(ARCH).vcvplugin
  66. install: dist
  67. mkdir -p "$(RACK_USER_DIR)"/plugins-v2/
  68. cp dist/$(SLUG)-"$(VERSION)"-$(ARCH).vcvplugin "$(RACK_USER_DIR)"/plugins-v2/
  69. .PHONY: clean dist
  70. .DEFAULT_GOAL := all