From bc3dfecc3489678f7f92df1e32838d4a9b14bcfb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= Date: Tue, 5 Dec 2017 14:57:55 +0100 Subject: [PATCH] Makefile: refactor detection and use of tools MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomáš Golembiovský --- .gitignore | 1 + Makefile | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index b99d5f8..5dd3503 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ nbdkit-1.*.tar.gz *.rpm /BUILDROOT +/Makefile.tools /x86_64 diff --git a/Makefile b/Makefile index 534d058..7a22647 100644 --- a/Makefile +++ b/Makefile @@ -36,8 +36,10 @@ PWD := $(shell pwd) VERSION := $(shell grep ^Version: nbdkit-plugin-vddk.spec | awk '{print $$2}') VDDK_DIR := $(shell grep '^%global vddkdir' nbdkit-plugin-vddk.spec | awk '{print $$3}') -all: check-tools check-vddk check-source - rpmbuild -ba \ +include Makefile.tools + +all: check-vddk check-source + $(RPMBUILD) -ba \ --define "_topdir $(PWD)" \ --define "_builddir $(PWD)" \ --define "_rpmdir $(PWD)" \ @@ -46,9 +48,23 @@ all: check-tools check-vddk check-source --define "_srcrpmdir $(PWD)" \ nbdkit-plugin-vddk.spec -check-tools: - @if ! rpmbuild --help >/dev/null 2>&1; then echo "‘rpmbuild’ not installed or not working. Install the ‘rpm-build’ package."; exit 1; fi - @if ! wget --help >/dev/null 2>&1; then echo "‘wget’ not installed or not working. Install the ‘wget’ package."; exit 1; fi +Makefile.tools: + @rm -rf $@ $@-t + @if ! rpmbuild --help >/dev/null 2>&1; then \ + echo -n "‘rpmbuild’ not installed or not working. "; \ + echo "Install the ‘rpm-build’ package."; \ + exit 1; \ + else \ + echo 'RPMBUILD=rpmbuild' >> $@-t; \ + fi + @if wget --help >/dev/null 2>&1; then \ + echo 'DOWNLOAD=wget -O -' >> $@-t; \ + else \ + echo -n "‘wget’ not installed or not working."; \ + echo "Install the ‘wget’ package."; \ + exit 1; \ + fi + @mv $@-t $@ check-vddk: @if ! [ -d $(VDDK_DIR) ] || ! [ -d $(VDDK_DIR)/include ]; then echo -e "You must download VDDK and edit ‘nbdkit-plugin-vddk.spec’ to point ‘vddkdir’\nto the location where you unpacked VDDK."; exit 1; fi @@ -57,7 +73,7 @@ check-source: nbdkit-$(VERSION).tar.gz nbdkit-$(VERSION).tar.gz: rm -rf $@ $@-t - wget -O $@-t http://libguestfs.org/download/nbdkit/$@ + $(DOWNLOAD) http://libguestfs.org/download/nbdkit/$@ > $@-t mv $@-t $@ clean: @@ -66,4 +82,4 @@ clean: rm -rf x86_64 rm -rf BUILDROOT -.PHONY: all check-source check-tools check-vddk clean +.PHONY: all check-source check-vddk clean -- 1.8.3.1