-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (48 loc) · 1.48 KB
/
Makefile
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
PREFIX ?= /usr/local
DESTDIR ?=
INSTALL_BIN = install -m 755
VERSION != cat VERSION
GOOS != go env GOOS
GOARCH != go env GOARCH
EXT != if [ "$(GOOS)" = "windows" ]; then echo -n ".exe"; else echo -n ""; fi
APPS := docproc.fileinput docproc.proc docproc.webinput
DISTFILES := LICENSE README.md examples doc/_build/html
DISTNAME := docproc-$(VERSION)-$(GOOS)-$(GOARCH)
DISTDIR := dist/$(DISTNAME)
LDFLAGS := -X main.version=$(VERSION)
STATICS != if [ "$(CGO_ENABLED)" = "0" ]; then echo -n "netgo"; else echo -n ""; fi
TAGS := beanstalk nsq $(STATICS)
.PHONY: clean install dist test $(APPS)
all: info $(APPS)
info:
@echo "Building docproc $(VERSION) for $(GOOS)/$(GOARCH)..."
clean:
rm -rf dist doc/_build
$(DISTDIR):
mkdir -p $(DISTDIR)
$(DISTDIR)/%:
go build -tags "$(TAGS)" -ldflags "$(LDFLAGS)" -o $@$(EXT) ./$*
$(APPS): $(DISTDIR) $(APPS:%=$(DISTDIR)/%)
test:
go test -tags "$(TAGS)" -ldflags "$(LDFLAGS)" ./...
docs:
make -C doc html
install: $(APPS)
$(INSTALL_BIN) -d $(DESTDIR)$(PREFIX)/bin
for app in $(APPS); do \
$(INSTALL_BIN) $(DISTDIR)/$$app $(DESTDIR)$(PREFIX)/bin; \
done
dist/$(DISTNAME).tar.gz: docs $(APPS)
for f in $(DISTFILES); do \
cp -rf $$f $(DISTDIR); \
done
if [ "$(GOOS)" = "windows" ]; then \
cd dist && zip -r $(DISTNAME).zip $(DISTNAME); \
else \
cd dist && tar -czf $(DISTNAME).tar.gz $(DISTNAME); \
fi
dist: dist/$(DISTNAME).tar.gz
PLATFORMS := windows linux darwin dragonfly freebsd
release: $(PLATFORMS)
$(PLATFORMS): %:
GOOS=$* make && make dist