maint: Update copyright years to 2018
[automake.git] / t / subobj-vpath-pr13928.sh
blob9abcbee0991b8a8d2268e5d61f80adb12c3dee28
1 #! /bin/sh
2 # Copyright (C) 2013-2018 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 <https://www.gnu.org/licenses/>.
17 # Expose part of automake bug#13928: if the subdir-objects option is
18 # in use and a source file is listed in a _SOURCES variable with a
19 # leading $(srcdir) component, Automake will generate a Makefile that
20 # tries to create the corresponding object file in $(srcdir) as well.
22 required=cc
23 . test-init.sh
25 cat >> configure.ac <<'END'
26 AC_PROG_CC
27 AM_PROG_CC_C_O
28 AM_CONDITIONAL([OBVIOUS], [:])
29 AC_CONFIG_FILES([sub/Makefile])
30 AC_OUTPUT
31 END
33 cat > Makefile.am <<'END'
34 AUTOMAKE_OPTIONS = subdir-objects
35 SUBDIRS = sub
37 LESS = more
39 noinst_PROGRAMS = test test2
40 test_SOURCES = $(srcdir)/test.c
42 test2_SOURCES = $(indir)
44 indir =
45 if OBVIOUS
46 indir += ${srcdir}/$(LESS)/test.c
47 else
48 endif
50 test-objs:
51 ls -la @srcdir@ .
53 test ! -f @srcdir@/test.$(OBJEXT)
54 test -f test.$(OBJEXT)
55 test ! -f @srcdir@/more/test.$(OBJEXT)
56 test -f more/test.$(OBJEXT)
58 test ! -f @srcdir@/bar.$(OBJEXT)
59 test -f bar.$(OBJEXT)
60 test ! -f @srcdir@/baz.$(OBJEXT)
61 test -f baz.$(OBJEXT)
63 test ! -d @srcdir@/$(DEPDIR)
64 test ! -d @srcdir@/more/$(DEPDIR)
65 test -d $(DEPDIR)
66 test -d more/$(DEPDIR)
68 check-local: test-objs
69 END
71 mkdir sub
72 cat > sub/Makefile.am <<'END'
73 AUTOMAKE_OPTIONS = subdir-objects
74 bin_PROGRAMS = foo
75 foo_SOURCES = foo.h \
76 $(top_srcdir)/bar.c \
77 ${top_srcdir}/baz.c
78 END
81 $ACLOCAL
82 $AUTOCONF
83 $AUTOMAKE -a
85 mkfiles='Makefile.in sub/Makefile.in'
86 $EGREP '(test|ba[rz])\.|DEPDIR|dirstamp|srcdir' $mkfiles # For debugging.
87 $EGREP '\$.(top_)?srcdir./(test|ba[rz])\.[o$]' $mkfiles && exit 1
88 $FGREP '\$.(top_)?srcdir./.*$(am__dirstamp)' $mkfiles && exit 1
89 $FGREP '\$.(top_)?srcdir./.*$(DEPDIR)' $mkfiles && exit 1
91 cat > test.c <<'END'
92 int main (void)
94 return 0;
96 END
98 mkdir more
99 cp test.c more/test.c
101 echo 'int foo (void);' > sub/foo.h
103 cat > bar.c <<'END'
104 #include "foo.h"
105 int main (void)
107 return foo ();
111 cat > baz.c <<'END'
112 #include "foo.h"
113 int foo (void)
115 return 0;
119 mkdir build
120 cd build
121 ../configure
123 $MAKE
124 $MAKE test-objs
125 $MAKE distcheck