-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
58 lines (43 loc) · 1.2 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
# Makefile for ingest project
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
# Binary name
BINARY_NAME=ingest
# Version information
VERSION := $(shell git describe --tags --always)
BUILD_TIME := $(shell date -u '+%Y-%m-%d_%I:%M:%S%p')
LDFLAGS := -ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)"
# Main package path
MAIN_PACKAGE=.
.PHONY: all build clean test deps
all: clean build
build:
$(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME) $(MAIN_PACKAGE)
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
test:
$(GOTEST) -v ./...
deps:
$(GOGET) ./...
# Run the application
run: build
./$(BINARY_NAME)
# Build for multiple platforms
build-all:
GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME)-linux-amd64 $(MAIN_PACKAGE)
GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME)-darwin-amd64 $(MAIN_PACKAGE)
GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME)-windows-amd64.exe $(MAIN_PACKAGE)
# Install the binary
install: build
mv $(BINARY_NAME) $(GOPATH)/bin/$(BINARY_NAME)
# Uninstall the binary
uninstall:
rm -f $(GOPATH)/bin/$(BINARY_NAME)
# output the version information
version:
@echo $(VERSION)