build: remove trailing blank lines; enable the syntax-check rule
[libguestfs.git] / appliance / 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 EXTRA_DIST = \
19         libguestfs-supermin-helper \
20         kmod.whitelist.in \
21         packagelist.in \
22         init \
23         debian/modules/install_kernel \
24         debian/modules/y0_install-guestfsd \
25         debian/modules/z99_final-cleanups \
26         debian/debirf.conf.in
27
28 # Build the root filesystem (appliance).
29 # Currently this is arch-dependent, so it seems like putting it in
30 # $(libdir) is best.  When we build cross-architecture filesystems we
31 # should probably move them to $(datadir).
32 fsdir = $(libdir)/guestfs
33 fs_DATA = $(APPLIANCE_FILES)
34
35 # These are the resulting output files from the whole process:
36 #   VMLINUZ        kernel for the full appliance
37 #   INITRAMFSIMG   initramfs (ie. root fs) for the full appliance
38 # For details of the supermin appliance, read the README file:
39 #   SUPERMINIMG    initramfs (ie. partial root fs) for the supermin appliance
40 #   SUPERMINFILES  list of missing files (the ones we will pull out of the
41 #                    host filesystem at runtime) in the supermin appliance
42 APPLIANCE_FILES = $(INITRAMFSIMG) $(VMLINUZ)
43 if SUPERMIN
44 APPLIANCE_FILES += $(SUPERMINIMG) $(SUPERMINFILES) kmod.whitelist
45 bin_SCRIPTS = libguestfs-supermin-helper
46 endif
47
48 # Don't change these names - they must be the same as in '*.sh' scripts.
49 INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img
50 VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
51 if SUPERMIN
52 SUPERMINIMG = initramfs.$(REPO).$(host_cpu).supermin.img
53 SUPERMINFILES = initramfs.$(REPO).$(host_cpu).supermin.hostfiles
54 endif
55
56 # This is for building the normal appliance:
57 $(INITRAMFSIMG) $(VMLINUZ): $(top_builddir)/initramfs/fakeroot.log
58
59 $(top_builddir)/initramfs/fakeroot.log: make.sh kmod.whitelist packagelist
60         mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak 2>/dev/null; :
61         mv $(VMLINUZ) $(VMLINUZ).bak 2>/dev/null; :
62         if ! bash make.sh; then rm -f $@; exit 1; fi
63
64 $(INITRAMFSIMG): $(top_builddir)/initramfs/fakeroot.log $(top_builddir)/daemon/guestfsd init update.sh
65         rm -f $@
66         bash update.sh
67         touch $@
68
69 kmod.whitelist: kmod.whitelist.in
70         grep -v '^[[:space:]]*$$' < $< | grep -v '^#' > $@
71
72 packagelist: packagelist.in
73         cpp -undef -D$(DIST)=1 < $< | \
74         grep -v '^[[:space:]]*$$' | grep -v '^#' > $@
75
76 # This is for building the supermin appliance.  It has to be enabled
77 # specifically with './configure --enable-supermin'.  You really need
78 # to read the README file.
79
80 if SUPERMIN
81
82 # First we need to decide which files go in and out of the supermin
83 # appliance.  This decision is made by 'supermin-split.sh'.
84 $(SUPERMINFILES): supermin.incfiles
85 supermin.incfiles: $(top_builddir)/initramfs/fakeroot.log $(top_builddir)/daemon/guestfsd supermin-split.sh
86         rm -f supermin.incfiles $(SUPERMINFILES)
87         bash supermin-split.sh
88
89 # Second we need to create a supermin appliance with just the included
90 # files (leaving out the host files, which we'll add back at runtime).
91 $(SUPERMINIMG): supermin.incfiles supermin-make.sh
92         rm -f $@
93         bash supermin-make.sh
94
95 endif
96
97 # Extra symlinks needed by the Debian appliance.
98 debirf_symlinks = \
99         a0_prep-root \
100         z0_remove-aptitude \
101         z0_remove-locales \
102         z1_clean-root
103 noinst_DATA = $(debirf_symlinks:%=debian/modules/%)
104 $(debirf_symlinks:%=debian/modules/%): stamp-debirf-modules
105 stamp-debirf-modules:
106         mkdir -p debian/modules
107         for f in $(debirf_symlinks); do \
108           ln -sf /usr/share/debirf/modules/$$f debian/modules/$$f; \
109         done
110         touch $@
111
112 #----------------------------------------------------------------------
113 # Extra rules for testing the appliance.
114
115 # Test-boot the appliance.
116
117 test-boot: emptydisk
118         qemu-system-$(host_cpu) \
119           -m 384 \
120           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
121           -hda emptydisk
122
123 emptydisk:
124         rm -f emptydisk
125         dd if=/dev/zero of=emptydisk bs=1024 count=1440
126         echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null
127
128 # This is a more realistic test boot command line which better
129 # reflects what the library does.
130
131 test-boot-realistic: emptydisk
132         qemu-system-$(host_cpu) \
133           -m 384 \
134           -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \
135           -hda emptydisk \
136           -append "console=ttyS0 guestfs=10.0.2.4:6666 guestfs_rescue=1" \
137           -nographic \
138           -serial stdio \
139           -net channel,6666:unix:/tmp/sock,server,nowait \
140           -net user,vlan=0 \
141           -net nic,model=virtio,vlan=0
142
143 # Make clean.
144
145 CLEANFILES = $(APPLIANCE_FILES) packagelist kmod.whitelist supermin.incfiles
146
147 clean-local:
148         rm -rf $(top_builddir)/initramfs