diff options
author | Manuel Messner | 2018-02-16 15:25:58 +0100 |
---|---|---|
committer | Manuel Messner | 2018-02-20 10:31:51 +0100 |
commit | 146a4ea6fecd2d5be2e566ef537fe4b324bd1264 (patch) | |
tree | 37e3065a252ba8b3133f99a7213772ff4c0d377c /Makefile | |
parent | Makefile: remove newline (diff) | |
download | packer-templates-146a4ea6fecd2d5be2e566ef537fe4b324bd1264.tar.gz packer-templates-146a4ea6fecd2d5be2e566ef537fe4b324bd1264.tar.xz packer-templates-146a4ea6fecd2d5be2e566ef537fe4b324bd1264.zip |
Makefile: refactor search for available builders
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -7,20 +7,24 @@ ANSIBLE_DIR ?= ansible-roles HASHER ?= sha256sum +SHELL := /usr/bin/env bash +ARCH := $(shell uname -m | sed 's/i686/i386/') -# check which hypervisors are available -ifndef BUILDER - ifeq ($(shell which qemu-system-$(shell uname -m | sed 's/i686/i386/') 2>&1 > /dev/null && echo $$?), 0) - AVAILABLE_BUILDERS += qemu - endif +BUILDER_QEMU_EXE := qemu-system-$(ARCH) +BUILDER_QEMU_NAME := qemu - ifeq ($(shell which virtualbox 2>&1 > /dev/null && echo $$?), 0) - AVAILABLE_BUILDERS += virtualbox-iso - endif +BUILDER_VMWARE_EXE := vmware +BUILDER_VMWARE_NAME := vmware-iso - ifeq ($(shell which vmplayer 2>&1 > /dev/null && echo $$?), 0) - AVAILABLE_BUILDERS += vmware-iso - endif +BUILDER_VIRTUALBOX_EXE := virtualbox +BUILDER_VIRTUALBOX_NAME := virtualbox-iso + +BUILDERS := QEMU VMWARE VIRTUALBOX + +ifndef BUILDER + $(foreach cur, $(BUILDERS),\ + $(if $(shell command -v $(BUILDER_$(cur)_EXE)),\ + $(eval AVAILABLE_BUILDERS += $(BUILDER_$(cur)_NAME)))) BUILDER := $(firstword $(AVAILABLE_BUILDERS)) endif |