tests: expose automake bug#13940
[platform/upstream/automake.git] / t / transform2.sh
1 #! /bin/sh
2 # Copyright (C) 2002-2013 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 # Make sure that --program-transform works even when multiple files are
18 # collapsed.
19
20 required=cc
21 . test-init.sh
22
23 cat >>configure.ac <<'END'
24 AC_PROG_CC
25 AC_OUTPUT
26 END
27
28 cat >Makefile.am <<'EOF'
29 bin_PROGRAMS = p1 p2
30 bin_SCRIPTS = s1.sh s2.sh
31 man_MANS = m1.1 m2.1
32
33 test-install: install
34         test -f inst/bin/p$(EXEEXT)
35         test -f inst/bin/s.sh
36         test -f inst/man/man1/m.1
37
38 test-install-foo: install
39         test -f inst/bin/foo$(EXEEXT)
40         test -f inst/bin/foo
41         test -f inst/man/man1/foo.1
42         test ! -f inst/bin/p1$(EXEEXT)
43         test ! -f inst/bin/p2$(EXEEXT)
44         test ! -f inst/bin/s1.sh
45         test ! -f inst/bin/s2.sh
46         test ! -f inst/man/man/m1.1
47         test ! -f inst/man/man/m2.1
48 EOF
49
50 cat >p1.c <<'EOF'
51 int
52 main ()
53 {
54   return 0;
55 }
56 EOF
57
58 cp p1.c p2.c
59
60 : > s1.sh
61 : > s2.sh
62 : > m1.1
63 : > m2.1
64
65 $ACLOCAL
66 $AUTOCONF
67 $AUTOMAKE
68
69 cwd=$(pwd) || fatal_ "getting current working directory"
70
71 ./configure --program-transform-name='s/[12]//' --prefix "$cwd/inst" \
72                                                 --mandir "$cwd/inst/man"
73 $MAKE
74 $MAKE test-install
75 $MAKE uninstall
76 test $(find inst -type f -print | wc -l) -eq 0
77
78 # Also squash all file types in question.
79
80 # On newer Cygwin versions, that won't work, likely due to overly
81 # aggressive appending of '.exe' suffix when copying/renaming Windows
82 # executables.  So let's skip this part of the test if we detect the
83 # faulty heuristic is present.  See also:
84 # <http://lists.gnu.org/archive/html/automake-patches/2010-08/msg00153.html>
85 # <http://thread.gmane.org/gmane.os.cygwin/119380>
86 echo Foo > foo
87 echo Bar > bar.exe
88 chmod a+x foo bar.exe
89 cp foo bar && cmp foo bar \
90   || skip_ "your Cygwin is too aggressive in tweaking '.exe' suffixes"
91
92 ./configure --program-transform-name='s/.*/foo/' --prefix "$cwd/inst" \
93                                                  --mandir "$cwd/inst/man"
94 $MAKE
95 $MAKE test-install-foo
96 $MAKE uninstall
97 test $(find inst -type f -print | wc -l) -eq 0
98
99 :