-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
36 lines (26 loc) · 850 Bytes
/
Copy pathmakefile
File metadata and controls
36 lines (26 loc) · 850 Bytes
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
BINARY := net-work
BACKENDDIR := ./
BUILDDIR ?= ./build
PLUGINDIR := $(BACKENDDIR)/plugins
GO := go
GOFLAGS := -v
PLUGINTAG := plugin
PLUGINMODE := plugin
PLUGINPATTERN := $(wildcard $(PLUGINDIR)/*)
PLUGINBUILD := $(patsubst $(PLUGINDIR)/%,$(BUILDDIR)/plugins/%.so,$(PLUGINPATTERN))
.PHONY: all build run clean clean_plugins
all: clean build plugins run
build:
cd $(BACKENDDIR) && $(GO) build $(GOFLAGS) -o $(abspath $(BUILDDIR))/$(BINARY)
run:
$(BUILDDIR)/$(BINARY)
plugins: clean_plugins
mkdir -p $(BUILDDIR)/plugins
$(MAKE) $(PLUGINBUILD)
$(BUILDDIR)/plugins/%.so: $(PLUGINDIR)/%
mkdir -p $(BUILDDIR)/plugins/$*
cd $(BACKENDDIR) && $(GO) build $(GOFLAGS) -tags $(PLUGINTAG) -buildmode=$(PLUGINMODE) -o $(abspath $(BUILDDIR))/plugins/$*/plugin.so $</main.go
clean:
$(RM) -r $(BUILDDIR)
clean_plugins:
$(RM) -r $(BUILDDIR)/plugins