f2cb9d93d88a967af83bda84052e52a5e7f4aea6
[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         guestfish.pod guestfish-actions.pod \
36         libguestfs.spec \
37         html/pod.css \
38         HACKING
39
40 # Build the root filesystem.
41 # Currently this is arch-dependent, so it seems like putting it in
42 # $(libdir) is best.  When we build cross-architecture filesystems we
43 # should probably move them to $(datadir).
44
45 fsdir = $(libdir)/guestfs
46
47 INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img
48 VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
49
50 fs_DATA =  $(INITRAMFSIMG) $(VMLINUZ)
51
52 $(INITRAMFSIMG) $(VMLINUZ): initramfs/fakeroot.log
53
54 initramfs/fakeroot.log: make-initramfs.sh.in
55         -mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak
56         -mv $(VMLINUZ) $(VMLINUZ).bak
57         if ! bash $(builddir)/make-initramfs.sh; then rm -f $@; exit 1; fi
58
59 $(INITRAMFSIMG): initramfs/fakeroot.log daemon/guestfsd
60         rm -f $@
61         bash $(builddir)/update-initramfs.sh
62         touch $@
63
64 # Manual pages.
65 # guestfs-actions.pod and guestfs-structs are autogenerated.  There is
66 # no include mechanism for POD, so we have to do it by hand.
67
68 man_MANS = guestfs.3 guestfish.1
69
70 guestfs.3: guestfs.pod guestfs-actions.pod guestfs-structs.pod
71         sed \
72           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
73           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
74           < $< | \
75         $(POD2MAN) \
76           --section 3 \
77           -c "Virtualization Support" \
78           --name "guestfs" \
79           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
80           > $@
81
82 guestfish.1: guestfish.pod guestfish-actions.pod
83         sed \
84           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
85           < $< | \
86         $(POD2MAN) \
87           --section 1 \
88           -c "Virtualization Support" \
89           --name "guestfish" \
90           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
91           > $@
92
93 noinst_DATA = html/guestfs.3.html html/guestfish.1.html
94
95 html/guestfs.3.html: guestfs.pod guestfs-actions.pod guestfs-structs.pod
96         sed \
97           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
98           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
99           < $< | \
100         pod2html \
101           --css 'pod.css' \
102           --title "libguestfs API documentation" \
103           --htmldir html \
104           --outfile $@
105
106 html/guestfish.1.html: guestfish.pod guestfish-actions.pod
107         sed \
108           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
109           < $< | \
110         pod2html \
111           --css 'pod.css' \
112           --title "guestfish, libguestfs filesystem interactive shell" \
113           --htmldir html \
114           --outfile $@
115
116 website: html/guestfs.3.html html/guestfish.1.html
117         cp $^ html/pod.css $(HOME)/d/redhat/et-website/libguestfs/
118
119 # Test-boot the image.
120
121 test-boot: emptydisk
122         qemu-system-$(host_cpu) \
123           -m 384 \
124           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
125           -hda emptydisk
126
127 emptydisk:
128         rm -f emptydisk
129         dd if=/dev/zero of=emptydisk bs=1024 count=1440
130         echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null
131
132 # This is a more realistic test boot command line which better
133 # reflects what the library does.
134
135 test-boot-realistic: emptydisk
136         qemu-system-$(host_cpu) \
137           -m 384 \
138           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
139           -hda emptydisk \
140           -append "console=ttyS0 guestfs=10.0.2.4:6666" \
141           -nographic \
142           -serial stdio \
143           -net channel,6666:unix:/tmp/sock,server,nowait \
144           -net user,vlan=0 \
145           -net nic,vlan=0
146
147 # Make clean.
148
149 CLEANFILES = $(fs_DATA) emptydisk pod2htm?.tmp
150
151 clean-local:
152         rm -rf initramfs