am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / posixsubst-sources.sh
1 #! /bin/sh
2 # Copyright (C) 2010-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 that POSIX variable expansion '$(var:str=rpl)' works when used
18 # with the SOURCES primary.
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 << 'END'
29 bin_PROGRAMS = foo
30
31 FOO = foo.cxx
32 BAR = bar__
33 BAZ = baz.
34
35 # Also try an empty match suffix, to ensure that the ':=' in there is
36 # not confused by the parser with an unportable assignment operator.
37 foo_SOURCES = main.c $(FOO:.cxx=.c)
38 dist_foo_SOURCES = $(BAR:__=.c)
39 nodist_foo_SOURCES = $(BAZ:=c)
40
41 bar.c baz.c:
42         echo 'int $@ (void) { return 0; }' | sed 's/\.c //' > $@
43 CLEANFILES = baz.c
44 CLEANFILES += bar.c # For FreeBSD make.
45
46 .PHONY: test test2
47 check-local: test1 test2
48 test1:
49         ls -l . $(srcdir)
50         test -f $(srcdir)/bar.c
51         test -f baz.c
52 test2: distdir
53         ls -l $(distdir)
54 ## These sources should be distributed ...
55         test -f $(distdir)/bar.c
56         test -f $(distdir)/foo.c
57         test -f $(distdir)/main.c
58 ## ... and this shouldn't.
59         test ! -r $(distdir)/baz.c
60 END
61
62 cat > main.c <<'END'
63 int main(void)
64 {
65   int foo(void), bar(void), baz(void);
66   return foo() + bar() + baz();
67 }
68 END
69
70 echo 'int foo(void) { return 0; }' > foo.c
71
72 $ACLOCAL
73 $AUTOCONF
74 $AUTOMAKE
75
76 ./configure
77 $MAKE
78 $MAKE test1 test2
79 $MAKE distcheck
80
81 :