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.

85 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. 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. else
  52. $(STRIP) -s dist/"$(SLUG)"/$(TARGET)
  53. endif
  54. @# Copy distributables
  55. ifdef ARCH_MAC
  56. rsync -rR $(DISTRIBUTABLES) dist/"$(SLUG)"/
  57. else
  58. cp -r --parents $(DISTRIBUTABLES) dist/"$(SLUG)"/
  59. endif
  60. @# Create ZIP package
  61. cd dist && ZSTD_CLEVEL=19 tar -cf "$(SLUG)"-"$(VERSION)"-$(ARCH).vcvplugin --zstd "$(SLUG)"
  62. install: dist
  63. mkdir -p "$(RACK_USER_DIR)"/plugins-v2/
  64. cp dist/"$(SLUG)"-"$(VERSION)"-$(ARCH).vcvplugin "$(RACK_USER_DIR)"/plugins-v2/
  65. .PHONY: clean dist
  66. .DEFAULT_GOAL := all