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