Removed contrib/*.spec files.
[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/febootstrap/install.title \
64         contrib/febootstrap/install.html \
65         contrib/febootstrap/install.sh \
66         test-bootbootboot.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_TEST_COMMAND_LINES=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \
109         SKIP_TEST_ZEROFREE=$(shell test -x initramfs/usr/sbin/zerofree || echo 1) \
110         $(VG)
111
112 $(TESTS): $(INITRAMFS) $(VMLINUZ)
113
114 # Run the tests under valgrind.
115
116 valgrind:
117         $(MAKE) check VG="valgrind --quiet --leak-check=full"
118
119 # This binary must be statically linked.  It is used for testing
120 # the "guestfs_command" and "guestfs_command_lines" functions.
121
122 test_command_SOURCES = test-command.c
123 test_command_LDFLAGS = -all-static
124
125 # Manual pages.
126 # guestfs-actions.pod and guestfs-structs are autogenerated.  There is
127 # no include mechanism for POD, so we have to do it by hand.
128
129 man_MANS = guestfs.3 guestfish.1
130
131 guestfs.3: guestfs.pod guestfs-actions.pod guestfs-structs.pod
132         sed \
133           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
134           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
135           < $< | \
136         $(POD2MAN) \
137           --section 3 \
138           -c "Virtualization Support" \
139           --name "guestfs" \
140           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
141           > $@
142
143 guestfish.1: guestfish.pod guestfish-actions.pod
144         sed \
145           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
146           < $< | \
147         $(POD2MAN) \
148           --section 1 \
149           -c "Virtualization Support" \
150           --name "guestfish" \
151           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
152           > $@
153
154 noinst_DATA = html/guestfs.3.html html/guestfish.1.html
155
156 html/guestfs.3.html: guestfs.pod guestfs-actions.pod guestfs-structs.pod
157         sed \
158           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
159           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
160           < $< | \
161         pod2html \
162           --css 'pod.css' \
163           --title "libguestfs API documentation" \
164           --htmldir html \
165           --outfile $@
166
167 html/guestfish.1.html: guestfish.pod guestfish-actions.pod
168         sed \
169           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
170           < $< | \
171         pod2html \
172           --css 'pod.css' \
173           --title "guestfish, libguestfs filesystem interactive shell" \
174           --htmldir html \
175           --outfile $@
176
177 # Recipes web page.
178 html/recipes.html: $(wildcard recipes/*.sh) $(wildcard recipes/*.html) $(wildcard recipes/*.example) Makefile make-recipes.sh
179         rm -f $@ $@-t
180         sh make-recipes.sh recipes/*.sh > $@-t
181         mv $@-t $@
182
183 HTMLFILES = html/guestfs.3.html html/guestfish.1.html \
184         html/virt-inspector.1.html \
185         html/recipes.html \
186         html/pod.css html/recipes.css
187
188 TEXTFILES = README TODO HACKING
189
190 WEBSITEDIR = $(HOME)/d/redhat/et-website/libguestfs
191
192 website: $(HTMLFILES) $(TEXTFILES)
193         cp $(HTMLFILES) $(WEBSITEDIR)
194         for f in $(TEXTFILES); do cp $$f $(WEBSITEDIR)/$$f.txt; done
195
196 # Generate the ChangeLog automatically from the gitlog.
197
198 dist-hook:
199         ./gitlog-to-changelog > ChangeLog
200         cp ChangeLog $(distdir)/ChangeLog
201
202 # Pkgconfig.
203
204 pkgconfigdir = $(libdir)/pkgconfig
205 pkgconfig_DATA = libguestfs.pc
206
207 # Test-boot the image.
208
209 test-boot: emptydisk
210         qemu-system-$(host_cpu) \
211           -m 384 \
212           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
213           -hda emptydisk
214
215 emptydisk:
216         rm -f emptydisk
217         dd if=/dev/zero of=emptydisk bs=1024 count=1440
218         echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null
219
220 # This is a more realistic test boot command line which better
221 # reflects what the library does.
222
223 test-boot-realistic: emptydisk
224         qemu-system-$(host_cpu) \
225           -m 384 \
226           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
227           -hda emptydisk \
228           -append "console=ttyS0 guestfs=10.0.2.4:6666" \
229           -nographic \
230           -serial stdio \
231           -net channel,6666:unix:/tmp/sock,server,nowait \
232           -net user,vlan=0 \
233           -net nic,model=virtio,vlan=0
234
235 # Make clean.
236
237 CLEANFILES = $(fs_DATA) emptydisk pod2htm?.tmp
238
239 clean-local:
240         rm -rf initramfs