-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (50 loc) · 1.45 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
59
60
61
62
63
64
65
CGO_ENABLED=1
CLANG=clang
BUILD := build-portable
CLEAN := clean-portable
PREPARE_COMPILE_TARGETS :=
ifneq ($(OS),Windows_NT)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
BUILD := build-native
CLEAN := clean-native
endif
ifeq ($(UNAME_S),Darwin)
BUILD := build-native-darwin
CLEAN := clean-native
LEAF7_FEATURES := $(shell sysctl -a | grep machdep.cpu.leaf7_features)
ifeq ($(LEAF7_FEATURES),)
PREPARE_COMPILE_TARGETS := cgo-sources-without-avx2
endif
endif
endif
.PHONY: build-native-darwin build-native build test build build-portable clean clean-portable
build: $(BUILD)
clean: $(CLEAN)
build-portable:
$(info building portable binaries)
$(info Operating System: $(OS))
$(info C compiler: $(shell $(CC) -v))
go build .
clean-portable:
rm word_cloud
@echo "done"
build-native:
@echo "building Linux binary"
$(info Operating System: $(shell uname -s))
$(info C compiler: )$(shell cc -v)
CGO_ENABLED=$(CGO_ENABLED) go build .
cgo-sources-without-avx2:
$(info WARN downgrading c source files to not use AVX2 instruction set)
sed -i .bak 's/ -mavx2 / /g' stats_nocgo_darwin.go
sed -i .bak 's/ -mavx2 / /g' stats_darwin.go
build-native-darwin: $(PREPARE_COMPILE_TARGETS)
@echo "building Darwin binary"
$(info Operating System: $(shell uname -s))
$(info C compiler: )$(shell cc -v)
CGO_ENABLED=$(CGO_ENABLED) go build .
clean-native:
rm word_cloud
@echo "done"
test: $(BUILD)
CGO_ENABLED=$(CGO_ENABLED) go test . -test.v