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