summaryrefslogtreecommitdiff
path: root/t/per-target-flags.sh
blob: e5278fb276b9703cdca4630d0bdbeb703ed0f57e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#! /bin/sh
# Copyright (C) 1999-2012 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Test executable-specific and library-specific flags, both with
# and without dependency tracking.

. ./defs || Exit 1

makefiles='Makefile libMakefile Makefile2 libMakefile2'

cat > configure.ac << END
AC_INIT([$me], [1.0])
AM_INIT_AUTOMAKE([-Wno-extra-portability])
AC_CONFIG_FILES([$makefiles])
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CXX
AC_PROG_RANLIB
AC_OUTPUT
END

$ACLOCAL

cat > Makefile.am << 'END'
bin_PROGRAMS = foo
foo_SOURCES = foo.c
foo_CFLAGS = -DBAR
END

cat > libMakefile.am << 'END'
lib_LIBRARIES = libfoo.a
libfoo_a_SOURCES = foo.c bar.cc
libfoo_a_CFLAGS = -DBAR
libfoo_a_CXXFLAGS = -DZOT
END

cat - Makefile.am > Makefile2.am << 'END'
AUTOMAKE_OPTIONS = no-dependencies
END

cat - libMakefile.am > libMakefile2.am << 'END'
AUTOMAKE_OPTIONS = no-dependencies
END

# Make sure 'compile' is required.
for m in $makefiles; do
  AUTOMAKE_fails $m
  $EGREP " required file.* '(compile|\./compile)'" stderr
done

makefiles=$(for mkf in $makefiles; do echo $mkf.in; done)

: > compile
$AUTOMAKE

# Sanity check.
for mkf in $makefiles; do test -f $mkf || exit 99; done

# Regression test for missing space.
$FGREP ')-c' $makefiles && exit 1

# Regression test for botchedly transformed object names.
$FGREP '.o.o' $makefiles && exit 1
$FGREP '.obj.obj' $makefiles && exit 1
$FGREP '.$(OBJEXT).$(OBJEXT)' $makefiles && exit 1

# Watch against non-transformed "foo.$(OBJEXT)", "foo.o" and "foo.obj"
# (and similarly for bar).
$EGREP '[^-](foo|bar)\.[o$]' $makefiles && exit 1

# All our programs and libraries have per-target flags, so all
# the compilers invocations must use an explicit '-c' option.
grep '\$.COMPILE' $makefiles | grep -v ' -c' && exit 1

$FGREP 'foo-foo.$(OBJEXT)' Makefile.in
$FGREP 'foo-foo.$(OBJEXT)' Makefile2.in
$FGREP 'libfoo_a-foo.$(OBJEXT)' libMakefile.in
$FGREP 'libfoo_a-foo.$(OBJEXT)' libMakefile2.in
$FGREP 'libfoo_a-bar.$(OBJEXT)' libMakefile.in
$FGREP 'libfoo_a-bar.$(OBJEXT)' libMakefile2.in

$FGREP '$(foo_CFLAGS)' Makefile.in
$FGREP '$(foo_CFLAGS)' Makefile2.in
$FGREP '$(libfoo_a_CFLAGS)' libMakefile.in
$FGREP '$(libfoo_a_CFLAGS)' libMakefile2.in

: