d4aed5520bf1924ac781f9c42c124c9652e7ebdb
[libguestfs.git] / images / Makefile.am
1 # libguestfs test images
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 # Old RHEL 5 autoconf doesn't have builddir.
19 builddir ?= $(top_builddir)/images
20
21 EXTRA_DIST = \
22         helloworld.tar \
23         helloworld.tar.gz \
24         mbr-ext2-empty.img.gz \
25         empty known-1 known-2 known-3 \
26         bin-i586-dynamic \
27         bin-sparc-dynamic \
28         bin-win32.exe \
29         bin-win64.exe \
30         bin-x86_64-dynamic \
31         lib-i586.so \
32         lib-sparc.so \
33         lib-win32.dll \
34         lib-win64.dll \
35         lib-x86_64.so
36
37
38 noinst_DATA = test.sqsh
39
40 CLEANFILES = \
41         test.sqsh \
42         100kallzeroes 100kallnewlines 100kallspaces 100krandom 10klines \
43         initrd
44
45 squash_files_src = \
46         $(srcdir)/helloworld.tar \
47         $(srcdir)/helloworld.tar.gz \
48         $(srcdir)/empty \
49         $(srcdir)/known-1 \
50         $(srcdir)/known-2 \
51         $(srcdir)/known-3 \
52         $(srcdir)/bin-i586-dynamic \
53         $(srcdir)/bin-sparc-dynamic \
54         $(srcdir)/bin-win32.exe \
55         $(srcdir)/bin-win64.exe \
56         $(srcdir)/bin-x86_64-dynamic \
57         $(srcdir)/lib-i586.so \
58         $(srcdir)/lib-sparc.so \
59         $(srcdir)/lib-win32.dll \
60         $(srcdir)/lib-win64.dll \
61         $(srcdir)/lib-x86_64.so
62
63 squash_files_build = \
64         $(builddir)/100kallzeroes \
65         $(builddir)/100kallnewlines \
66         $(builddir)/100kallspaces \
67         $(builddir)/100krandom \
68         $(builddir)/10klines \
69         $(builddir)/initrd \
70         $(builddir)/initrd-x86_64.img \
71         $(builddir)/initrd-x86_64.img.gz
72
73 squash_files = $(squash_files_src) $(squash_files_build)
74
75 test.sqsh: $(squash_files)
76         rm -f $@
77         $(MKSQUASHFS) $(squash_files) $@
78
79 $(builddir)/100kallzeroes:
80         rm -f $@ $@-t
81         dd if=/dev/zero of=$@-t bs=1024 count=100
82         mv $@-t $@
83
84 $(builddir)/100kallnewlines: $(builddir)/100kallzeroes
85         rm -f $@ $@-t
86         tr '\0' '\n' < $< > $@-t
87         mv $@-t $@
88
89 $(builddir)/100kallspaces: $(builddir)/100kallzeroes
90         rm -f $@ $@-t
91         tr '\0' ' ' < $< > $@-t
92         mv $@-t $@
93
94 $(builddir)/100krandom:
95         rm -f $@ $@-t
96         dd if=/dev/urandom of=$@-t bs=1024 count=100
97         mv $@-t $@
98
99 $(builddir)/10klines:
100         rm -f $@ $@-t
101         i=0; \
102         while [ $$i -lt 10000 ]; do \
103           echo "$${i}abcdefghijklmnopqrstuvwxyz"; \
104           i=$$(($$i+1)); \
105         done > $@-t
106         mv $@-t $@
107
108 $(builddir)/initrd: empty known-1 known-2 known-3
109         rm -f $@ $@-t
110         for f in $^; do echo $$f; done | cpio -o -H newc | gzip --best > $@-t
111         mv $@-t $@
112
113 # Create a dummy initrd with a single file called 'bin/nash' which
114 # is used to test the Sys::Guestfs::Lib::file_architecture function.
115 $(builddir)/initrd-x86_64.img: bin-x86_64-dynamic
116         rm -rf bin $@ $@-t
117         mkdir bin
118         cp $< bin/nash
119         echo bin/nash | cpio -o -H newc > $@-t
120         mv $@-t $@
121         rm -rf bin $@-t
122
123 $(builddir)/initrd-x86_64.img.gz: initrd-x86_64.img
124         rm -f $@ $@-t
125         gzip --best -c $< > $@-t
126         mv $@-t $@