summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile26
1 files changed, 15 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index d1f8426..e878aac 100644
--- a/Makefile
+++ b/Makefile
@@ -24,19 +24,23 @@ BUILDER_VIRTUALBOX_PROV := virtualbox-ovf
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
+$(foreach cur, $(BUILDERS),\
+ $(if $(shell command -v $(BUILDER_$(cur)_EXE)),\
+ $(eval AVAILABLE_BUILDERS += $(cur))))
-ifndef PROVISIONER
- $(foreach cur, $(BUILDERS),\
- $(if $(filter $(BUILDER),$(BUILDER_$(cur)_NAME)),\
- $(eval PROVISIONER := $(BUILDER_$(cur)_PROV))))
-endif
+
+# If now BUILDER or PROVISIONER was specified on the command line, take the
+# first available one; otherwise use that specified one.
+BUILDER_SELECTED := $(strip $(if $(filter $(BUILDER),$(AVAILABLE_BUILDERS)),\
+ $(BUILDER),\
+ $(firstword $(AVAILABLE_BUILDERS))))
+PROVISIONER_SELECTED := $(strip $(if $(filter $(PROVISIONER),$(AVAILABLE_BUILDERS)),\
+ $(PROVISIONER),\
+ $(BUILDER_SELECTED)))
+
+override BUILDER = $(BUILDER_$(BUILDER_SELECTED)_NAME)
+override PROVISIONER = $(BUILDER_$(PROVISIONER_SELECTED)_PROV)
# The packer templates, detected as *.json (excluding base.json)