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.

81 lines
1.7KB

  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. # This prevents static variables in the DSO (dynamic shared object) from being preserved after dlclose().
  16. # I don't really understand the side effects (see GCC manual), but so far tests are positive.
  17. FLAGS += -fno-gnu-unique
  18. include $(RACK_DIR)/arch.mk
  19. ifdef ARCH_LIN
  20. LDFLAGS += -shared
  21. TARGET := plugin.so
  22. RACK_USER_DIR ?= $(HOME)/.Rack
  23. # Link to glibc 2.23
  24. # FLAGS += -include force_link_glibc_2.23.h
  25. endif
  26. ifdef ARCH_MAC
  27. LDFLAGS += -shared -undefined dynamic_lookup
  28. TARGET := plugin.dylib
  29. RACK_USER_DIR ?= $(HOME)/Documents/Rack
  30. endif
  31. ifdef ARCH_WIN
  32. LDFLAGS += -shared -L$(RACK_DIR) -lRack
  33. TARGET := plugin.dll
  34. RACK_USER_DIR ?= "$(USERPROFILE)"/Documents/Rack
  35. endif
  36. DEP_FLAGS += -fPIC
  37. include $(RACK_DIR)/dep.mk
  38. all: $(TARGET)
  39. include $(RACK_DIR)/compile.mk
  40. clean:
  41. rm -rfv build $(TARGET) dist
  42. dist: all
  43. rm -rf dist
  44. mkdir -p dist/"$(SLUG)"
  45. @# Strip and copy plugin binary
  46. cp $(TARGET) dist/"$(SLUG)"/
  47. ifdef ARCH_MAC
  48. $(STRIP) -S dist/"$(SLUG)"/$(TARGET)
  49. else
  50. $(STRIP) -s dist/"$(SLUG)"/$(TARGET)
  51. endif
  52. @# Copy distributables
  53. ifdef ARCH_MAC
  54. rsync -rR $(DISTRIBUTABLES) dist/"$(SLUG)"/
  55. else
  56. cp -r --parents $(DISTRIBUTABLES) dist/"$(SLUG)"/
  57. endif
  58. @# Create ZIP package
  59. cd dist && zip -q -9 -r "$(SLUG)"-"$(VERSION)"-$(ARCH).zip "$(SLUG)"
  60. install: dist
  61. cp dist/"$(SLUG)"-"$(VERSION)"-$(ARCH).zip $(RACK_USER_DIR)/plugins-v2/
  62. .PHONY: clean dist
  63. .DEFAULT_GOAL := all