Merge branch 'maint'
[platform/upstream/automake.git] / t / location.sh
1 #! /bin/sh
2 # Copyright (C) 2002-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 for locations in error messages.
18
19 . ./defs || Exit 1
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 cat >expected <<\EOF
63 Makefile.am:12: warning: VAR multiply defined in condition TRUE ...
64 Makefile.am:8: ... 'VAR' previously defined here
65 automake: error: libfoo_a_OBJECTS should not be defined
66 Makefile.am:3:   while processing library 'libfoo.a'
67 automake: error: use 'libfoo_a_LDADD', not 'libfoo_a_LIBADD'
68 Makefile.am:3:   while processing library 'libfoo.a'
69 library.am: warning: deprecated feature: target 'libfoo.a' overrides 'libfoo.a$(EXEEXT)'
70 library.am: change your target to read 'libfoo.a$(EXEEXT)'
71 Makefile.am:3:   while processing library 'libfoo.a'
72 program.am: target 'libfoo.a$(EXEEXT)' was defined here
73 Makefile.am:1:   while processing program 'libfoo.a'
74 program.am: warning: redefinition of 'libfoo.a$(EXEEXT)' ...
75 Makefile.am:1:   while processing program 'libfoo.a'
76 library.am: ... 'libfoo.a' previously defined here
77 Makefile.am:3:   while processing library 'libfoo.a'
78 tags.am: warning: redefinition of 'ctags' ...
79 program.am: ... 'ctags$(EXEEXT)' previously defined here
80 Makefile.am:6:   while processing program 'ctags'
81 EOF
82
83 cat expected
84 cat observed
85 diff expected observed || Exit 1
86
87 AUTOMAKE_fails -Werror
88 smash_useless_diffs stderr >observed
89 (echo 'automake: warnings are treated as errors' && cat expected) > t
90 mv -f t expected
91
92 cat expected
93 cat observed
94
95 diff expected observed || Exit 1
96
97 :