From 4259d5f66695e3faedb8335eb5790ffb5ce52129 Mon Sep 17 00:00:00 2001 From: Rodrigo Chiossi Date: Sun, 17 Nov 2019 04:27:47 +0100 Subject: [PATCH] Makefile: Remove unused local gopath A local gopath is no longer needed to build if the code is outside the go src/ folder. This change also allows `make lint` to work if the code is outside the go tree. Signed-off-by: Rodrigo Chiossi --- Makefile | 40 +++++----------------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index 13b99a6..a326742 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,3 @@ -# Makefile used to create packages for mixer-tools. It doesn't assume -# that the code is inside a GOPATH, and always copy the files into a -# new workspace to get the work done. Go tools doesn't reliably work -# with symbolic links. -# -# For historical purposes, it also works in a development environment -# when the repository is already inside a GOPATH. include Makefile.bats .NOTPARALLEL: @@ -12,38 +5,19 @@ include Makefile.bats VERSION=6.1.4 GO_PACKAGE_PREFIX := github.com/clearlinux/mixer-tools -.PHONY: gopath - -# Strictly speaking we should check if it the directory is inside an -# actual GOPATH, but the directory structure matching is likely enough. -ifeq (,$(findstring ${GO_PACKAGE_PREFIX},${CURDIR})) -LOCAL_GOPATH := ${CURDIR}/.gopath -export GOPATH := ${LOCAL_GOPATH} -gopath: - @rm -rf ${LOCAL_GOPATH}/src - @mkdir -p ${LOCAL_GOPATH}/src/${GO_PACKAGE_PREFIX} - @cp -af * ${LOCAL_GOPATH}/src/${GO_PACKAGE_PREFIX} - @echo "Prepared a local GOPATH=${GOPATH}" -else -LOCAL_GOPATH := -GOPATH ?= ${HOME}/go -gopath: - @echo "Code already in existing GOPATH=${GOPATH}" -endif - .PHONY: build install clean check .DEFAULT_GOAL := build -build: gopath +build: go install -ldflags="-X ${GO_PACKAGE_PREFIX}/builder.Version=${VERSION}" ${GO_PACKAGE_PREFIX}/mixer go install ${GO_PACKAGE_PREFIX}/mixin go install ${GO_PACKAGE_PREFIX}/swupd-extract go install ${GO_PACKAGE_PREFIX}/swupd-inspector go install ${GO_PACKAGE_PREFIX}/mixer-completion -install: gopath +install: test -d $(DESTDIR)/usr/bin || install -D -d -m 00755 $(DESTDIR)/usr/bin; install -m 00755 $(GOPATH)/bin/mixer $(DESTDIR)/usr/bin/. install -m 00755 $(GOPATH)/bin/mixin $(DESTDIR)/usr/bin/. @@ -54,7 +28,7 @@ install: gopath test -d $(DESTDIR)/usr/share/man/man1 || install -D -d -m 00755 $(DESTDIR)/usr/share/man/man1 install -m 00644 $(MANPAGES) $(DESTDIR)/usr/share/man/man1/ -check: gopath +check: go test -cover ${GO_PACKAGE_PREFIX}/... .PHONY: checkcoverage @@ -63,7 +37,7 @@ checkcoverage: go tool cover -html=coverage.out .PHONY: lint -lint: gopath +lint: @golangci-lint run --deadline=10m --tests --disable-all \ --enable=misspell \ --enable=vet \ @@ -80,11 +54,7 @@ lint: gopath ./... clean: -ifeq (,${LOCAL_GOPATH}) - go clean -i -x -else - rm -rf ${LOCAL_GOPATH} -endif + go clean -i -x ${GO_PACKAGE_PREFIX}/... rm -f mixer-tools-*.tar.gz release: