1 # Makefile for virt-p2v
4 # Copyright (C) 2007-2008 Red Hat Inc.
5 # Written by Richard W.M. Jones <rjones@redhat.com>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #----------------------------------------------------------------------
22 # General configuration
24 PACKAGE := @PACKAGE_NAME@
25 VERSION := @PACKAGE_VERSION@
29 HAVE_PERLDOC := @HAVE_PERLDOC@
30 HAVE_QEMU := @HAVE_QEMU@
31 HAVE_QEMU_KVM := @HAVE_QEMU_KVM@
32 HAVE_LIVECD_CREATOR := @HAVE_LIVECD_CREATOR@
33 HAVE_LIVECD_ISO_TO_PXEBOOT := @HAVE_LIVECD_ISO_TO_PXEBOOT@
35 LABEL := $(PACKAGE)-$(VERSION)
37 PXE_TAR := $(PACKAGE)-$(VERSION)-pxeboot.tar
38 VIRTP2V_RPM := $(PACKAGE)-$(VERSION)-1.noarch.rpm
40 #----------------------------------------------------------------------
43 @echo "make rpm Build the virt-p2v RPM"
44 @echo "make build Build the live CD ISO"
45 @echo "make boot [HDA=hda.img] [HDB=hdb.img] [ISO=livecd.iso]"
46 @echo " Boot built/named ISO (uses qemu)"
47 @echo "make update Update an existing live CD ISO with new"
48 @echo " virt-p2v script, without doing full rebuild"
49 @echo "make pxe Build a PXE image (in tftpboot/ subdirectory)"
50 @echo "make man Make man pages (needs POD)"
54 ifeq ($(HAVE_LIVECD_CREATOR),livecd-creator)
56 build: checkroot checkrpm checkscript
58 livecd-creator --config=p2v.ks --fslabel=$(LABEL)
63 # Build RPM of virt-p2v.
65 rpm: checknotroot rpmbuild/$(VIRTP2V_RPM)
67 RPM_FLAGS := --define "_topdir %(pwd)/rpmbuild" \
68 --define "_builddir %{_topdir}" \
69 --define "_rpmdir %{_topdir}" \
70 --define "_srcrpmdir %{_topdir}" \
71 --define "_rpmfilename $(VIRTP2V_RPM)" \
72 --define "_specdir %{_topdir}" \
73 --define "_sourcedir %(pwd)"
75 rpmbuild/$(VIRTP2V_RPM): \
77 virt-p2v virt-p2v-update-wrapper iso-attach \
80 rpmbuild $(RPM_FLAGS) -ba $<
83 # Make the final script.
85 virt-p2v: virt-p2v.ml0 virt-p2v.ml
89 # Run live CD under qemu.
91 ifeq ($(HAVE_QEMU_KVM),qemu-kvm)
94 ifeq ($(HAVE_QEMU),qemu)
103 QEMU_ARGS := -m 512 -cdrom $(ISO) -boot d
105 QEMU_ARGS += -hda $(HDA)
108 QEMU_ARGS += -hdb $(HDB)
115 # Update an existing ISO.
117 update: checkroot checkscript
118 -./iso-attach delete $(ISO) 2>/dev/null
119 ./iso-attach add $(ISO) virt-p2v
123 ifeq ($(HAVE_LIVECD_ISO_TO_PXEBOOT),livecd-iso-to-pxeboot)
125 pxe: checkroot checkscript
126 livecd-iso-to-pxeboot $(ISO)
130 # Check that we are root.
133 @if [ `id -u` -ne 0 ]; then \
134 echo "You must be root to perform this operation."; \
138 # Check that we are not root.
141 @if [ `id -u` -eq 0 ]; then \
142 echo "You must not perform this step as root."; \
146 # Check that the script compiles.
152 # Check that the RPM has been built.
155 test -f rpmbuild/$(VIRTP2V_RPM)
160 rm -f *~ core virt-p2v pod2htm*
163 rm -rf autom4te.cache config.log config.status configure \
164 p2v.ks Makefile po/Makefile virt-p2v.spec
166 reallyreallyclean: distclean
167 rm -f virt-p2v-*.tar.gz virt-p2v-*.iso
172 $(MAKE) check-manifest
173 rm -rf $(PACKAGE)-$(VERSION)
174 mkdir $(PACKAGE)-$(VERSION)
175 tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
176 $(INSTALL) -m 0755 configure $(PACKAGE)-$(VERSION)/
177 tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
178 rm -rf $(PACKAGE)-$(VERSION)
179 ls -l $(PACKAGE)-$(VERSION).tar.gz
182 @hg manifest | sort > .check-manifest; \
183 sort MANIFEST > .orig-manifest; \
184 diff -u .orig-manifest .check-manifest; rv=$$?; \
185 rm -f .orig-manifest .check-manifest; \
190 ifeq ($(HAVE_PERLDOC),perldoc)
192 MAN_SECTION := Virtualization Support
194 man: virt-p2v.1 virt-p2v.1.txt virt-p2v.1.html
196 virt-p2v.1: virt-p2v.pod
197 pod2man -c "$(MAN_SECTION)" --release "$(PACKAGE)-$(VERSION)" $< > $@
199 virt-p2v.1.txt: virt-p2v.pod
202 virt-p2v.1.html: virt-p2v.pod
203 pod2html -css virt-p2v.1.css $< > $@
209 WEBSITE_DIR := ../redhat/et-website/virt-p2v
212 cp virt-p2v.1.html $(WEBSITE_DIR)
213 cp virt-p2v.1.css $(WEBSITE_DIR)
214 cp $(PACKAGE)-$(VERSION).tar.gz $(WEBSITE_DIR)
218 upload: upload_iso upload_pxe
223 scp -l 300 $(ISO) et.redhat.com:public_html/tmp/
228 tar cf $(PXE_TAR) tftpboot
229 scp -l 300 $(PXE_TAR) et.redhat.com:public_html/tmp/
232 .PHONY: build boot checkroot