2 # Copyright (C) 2015-2024 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)
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, also for non-C languages: if the
18 # subdir-objects option is in use and a source file is listed in a
19 # _SOURCES variable with a leading $(srcdir) component, Automake will
20 # generate a Makefile that tries to create the corresponding object
21 # file in $(srcdir) as well.
23 required
='cc c++ fortran77 fortran'
26 cat >> configure.ac
<<'END'
31 AM_CONDITIONAL([OBVIOUS], [:])
32 AC_CONFIG_FILES([sub/Makefile])
36 cat > Makefile.am
<<'END'
37 AUTOMAKE_OPTIONS = subdir-objects
42 noinst_PROGRAMS = test test2
43 test_SOURCES = $(srcdir)/test.f90
45 test2_SOURCES = $(indir)
47 indir = ${indir2} $(empty)
50 indir2 += ${srcdir}/$(LESS)///test.f
57 test ! -f @srcdir@/test.$(OBJEXT)
58 test -f test.$(OBJEXT)
59 test ! -f @srcdir@/m/o/r/e/test.$(OBJEXT)
60 test -f m/o/r/e/test.$(OBJEXT)
62 test ! -f @srcdir@/bar.$(OBJEXT)
64 test ! -f @srcdir@/baz.$(OBJEXT)
67 test ! -d @srcdir@/$(DEPDIR)
68 test ! -d @srcdir@/m/o/r/e/$(DEPDIR)
70 test -d m/o/r/e/$(DEPDIR)
72 check-local: test-objs
76 cat > sub
/Makefile.am
<<'END'
77 AUTOMAKE_OPTIONS = subdir-objects
81 $(top_srcdir)/bar.cc \
82 ${top_srcdir}/$(foo).c
90 mkfiles
='Makefile.in sub/Makefile.in'
91 $EGREP '(test|ba[rz])\.|DEPDIR|dirstamp|srcdir' $mkfiles # For debugging.
92 $EGREP '\$.(top_)?srcdir./(test|ba[rz]|\$.foo.)\.[o$]' $mkfiles && exit 1
93 $FGREP '\$.(top_)?srcdir./.*$(am__dirstamp)' $mkfiles && exit 1
94 $FGREP '\$.(top_)?srcdir./.*$(DEPDIR)' $mkfiles && exit 1
96 cat > test.f90
<<'EOF'
103 cp test.f90 m
/o
/r
/e
/test.f
105 cat > sub
/foo.h
<<'END'
117 std::cout << "OK!" << "\n";