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 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. RACK_USER_DIR ?= $(HOME)/.Rack
  25. endif
  26. ifdef ARCH_MAC
  27. TARGET := plugin.dylib
  28. LDFLAGS += -undefined dynamic_lookup
  29. RACK_USER_DIR ?= $(HOME)/Documents/Rack
  30. endif
  31. ifdef ARCH_WIN
  32. TARGET := plugin.dll
  33. RACK_USER_DIR ?= "$(USERPROFILE)"/Documents/Rack
  34. endif
  35. DEP_FLAGS += -fPIC
  36. include $(RACK_DIR)/dep.mk
  37. all: $(TARGET)
  38. include $(RACK_DIR)/compile.mk
  39. clean:
  40. rm -rfv build $(TARGET) dist
  41. dist: all
  42. rm -rf dist
  43. mkdir -p dist/"$(SLUG)"
  44. @# Strip and copy plugin binary
  45. cp $(TARGET) dist/"$(SLUG)"/
  46. ifdef ARCH_MAC
  47. $(STRIP) -S dist/"$(SLUG)"/$(TARGET)
  48. else
  49. $(STRIP) -s dist/"$(SLUG)"/$(TARGET)
  50. endif
  51. @# Copy distributables
  52. ifdef ARCH_MAC
  53. rsync -rR $(DISTRIBUTABLES) dist/"$(SLUG)"/
  54. else
  55. cp -r --parents $(DISTRIBUTABLES) dist/"$(SLUG)"/
  56. endif
  57. @# Create ZIP package
  58. cd dist && zip -q -9 -r "$(SLUG)"-"$(VERSION)"-$(ARCH).zip "$(SLUG)"
  59. install: dist
  60. cp dist/"$(SLUG)"-"$(VERSION)"-$(ARCH).zip $(RACK_USER_DIR)/plugins-v2/
  61. .PHONY: clean dist
  62. .DEFAULT_GOAL := all