d34b9429c8f4fff8a540b6fb41184dbe8863018c
[libguestfs.git] / Makefile.am
1 # libguestfs
2 # Copyright (C) 2009 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 ACLOCAL_AMFLAGS = -I m4
19
20 SUBDIRS = src daemon fish examples images
21
22 if HAVE_OCAML
23 SUBDIRS += ocaml
24 endif
25 if HAVE_PERL
26 SUBDIRS += perl
27 endif
28 if HAVE_PYTHON
29 SUBDIRS += python
30 endif
31
32 EXTRA_DIST = \
33         make-initramfs.sh update-initramfs.sh \
34         guestfs.pod guestfs-actions.pod guestfs-structs.pod \
35         libguestfs.spec \
36         HACKING
37
38 # Build the root filesystem.
39 # Currently this is arch-dependent, so it seems like putting it in
40 # $(libdir) is best.  When we build cross-architecture filesystems we
41 # should probably move them to $(datadir).
42
43 fsdir = $(libdir)/guestfs
44
45 INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img
46 VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
47
48 fs_DATA =  $(INITRAMFSIMG) $(VMLINUZ)
49
50 $(INITRAMFSIMG) $(VMLINUZ): initramfs/fakeroot.log
51
52 initramfs/fakeroot.log: make-initramfs.sh.in
53         -mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak
54         -mv $(VMLINUZ) $(VMLINUZ).bak
55         if ! bash $(builddir)/make-initramfs.sh; then rm -f $@; exit 1; fi
56
57 $(INITRAMFSIMG): initramfs/fakeroot.log daemon/guestfsd
58         rm -f $@
59         bash $(builddir)/update-initramfs.sh
60         touch $@
61
62 # Make clean.
63
64 CLEANFILES = $(fs_DATA) emptydisk
65
66 clean-local:
67         rm -rf initramfs
68
69 # Manual page.
70 # guestfs-actions.pod and guestfs-structs are autogenerated.  There is
71 # no include mechanism for POD, so we have to do it by hand.
72
73 man_MANS = guestfs.3
74
75 guestfs.3: guestfs.pod guestfs-actions.pod guestfs-structs.pod
76         sed \
77           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
78           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
79           < $< | \
80         $(POD2MAN) \
81           --section 3 \
82           -c "Virtualization Support" \
83           --name "guestfs" \
84           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
85           > $@
86
87 # Test-boot the image.
88
89 test-boot: emptydisk
90         qemu-system-$(host_cpu) \
91           -m 384 \
92           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
93           -hda emptydisk
94
95 emptydisk:
96         rm -f emptydisk
97         dd if=/dev/zero of=emptydisk bs=1024 count=1440
98         echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null
99
100 # This is a more realistic test boot command line which better
101 # reflects what the library does.
102
103 test-boot-realistic: emptydisk
104         qemu-system-$(host_cpu) \
105           -m 384 \
106           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
107           -hda emptydisk \
108           -append "console=ttyS0 guestfs=10.0.2.4:6666" \
109           -nographic \
110           -serial stdio \
111           -net channel,6666:unix:/tmp/sock,server,nowait \
112           -net user,vlan=0 \
113           -net nic,vlan=0