a5bb4780514a480d86f6110fac97183730da05c7
[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.4
27
28 # i386 images also work on x86-64, so best to stick with i386.
29 ARCH     := i386
30
31 LANG     := en_US.UTF-8
32 KEYBOARD := us
33 TIMEZONE := US/Eastern
34
35 BASEREPO := http://download.fedora.redhat.com/pub/fedora/linux/releases/7/Fedora/$(ARCH)/os/
36
37 # Select a suitable HTTP proxy.
38 # The default assumes a local squid proxy.
39 export http_proxy := http://127.0.0.1:3128/
40 export ftp_proxy := http://127.0.0.1:3128/
41
42 LABEL    := $(PACKAGE)-$(VERSION)
43
44 #----------------------------------------------------------------------
45
46 all:
47         @echo "make build     Build the live CD ISO"
48         @echo "make boot [HDA=hda.img] [HDB=hdb.img] [ISO=livecd.iso]"
49         @echo "               Boot built/named ISO (uses qemu)"
50
51 # Build live CD.
52
53 build: checkroot livecd.ks
54         rm -f $(LABEL).iso
55         livecd-creator --config=livecd.ks --fslabel=$(LABEL)
56         ls -lhtr *.iso
57
58 livecd.ks: livecd.ks.in livecd-post.sh Makefile
59         rm -f $@
60         sed \
61           -e 's|@BASEREPO@|$(BASEREPO)|g' \
62           -e 's|@LANG@|$(LANG)|g' \
63           -e 's|@KEYBOARD@|$(KEYBOARD)|g' \
64           -e 's|@TIMEZONE@|$(TIMEZONE)|g' \
65           < $< | cat - livecd-post.sh > $@
66
67 livecd-post.sh: livecd-post.sh.in p2v.init virt-p2v.sh inittab lvm.conf Makefile
68         rm -f $@
69         sed \
70           -e '/@P2V.INIT@/ r p2v.init' \
71           -e '/@P2V.INIT@/ d' \
72           -e '/@VIRT-P2V.SH@/ r virt-p2v.sh' \
73           -e '/@VIRT-P2V.SH@/ d' \
74           -e '/@INITTAB@/ r inittab' \
75           -e '/@INITTAB@/ d' \
76           -e '/@LVM.CONF@/ r lvm.conf' \
77           -e '/@LVM.CONF@/ d' \
78           < $< > $@
79
80 # Run live CD under qemu.
81
82 QEMU    := qemu
83 ISO     := $(LABEL).iso
84 HDA     :=
85 HDB     :=
86
87 QEMU_ARGS := -m 512 -cdrom $(ISO) -boot d
88 ifneq ($(HDA),)
89 QEMU_ARGS += -hda $(HDA)
90 endif
91 ifneq ($(HDB),)
92 QEMU_ARGS += -hdb $(HDB)
93 endif
94
95 boot:
96         $(QEMU) $(QEMU_ARGS)
97
98 # Standard rules.
99
100 checkroot:
101         @if [ `id -u` -ne 0 ]; then \
102           echo "You must be root to perform this operation."; \
103           exit 1; \
104         fi
105
106 clean:
107         rm -f *~ core livecd.ks livecd-post.sh
108
109 # Manifest.
110
111 dist:
112         $(MAKE) check-manifest
113         rm -rf $(PACKAGE)-$(VERSION)
114         mkdir $(PACKAGE)-$(VERSION)
115         tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
116         tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
117         rm -rf $(PACKAGE)-$(VERSION)
118         ls -l $(PACKAGE)-$(VERSION).tar.gz
119
120 check-manifest:
121         @for d in `find -type d -name CVS | grep -v '^\./debian/'`; \
122         do \
123         b=`dirname $$d`/; \
124         awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
125         sed -e "s|^|$$b|" -e "s|^\./||"; \
126         done | sort > .check-manifest; \
127         sort MANIFEST > .orig-manifest; \
128         diff -u .orig-manifest .check-manifest; rv=$$?; \
129         rm -f .orig-manifest .check-manifest; \
130         exit $$rv
131
132 .PHONY: build boot checkroot