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