美文网首页
Makefile示例

Makefile示例

作者: Vicky丶云 | 来源:发表于2021-04-15 17:59 被阅读0次
    SHELL=/usr/bin/env bash
    
    GOVERSION:=$(shell go version | cut -d' ' -f 3 | sed 's/^go//' | awk -F. '{printf "%d%03d%03d", $$1, $$2, $$3}')
    ifeq ($(shell expr $(GOVERSION) \< 1015005), 1)
    $(warning Your Golang version is go$(shell expr $(GOVERSION) / 1000000).$(shell expr $(GOVERSION) % 1000000 / 1000).$(shell expr $(GOVERSION) % 1000))
    $(error Update Golang to version to at least 1.15.5)
    endif
    
    VERSION=1.0.0
    BUILD=`date +%FT%T%z`
    
    PACKAGES=`go list ./... | grep -v /vendor/`
    VETPACKAGES=`go list ./... | grep -v /vendor/ | grep -v /examples/`
    GOFILES=`find . -name "*.go" -type f -not -path "./vendor/*"`
    
    all:
        @go build -o  main
    
    list:
        @echo ${PACKAGES}
        @echo ${VETPACKAGES}
        @echo ${GOFILES}
    
    fmt:
        @gofmt -s -w ${GOFILES}
    
    vet:
        @go vet $(VETPACKAGES)
    
    clean:
        @if [ -f main ] ; then rm main ; fi
    
    .PHONY: all list fmt vet clean
    

    相关文章

      网友评论

          本文标题:Makefile示例

          本文链接:https://www.haomeiwen.com/subject/rlhjlltx.html