github.com/cloudflare/circl@v1.5.0/Makefile (about)

     1  # I'm sure there is better way. But I would need to find it first
     2  MK_FILE_PATH = $(lastword $(MAKEFILE_LIST))
     3  PRJ_DIR      = $(abspath $(dir $(MK_FILE_PATH)))
     4  GOPATH_BUILD = $(PRJ_DIR)/build
     5  COVER_DIR    = $(GOPATH_BUILD)/coverage
     6  TOOLS_DIR   ?= $(GOPATH)/bin
     7  ETC_DIR      = $(PRJ_DIR)/.etc
     8  OPTS         ?=
     9  NOASM        ?=
    10  GO           ?= go
    11  GOLANGCILINT ?= golangci-lint
    12  # -run="^_" as we want to avoid running tests by 'bench' and there never be a test starting with _
    13  BENCH_OPTS   ?= -bench=. -run="^_" -benchmem
    14  V            ?= 1
    15  GOARCH       ?=
    16  BUILD_ARCH   = $(shell $(GO) env GOARCH)
    17  
    18  ifeq ($(NOASM),1)
    19  	OPTS+=--tags purego
    20  endif
    21  
    22  ifeq ($(V),1)
    23  	OPTS += -v              # Be verbose
    24  endif
    25  
    26  all: build
    27  
    28  lint:
    29  	$(GOLANGCILINT) run
    30  
    31  lint-fix:
    32  	$(GOLANGCILINT) run --fix
    33  
    34  build:
    35  	$(GO) build ./...
    36  
    37  test: clean
    38  	$(GO) vet ./...
    39  	$(GO) test $(OPTS) ./...
    40  
    41  bench: clean
    42  	$(GO) test $(BENCH_OPTS) $(OPTS) ./...
    43  
    44  cover: clean
    45  	mkdir -p $(COVER_DIR)
    46  	$(GO) test -race -coverprofile=$(COVER_DIR)/coverage.txt -covermode=atomic $(OPTS) ./...
    47  	$(GO) tool cover -html $(COVER_DIR)/coverage.txt -o $(COVER_DIR)/coverage.html
    48  
    49  generate: clean
    50  	$(GO) generate -v ./...
    51  
    52  bootstrap:
    53  	curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(TOOLS_DIR) v1.18.0
    54  
    55  clean:
    56  	rm -rf $(GOPATH_BUILD)
    57  
    58  .INTERMEDIATE: circl.go circl_static.exe circl_plugin.so
    59  circl_static: circl_static.exe
    60  circl_static.exe: circl.go
    61  	go clean -cache -modcache
    62  	go build -buildmode=default -o $@ $^
    63  
    64  circl_plugin: circl_plugin.so
    65  circl_plugin.so: circl.go
    66  	go clean -cache -modcache
    67  	go build -buildmode=plugin -o $@ $^
    68  
    69  circl.go:
    70  	go run .etc/all_imports.go -out $@