Fixes for CDPATH being set.
[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
35 EXTRA_DIST = \
36         make-initramfs.sh update-initramfs.sh \
37         guestfs.pod guestfs-actions.pod guestfs-structs.pod \
38         guestfish.pod guestfish-actions.pod \
39         libguestfs.spec \
40         html/pod.css \
41         HACKING TODO \
42         tests.c
43
44 # Build the root filesystem.
45 # Currently this is arch-dependent, so it seems like putting it in
46 # $(libdir) is best.  When we build cross-architecture filesystems we
47 # should probably move them to $(datadir).
48
49 fsdir = $(libdir)/guestfs
50
51 INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img
52 VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
53
54 fs_DATA =  $(INITRAMFSIMG) $(VMLINUZ)
55
56 $(INITRAMFSIMG) $(VMLINUZ): initramfs/fakeroot.log
57
58 initramfs/fakeroot.log: make-initramfs.sh.in
59         -mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak
60         -mv $(VMLINUZ) $(VMLINUZ).bak
61         if ! bash $(builddir)/make-initramfs.sh; then rm -f $@; exit 1; fi
62
63 $(INITRAMFSIMG): initramfs/fakeroot.log daemon/guestfsd
64         rm -f $@
65         bash $(builddir)/update-initramfs.sh
66         touch $@
67
68 # Tests.  These are auto-generated from the test descriptions.
69
70 check_PROGRAMS = tests
71
72 tests_SOURCES = tests.c
73 tests_CFLAGS = \
74         -I$(top_builddir)/src -Wall
75 tests_LDADD = $(top_builddir)/src/libguestfs.la
76
77 TESTS = $(check_PROGRAMS)
78
79 $(TESTS): $(INITRAMFS) $(VMLINUZ)
80
81 # Manual pages.
82 # guestfs-actions.pod and guestfs-structs are autogenerated.  There is
83 # no include mechanism for POD, so we have to do it by hand.
84
85 man_MANS = guestfs.3 guestfish.1
86
87 guestfs.3: guestfs.pod guestfs-actions.pod guestfs-structs.pod
88         sed \
89           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
90           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
91           < $< | \
92         $(POD2MAN) \
93           --section 3 \
94           -c "Virtualization Support" \
95           --name "guestfs" \
96           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
97           > $@
98
99 guestfish.1: guestfish.pod guestfish-actions.pod
100         sed \
101           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
102           < $< | \
103         $(POD2MAN) \
104           --section 1 \
105           -c "Virtualization Support" \
106           --name "guestfish" \
107           --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
108           > $@
109
110 noinst_DATA = html/guestfs.3.html html/guestfish.1.html
111
112 html/guestfs.3.html: guestfs.pod guestfs-actions.pod guestfs-structs.pod
113         sed \
114           -e '/@ACTIONS@/rguestfs-actions.pod' -e 's/@ACTIONS@//' \
115           -e '/@STRUCTS@/rguestfs-structs.pod' -e 's/@STRUCTS@//' \
116           < $< | \
117         pod2html \
118           --css 'pod.css' \
119           --title "libguestfs API documentation" \
120           --htmldir html \
121           --outfile $@
122
123 html/guestfish.1.html: guestfish.pod guestfish-actions.pod
124         sed \
125           -e '/@ACTIONS@/rguestfish-actions.pod' -e 's/@ACTIONS@//' \
126           < $< | \
127         pod2html \
128           --css 'pod.css' \
129           --title "guestfish, libguestfs filesystem interactive shell" \
130           --htmldir html \
131           --outfile $@
132
133 website: html/guestfs.3.html html/guestfish.1.html
134         cp $^ html/pod.css $(HOME)/d/redhat/et-website/libguestfs/
135
136 # Test-boot the image.
137
138 test-boot: emptydisk
139         qemu-system-$(host_cpu) \
140           -m 384 \
141           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
142           -hda emptydisk
143
144 emptydisk:
145         rm -f emptydisk
146         dd if=/dev/zero of=emptydisk bs=1024 count=1440
147         echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null
148
149 # This is a more realistic test boot command line which better
150 # reflects what the library does.
151
152 test-boot-realistic: emptydisk
153         qemu-system-$(host_cpu) \
154           -m 384 \
155           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
156           -hda emptydisk \
157           -append "console=ttyS0 guestfs=10.0.2.4:6666" \
158           -nographic \
159           -serial stdio \
160           -net channel,6666:unix:/tmp/sock,server,nowait \
161           -net user,vlan=0 \
162           -net nic,vlan=0
163
164 # Make clean.
165
166 CLEANFILES = $(fs_DATA) emptydisk pod2htm?.tmp *~ html/*~
167
168 clean-local:
169         rm -rf initramfs