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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. # Plugins must link to libRack because when Rack is used as a plugin of another application, its symbols are not available to subsequently loaded shared libraries.
  17. LDFLAGS += -L$(RACK_DIR) -lRack
  18. include $(RACK_DIR)/arch.mk
  19. ifdef ARCH_LIN
  20. TARGET := plugin.so
  21. # This prevents static variables in the DSO (dynamic shared object) from being preserved after dlclose().
  22. # I don't really understand the side effects (see GCC manual), but so far tests are positive.
  23. FLAGS += -fno-gnu-unique
  24. LDFLAGS += -Wl,-rpath=.
  25. # Since the plugin's compiler could be a different version than Rack's compiler, link libstdc++ and libgcc statically to avoid ABI issues.
  26. LDFLAGS += -static-libstdc++ -static-libgcc
  27. RACK_USER_DIR ?= $(HOME)/.Rack2
  28. endif
  29. ifdef ARCH_MAC
  30. TARGET := plugin.dylib
  31. LDFLAGS += -undefined dynamic_lookup
  32. RACK_USER_DIR ?= $(HOME)/Documents/Rack2
  33. endif
  34. ifdef ARCH_WIN
  35. TARGET := plugin.dll
  36. LDFLAGS += -static-libstdc++
  37. RACK_USER_DIR ?= $(USERPROFILE)/Documents/Rack2
  38. endif
  39. DEP_FLAGS += -fPIC
  40. include $(RACK_DIR)/dep.mk
  41. all: $(TARGET)
  42. include $(RACK_DIR)/compile.mk
  43. clean:
  44. rm -rfv build $(TARGET) dist
  45. ZSTD_COMPRESSION_LEVEL ?= 19
  46. dist: all
  47. rm -rf dist
  48. mkdir -p dist/$(SLUG)
  49. @# Strip and copy plugin binary
  50. cp $(TARGET) dist/$(SLUG)/
  51. ifdef ARCH_MAC
  52. $(STRIP) -S dist/$(SLUG)/$(TARGET)
  53. $(INSTALL_NAME_TOOL) -change libRack.dylib @rpath/libRack.dylib dist/$(SLUG)/$(TARGET)
  54. $(INSTALL_NAME_TOOL) -add_rpath . dist/$(SLUG)/$(TARGET)
  55. $(OTOOL) -L dist/$(SLUG)/$(TARGET)
  56. else
  57. $(STRIP) -s dist/$(SLUG)/$(TARGET)
  58. endif
  59. @# Copy distributables
  60. ifdef ARCH_MAC
  61. rsync -rR $(DISTRIBUTABLES) dist/$(SLUG)/
  62. else
  63. cp -r --parents $(DISTRIBUTABLES) dist/$(SLUG)/
  64. endif
  65. @# Create ZIP package
  66. cd dist && tar -c $(SLUG) | zstd -$(ZSTD_COMPRESSION_LEVEL) -o "$(SLUG)"-"$(VERSION)"-$(ARCH_OS_NAME).vcvplugin
  67. install: dist
  68. mkdir -p "$(RACK_USER_DIR)"/plugins/
  69. cp dist/*.vcvplugin "$(RACK_USER_DIR)"/plugins/
  70. .PHONY: clean dist
  71. .DEFAULT_GOAL := all