doc: update Vala documentation
[automake.git] / t / subobj-pr13928-more-langs.sh
blobeecba6186eddc13b70989ab3f5c0e3b7afd68b85
1 #! /bin/sh
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)
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, 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'
24 . test-init.sh
26 cat >> configure.ac <<'END'
27 AC_PROG_CC
28 AC_PROG_CXX
29 AC_PROG_F77
30 AC_PROG_FC
31 AM_CONDITIONAL([OBVIOUS], [:])
32 AC_CONFIG_FILES([sub/Makefile])
33 AC_OUTPUT
34 END
36 cat > Makefile.am <<'END'
37 AUTOMAKE_OPTIONS = subdir-objects
38 SUBDIRS = sub
40 LESS = m/o/r/e
42 noinst_PROGRAMS = test test2
43 test_SOURCES = $(srcdir)/test.f90
45 test2_SOURCES = $(indir)
47 indir = ${indir2} $(empty)
48 indir2 =
49 if OBVIOUS
50 indir2 += ${srcdir}/$(LESS)///test.f
51 else
52 endif
54 test-objs:
55 ls -la @srcdir@ .
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)
63 test -f bar.$(OBJEXT)
64 test ! -f @srcdir@/baz.$(OBJEXT)
65 test -f baz.$(OBJEXT)
67 test ! -d @srcdir@/$(DEPDIR)
68 test ! -d @srcdir@/m/o/r/e/$(DEPDIR)
69 test -d $(DEPDIR)
70 test -d m/o/r/e/$(DEPDIR)
72 check-local: test-objs
73 END
75 mkdir sub
76 cat > sub/Makefile.am <<'END'
77 AUTOMAKE_OPTIONS = subdir-objects
78 bin_PROGRAMS = foo
79 foo = baz
80 foo_SOURCES = foo.h \
81 $(top_srcdir)/bar.cc \
82 ${top_srcdir}/$(foo).c
83 END
86 $ACLOCAL
87 $AUTOCONF
88 $AUTOMAKE -a
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'
97 program foo
98 stop
99 end
102 mkdir -p m/o/r/e
103 cp test.f90 m/o/r/e/test.f
105 cat > sub/foo.h <<'END'
106 #ifdef __cplusplus
107 extern "C"
108 #endif
109 int foo (void);
112 cat > bar.cc <<'END'
113 #include "foo.h"
114 #include <iostream>
115 int main (void)
117 std::cout << "OK!" << "\n";
118 return foo ();
122 cat > baz.c <<'END'
123 #include "foo.h"
124 int foo (void)
126 return 0;
130 mkdir build
131 cd build
132 ../configure
134 $MAKE
135 $MAKE test-objs
136 $MAKE distcheck