9804e9942d8581ce20463c995ff69f321a0918b4
[platform/upstream/automake.git] / tests / disthook.test
1 #! /bin/sh
2 # Copyright (C) 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 # Check that 'dist-hook' works.  See automake bug#10878.
18
19 . ./defs || Exit 1
20
21 echo AC_OUTPUT >> configure.ac
22
23 cat > Makefile.am <<'END'
24 EXTRA_DIST = write execute removed doc
25
26 removed:
27         echo I will be deleted > $@
28 DISTCLEANFILES = removed
29
30 dist-hook:
31         chmod u+w $(distdir)/write $(distdir)/doc
32         chmod u+x $(distdir)/execute
33         rm -f $(distdir)/removed
34         rm -f $(distdir)/doc/HACKING
35         rm -f $(distdir)/doc/RELEASE-DATE
36         date > $(distdir)/doc/RELEASE-DATE
37         echo all is ok > $(distdir)/write
38
39 check-local:
40         ls -l $(srcdir) $(srcdir)/doc
41         test "`cat $(srcdir)/write`" = "all is ok"
42         test -f $(srcdir)/doc/README
43         test -f $(srcdir)/doc/RELEASE-DATE
44         test ! -f $(srcdir)/removed
45         test ! -r $(srcdir)/removed
46         test ! -f $(srcdir)/doc/HACKING
47         test ! -r $(srcdir)/doc/HACKING
48         $(srcdir)/execute
49         $(srcdir)/execute | grep 'I run successfully'
50 ## Sanity check.
51         echo ok > $(srcdir)/../distcheck-run
52 END
53
54 $ACLOCAL
55 $AUTOMAKE
56 $AUTOCONF
57
58 ./configure
59 mkdir doc
60 : > doc/README
61 : > doc/HACKING
62 echo will be clobbered > write
63 cat > execute <<'END'
64 #!/bin/sh
65 echo I run successfully
66 END
67
68 chmod a-w write
69 chmod a-x execute
70
71 $MAKE distdir
72 ls -l $distdir $distdir/doc
73 cd $distdir
74 test "`cat write`" = "all is ok"
75 test ! -f removed
76 test ! -r removed
77 test -f doc/README
78 test -f doc/RELEASE-DATE
79 test ! -f doc/HACING
80 test ! -r doc/HACING
81 ./execute
82 ./execute | grep 'I run successfully'
83 cd ..
84
85
86 $MAKE distcheck
87 test -f distcheck-run
88
89 :