More
[virt-p2v.git] / Makefile
1 # $Id$
2
3 #----------------------------------------------------------------------
4 # General configuration
5
6 VERSION  := 0.1
7
8 # i386 images also work on x86-64, so best to stick with i386.
9 ARCH     := i386
10
11 LANG     := en_US.UTF-8
12 KEYBOARD := us
13 TIMEZONE := US/Eastern
14
15 BASEREPO := http://download.fedora.redhat.com/pub/fedora/linux/releases/7/Fedora/$(ARCH)/os/
16
17 # Select a suitable HTTP proxy.
18 # The default assumes a local squid proxy.
19 export http_proxy := http://127.0.0.1:3128/
20 export ftp_proxy := http://127.0.0.1:3128/
21
22 LABEL    := virt-p2v-$(VERSION)
23
24 #----------------------------------------------------------------------
25
26 all:
27         @echo "make build     Build the live CD ISO"
28         @echo "make boot [HDA=hda.img] [HDB=hdb.img] [ISO=livecd.iso]"
29         @echo "               Boot built/named ISO (uses qemu)"
30
31 # Build live CD.
32
33 build: checkroot livecd.ks
34         rm -f $(LABEL).iso
35         livecd-creator --config=livecd.ks --fslabel=$(LABEL)
36         ls -lhtr *.iso
37
38 livecd.ks: livecd.ks.in livecd-post.sh Makefile
39         sed \
40           -e 's|@BASEREPO@|$(BASEREPO)|g' \
41           -e 's|@LANG@|$(LANG)|g' \
42           -e 's|@KEYBOARD@|$(KEYBOARD)|g' \
43           -e 's|@TIMEZONE@|$(TIMEZONE)|g' \
44           < $< | cat - livecd-post.sh > $@
45
46 livecd-post.sh: livecd-post.sh.in p2v.init virt-p2v.sh inittab Makefile
47         sed \
48           -e '/@P2V.INIT@/ r p2v.init' \
49           -e '/@P2V.INIT@/ d' \
50           -e '/@VIRT-P2V.SH@/ r virt-p2v.sh' \
51           -e '/@VIRT-P2V.SH@/ d' \
52           -e '/@INITTAB@/ r inittab' \
53           -e '/@INITTAB@/ d' \
54           < $< > $@
55
56 # Run live CD under qemu.
57
58 QEMU    := qemu
59 ISO     := $(LABEL).iso
60 HDA     :=
61 HDB     :=
62
63 QEMU_ARGS := -m 512 -cdrom $(ISO) -boot d
64 ifneq ($(HDA),)
65 QEMU_ARGS += -hda $(HDA)
66 endif
67 ifneq ($(HDB),)
68 QEMU_ARGS += -hdb $(HDB)
69 endif
70
71 boot:
72         $(QEMU) $(QEMU_ARGS)
73
74 # Standard rules.
75
76 checkroot:
77         @if [ `id -u` -ne 0 ]; then \
78           echo "You must be root to perform this operation."; \
79           exit 1; \
80         fi
81
82 clean:
83         rm -f *~ core livecd.ks livecd-post.sh
84
85 .PHONY: build boot checkroot