47954a50e156e4d36e0341adcab32e03dc940dfd
[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 # Tests.  These are auto-generated from the test descriptions.
65
66 check_PROGRAMS = tests
67
68 tests_SOURCES = tests.c
69 tests_CFLAGS = \
70         -I$(top_builddir)/src -Wall
71 tests_LDADD = $(top_builddir)/src/libguestfs.la
72
73 TESTS = $(check_PROGRAMS)
74
75 # Manual pages.
76 # guestfs-actions.pod and guestfs-structs are autogenerated.  There is
77 # no include mechanism for POD, so we have to do it by hand.
78
79 man_MANS = guestfs.3 guestfish.1
80
81 guestfs.3: guestfs.pod guestfs-actions.pod guestfs-structs.pod
82         sed \
83           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
84           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
85           < $< | \
86         $(POD2MAN) \
87           --section 3 \
88           -c "Virtualization Support" \
89           --name "guestfs" \
90           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
91           > $@
92
93 guestfish.1: guestfish.pod guestfish-actions.pod
94         sed \
95           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
96           < $< | \
97         $(POD2MAN) \
98           --section 1 \
99           -c "Virtualization Support" \
100           --name "guestfish" \
101           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
102           > $@
103
104 noinst_DATA = html/guestfs.3.html html/guestfish.1.html
105
106 html/guestfs.3.html: guestfs.pod guestfs-actions.pod guestfs-structs.pod
107         sed \
108           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
109           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
110           < $< | \
111         pod2html \
112           --css 'pod.css' \
113           --title "libguestfs API documentation" \
114           --htmldir html \
115           --outfile $@
116
117 html/guestfish.1.html: guestfish.pod guestfish-actions.pod
118         sed \
119           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
120           < $< | \
121         pod2html \
122           --css 'pod.css' \
123           --title "guestfish, libguestfs filesystem interactive shell" \
124           --htmldir html \
125           --outfile $@
126
127 website: html/guestfs.3.html html/guestfish.1.html
128         cp $^ html/pod.css $(HOME)/d/redhat/et-website/libguestfs/
129
130 # Test-boot the image.
131
132 test-boot: emptydisk
133         qemu-system-$(host_cpu) \
134           -m 384 \
135           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
136           -hda emptydisk
137
138 emptydisk:
139         rm -f emptydisk
140         dd if=/dev/zero of=emptydisk bs=1024 count=1440
141         echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null
142
143 # This is a more realistic test boot command line which better
144 # reflects what the library does.
145
146 test-boot-realistic: emptydisk
147         qemu-system-$(host_cpu) \
148           -m 384 \
149           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
150           -hda emptydisk \
151           -append "console=ttyS0 guestfs=10.0.2.4:6666" \
152           -nographic \
153           -serial stdio \
154           -net channel,6666:unix:/tmp/sock,server,nowait \
155           -net user,vlan=0 \
156           -net nic,vlan=0
157
158 # Make clean.
159
160 CLEANFILES = $(fs_DATA) emptydisk pod2htm?.tmp *~ html/*~
161
162 clean-local:
163         rm -rf initramfs