From c2b5729ebd26a648bb0249331c9db7453c7bcf72 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Thu, 23 Nov 2017 15:18:25 +0100 Subject: [PATCH] build: Build mgmt on any go file change Prior to this commit, running make would only rebuild mgmt when main.go was changed. It means that make clean build was needed. With this commit, any go file change in this directory will trigger a new compilation. Signed-off-by: Julien Pivotto --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 01edcc80..fca2b31a 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ SHELL = /usr/bin/env bash .PHONY: all art cleanart version program path deps run race generate build clean test gofmt yamlfmt format docs rpmbuild mkdirs rpm srpm spec tar upload upload-sources upload-srpms upload-rpms copr .SILENT: clean +GO_FILES := $(shell find . -name '*.go') SVERSION := $(or $(SVERSION),$(shell git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --dirty --always)) VERSION := $(or $(VERSION),$(shell git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --abbrev=0)) PROGRAM := $(shell echo $(notdir $(CURDIR)) | cut -f1 -d"-") @@ -106,7 +107,7 @@ generate: build: $(PROGRAM) -$(PROGRAM): main.go +$(PROGRAM): $(GO_FILES) @echo "Building: $(PROGRAM), version: $(SVERSION)..." ifneq ($(OLDGOLANG),) @# avoid equals sign in old golang versions eg in: -X foo=bar @@ -115,7 +116,7 @@ else time go build -i -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION)" -o $(PROGRAM) $(BUILD_FLAGS); endif -$(PROGRAM).static: main.go +$(PROGRAM).static: $(GO_FILES) @echo "Building: $(PROGRAM).static, version: $(SVERSION)..." go generate ifneq ($(OLDGOLANG),)