tests: cosmetic changes in t/extra-sources.sh
[platform/upstream/automake.git] / t / per-target-flags.sh
1 #! /bin/sh
2 # Copyright (C) 1999-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 executable-specific and library-specific flags, both with
18 # and without dependency tracking.
19
20 . test-init.sh
21
22 makefiles='Makefile libMakefile Makefile2 libMakefile2'
23
24 cat > configure.ac << END
25 AC_INIT([$me], [1.0])
26 AM_INIT_AUTOMAKE([-Wno-extra-portability])
27 AC_CONFIG_FILES([$makefiles])
28 AC_PROG_CC
29 AC_PROG_CXX
30 AC_PROG_RANLIB
31 AC_OUTPUT
32 END
33
34 $ACLOCAL
35
36 cat > Makefile.am << 'END'
37 bin_PROGRAMS = foo
38 foo_SOURCES = foo.c
39 foo_CFLAGS = -DBAR
40 END
41
42 cat > libMakefile.am << 'END'
43 lib_LIBRARIES = libfoo.a
44 libfoo_a_SOURCES = foo.c bar.cc
45 libfoo_a_CFLAGS = -DBAR
46 libfoo_a_CXXFLAGS = -DZOT
47 END
48
49 cat - Makefile.am > Makefile2.am << 'END'
50 AUTOMAKE_OPTIONS = no-dependencies
51 END
52
53 cat - libMakefile.am > libMakefile2.am << 'END'
54 AUTOMAKE_OPTIONS = no-dependencies
55 END
56
57 makefiles=$(for mkf in $makefiles; do echo $mkf.in; done)
58
59 $AUTOMAKE
60
61 # Sanity check.
62 for mkf in $makefiles; do test -f $mkf || exit 99; done
63
64 # Regression test for missing space.
65 $FGREP ')-c' $makefiles && exit 1
66
67 # Regression test for botchedly transformed object names.
68 $FGREP '.o.o' $makefiles && exit 1
69 $FGREP '.obj.obj' $makefiles && exit 1
70 $FGREP '.$(OBJEXT).$(OBJEXT)' $makefiles && exit 1
71
72 # Watch against non-transformed "foo.$(OBJEXT)", "foo.o" and "foo.obj"
73 # (and similarly for bar).
74 $EGREP '[^-](foo|bar)\.[o$]' $makefiles && exit 1
75
76 # All our programs and libraries have per-target flags, so all
77 # the compilers invocations must use an explicit '-c' option.
78 grep '\$.COMPILE' $makefiles | grep -v ' -c' && exit 1
79
80 $FGREP 'foo-foo.$(OBJEXT)' Makefile.in
81 $FGREP 'foo-foo.$(OBJEXT)' Makefile2.in
82 $FGREP 'libfoo_a-foo.$(OBJEXT)' libMakefile.in
83 $FGREP 'libfoo_a-foo.$(OBJEXT)' libMakefile2.in
84 $FGREP 'libfoo_a-bar.$(OBJEXT)' libMakefile.in
85 $FGREP 'libfoo_a-bar.$(OBJEXT)' libMakefile2.in
86
87 $FGREP '$(foo_CFLAGS)' Makefile.in
88 $FGREP '$(foo_CFLAGS)' Makefile2.in
89 $FGREP '$(libfoo_a_CFLAGS)' libMakefile.in
90 $FGREP '$(libfoo_a_CFLAGS)' libMakefile2.in
91
92 :