/
Makefile
41 lines (32 loc) · 1.28 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
.DEFAULT_GOAL := build
BUILD_FOLDER = $(shell pwd)/build
FLAGS_WINDOWS = GOOS=windows GOARCH=386 CC=i686-w64-mingw32-gcc CGO_ENABLED=1
MINGW32GCC = $(shell command -v i686-w64-mingw32-gcc 2> /dev/null)
GOFLAGS_WINUI = -trimpath -buildvcs=false --ldflags '-s -w -extldflags "-static" -H windowsgui'
GOFLAGS_CLI = -trimpath -buildvcs=false -tags=cli --ldflags '-s -w -extldflags "-static"'
clean:
rm -rf $(BUILD_FOLDER)
pre: clean
@mkdir -p $(BUILD_FOLDER)
cat tools.go | grep _ | awk -F'"' '{print $$2"@latest"}' | xargs -tI % go install %
go mod download
build: pre lint vet
ifndef MINGW32GCC
$(error "i686-w64-mingw32-gcc is not available. Please install package mingw32-cross-gcc")
endif
@echo "[builder] Building Windows executable"
@mkdir -p $(BUILD_FOLDER)/
$(GOPATH)/bin/rsrc -arch 386 -manifest harden.manifest -ico harden.ico -o rsrc.syso
$(FLAGS_WINDOWS) go build $(GOFLAGS_WINUI) -o $(BUILD_FOLDER)/hardentools.exe
@echo "[builder] Building Windows commandline executable"
$(FLAGS_WINDOWS) go build $(GOFLAGS_CLI) -o $(BUILD_FOLDER)/hardentools-cli.exe
@echo "[builder] Done!"
lint: fmt
@echo "[lint] Running linter on codebase"
@golint ./...
fmt:
@echo "[gofmt] Formatting code"
gofmt -s -w .
vet: fmt
@echo "[go vet] Checking code"
$(FLAGS_WINDOWS) go vet ./...