blob: 22da24a63a90084d04b8a8fc122eba6842853b99 (
plain)
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
|
# Makefile for fscrypt
#
# Copyright 2017 Google Inc.
# Author: Joe Richey (joerichey@google.com)
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
NAME = fscrypt
# VERSION is formatted as <major>.<minor>.<bugfix>
# Bugfix releases resolve issues in existing features.
# Minor releases introduce new features.
# Major releases may introduce breaking changes to the API.
VERSION = 0.1.0
# Holds a formatted string of the build time
BUILD_TIME = $(shell date)
CFLAGS += -O2 -Wall
CMD_DIR = $(NAME)/cmd/$(NAME)
# The code below lets the caller of the makefile change the build flags for
# fscrypt in a familiar manner. For example, to force the program to statically
# link its C components, run "make fscrypt" with:
# make fscrypt "LDFLAGS += -static"
#
# Similarly, to modify the flags passed to the C components, just modify CFLAGS
# or LDFLAGS as you would with a C program. To modify the Go flags, either
# modify GO_FLAGS or GO_LINK_FLAGS (as appropriate).
# Set the C flags so we don't need to set C flags in each CGO file.
export CGO_CFLAGS = $(CFLAGS)
# Pass the version to the command line program
VERSION_FLAG = -X "main.version=$(VERSION)"
# Pass the current date and time to the command line program
DATE_FLAG = -X "main.buildTime=$(BUILD_TIME)"
# Pass the C linking flags into Go
GO_LINK_FLAGS += -s -w $(VERSION_FLAG) $(DATE_FLAG) -extldflags "$(LDFLAGS)"
GOFLAGS += --ldflags '$(GO_LINK_FLAGS)'
.PHONY: default all $(NAME) go update lint format install clean
default: $(NAME)
all: update go format lint $(NAME)
$(NAME):
go build $(GOFLAGS) -o $(NAME) $(CMD_DIR)
# Makes sure go files build and tests pass
go:
govendor generate +local
govendor build $(GOFLAGS) +local
govendor test $(GOFLAGS) +local
update:
@govendor fetch +missing
@govendor add +external
@govendor remove +unused
lint:
@golint $$(go list ./... | grep -v vendor) | grep -v "pb.go" || true
@govendor vet +local
format:
@govendor fmt +local
@find . -name "*.h" -o -name "*.c" -not -path "./vendor/*" | xargs clang-format -i -style=Google
install:
govendor install $(GOFLAGS) +local
clean:
rm -rf $(NAME)
|