news: update w.r.t. recent depcomp changes
[automake.git] / t / per-target-flags.sh
blob4114079cbf6131d180cc2ab81d50f8640deb0cb4
1 #! /bin/sh
2 # Copyright (C) 1999-2012 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Test executable-specific and library-specific flags, both with
18 # and without dependency tracking.
20 . test-init.sh
22 makefiles='Makefile libMakefile Makefile2 libMakefile2'
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 AM_PROG_CC_C_O
30 AC_PROG_CXX
31 AC_PROG_RANLIB
32 AC_OUTPUT
33 END
35 $ACLOCAL
37 cat > Makefile.am << 'END'
38 bin_PROGRAMS = foo
39 foo_SOURCES = foo.c
40 foo_CFLAGS = -DBAR
41 END
43 cat > libMakefile.am << 'END'
44 lib_LIBRARIES = libfoo.a
45 libfoo_a_SOURCES = foo.c bar.cc
46 libfoo_a_CFLAGS = -DBAR
47 libfoo_a_CXXFLAGS = -DZOT
48 END
50 cat - Makefile.am > Makefile2.am << 'END'
51 AUTOMAKE_OPTIONS = no-dependencies
52 END
54 cat - libMakefile.am > libMakefile2.am << 'END'
55 AUTOMAKE_OPTIONS = no-dependencies
56 END
58 # Make sure 'compile' is required.
59 for m in $makefiles; do
60 AUTOMAKE_fails $m
61 $EGREP " required file.* '(compile|\./compile)'" stderr
62 done
64 makefiles=$(for mkf in $makefiles; do echo $mkf.in; done)
66 : > compile
67 $AUTOMAKE
69 # Sanity check.
70 for mkf in $makefiles; do test -f $mkf || exit 99; done
72 # Regression test for missing space.
73 $FGREP ')-c' $makefiles && exit 1
75 # Regression test for botchedly transformed object names.
76 $FGREP '.o.o' $makefiles && exit 1
77 $FGREP '.obj.obj' $makefiles && exit 1
78 $FGREP '.$(OBJEXT).$(OBJEXT)' $makefiles && exit 1
80 # Watch against non-transformed "foo.$(OBJEXT)", "foo.o" and "foo.obj"
81 # (and similarly for bar).
82 $EGREP '[^-](foo|bar)\.[o$]' $makefiles && exit 1
84 # All our programs and libraries have per-target flags, so all
85 # the compilers invocations must use an explicit '-c' option.
86 grep '\$.COMPILE' $makefiles | grep -v ' -c' && exit 1
88 $FGREP 'foo-foo.$(OBJEXT)' Makefile.in
89 $FGREP 'foo-foo.$(OBJEXT)' Makefile2.in
90 $FGREP 'libfoo_a-foo.$(OBJEXT)' libMakefile.in
91 $FGREP 'libfoo_a-foo.$(OBJEXT)' libMakefile2.in
92 $FGREP 'libfoo_a-bar.$(OBJEXT)' libMakefile.in
93 $FGREP 'libfoo_a-bar.$(OBJEXT)' libMakefile2.in
95 $FGREP '$(foo_CFLAGS)' Makefile.in
96 $FGREP '$(foo_CFLAGS)' Makefile2.in
97 $FGREP '$(libfoo_a_CFLAGS)' libMakefile.in
98 $FGREP '$(libfoo_a_CFLAGS)' libMakefile2.in