appliance: Use a temporary file when processing packagelist.in.
[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         packagelist.in \
22         init \
23         make.sh.in
24
25 fsdir = $(libdir)/guestfs
26 superminfsdir = $(libdir)/guestfs/supermin.d
27
28 fs_DATA =
29 superminfs_DATA = \
30         supermin.d/base.img \
31         supermin.d/daemon.img \
32         supermin.d/init.img \
33         supermin.d/hostfiles
34
35 # This used to be a configure-generated file (as is update.sh still).
36 # However config.status always touches the destination file, which
37 # means the appliance got rebuilt too often.
38 make.sh: make.sh.in
39         cd $(top_builddir) && \
40           ./config.status --file=appliance/$@-t:appliance/$<
41         chmod +x $@-t
42         mv $@-t $@
43
44 packagelist: packagelist.in
45         cpp -undef -D$(DISTRO)=1 < $< | \
46         grep -v '^[[:space:]]*$$' | grep -v '^#' > $@-t
47         mv $@-t $@
48
49 supermin.d/base.img supermin.d/hostfiles: stamp-supermin
50 stamp-supermin: make.sh packagelist
51         mkdir -p supermin.d
52         rm -f $@ supermin.d/base.img supermin.d/hostfiles
53         ./make.sh
54         touch $@
55
56 supermin.d/daemon.img: ../daemon/guestfsd
57         mkdir -p supermin.d
58         rm -f $@ $@-t
59         mkdir sbin
60         cd sbin && ln ../../daemon/guestfsd
61         echo -e "sbin\nsbin/guestfsd" | cpio --quiet -o -H newc > $@-t
62         rm -r sbin
63         mv $@-t $@
64
65 supermin.d/init.img: init
66         mkdir -p supermin.d
67         rm -f $@ $@-t
68         echo "init" | cpio --quiet -o -H newc > $@-t
69         mv $@-t $@
70
71 # Make clean.
72
73 CLEANFILES = packagelist
74
75 clean-local:
76         rm -rf supermin.d