1
1
$(if $(filter 4.%,$(MAKE_VERSION)),,\
2
2
$(error GNU make 4.0 or above is required.))
3
3
4
- export GO111MODULE := off
4
+ export GOPATH = $( CURDIR ) /_gopath
5
5
6
6
all :
7
7
@@ -12,9 +12,8 @@ include 3rdparty.mk
12
12
GOROOT ?= /usr/lib/go-$(lastword $(shell echo '$(foreach elem,\
13
13
$(sort $(patsubst go-% ,% ,$(notdir $(wildcard /usr/lib/go-1.* ) ) ) ) ,\
14
14
$(elem ) \n) ' | sort --version-sort) )
15
- NAMESPACE := github.com/spyre-project/spyre
15
+ NAMESPACE := $( shell awk '/^module / {print $$2}' go.mod)
16
16
GOFILES := $(shell find $(CURDIR ) \
17
- -not -path '$(CURDIR ) /vendor/* ' \
18
17
-not -path '$(CURDIR ) /_* ' \
19
18
-type f -name '* .go')
20
19
VERSION := $(shell < cmd/spyre/version.go sed -ne '/var version/{ s/.* "\(.* \) "/\1/;p }')
@@ -54,49 +53,31 @@ unit-test: private export GOARCH=amd64
54
53
55
54
$(EXE ) unit-test : private export CGO_ENABLED=1
56
55
$(EXE ) unit-test : private export PATH := $(CURDIR ) /_3rdparty/tgt/bin:$(PATH )
57
- $(EXE ) vendor/.exists dep-% unit-test : private export GOPATH=$(CURDIR ) /_gopath
58
-
59
- # Set up vendor directory using github.com/golang/dep
60
- _gopath/.exists : Gopkg.lock Gopkg.toml
61
- rm -f $(@D ) /src/$(NAMESPACE )
62
- mkdir -p $(dir $(@D ) /src/$(NAMESPACE ) )
63
- ln -sf $(CURDIR ) $(@D ) /src/$(NAMESPACE )
64
- touch $@
65
-
66
- # Set up GOPATH via symlink
67
- # (Technically, this does not need to be in the build directory.)
68
- vendor/.exists : _gopath/.exists
69
- $(info [+] Populating vendor/ directory...)
70
- mkdir -p vendor
71
- cd _gopath/src/$(NAMESPACE ) && dep ensure -vendor-only -v
72
- touch $@
73
-
74
- .PHONY : dep-ensure
75
- dep-ensure : _gopath/.exists
76
- cd _gopath/src/$(NAMESPACE ) && dep ensure -v
77
- dep-ensure-update : _gopath/.exists
78
- cd _gopath/src/$(NAMESPACE ) && dep ensure -update -v
79
56
80
57
# Build resource files
81
58
% _resource_windows_amd64.syso : % .rc
82
59
x86_64-w64-mingw32-windres --output-format coff -o $@ -i $<
83
60
% _resource_windows_386.syso : % .rc
84
61
i686-w64-mingw32-windres --output-format coff -o $@ -i $<
85
62
63
+ .PHONY : dump-go-dependencies
64
+ dump-go-dependencies :
65
+ go mod download -json | jq -r ' [.Path,"=",.Version] | add'
66
+
86
67
.PHONY : unit-test
68
+ unit-test : test_pathspec ?= $(NAMESPACE ) /...
69
+ unit-test : test_flags ?= -v
87
70
unit-test :
88
71
$(info [+] Running tests...)
72
+ $(info [+] test_flags=$(test_flags ) test_pathspec=$(test_pathspec ) )
89
73
$(info [+] GOROOT=$(GOROOT ) GOOS=$(GOOS ) GOARCH=$(GOARCH ) CC=$(CC ) )
90
74
$(info [+] PKG_CONFIG_PATH=$(PKG_CONFIG_PATH ) )
91
- $(GOROOT ) /bin/go test -v \
75
+ $(GOROOT ) /bin/go test $( test_flags ) \
92
76
-ldflags ' -w -s -linkmode=external -extldflags "-static"' \
93
77
-tags yara_static \
94
- $(patsubst % ,$(NAMESPACE ) /% ,$(shell find -not -path '* /vendor/* ' \
95
- -not -path ' */_gopath/*' \
96
- -type f -name ' *_test.go' \
97
- | xargs dirname | sed -e ' s/^\.//' ))
78
+ $(test_pathspec )
98
79
99
- $(EXE ) unit-test : $(GOFILES ) $(RCFILES ) Makefile 3rdparty.mk 3rdparty-all.stamp _gopath/.exists vendor/.exists
80
+ $(EXE ) unit-test : $(GOFILES ) $(RCFILES ) Makefile 3rdparty.mk 3rdparty-all.stamp
100
81
101
82
$(EXE ) :
102
83
$(info [+] Building spyre...)
@@ -118,4 +99,3 @@ spyre-$(VERSION).zip: $(EXE)
118
99
clean :
119
100
rm -rf _build $(RCFILES ) spyre-$(VERSION ) .zip
120
101
distclean : clean 3rdparty-distclean
121
- rm -rf _gopath _vendor
0 commit comments