Instructions for building a PXE boot image.
[virt-p2v.git] / Makefile.in
1 # Makefile for virt-p2v
2 # @configure_input@
3 #
4 # Copyright (C) 2007-2008 Red Hat Inc.
5 # Written by Richard W.M. Jones <rjones@redhat.com>
6 #
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.
11 #
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.
16 #
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
20
21 #----------------------------------------------------------------------
22 # General configuration
23
24 PACKAGE         := @PACKAGE_NAME@
25 VERSION         := @PACKAGE_VERSION@
26
27 INSTALL         := @INSTALL@
28
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@
34
35 LABEL           := $(PACKAGE)-$(VERSION)
36 ISO             := $(LABEL).iso
37
38 #----------------------------------------------------------------------
39
40 all:
41         @echo "make build     Build the live CD ISO"
42         @echo "make boot [HDA=hda.img] [HDB=hdb.img] [ISO=livecd.iso]"
43         @echo "                 Boot built/named ISO (uses qemu)"
44         @echo "make update    Update an existing live CD ISO with new"
45         @echo "                 virt-p2v script, without doing full rebuild"
46         @echo "make pxe       Build a PXE image (in tftpboot/ subdirectory)"
47         @echo "make man       Make man pages (needs POD)"
48
49 # Build live CD.
50
51 ifeq ($(HAVE_LIVECD_CREATOR),livecd-creator)
52
53 build:  p2v.ks checkroot checkscript
54         rm -f $(ISO)
55         livecd-creator --config=$< --fslabel=$(LABEL)
56         ls -lhtr *.iso
57
58 endif
59
60 # Run live CD under qemu.
61
62 ifeq ($(HAVE_QEMU_KVM),qemu-kvm)
63 QEMU    := qemu-kvm
64 else
65 ifeq ($(HAVE_QEMU),qemu)
66 QEMU    := qemu
67 endif
68 endif
69
70 ifneq ($(QEMU),)
71 HDA     :=
72 HDB     :=
73
74 QEMU_ARGS := -m 512 -cdrom $(ISO) -boot d
75 ifneq ($(HDA),)
76 QEMU_ARGS += -hda $(HDA)
77 endif
78 ifneq ($(HDB),)
79 QEMU_ARGS += -hdb $(HDB)
80 endif
81
82 boot:
83         $(QEMU) $(QEMU_ARGS)
84 endif
85
86 # Update an existing ISO.
87
88 update: checkroot checkscript
89         -./iso-attach delete $(ISO) 2>/dev/null
90         ./iso-attach add $(ISO) virt-p2v
91
92 # PXE boot.
93
94 ifeq ($(HAVE_LIVECD_ISO_TO_PXEBOOT),livecd-iso-to-pxeboot)
95
96 pxe: checkroot checkscript
97         livecd-iso-to-pxeboot $(ISO)
98
99 endif
100
101 # Check that we are root.
102
103 checkroot:
104         @if [ `id -u` -ne 0 ]; then \
105           echo "You must be root to perform this operation."; \
106           exit 1; \
107         fi
108
109 # Check that the script compiles.
110
111 checkscript:
112         ./virt-p2v --test
113
114 # Clean.
115
116 clean:
117         rm -f *~ core p2v.ks pod2htm*
118
119 distclean: clean
120         rm -rf autom4te.cache config.log config.status configure
121
122 reallyreallyclean: distclean
123         rm -f virt-p2v-*.tar.gz virt-p2v-*.iso
124
125 # Manifest.
126
127 dist:
128         $(MAKE) check-manifest
129         rm -rf $(PACKAGE)-$(VERSION)
130         mkdir $(PACKAGE)-$(VERSION)
131         tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
132         $(INSTALL) -m 0755 configure $(PACKAGE)-$(VERSION)/
133         tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
134         rm -rf $(PACKAGE)-$(VERSION)
135         ls -l $(PACKAGE)-$(VERSION).tar.gz
136
137 check-manifest:
138         @hg manifest | sort > .check-manifest; \
139         sort MANIFEST > .orig-manifest; \
140         diff -u .orig-manifest .check-manifest; rv=$$?; \
141         rm -f .orig-manifest .check-manifest; \
142         exit $$rv
143
144 # Manual page.
145
146 ifeq ($(HAVE_PERLDOC),perldoc)
147
148 MAN_SECTION := Virtualization Support
149
150 man: virt-p2v.1 virt-p2v.1.txt virt-p2v.1.html
151
152 virt-p2v.1: virt-p2v.pod
153         pod2man -c "$(MAN_SECTION)" --release "$(PACKAGE)-$(VERSION)" $< > $@
154
155 virt-p2v.1.txt: virt-p2v.pod
156         pod2text $< > $@
157
158 virt-p2v.1.html: virt-p2v.pod
159         pod2html -css virt-p2v.1.css $< > $@
160
161 endif
162
163 # Website.
164
165 WEBSITE_DIR := ../redhat/et-website/virt-p2v
166
167 website: man dist
168         cp virt-p2v.1.html $(WEBSITE_DIR)
169         cp virt-p2v.1.css $(WEBSITE_DIR)
170         cp $(PACKAGE)-$(VERSION).tar.gz $(WEBSITE_DIR)
171
172 # Upload everything.
173
174 upload: upload_iso upload_pxe
175
176 # Upload ISO.
177
178 upload_iso:
179         scp -l 300 $(ISO) et.redhat.com:public_html/tmp/
180
181 # Upload PXE image.
182
183 PXE_TAR := $(PACKAGE)-$(VERSION)-pxeboot.tar
184
185 upload_pxe:
186         tar cf $(PXE_TAR) tftpboot
187         scp -l 300 $(PXE_TAR) et.redhat.com:public_html/tmp/
188         rm $(PXE_TAR)
189
190 .PHONY: build boot checkroot