c0c2ebbef580d167691c90dc61d7475ef6bc6633
[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
54 # Build the root filesystem.
55 # Currently this is arch-dependent, so it seems like putting it in
56 # $(libdir) is best.  When we build cross-architecture filesystems we
57 # should probably move them to $(datadir).
58
59 fsdir = $(libdir)/guestfs
60
61 INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img
62 VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
63
64 fs_DATA =  $(INITRAMFSIMG) $(VMLINUZ)
65
66 $(INITRAMFSIMG) $(VMLINUZ): initramfs/fakeroot.log
67
68 initramfs/fakeroot.log: make-initramfs.sh.in
69         -mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak
70         -mv $(VMLINUZ) $(VMLINUZ).bak
71         if ! bash $(builddir)/make-initramfs.sh; then rm -f $@; exit 1; fi
72
73 $(INITRAMFSIMG): initramfs/fakeroot.log daemon/guestfsd
74         rm -f $@
75         bash $(builddir)/update-initramfs.sh
76         touch $@
77
78 # Tests.  These are auto-generated from the test descriptions.
79
80 check_PROGRAMS = tests
81
82 tests_SOURCES = tests.c
83 tests_CFLAGS = \
84         -I$(top_builddir)/src -Wall
85 tests_LDADD = $(top_builddir)/src/libguestfs.la
86
87 TESTS = $(check_PROGRAMS)
88
89 $(TESTS): $(INITRAMFS) $(VMLINUZ)
90
91 # Manual pages.
92 # guestfs-actions.pod and guestfs-structs are autogenerated.  There is
93 # no include mechanism for POD, so we have to do it by hand.
94
95 man_MANS = guestfs.3 guestfish.1
96
97 guestfs.3: guestfs.pod guestfs-actions.pod guestfs-structs.pod
98         sed \
99           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
100           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
101           < $< | \
102         $(POD2MAN) \
103           --section 3 \
104           -c "Virtualization Support" \
105           --name "guestfs" \
106           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
107           > $@
108
109 guestfish.1: guestfish.pod guestfish-actions.pod
110         sed \
111           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
112           < $< | \
113         $(POD2MAN) \
114           --section 1 \
115           -c "Virtualization Support" \
116           --name "guestfish" \
117           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
118           > $@
119
120 noinst_DATA = html/guestfs.3.html html/guestfish.1.html
121
122 html/guestfs.3.html: guestfs.pod guestfs-actions.pod guestfs-structs.pod
123         sed \
124           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
125           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
126           < $< | \
127         pod2html \
128           --css 'pod.css' \
129           --title "libguestfs API documentation" \
130           --htmldir html \
131           --outfile $@
132
133 html/guestfish.1.html: guestfish.pod guestfish-actions.pod
134         sed \
135           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
136           < $< | \
137         pod2html \
138           --css 'pod.css' \
139           --title "guestfish, libguestfs filesystem interactive shell" \
140           --htmldir html \
141           --outfile $@
142
143 # Recipes web page.
144 html/recipes.html: $(wildcard recipes/*.sh) $(wildcard recipes/*.html) $(wildcard recipes/*.example) Makefile
145         rm -f $@ $@-t
146         echo '<html><head><title>guestfish recipes</title>' >> $@-t; \
147         echo '<link rel="stylesheet" href="http://et.redhat.com/~rjones/css/standard.css" type="text/css" title="Standard"/>' >> $@-t; \
148         echo '<link rel="stylesheet" href="http://et.redhat.com/~rjones/css/numbering.css" type="text/css" title="Standard"/>' >> $@-t; \
149         echo '<link rel="alternate stylesheet" href="http://et.redhat.com/~rjones/css/easytoread.css" type="text/css" title="High contrast, big fonts"/>' >> $@-t; \
150         echo '</head><body>' >> $@-t; \
151         echo '<h1>guestfish recipes</h1>' >> $@-t; \
152         echo '<p>You can also find these in the <code>recipes/</code> subdirectory of the source.</p>' >> $@-t; \
153         for f in recipes/*.sh; do \
154           b=`basename $$f .sh`; \
155           echo -n '<a name="'$$b'"></a>' >> $@-t; \
156           if [ -r recipes/$$b.html ]; then \
157             cat recipes/$$b.html >> $@-t; \
158           else \
159             echo '<h2>$$b</h2>' >> $@-t; \
160           fi; \
161           echo '<pre>' >> $@-t; \
162           sed -e 's,&,\&amp;,g' -e 's,<,\&lt;,g' -e 's,>,\&gt;,g' < $$f >> $@-t; \
163           echo '</pre>' >> $@-t; \
164           if [ -r recipes/$$b.example ]; then \
165             echo '<h3>Example output</h3>' >> $@-t; \
166             echo '<pre>' >> $@-t; \
167             sed -e 's,&,\&amp;,g' -e 's,<,\&lt;,g' -e 's,>,\&gt;,g' < recipes/$$b.example >> $@-t; \
168             echo '</pre>' >> $@-t; \
169           fi; \
170         done; \
171         echo '</body></html>' >> $@-t; \
172         mv $@-t $@
173
174 website: html/guestfs.3.html html/guestfish.1.html html/recipes.html
175         cp $^ html/pod.css $(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