export2tar recipe
[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
38 EXTRA_DIST = \
39         make-initramfs.sh update-initramfs.sh \
40         guestfs.pod guestfs-actions.pod guestfs-structs.pod \
41         guestfish.pod guestfish-actions.pod \
42         libguestfs.spec \
43         html/pod.css \
44         HACKING TODO \
45         tests.c \
46         libguestfs.pc libguestfs.pc.in \
47         gitlog-to-changelog \
48         recipes/LICENSE \
49         recipes/README \
50         recipes/*.html \
51         recipes/*.sh \
52         recipes/*.example \
53         html/recipes.css
54
55 # Build the root filesystem.
56 # Currently this is arch-dependent, so it seems like putting it in
57 # $(libdir) is best.  When we build cross-architecture filesystems we
58 # should probably move them to $(datadir).
59
60 fsdir = $(libdir)/guestfs
61
62 INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img
63 VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
64
65 fs_DATA =  $(INITRAMFSIMG) $(VMLINUZ)
66
67 $(INITRAMFSIMG) $(VMLINUZ): initramfs/fakeroot.log
68
69 initramfs/fakeroot.log: make-initramfs.sh.in
70         -mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak
71         -mv $(VMLINUZ) $(VMLINUZ).bak
72         if ! bash $(builddir)/make-initramfs.sh; then rm -f $@; exit 1; fi
73
74 $(INITRAMFSIMG): initramfs/fakeroot.log daemon/guestfsd
75         rm -f $@
76         bash $(builddir)/update-initramfs.sh
77         touch $@
78
79 # Tests.  These are auto-generated from the test descriptions.
80
81 check_PROGRAMS = tests
82
83 tests_SOURCES = tests.c
84 tests_CFLAGS = \
85         -I$(top_builddir)/src -Wall
86 tests_LDADD = $(top_builddir)/src/libguestfs.la
87
88 TESTS = $(check_PROGRAMS)
89
90 $(TESTS): $(INITRAMFS) $(VMLINUZ)
91
92 # Manual pages.
93 # guestfs-actions.pod and guestfs-structs are autogenerated.  There is
94 # no include mechanism for POD, so we have to do it by hand.
95
96 man_MANS = guestfs.3 guestfish.1
97
98 guestfs.3: guestfs.pod guestfs-actions.pod guestfs-structs.pod
99         sed \
100           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
101           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
102           < $< | \
103         $(POD2MAN) \
104           --section 3 \
105           -c "Virtualization Support" \
106           --name "guestfs" \
107           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
108           > $@
109
110 guestfish.1: guestfish.pod guestfish-actions.pod
111         sed \
112           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
113           < $< | \
114         $(POD2MAN) \
115           --section 1 \
116           -c "Virtualization Support" \
117           --name "guestfish" \
118           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
119           > $@
120
121 noinst_DATA = html/guestfs.3.html html/guestfish.1.html
122
123 html/guestfs.3.html: guestfs.pod guestfs-actions.pod guestfs-structs.pod
124         sed \
125           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
126           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
127           < $< | \
128         pod2html \
129           --css 'pod.css' \
130           --title "libguestfs API documentation" \
131           --htmldir html \
132           --outfile $@
133
134 html/guestfish.1.html: guestfish.pod guestfish-actions.pod
135         sed \
136           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
137           < $< | \
138         pod2html \
139           --css 'pod.css' \
140           --title "guestfish, libguestfs filesystem interactive shell" \
141           --htmldir html \
142           --outfile $@
143
144 # Recipes web page.
145 html/recipes.html: $(wildcard recipes/*.sh) $(wildcard recipes/*.html) $(wildcard recipes/*.example) Makefile
146         rm -f $@ $@-t
147         echo '<html><head><title>guestfish recipes</title>' >> $@-t; \
148         echo '<link rel="stylesheet" href="recipes.css" type="text/css" title="Standard"/>' >> $@-t; \
149         echo '</head><body>' >> $@-t; \
150         echo '<h1>guestfish recipes</h1>' >> $@-t; \
151         echo '<p>You can also find these in the <code>recipes/</code> subdirectory of the source.</p>' >> $@-t; \
152         for f in recipes/*.sh; do \
153           b=`basename $$f .sh`; \
154           echo -n '<a name="'$$b'"></a>' >> $@-t; \
155           if [ -r recipes/$$b.html ]; then \
156             cat recipes/$$b.html >> $@-t; \
157           else \
158             echo '<h2>$$b</h2>' >> $@-t; \
159           fi; \
160           echo '<pre class="example">' >> $@-t; \
161           sed -e 's,&,\&amp;,g' -e 's,<,\&lt;,g' -e 's,>,\&gt;,g' < $$f >> $@-t; \
162           echo '</pre>' >> $@-t; \
163           if [ -r recipes/$$b.example ]; then \
164             echo '<h3>Example output</h3>' >> $@-t; \
165             echo '<pre>' >> $@-t; \
166             sed -e 's,&,\&amp;,g' -e 's,<,\&lt;,g' -e 's,>,\&gt;,g' < recipes/$$b.example >> $@-t; \
167             echo '</pre>' >> $@-t; \
168           fi; \
169         done; \
170         echo '</body></html>' >> $@-t; \
171         mv $@-t $@
172
173 website: html/guestfs.3.html html/guestfish.1.html html/recipes.html
174         cp $^ html/pod.css html/recipes.css \
175           $(HOME)/d/redhat/et-website/libguestfs/
176
177 # Generate the ChangeLog automatically from the gitlog.
178
179 dist-hook:
180         ./gitlog-to-changelog > ChangeLog
181         cp ChangeLog $(distdir)/ChangeLog
182
183 # Pkgconfig.
184
185 pkgconfigdir = $(libdir)/pkgconfig
186 pkgconfig_DATA = libguestfs.pc
187
188 # Test-boot the image.
189
190 test-boot: emptydisk
191         qemu-system-$(host_cpu) \
192           -m 384 \
193           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
194           -hda emptydisk
195
196 emptydisk:
197         rm -f emptydisk
198         dd if=/dev/zero of=emptydisk bs=1024 count=1440
199         echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null
200
201 # This is a more realistic test boot command line which better
202 # reflects what the library does.
203
204 test-boot-realistic: emptydisk
205         qemu-system-$(host_cpu) \
206           -m 384 \
207           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
208           -hda emptydisk \
209           -append "console=ttyS0 guestfs=10.0.2.4:6666" \
210           -nographic \
211           -serial stdio \
212           -net channel,6666:unix:/tmp/sock,server,nowait \
213           -net user,vlan=0 \
214           -net nic,vlan=0
215
216 # Make clean.
217
218 CLEANFILES = $(fs_DATA) emptydisk pod2htm?.tmp *~ html/*~
219
220 clean-local:
221         rm -rf initramfs