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.

88 lines
2.1KB

  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. dist: all
  45. rm -rf dist
  46. mkdir -p dist/$(SLUG)
  47. @# Strip and copy plugin binary
  48. cp $(TARGET) dist/$(SLUG)/
  49. ifdef ARCH_MAC
  50. $(STRIP) -S dist/$(SLUG)/$(TARGET)
  51. install_name_tool -change libRack.dylib @rpath/libRack.dylib dist/$(SLUG)/$(TARGET)
  52. install_name_tool -add_rpath . dist/$(SLUG)/$(TARGET)
  53. otool -L dist/$(SLUG)/$(TARGET)
  54. else
  55. $(STRIP) -s dist/$(SLUG)/$(TARGET)
  56. endif
  57. @# Copy distributables
  58. ifdef ARCH_MAC
  59. rsync -rR $(DISTRIBUTABLES) dist/$(SLUG)/
  60. else
  61. cp -r --parents $(DISTRIBUTABLES) dist/$(SLUG)/
  62. endif
  63. @# Create ZIP package
  64. cd dist && tar -c $(SLUG) | zstd -19 -o $(SLUG)-"$(VERSION)"-$(ARCH).vcvplugin
  65. install: dist
  66. mkdir -p "$(RACK_USER_DIR)"/plugins-v2/
  67. cp dist/$(SLUG)-"$(VERSION)"-$(ARCH).vcvplugin "$(RACK_USER_DIR)"/plugins-v2/
  68. .PHONY: clean dist
  69. .DEFAULT_GOAL := all