Version 1.7.6.
[libguestfs.git] / images / Makefile.am
1 # libguestfs test images
2 # Copyright (C) 2009-2010 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 # Old RHEL 5 autoconf doesn't have builddir.
21 builddir ?= $(top_builddir)/images
22
23 EXTRA_DIST = \
24         helloworld.tar \
25         helloworld.tar.gz \
26         helloworld.tar.xz \
27         mbr-ext2-empty.img.gz \
28         empty known-1 known-2 known-3 known-4 known-5 \
29         bin-i586-dynamic \
30         bin-sparc-dynamic \
31         bin-win32.exe \
32         bin-win64.exe \
33         bin-x86_64-dynamic \
34         lib-i586.so \
35         lib-sparc.so \
36         lib-win32.dll \
37         lib-win64.dll \
38         lib-x86_64.so \
39         test-grep.txt \
40         make-dummy-fedora-img.sh
41
42 noinst_DATA = test.iso
43
44 # This is 'check_DATA' because we don't need it until 'make check'
45 # time and we need the tools we have built in order to make it.
46 check_DATA = fedora.img
47
48 CLEANFILES = \
49         test.iso test.sqsh \
50         100kallzeroes 100kallnewlines 100kallspaces 100krandom 10klines \
51         initrd fedora.img
52
53 images_files_src = \
54         $(srcdir)/helloworld.tar \
55         $(srcdir)/helloworld.tar.gz \
56         $(srcdir)/helloworld.tar.xz \
57         $(srcdir)/empty \
58         $(srcdir)/known-1 \
59         $(srcdir)/known-2 \
60         $(srcdir)/known-3 \
61         $(srcdir)/known-4 \
62         $(srcdir)/known-5 \
63         $(srcdir)/bin-i586-dynamic \
64         $(srcdir)/bin-sparc-dynamic \
65         $(srcdir)/bin-win32.exe \
66         $(srcdir)/bin-win64.exe \
67         $(srcdir)/bin-x86_64-dynamic \
68         $(srcdir)/lib-i586.so \
69         $(srcdir)/lib-sparc.so \
70         $(srcdir)/lib-win32.dll \
71         $(srcdir)/lib-win64.dll \
72         $(srcdir)/lib-x86_64.so \
73         $(srcdir)/test-grep.txt
74
75 images_files_build = \
76         $(builddir)/100kallzeroes \
77         $(builddir)/100kallnewlines \
78         $(builddir)/100kallspaces \
79         $(builddir)/100krandom \
80         $(builddir)/10klines \
81         $(builddir)/abssymlink \
82         $(builddir)/hello.b64 \
83         $(builddir)/initrd \
84         $(builddir)/initrd-x86_64.img \
85         $(builddir)/initrd-x86_64.img.gz \
86         $(builddir)/test-grep.txt.gz
87
88 images_files = $(images_files_src) $(images_files_build)
89
90 test.iso: $(images_files)
91         rm -f $@ $@-t
92         mkdir -p directory
93         $(MKISOFS) -J -r -graft-points \
94           -o $@-t \
95           $(images_files) /directory=directory
96         rmdir directory
97         mv $@-t $@
98
99 $(builddir)/100kallzeroes:
100         rm -f $@ $@-t
101         dd if=/dev/zero of=$@-t bs=1024 count=100
102         mv $@-t $@
103
104 $(builddir)/100kallnewlines: $(builddir)/100kallzeroes
105         rm -f $@ $@-t
106         tr '\0' '\n' < $< > $@-t
107         mv $@-t $@
108
109 $(builddir)/100kallspaces: $(builddir)/100kallzeroes
110         rm -f $@ $@-t
111         tr '\0' ' ' < $< > $@-t
112         mv $@-t $@
113
114 $(builddir)/100krandom:
115         rm -f $@ $@-t
116         dd if=/dev/urandom of=$@-t bs=1024 count=100
117         mv $@-t $@
118
119 $(builddir)/10klines:
120         rm -f $@ $@-t
121         i=0; \
122         while [ $$i -lt 10000 ]; do \
123           echo "$${i}abcdefghijklmnopqrstuvwxyz"; \
124           i=$$(($$i+1)); \
125         done > $@-t
126         mv $@-t $@
127
128 $(builddir)/abssymlink:
129         ln -sf /10klines $@
130
131 $(builddir)/hello.b64:
132         echo "hello" | base64 > $@
133
134 $(builddir)/initrd: empty known-1 known-2 known-3 known-4 known-5
135         rm -f $@ $@-t
136         for f in $^; do echo $$f; done | cpio -o -H newc | gzip --best > $@-t
137         mv $@-t $@
138
139 # Create a dummy initrd with a single file called 'bin/nash' which
140 # is used to test the Sys::Guestfs::Lib::file_architecture function.
141 $(builddir)/initrd-x86_64.img: bin-x86_64-dynamic
142         rm -rf bin $@ $@-t
143         mkdir bin
144         cp $< bin/nash
145         echo bin/nash | cpio -o -H newc > $@-t
146         mv $@-t $@
147         rm -rf bin $@-t
148
149 $(builddir)/initrd-x86_64.img.gz: initrd-x86_64.img
150         rm -f $@ $@-t
151         gzip --best -c $< > $@-t
152         mv $@-t $@
153
154 $(builddir)/test-grep.txt.gz: test-grep.txt
155         rm -f $@ $@-t
156         gzip --best -c $< > $@-t
157         mv $@-t $@
158
159 # Make a (dummy) Fedora image.
160 fedora.img: make-dummy-fedora-img.sh
161         LIBGUESTFS_PATH=../appliance \
162         LD_LIBRARY_PATH=../src/.libs \
163         bash $<