-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
42 lines (31 loc) · 902 Bytes
/
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
VERSION = v$(strip $(shell cat VERSION))
GO := $(shell which go)
BUILDSTRING := git:[$(shell git log --pretty=format:'%h' -n 1)] go:[$(shell $(GO) version | sed 's/go version //')]
VERSIONSTRING := certgrep $(VERSION) $(BUILDSTRING)
DIMAGE := kung-foo/certgrep
ifndef GOARCH
GOARCH := $(shell $(GO) env GOARCH)
endif
ifndef GOOS
GOOS := $(shell $(GO) env GOOS)
endif
OUTPUT := ./dist/certgrep-$(GOOS)-$(GOARCH)
ifeq ($(GOOS), windows)
OUTPUT := $(OUTPUT).exe
endif
.PHONY: default all clean
default: build
$(OUTPUT): *.go cmd/certgrep/*.go tls_clone/*.go
mkdir -p dist/
$(GO) build -v -o $(OUTPUT) -ldflags '-X "main.VERSION=$(VERSIONSTRING)"' cmd/certgrep/main.go
ifdef CALLING_UID
ifdef CALLING_GID
@echo Reseting owner to $(CALLING_UID):$(CALLING_GID)
chown $(CALLING_UID):$(CALLING_GID) $(OUTPUT)
endif
endif
@echo
@echo Built $(OUTPUT)
build: $(OUTPUT)
clean:
rm -f $(OUTPUT)