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