Manual page with centralised documentation.
[virt-p2v.git] / Makefile
1 # Makefile for virt-p2v
2 #
3 # Copyright (C) 2007 Red Hat Inc.
4 # Written by Richard W.M. Jones <rjones@redhat.com>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 #
20 # $Id$
21
22 #----------------------------------------------------------------------
23 # General configuration
24
25 PACKAGE  := virt-p2v
26 VERSION  := 0.9.1
27
28 # i386 images also work on x86-64, so best to stick with i386.
29 ARCH     := i386
30
31 # Base repository.
32 BASE     := 8
33 BASEURL  := http://download.fedora.redhat.com/pub/fedora/linux/releases/$(BASE)/Everything/$(ARCH)/os/
34
35 LANG     := en_US.UTF-8
36 KEYBOARD := us
37 TIMEZONE := US/Eastern
38
39 # Select a suitable HTTP proxy.
40 # The default assumes a local squid proxy.
41 export http_proxy := http://127.0.0.1:3128/
42 export ftp_proxy := http://127.0.0.1:3128/
43
44 LABEL    := $(PACKAGE)-$(VERSION)
45
46 ISO      := $(LABEL).iso
47
48 #----------------------------------------------------------------------
49
50 all:
51         @echo "make build     Build the live CD ISO"
52         @echo "make boot [HDA=hda.img] [HDB=hdb.img] [ISO=livecd.iso]"
53         @echo "                 Boot built/named ISO (uses qemu)"
54         @echo "make update    Update an existing live CD ISO with new"
55         @echo "                 virt-p2v script, without doing full rebuild"
56         @echo "make man       Make man pages (needs POD)"
57
58 # Build live CD.
59
60 build: checkroot checkscript livecd.ks
61         rm -f $(ISO)
62         livecd-creator --config=livecd.ks --fslabel=$(LABEL)
63         ls -lhtr *.iso
64
65 livecd.ks: livecd.ks.in livecd-post.sh Makefile
66         rm -f $@
67         sed \
68           -e 's|@ARCH@|$(ARCH)|g' \
69           -e 's|@BASE@|$(BASE)|g' \
70           -e 's|@BASEURL@|$(BASEURL)|g' \
71           -e 's|@LANG@|$(LANG)|g' \
72           -e 's|@KEYBOARD@|$(KEYBOARD)|g' \
73           -e 's|@TIMEZONE@|$(TIMEZONE)|g' \
74           < $< | cat - livecd-post.sh > $@
75
76 livecd-post.sh: livecd-post.sh.in virt-p2v virt-p2v-update-wrapper iso-attach inittab lvm.conf Makefile
77         rm -f $@
78         sed \
79           -e '/@VIRT-P2V@/ r virt-p2v' \
80           -e '/@VIRT-P2V@/ d' \
81           -e '/@VIRT-P2V-UPDATE-WRAPPER@/ r virt-p2v-update-wrapper' \
82           -e '/@VIRT-P2V-UPDATE-WRAPPER@/ d' \
83           -e '/@ISO-ATTACH@/ r iso-attach' \
84           -e '/@ISO-ATTACH@/ d' \
85           -e '/@INITTAB@/ r inittab' \
86           -e '/@INITTAB@/ d' \
87           -e '/@LVM.CONF@/ r lvm.conf' \
88           -e '/@LVM.CONF@/ d' \
89           < $< > $@
90
91 # Run live CD under qemu.
92
93 QEMU    := qemu
94 HDA     :=
95 HDB     :=
96
97 QEMU_ARGS := -m 512 -cdrom $(ISO) -boot d
98 ifneq ($(HDA),)
99 QEMU_ARGS += -hda $(HDA)
100 endif
101 ifneq ($(HDB),)
102 QEMU_ARGS += -hdb $(HDB)
103 endif
104
105 boot:
106         $(QEMU) $(QEMU_ARGS)
107
108 # Update an existing ISO.
109
110 update: checkroot checkscript
111         -./iso-attach delete $(ISO)
112         ./iso-attach add $(ISO) virt-p2v
113
114 # Check that we are root.
115
116 checkroot:
117         @if [ `id -u` -ne 0 ]; then \
118           echo "You must be root to perform this operation."; \
119           exit 1; \
120         fi
121
122 # Check that the script compiles.
123
124 checkscript:
125         ./virt-p2v --test
126
127 # Clean.
128
129 clean:
130         rm -f *~ core livecd.ks livecd-post.sh
131
132 # Manifest.
133
134 dist:
135         $(MAKE) check-manifest
136         rm -rf $(PACKAGE)-$(VERSION)
137         mkdir $(PACKAGE)-$(VERSION)
138         tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
139         tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
140         rm -rf $(PACKAGE)-$(VERSION)
141         ls -l $(PACKAGE)-$(VERSION).tar.gz
142
143 check-manifest:
144         @hg manifest | sort > .check-manifest; \
145         sort MANIFEST > .orig-manifest; \
146         diff -u .orig-manifest .check-manifest; rv=$$?; \
147         rm -f .orig-manifest .check-manifest; \
148         exit $$rv
149
150 # Manual page.
151
152 MAN_SECTION := Virtualization Support
153
154 man: virt-p2v.1 virt-p2v.1.txt virt-p2v.1.html
155
156 virt-p2v.1: virt-p2v.pod
157         pod2man -c "$(MAN_SECTION)" --release "$(PACKAGE)-$(VERSION)" $< > $@
158
159 virt-p2v.1.txt: virt-p2v.pod
160         pod2text $< > $@
161
162 virt-p2v.1.html: virt-p2v.pod
163         pod2html -css virt-p2v.1.css $< > $@
164
165 # Website.
166
167 WEBSITE_DIR := ../redhat/et-website/virt-p2v
168
169 website: man dist
170         cp virt-p2v.1.html $(WEBSITE_DIR)
171         cp $(PACKAGE)-$(VERSION).tar.gz $(WEBSITE_DIR)
172
173 .PHONY: build boot checkroot