xref: /freebsd/release/Makefile.vm (revision 7d2ef96183ea3e29543eca16bf5774b054046373)
1#
2# $FreeBSD$
3#
4#
5# Makefile for building virtual machine and cloud provider disk images.
6#
7
8VMTARGETS=	vm-base vm-image
9VMFORMATS?=	vhd vmdk qcow2 raw
10VMSIZE?=	20G
11VMBASE?=	vm
12
13CLOUDWARE?=	AZURE \
14		OPENSTACK
15AZURE_FORMAT=	vhdf
16OPENSTACK_FORMAT=qcow2
17
18.if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE)
19. for _CW in ${CLOUDWARE}
20CLOUDTARGETS+=	vm-${_CW:tl}
21CLEANDIRS+=	vm-${_CW:tl}
22CLEANFILES+=	${_CW:tl}.img \
23		${_CW:tl}.${${_CW:tu}_FORMAT} \
24		${_CW:tl}.${${_CW:tu}_FORMAT}.raw
25${_CW:tu}IMAGE=	${_CW:tl}.${${_CW:tu}_FORMAT}
26.  if exists(${.CURDIR}/tools/${_CW:tl}.conf) && !defined(${_CW:tu}CONF)
27${_CW:tu}CONF?=	${.CURDIR}/tools/${_CW:tl}.conf
28.  endif
29. endfor
30.endif
31
32.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
33CLEANDIRS+=	${VMTARGETS}
34CLEANFILES+=	${VMBASE}.img
35. for FORMAT in ${VMFORMATS}
36CLEANFILES+=	${VMBASE}.${FORMAT}
37. endfor
38.endif
39
40vm-base:
41.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
42. if exists(${.CURDIR}/${TARGET}/mk-vmimage.sh)
43	env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
44		${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET} \
45		${VMBASE}.img ${WORLDDIR} ${.OBJDIR}/${.TARGET} ${VMSIZE}
46. endif
47.endif
48	touch ${.TARGET}
49
50vm-image: vm-base
51.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
52. if exists(${.CURDIR}/${TARGET}/mk-vmimage.sh)
53.  for FORMAT in ${VMFORMATS}
54	env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
55		${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET} \
56		${VMBASE}.img ${FORMAT} ${VMBASE}.${FORMAT}
57.  endfor
58. endif
59.endif
60	touch ${.TARGET}
61
62vm-cloudware:	${CLOUDTARGETS}
63
64vm-azure:
65.if exists(${.CURDIR}/${TARGET}/mk-azure.sh)
66	env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} AZURECONF=${AZURECONF} \
67		AZURE_FORMAT=${AZURE_FORMAT} \
68		${.CURDIR}/${TARGET}/mk-azure.sh ${.TARGET} azure.img \
69		${WORLDDIR} ${.TARGET} ${VMSIZE} ${AZUREIMAGE}
70.endif
71	touch ${.TARGET}
72
73vm-openstack:
74.if exists(${.CURDIR}/${TARGET}/mk-openstack.sh)
75	env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
76		OPENSTACKCONF=${OPENSTACKCONF} \
77		OPENSTACK_FORMAT=${OPENSTACK_FORMAT} \
78		${.CURDIR}/${TARGET}/mk-openstack.sh ${.TARGET} openstack.img \
79		${WORLDDIR} ${.TARGET} ${VMSIZE} ${OPENSTACKIMAGE}
80.endif
81	touch ${.TARGET}
82