5 # Makefile for building virtual machine and cloud provider disk images.
9 VMFORMATS?= vhd vmdk qcow2 raw
13 VHD_DESC= Azure, VirtualPC, Hyper-V, Xen disk image
14 VMDK_DESC= VMWare, VirtualBox disk image
15 QCOW2_DESC= Qemu, KVM disk image
16 RAW_DESC= Unformatted raw disk image
25 AZURE_DESC= Microsoft Azure platform image
26 AZURE_DISK= ${OSRELEASE}.${AZURE_FORMAT}
28 EC2_DESC= Amazon EC2 image
29 EC2_DISK= ${OSRELEASE}.${EC2_FORMAT}
31 GCE_DESC= Google Compute Engine image
32 GCE_DISK= disk.${GCE_FORMAT}
33 OPENSTACK_FORMAT=qcow2
34 OPENSTACK_DESC= OpenStack platform image
35 OPENSTACK_DISK= ${OSRELEASE}.${OPENSTACK_FORMAT}
36 VAGRANT-VIRTUALBOX_FORMAT= vmdk
37 VAGRANT-VIRTUALBOX_DESC= Vagrant Image for VirtualBox
38 VAGRANT-VIRTUALBOX_DISK= ${OSRELEASE}.vbox.${VAGRANT_FORMAT}
39 VAGRANT-VMWARE_FORMAT= vmdk
40 VAGRANT-VMWARE_DESC= Vagrant Image for VMWare
41 VAGRANT-VMWARE_DISK= ${OSRELEASE}.vmware.${VAGRANT_FORMAT}
43 .if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE)
44 . for _CW in ${CLOUDWARE}
45 CLOUDTARGETS+= cw-${_CW:tl}
46 CLEANDIRS+= cw-${_CW:tl}
47 CLEANFILES+= ${_CW:tl}.img \
48 ${_CW:tl}.${${_CW:tu}_FORMAT} \
49 ${_CW:tl}.${${_CW:tu}_FORMAT}.raw \
51 CLOUDINSTALL+= cw${_CW:tl}-install
52 CLOUDPACKAGE+= cw${_CW:tl}-package
53 ${_CW:tu}IMAGE= ${_CW:tl}.${${_CW:tu}_FORMAT}
54 . if exists(${.CURDIR}/tools/${_CW:tl}.conf) && !defined(${_CW:tu}CONF)
55 ${_CW:tu}CONF?= ${.CURDIR}/tools/${_CW:tl}.conf
59 mkdir -p ${.OBJDIR}/${.TARGET}
60 env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
61 ${.CURDIR}/scripts/mk-vmimage.sh \
62 -C ${.CURDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} \
63 -i ${.OBJDIR}/${_CW:tl}.img -s ${VMSIZE} -f ${${_CW}_FORMAT} \
64 -S ${WORLDDIR} -o ${.OBJDIR}/${${_CW}IMAGE} -c ${${_CW}CONF}
68 mkdir -p ${DESTDIR}/${_CW:tl}
69 cp -p ${${_CW}IMAGE} \
70 ${DESTDIR}/${_CW:tl}/${${_CW}_DISK}
71 cd ${DESTDIR}/${_CW:tl} && sha512 ${${_CW}_DISK}* > \
72 ${DESTDIR}/${_CW:tl}/CHECKSUM.SHA512
73 cd ${DESTDIR}/${_CW:tl} && sha256 ${${_CW}_DISK}* > \
74 ${DESTDIR}/${_CW:tl}/CHECKSUM.SHA256
77 @# Special target to handle packaging cloud images in the formats
78 @# specific to each hosting provider.
79 .if exists(${.CURDIR}/tools/${_CW:tl}-package.sh)
80 env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
81 ${.CURDIR}/tools/${_CW:tl}-package.sh \
82 -D ${DESTDIR} -I ${${_CW}_DISK} -S ${WORLDDIR}
89 .if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
90 CLEANDIRS+= ${VMTARGETS}
91 . for FORMAT in ${VMFORMATS}
92 CLEANFILES+= ${FORMAT}.img
93 CLEANFILES+= ${VMBASE}.${FORMAT}
100 .if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
101 . for FORMAT in ${VMFORMATS}
102 mkdir -p ${.OBJDIR}/${.TARGET}
103 env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
104 ${.CURDIR}/scripts/mk-vmimage.sh \
105 -C ${.CURDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} \
106 -i ${.OBJDIR}/${FORMAT}.img -s ${VMSIZE} -f ${FORMAT} \
107 -S ${WORLDDIR} -o ${.OBJDIR}/${VMBASE}.${FORMAT}
112 vm-cloudware: ${CLOUDTARGETS}
114 list-vmtargets: list-cloudware
116 @${ECHO} "Supported virtual machine disk image formats:"
117 .for FORMAT in ${VMFORMATS:tu}
118 @${ECHO} " ${FORMAT:tl}: ${${FORMAT}_DESC}"
122 .if !empty(CLOUDWARE)
124 @${ECHO} "Supported cloud hosting provider images:"
125 . for _CW in ${CLOUDWARE}
126 @${ECHO} " ${_CW:tu}: ${${_CW:tu}_DESC}"
131 .if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
132 mkdir -p ${DESTDIR}/vmimages
133 . for FORMAT in ${VMFORMATS}
134 cp -p ${VMBASE}.${FORMAT} \
135 ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT}
137 . if defined(WITH_COMPRESSED_VMIMAGES) && !empty(WITH_COMPRESSED_VMIMAGES)
138 . for FORMAT in ${VMFORMATS}
139 # Don't keep the originals. There is a copy in ${.OBJDIR} if needed.
140 ${XZ_CMD} ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT}
143 cd ${DESTDIR}/vmimages && sha512 ${OSRELEASE}* > \
144 ${DESTDIR}/vmimages/CHECKSUM.SHA512
145 cd ${DESTDIR}/vmimages && sha256 ${OSRELEASE}* > \
146 ${DESTDIR}/vmimages/CHECKSUM.SHA256
150 .if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
151 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${VMTARGETS}
155 .if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE)
156 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${CLOUDTARGETS}
160 .if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE)
161 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${CLOUDINSTALL}
164 .include "${.CURDIR}/Makefile.ec2"
165 .include "${.CURDIR}/Makefile.azure"
166 .include "${.CURDIR}/Makefile.gce"
167 .include "${.CURDIR}/Makefile.vagrant"