File: Makefile

package info (click to toggle)
golang-gopkg-lxc-go-lxc.v2 0.0%2Bgit20240606.27b3d11-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 444 kB
  • sloc: ansic: 582; makefile: 77
file content (33 lines) | stat: -rw-r--r-- 824 bytes parent folder | download | duplicates (3)
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
NO_COLOR=\033[0m
OK_COLOR=\033[0;32m

ALL_GO_FILES = $(wildcard */*.go)
ALL_BIN_FILES = $(patsubst %.go,%,$(ALL_GO_FILES))

all: $(ALL_GO_FILES)

define PROGRAM_template
$(1): vet
	@echo "$(OK_COLOR)==> Building $(1) $(NO_COLOR)"
	@cd $(dir $1); go build
endef

$(foreach prog,$(ALL_GO_FILES),$(eval $(call PROGRAM_template,$(prog))))

clean:
	@$(foreach file,$(ALL_BIN_FILES),rm -f $(file);)

format:
	@echo "$(OK_COLOR)==> Formatting the code $(NO_COLOR)"
	@$(foreach file,$(ALL_GO_FILES),gofmt -s -w $(file);)
	@$(foreach file,$(ALL_GO_FILES),goimports -w $(file);)

vet:
	@echo "$(OK_COLOR)==> Running go vet $(NO_COLOR)"
	@$(foreach file,$(ALL_GO_FILES),go vet -all $(file);)

lint:
	@echo "$(OK_COLOR)==> Running golint $(NO_COLOR)"
	@$(foreach file,$(ALL_GO_FILES),golint $(file);)

.PHONY: all clean format vet lint