summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorManuel Messner2018-05-04 15:02:34 +0200
committerManuel Messner2018-05-04 15:50:06 +0200
commit874d3dfbdd9f6a8a8a158b53f714b8dbce7bfe1b (patch)
tree84230bad9873618df4401716ab5aa12627fd58e9 /Makefile
parentMakefile: differentiate between ISO and provisioning builders (diff)
downloadpacker-templates-874d3dfbdd9f6a8a8a158b53f714b8dbce7bfe1b.tar.gz
packer-templates-874d3dfbdd9f6a8a8a158b53f714b8dbce7bfe1b.tar.xz
packer-templates-874d3dfbdd9f6a8a8a158b53f714b8dbce7bfe1b.zip
Makefile: simplify provisioner and builder selection
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)