-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (43 loc) · 1.76 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
# Source from https://github.com/krisnova/go-nova/blob/main/Makefile
all: compile
version ?= @(git describe --tags --abbrev=0)
org ?= y0rune
target ?= fortios-release
authorname ?= Marcin Woźniak
authoremail ?= [email protected]
license ?= MIT
year ?= 2022
copyright ?= Copyright (c) $(year)
gofile ?= main.go
compile:
@echo "Compiling..."
go build -ldflags "\
-X 'github.com/$(org)/$(target).Version=$(version)' \
-X 'github.com/$(org)/$(target).AuthorName=$(authorname)' \
-X 'github.com/$(org)/$(target).AuthorEmail=$(authoremail)' \
-X 'github.com/$(org)/$(target).Copyright=$(copyright)' \
-X 'github.com/$(org)/$(target).License=$(license)' \
-X 'github.com/$(org)/$(target).Name=$(target)'" \
-o $(target) $(gofile)
# install:
# @echo "Installing..."
# sudo cp $(target) /usr/bin/$(target)
build: clean compile
clean:
@echo "Cleaning..."
rm -rvf release/*
rm -rvf $(target)
# test: clean compile install
# test: clean compile
# @echo "Testing..."
# go test -v .
.PHONY: release
release:
mkdir -p release
GOOS="linux" GOARCH="amd64" go build -ldflags "-X 'github.com/$(org)/$(target).Version=$(version)'" -o release/$(target)-linux-amd64 $(gofile)
GOOS="linux" GOARCH="arm" go build -ldflags "-X 'github.com/$(org)/$(target).Version=$(version)'" -o release/$(target)-linux-arm $(gofile)
GOOS="linux" GOARCH="arm64" go build -ldflags "-X 'github.com/$(org)/$(target).Version=$(version)'" -o release/$(target)-linux-arm64 $(gofile)
GOOS="darwin" GOARCH="amd64" go build -ldflags "-X 'github.com/$(org)/$(target).Version=$(version)'" -o release/$(target)-darwin-amd64 $(gofile)
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'