Merge branch 'maint'
[platform/upstream/automake.git] / tests / dist-readonly.test
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, 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, or (at your option)
7 # 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, see <http://www.gnu.org/licenses/>.
16
17 # Test that a readonly files are distributed as such, and not make
18 # writable while being copied in the $(distdir).
19
20 required=cc
21 . ./defs || Exit 1
22
23 cat >> configure.ac << 'END'
24 AC_PROG_CC
25 AC_OUTPUT
26 END
27
28 cat > Makefile.am << 'END'
29 bin_PROGRAMS = foo
30 foo_SOURCES = foo.c
31 EXTRA_DIST = bar.txt
32 check-local: test
33 .PHONY: test
34 test:
35         test -f $(srcdir)/foo.c && test ! -w $(srcdir)/foo.c
36         if (echo x > $(srcdir)/foo.c); then exit 1; else :; fi
37         grep 'main (void)' $(srcdir)/foo.c
38         test -f $(srcdir)/bar.txt && test ! -w $(srcdir)/bar.txt
39         if (echo x > $(srcdir)/bar.txt); then exit 1; else :; fi
40         grep 'To be, or not to be' $(srcdir)/bar.txt
41 END
42
43 echo 'int main (void) { return 0; }' > foo.c
44 echo To be, or not to be ... > bar.txt
45 chmod a-w foo.c bar.txt
46
47 $ACLOCAL
48 $AUTOCONF
49 $AUTOMAKE
50
51 ./configure
52 $MAKE distdir
53 ls -l $distdir # For debugging.
54 test -f foo.c && test ! -w foo.c || Exit 1
55 (echo x > foo.c) && Exit 1
56 test -f bar.txt && test ! -w bar.txt || Exit 1
57 (echo x > bar.txt) && Exit 1
58 $MAKE distcheck
59
60 :