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