-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.bac
99 lines (79 loc) · 2.52 KB
/
Makefile.bac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
ifndef RACK_DIR
$(error RACK_DIR is not defined)
endif
SLUG := $(shell jq -r .slug plugin.json)
VERSION := $(shell jq -r .version plugin.json)
ifndef SLUG
$(error SLUG could not be found in manifest)
endif
ifndef VERSION
$(error VERSION could not be found in manifest)
endif
DISTRIBUTABLES += plugin.json
FLAGS += -fPIC
FLAGS += -I$(RACK_DIR)/include -I$(RACK_DIR)/dep/include
LDFLAGS += -shared
# 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.
LDFLAGS += -L$(RACK_DIR) -lRack
include $(RACK_DIR)/arch.mk
TARGET := plugin
ifndef ARCH_X64
# On non-x64, append CPU name to plugin binary
TARGET := $(TARGET)-$(ARCH_CPU)
endif
ifdef ARCH_LIN
TARGET := $(TARGET).so
# This prevents static variables in the DSO (dynamic shared object) from being preserved after dlclose().
FLAGS += -fno-gnu-unique
# When Rack loads a plugin, it symlinks /tmp/Rack2 to its system dir, so the plugin can link to libRack.
LDFLAGS += -Wl,-rpath=/tmp/Rack2
# Since the plugin's compiler could be a different version than Rack's compiler, link libstdc++ and libgcc statically to avoid ABI issues.
LDFLAGS += -static-libstdc++ -static-libgcc
RACK_USER_DIR ?= $(HOME)/.Rack2
endif
ifdef ARCH_MAC
CC := /usr/bin/clang
CXX := /usr/bin/clang++
CFLAGS += -arch x86_64
CXXFLAGS += -arch x86_64
TARGET := $(TARGET).dylib
LDFLAGS += -undefined dynamic_lookup -Wl -export-all-symbols
RACK_USER_DIR ?= $(HOME)/Documents/Rack2
endif
ifdef ARCH_WIN
TARGET := $(TARGET).dll
LDFLAGS += -static-libstdc++
RACK_USER_DIR ?= $(USERPROFILE)/Documents/Rack2
endif
DEP_FLAGS += -fPIC
include $(RACK_DIR)/dep.mk
all: $(TARGET)
include $(RACK_DIR)/compile.mk
clean:
rm -rfv build $(TARGET) dist
ZSTD_COMPRESSION_LEVEL ?= 19
dist: all
rm -rf dist
mkdir -p dist/$(SLUG)
@# Strip and copy plugin binary
cp $(TARGET) dist/$(SLUG)/
ifdef ARCH_MAC
$(STRIP) -S dist/$(SLUG)/$(TARGET)
$(INSTALL_NAME_TOOL) -change libRack.dylib /tmp/Rack2/libRack.dylib dist/$(SLUG)/$(TARGET)
$(OTOOL) -L dist/$(SLUG)/$(TARGET)
else
$(STRIP) -s dist/$(SLUG)/$(TARGET)
endif
@# Copy distributables
ifdef ARCH_MAC
rsync -rR $(DISTRIBUTABLES) dist/$(SLUG)/
else
cp -r --parents $(DISTRIBUTABLES) dist/$(SLUG)/
endif
@# Create ZIP package
cd dist && tar -c $(SLUG) | zstd -$(ZSTD_COMPRESSION_LEVEL) -o "$(SLUG)"-"$(VERSION)"-$(ARCH_NAME).vcvplugin
install: dist
mkdir -p "$(RACK_USER_DIR)"/plugins/
cp dist/*.vcvplugin "$(RACK_USER_DIR)"/plugins/
.PHONY: clean dist
.DEFAULT_GOAL := all