Add test-bootbootboot.sh script to EXTRA_DIST.
[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 po 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 if HAVE_RUBY
32 SUBDIRS += ruby
33 endif
34 if HAVE_JAVA
35 SUBDIRS += java
36 endif
37 if HAVE_HASKELL
38 SUBDIRS += haskell
39 endif
40 if HAVE_INSPECTOR
41 SUBDIRS += inspector
42 endif
43
44 EXTRA_DIST = \
45         config.rpath \
46         make-initramfs.sh update-initramfs.sh \
47         guestfs.pod guestfs-actions.pod guestfs-structs.pod \
48         guestfish.pod guestfish-actions.pod \
49         html/pod.css \
50         HACKING TODO \
51         tests.c \
52         libguestfs.pc libguestfs.pc.in \
53         gitlog-to-changelog \
54         recipes/LICENSE \
55         recipes/README \
56         recipes/*.html \
57         recipes/*.sh \
58         recipes/*.example \
59         html/recipes.css \
60         make-recipes.sh \
61         test-cleanup.sh \
62         contrib/README \
63         contrib/centos5.3-libguestfs.spec \
64         contrib/fedora-libguestfs.spec \
65         contrib/febootstrap/install.title \
66         contrib/febootstrap/install.html \
67         contrib/febootstrap/install.sh \
68         test-bootbootboot.sh
69
70 # Build the root filesystem.
71 # Currently this is arch-dependent, so it seems like putting it in
72 # $(libdir) is best.  When we build cross-architecture filesystems we
73 # should probably move them to $(datadir).
74
75 fsdir = $(libdir)/guestfs
76
77 INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img
78 VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
79
80 fs_DATA =  $(INITRAMFSIMG) $(VMLINUZ)
81
82 $(INITRAMFSIMG) $(VMLINUZ): initramfs/fakeroot.log
83
84 initramfs/fakeroot.log: make-initramfs.sh.in
85         -mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak
86         -mv $(VMLINUZ) $(VMLINUZ).bak
87         if ! bash $(top_builddir)/make-initramfs.sh; then rm -f $@; exit 1; fi
88
89 $(INITRAMFSIMG): initramfs/fakeroot.log daemon/guestfsd
90         rm -f $@
91         bash $(top_builddir)/update-initramfs.sh
92         touch $@
93
94 make-initramfs.sh: make-initramfs.sh.in
95         ./config.status $@
96
97 # Tests.  These are auto-generated from the test descriptions
98 # in the generator.
99
100 check_PROGRAMS = tests test-command
101
102 tests_SOURCES = tests.c
103 tests_CFLAGS = \
104         -I$(top_builddir)/src -Wall
105 tests_LDADD = $(top_builddir)/src/libguestfs.la
106
107 TESTS = tests test-bootbootboot.sh
108 TESTS_ENVIRONMENT = \
109         SKIP_TEST_COMMAND=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \
110         SKIP_ZEROFREE=$(shell test -x initramfs/usr/sbin/zerofree || echo 1) \
111         $(VG)
112
113 $(TESTS): $(INITRAMFS) $(VMLINUZ)
114
115 # Run the tests under valgrind.
116
117 valgrind:
118         $(MAKE) check VG="valgrind --quiet --leak-check=full"
119
120 # This binary must be statically linked.  It is used for testing
121 # the "guestfs_command" and "guestfs_command_lines" functions.
122
123 test_command_SOURCES = test-command.c
124 test_command_LDFLAGS = -all-static
125
126 # Manual pages.
127 # guestfs-actions.pod and guestfs-structs are autogenerated.  There is
128 # no include mechanism for POD, so we have to do it by hand.
129
130 man_MANS = guestfs.3 guestfish.1
131
132 guestfs.3: guestfs.pod guestfs-actions.pod guestfs-structs.pod
133         sed \
134           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
135           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
136           < $< | \
137         $(POD2MAN) \
138           --section 3 \
139           -c "Virtualization Support" \
140           --name "guestfs" \
141           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
142           > $@
143
144 guestfish.1: guestfish.pod guestfish-actions.pod
145         sed \
146           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
147           < $< | \
148         $(POD2MAN) \
149           --section 1 \
150           -c "Virtualization Support" \
151           --name "guestfish" \
152           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
153           > $@
154
155 noinst_DATA = html/guestfs.3.html html/guestfish.1.html
156
157 html/guestfs.3.html: guestfs.pod guestfs-actions.pod guestfs-structs.pod
158         sed \
159           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
160           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
161           < $< | \
162         pod2html \
163           --css 'pod.css' \
164           --title "libguestfs API documentation" \
165           --htmldir html \
166           --outfile $@
167
168 html/guestfish.1.html: guestfish.pod guestfish-actions.pod
169         sed \
170           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
171           < $< | \
172         pod2html \
173           --css 'pod.css' \
174           --title "guestfish, libguestfs filesystem interactive shell" \
175           --htmldir html \
176           --outfile $@
177
178 # Recipes web page.
179 html/recipes.html: $(wildcard recipes/*.sh) $(wildcard recipes/*.html) $(wildcard recipes/*.example) Makefile make-recipes.sh
180         rm -f $@ $@-t
181         sh make-recipes.sh recipes/*.sh > $@-t
182         mv $@-t $@
183
184 website: html/guestfs.3.html html/guestfish.1.html \
185         html/virt-inspector.1.html \
186         html/recipes.html
187         cp $^ html/pod.css html/recipes.css \
188           $(HOME)/d/redhat/et-website/libguestfs/
189
190 # Generate the ChangeLog automatically from the gitlog.
191
192 dist-hook:
193         ./gitlog-to-changelog > ChangeLog
194         cp ChangeLog $(distdir)/ChangeLog
195
196 # Pkgconfig.
197
198 pkgconfigdir = $(libdir)/pkgconfig
199 pkgconfig_DATA = libguestfs.pc
200
201 # Test-boot the image.
202
203 test-boot: emptydisk
204         qemu-system-$(host_cpu) \
205           -m 384 \
206           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
207           -hda emptydisk
208
209 emptydisk:
210         rm -f emptydisk
211         dd if=/dev/zero of=emptydisk bs=1024 count=1440
212         echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null
213
214 # This is a more realistic test boot command line which better
215 # reflects what the library does.
216
217 test-boot-realistic: emptydisk
218         qemu-system-$(host_cpu) \
219           -m 384 \
220           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
221           -hda emptydisk \
222           -append "console=ttyS0 guestfs=10.0.2.4:6666" \
223           -nographic \
224           -serial stdio \
225           -net channel,6666:unix:/tmp/sock,server,nowait \
226           -net user,vlan=0 \
227           -net nic,model=virtio,vlan=0
228
229 # Make clean.
230
231 CLEANFILES = $(fs_DATA) emptydisk pod2htm?.tmp
232
233 clean-local:
234         rm -rf initramfs