172f0cf7dad911f4e9f04fdb3022fb3bdf3eeae2
[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 include $(top_srcdir)/subdir-rules.mk
19
20 EXTRA_DIST = \
21         kmod.whitelist.in \
22         packagelist.in \
23         init \
24         debian/modules/y0_install-guestfsd \
25         debian/modules/z99_final-cleanups \
26         debian/debirf.conf.in \
27         make.sh.in
28
29 # Build the root filesystem (appliance).
30 # Currently this is arch-dependent, so it seems like putting it in
31 # $(libdir) is best.  When we build cross-architecture filesystems we
32 # should probably move them to $(datadir).
33 fsdir = $(libdir)/guestfs
34 superminfsdir = $(libdir)/guestfs/supermin.d
35
36 # These are the resulting output files from the whole process:
37 #   VMLINUZ        kernel for the full appliance
38 #   INITRAMFSIMG   initramfs (ie. root fs) for the full appliance
39 # For details of the supermin appliance, read the README file.
40 fs_DATA = $(INITRAMFSIMG) $(VMLINUZ)
41 if SUPERMIN
42 fs_DATA += kmod.whitelist
43 superminfs_DATA = \
44         supermin.d/base.img \
45         supermin.d/daemon.img \
46         supermin.d/hostfiles
47 endif
48
49 # Don't change these names - they must be the same as in '*.sh' scripts.
50 INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img
51 VMLINUZ = vmlinuz.$(REPO).$(host_cpu)
52
53 # This is for building the normal appliance:
54 $(INITRAMFSIMG) $(VMLINUZ): $(top_builddir)/initramfs/fakeroot.log
55
56 $(top_builddir)/initramfs/fakeroot.log: make.sh kmod.whitelist packagelist
57         mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak 2>/dev/null; :
58         mv $(VMLINUZ) $(VMLINUZ).bak 2>/dev/null; :
59         if ! bash make.sh; then rm -f $@; exit 1; fi
60
61 # This used to be a configure-generated file (as is update.sh still).
62 # However config.status always touches the destination file, which
63 # means the appliance got rebuilt too often.
64 make.sh: make.sh.in
65         cd $(top_builddir) && \
66           ./config.status --file=appliance/$@-t:appliance/$<
67         chmod +x $@-t
68         mv $@-t $@
69
70 $(INITRAMFSIMG): $(top_builddir)/initramfs/fakeroot.log $(top_builddir)/daemon/guestfsd init update.sh
71         rm -f $@
72         bash update.sh
73         touch $@
74
75 kmod.whitelist: kmod.whitelist.in
76         grep -v '^[[:space:]]*$$' < $< | grep -v '^#' > $@
77
78 packagelist: packagelist.in
79         cpp -undef -D$(DIST)=1 < $< | \
80         grep -v '^[[:space:]]*$$' | grep -v '^#' > $@
81
82 # This is for building the supermin appliance.  It has to be enabled
83 # specifically with './configure --enable-supermin'.  You really need
84 # to read the README file.
85
86 if SUPERMIN
87
88 supermin.d/base.img supermin.d/hostfiles: stamp-supermin
89 stamp-supermin: $(INITRAMFSIMG)
90         mkdir -p supermin.d
91         rm -f $@ supermin.d/base.img supermin.d/hostfiles
92         febootstrap-to-supermin $(top_builddir)/initramfs supermin.d/base.img supermin.d/hostfiles
93         if grep -q /usr/share/augeas/lenses supermin.d/hostfiles; then \
94                 echo "./usr/share/augeas/lenses/*.aug" >> supermin.d/hostfiles; \
95         fi
96         touch $@
97
98 supermin.d/daemon.img: $(INITRAMFSIMG)
99         mkdir -p supermin.d
100         rm -f $@ $@-t
101         (cd $(top_builddir)/initramfs && \
102           echo -e "sbin\nsbin/guestfsd" | cpio --quiet -o -H newc ) > $@-t
103         mv $@-t $@
104 endif
105
106 # Extra symlinks needed by the Debian appliance.
107 debirf_symlinks = \
108         a0_prep-root \
109         install-kernel \
110         z0_remove-aptitude \
111         z0_remove-locales \
112         z1_clean-root
113 noinst_DATA = $(debirf_symlinks:%=debian/modules/%)
114 $(debirf_symlinks:%=debian/modules/%): stamp-debirf-modules
115 stamp-debirf-modules:
116         mkdir -p debian/modules
117         for f in $(debirf_symlinks); do \
118           ln -sf /usr/share/debirf/modules/$$f debian/modules/$$f; \
119         done
120         touch $@
121
122 # Make clean.
123
124 CLEANFILES = packagelist kmod.whitelist
125
126 clean-local:
127         rm -f supermin.d/*
128         rm -rf $(top_builddir)/initramfs