+# Build RPM of virt-p2v.
+
+rpm: checknotroot p2vrepo/$(VIRTP2V_RPM)
+
+RPM_FLAGS := --define "_topdir %(pwd)/rpmbuild" \
+ --define "_builddir %{_topdir}/BUILD" \
+ --define "_rpmdir %{_topdir}/RPMS" \
+ --define "_srcrpmdir %{_topdir}/SRPMS" \
+ --define "_specdir %{_topdir}/SPECS" \
+ --define "_sourcedir %(pwd)"
+
+p2vrepo/$(VIRTP2V_RPM): \
+ virt-p2v.spec \
+ virt-p2v virt-p2v-update-wrapper iso-attach \
+ inittab
+ $(MAKE) dist
+ rm -rf rpmbuild
+ mkdir rpmbuild rpmbuild/{RPMS,BUILD,SRPMS,SPECS} rpmbuild/RPMS/noarch
+ rpmbuild $(RPM_FLAGS) -ba $<
+ mkdir -p p2vrepo
+ cp rpmbuild/RPMS/noarch/$(VIRTP2V_RPM) p2vrepo
+ createrepo p2vrepo
+
+# Make the final script.
+
+virt-p2v: virt-p2v.ml0 virt-p2v.ml
+ cat $^ > $@
+ chmod 0555 $@
+