tests: only activate 'unset' alias if required
[platform/upstream/automake.git] / t / location.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 # Test for locations in error messages.
18
19 . test-init.sh
20
21 cat >> configure.ac << 'END'
22 AM_CONDITIONAL([COND1], [true])
23 AM_CONDITIONAL([COND2], [true])
24 AC_PROG_CC
25 AM_PROG_AR
26 AC_PROG_RANLIB
27 END
28
29 cat > Makefile.am << 'END'
30 bin_PROGRAMS = libfoo.a
31 if COND2
32   lib_LIBRARIES = libfoo.a
33 endif
34 if COND1
35   bin_PROGRAMS += ctags
36 endif
37 VAR = 1 \
38       2 \
39       3
40
41 VAR = 1 \
42       2 \
43       3
44 END
45
46 : > ar-lib
47
48 # Smash the useless difference of lib file locations.
49 smash_useless_diffs ()
50 {
51   # FIXME: we could get rid of the second 's,,,' once we improve our
52   # wrapper scripts ...
53   sed -e "s,^$am_amdir/\\([a-z]*\.am\\),\\1," \
54       -e "s,^automake-$APIVERSION:,automake:," ${1+"$@"};
55 }
56
57 $ACLOCAL
58 AUTOMAKE_fails -Wno-error
59
60 smash_useless_diffs stderr >observed
61
62 # Apparently useless use of sed here required to avoid spuriously
63 # triggering some maintainer-checks failures.
64 sed 's/^> //' > expected << 'END'
65 > Makefile.am:12: warning: VAR multiply defined in condition TRUE ...
66 > Makefile.am:8: ... 'VAR' previously defined here
67 > automake: error: libfoo_a_OBJECTS should not be defined
68 > Makefile.am:3:   while processing library 'libfoo.a'
69 > automake: error: use 'libfoo_a_LDADD', not 'libfoo_a_LIBADD'
70 > Makefile.am:3:   while processing library 'libfoo.a'
71 > library.am: warning: deprecated feature: target 'libfoo.a' overrides 'libfoo.a$(EXEEXT)'
72 > library.am: change your target to read 'libfoo.a$(EXEEXT)'
73 > Makefile.am:3:   while processing library 'libfoo.a'
74 > program.am: target 'libfoo.a$(EXEEXT)' was defined here
75 > Makefile.am:1:   while processing program 'libfoo.a'
76 > program.am: warning: redefinition of 'libfoo.a$(EXEEXT)' ...
77 > Makefile.am:1:   while processing program 'libfoo.a'
78 > library.am: ... 'libfoo.a' previously defined here
79 > Makefile.am:3:   while processing library 'libfoo.a'
80 > tags.am: warning: redefinition of 'ctags' ...
81 > program.am: ... 'ctags$(EXEEXT)' previously defined here
82 > Makefile.am:6:   while processing program 'ctags'
83 END
84
85 cat expected
86 cat observed
87 diff expected observed || exit 1
88
89 AUTOMAKE_fails -Werror
90 smash_useless_diffs stderr >observed
91 (echo 'automake: warnings are treated as errors' && cat expected) > t
92 mv -f t expected
93
94 cat expected
95 cat observed
96
97 diff expected observed || exit 1
98
99 :