-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathMakefile
More file actions
145 lines (119 loc) · 3.83 KB
/
Makefile
File metadata and controls
145 lines (119 loc) · 3.83 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
##
# Makefile automatically generated by genmake 1.0, May-03-00
# genmake 1.0 by muquit@muquit.com, http://www.muquit.com/
PROGNAME= mailsend-go
PROGNAME_WIN= $(PROGNAME).exe
PROGNAME_PI= $(PROGNAME)-raspberry-pi
PROGNAME_PI_JESSIE= $(PROGNAME)-raspberry-pi-jessie
DESTDIR=
VERSION := $(shell cat VERSION)
LDFLAGS := -ldflags "-w -s -X 'github.com/muquit/mailsend-go/pkg/version.Version=$(VERSION)'"
BUILD_OPTIONS := -trimpath
BINDIR= /usr/local/bin
MANPAGE= docs/mailsend-go.1
MANDIR= /usr/local/share/man/man1
CP= /bin/cp -v
OS= $(shell go env GOOS)
MTOC=markdown-toc-go
FORMULA_DIR=$(HOME)/gitdev/homebrew-formulae/Formula
FORMULA_FILE=$(FORMULA_DIR)/mailsend-go.rb
all: build_all gen
@echo "- Getting go get github.com/muquit/gomail@master ..."
go get github.com/muquit/gomail@master
go mod tidy
@echo "- Compiling ${PROGNAME} ..."
go build $(BUILD_OPTIONS) $(LDFLAGS)
/bin/ls -lt ${PROGNAME}
# use go-xbuild-go
build_all:
@echo "- Building for all selected platforms ..."
/bin/rm -f bin/*
go-xbuild-go -build-args '$(BUILD_OPTIONS) $(LDFLAGS)'
example:
echo "Generating examples ..."
@./scripts/mkexamples.sh
$(PROGNAME) : native
# to strip out debug info: go build -ldflags="-s -w"
linux:
@echo "- Building $(PROGNAME)_linux"
@CGO_ENABLED=0 GOOS=linux go build $(BUILD_OPTIONS) $(LDFLAGS) -o $(PROGNAME)_linux
/bin/ls -lt $(PROGNAME)_linux
@echo ""
native:
@echo "- Building $(PROGNAME)"
go build $(BUILD_OPTIONS) $(LDFLAGS) -o $(PROGNAME)
/bin/ls -lt $(PROGNAME)
@echo ""
windows:
@echo "- Building $(PROGNAME_WIN) for Windows amd64"
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build $(BUILD_OPTIONS) $(LDFLAGS) -o $(PROGNAME_WIN)
/bin/ls -lt $(PROGNAME_WIN)
@echo ""
mac:
@echo "- Building $(PROGNAME) for Mac amd64"
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build $(BUILD_OPTIONS) $(LDFLAGS) -o $(PROGNAME)_mac
/bin/ls -lt $(PROGNAME)_mac
@echo ""
pi:
@echo "- Building $(PROGNAME) for raspberry pi"
GOOS=linux GOARCH=arm GOARM=7 go build $(BUILD_OPTIONS) $(LDFLAGS) -o $(PROGNAME_PI)
/bin/ls -lt $(PROGNAME_PI)
@echo ""
pijessie:
@echo "- Building $(PROGNAME) for raspberry pi jessie"
GOARM=6 GOARCH=arm GOOS=linux go build $(BUILD_OPTIONS) $(LDFLAGS) -o $(PROGNAME_PI_JESSIE)
/bin/ls -lt $(PROGNAME_PI_JESSIE)
@echo ""
# generate files/examples.txt from docs/examples.md
# generate examples.go from examples.txt for -ex flag
.PHONY: gen
gen: example usage docs
.PHONE: usage
usage:
echo "# Synopsis" > docs/usage.md
echo '```' >> docs/usage.md
@./mailsend-go -h >> docs/usage.md
echo '```' >> docs/usage.md
.PHONY: dev
dev: gen all doc
.PHONY: mod_clean
mod_clean:
@./scripts/mod_clean.sh
.PHONY: docs
docs:
echo "Generating docs ..."
$(MTOC) -i docs/main.md -o ./README.md --glossary docs/glossary.txt --pre-toc-file docs/badges.md -f
$(MTOC) -i docs/ChangeLog.md -o ./ChangeLog.md --glossary docs/glossary.txt -f -no-credit
@./scripts/mk_man.sh
.PHONY: install
install: install-bin
.PHONY: help
help:
@echo "============================================================"
@echo " make gen - assemble document, create usage.txt and examples.
go"
@echo " make - build native client"
@echo " make linux - build linux client"
@echo " make mac - build mac client"
@echo " make win - build windows client"
@echo " make clean"
@echo "============================================================"
.PHONY: install-bin
install-bin:
$(CP) $(PROGNAME) $(BINDIR)
$(CP) $(MANPAGE) $(MANDIR)
.PHONY: release
release:
go-xbuild-go --release
# create formula for homebrew
.PHONY: brew
brew:
./scripts/gen_homebrew_formula.rb \
--desc "A CLI tool to send mail via SMTP protocol" \
--output $(FORMULA_DIR)
/bin/ls -lt $(FORMULA_FILE)
@echo "*** Do not forget to check-in the formula!"
.PHONY: clean
clean:
/bin/rm -f $(PROGNAME) $(PROGNAME_WIN) $(PROGNAME)_$(OS) $(PROGNAME)_* *.bak \
$(PROGNAME)_linux $(PROGNAME)_mac