1DIRS := \
2	. \
3	nl
4
5DEPS = \
6	github.com/vishvananda/netns \
7	golang.org/x/sys/unix
8
9uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
10testdirs = $(call uniq,$(foreach d,$(1),$(dir $(wildcard $(d)/*_test.go))))
11goroot = $(addprefix ../../../,$(1))
12unroot = $(subst ../../../,,$(1))
13fmt = $(addprefix fmt-,$(1))
14
15all: test
16
17$(call goroot,$(DEPS)):
18	go get $(call unroot,$@)
19
20.PHONY: $(call testdirs,$(DIRS))
21$(call testdirs,$(DIRS)):
22	go test -test.exec sudo -test.parallel 4 -timeout 60s -test.v github.com/vishvananda/netlink/$@
23
24$(call fmt,$(call testdirs,$(DIRS))):
25	! gofmt -l $(subst fmt-,,$@)/*.go | grep -q .
26
27.PHONY: fmt
28fmt: $(call fmt,$(call testdirs,$(DIRS)))
29
30test: fmt $(call goroot,$(DEPS)) $(call testdirs,$(DIRS))
31