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)" \
--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
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:
rm -rf x86_64
rm -rf BUILDROOT
-.PHONY: all check-source check-tools check-vddk clean
+.PHONY: all check-source check-vddk clean