Support more C++ file extensions for MSVC in the compile script.
[platform/upstream/automake.git] / tests / pr401b.test
1 #! /bin/sh
2 # Copyright (C) 2005, 2006, 2007  Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # Check support for AC_CONFIG_LIBOBJ_DIR vs LTLIBOBJS.
18 # (pr401.test and pr401c.test do the same for LIBOBJS and ALLOCA)
19
20 required='gcc libtoolize'
21 . ./defs || Exit 1
22
23 set -e
24
25 mkdir lib src
26
27 cat >lib/feep.c <<'EOF'
28 char *
29 feep ()
30 {
31   return "feep";
32 }
33 EOF
34
35 cat >src/main.c <<'EOF'
36 #include <stdio.h>
37
38 extern char *feep ();
39
40 int
41 main (int argc, char **argv)
42 {
43   puts (feep ());
44   return 0;
45 }
46 EOF
47
48 cat >>configure.in << 'EOF'
49 ## These lines are activated for later tests
50 #: AC_CONFIG_LIBOBJ_DIR([lib])
51 AC_PROG_CC
52 #x AM_PROG_CC_C_O
53 AC_LIBOBJ([feep])
54 AC_LIBSOURCE([feep.c])
55 AC_PROG_LIBTOOL
56 AC_CONFIG_FILES([lib/Makefile src/Makefile])
57 AC_OUTPUT
58 EOF
59
60 ## -------------------------------------------- ##
61 ## First a test of traditional LTLIBOBJS usage. ##
62 ## -------------------------------------------- ##
63
64 cat >Makefile.am <<'EOF'
65 SUBDIRS = lib src
66 EOF
67
68 cat >lib/Makefile.am <<'EOF'
69 noinst_LTLIBRARIES = libfeep.la
70 libfeep_la_SOURCES =
71 libfeep_la_LIBADD = $(LTLIBOBJS)
72 EOF
73
74 cat >src/Makefile.am <<'EOF'
75 check_PROGRAMS = main
76 main_LDADD = ../lib/libfeep.la
77
78 TESTS = main
79 EOF
80
81 libtoolize
82 $ACLOCAL
83 $AUTOCONF
84 $AUTOMAKE -a
85 ./configure
86 $MAKE distcheck
87
88
89 ## ------------------------------------------ ##
90 ## Traditional LIBOBJS with LIBOBJDIR set.    ##
91 ## ------------------------------------------ ##
92
93 # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
94 # unrelated to Automake or Makefile.am layout.
95
96 sed 's/#: //' configure.in >configure.int
97 mv -f configure.int configure.in
98
99 $ACLOCAL
100 $AUTOCONF
101 $AUTOMAKE -a
102 ./configure
103 test ! -d lib/lib
104 $MAKE distcheck
105
106 ## -------------------------------------------- ##
107 ## Error message with usage in wrong directory. ##
108 ## -------------------------------------------- ##
109
110 mv -f src/Makefile.am src/t
111 sed 's/LDADD = .*/LDADD = @LTLIBOBJS@/' src/t > src/Makefile.am
112 AUTOMAKE_fails
113 grep 'cannot be used outside.*lib' stderr
114 mv -f src/t src/Makefile.am
115
116 ## ---------------------------------------------- ##
117 ## Test using LTLIBOBJS from a sibling directory. ##
118 ## ---------------------------------------------- ##
119
120 sed 's/#x //; s/lib\/Makefile //' configure.in >configure.int
121 mv -f configure.int configure.in
122
123 cat >Makefile.am <<'EOF'
124 SUBDIRS = src
125 EOF
126
127 cat > src/Makefile.am <<'EOF'
128 AUTOMAKE_OPTIONS = subdir-objects
129
130 noinst_LTLIBRARIES = libfeep.la
131 libfeep_la_SOURCES =
132 libfeep_la_LIBADD = $(LTLIBOBJS)
133
134 check_PROGRAMS = main
135 main_LDADD = libfeep.la
136
137 TESTS = main
138 EOF
139
140 $ACLOCAL
141 $AUTOCONF
142 $AUTOMAKE --add-missing
143 ./configure
144 test ! -d src/lib
145 test ! -d 'src/$(top_builddir)'
146 $MAKE
147 $MAKE check
148 $MAKE distclean
149
150
151 ## ------------------------------------------- ##
152 ## Test using LTLIBOBJS from parent directory. ##
153 ## ------------------------------------------- ##
154
155 sed 's/^.*src\/Makefile.*$//' configure.in >configure.int
156 mv -f configure.int configure.in
157
158 cat >Makefile.am <<'EOF'
159 AUTOMAKE_OPTIONS = subdir-objects
160
161 noinst_LTLIBRARIES = lib/libfeep.la
162 lib_libfeep_la_SOURCES =
163 lib_libfeep_la_LIBADD = $(LTLIBOBJS)
164
165 check_PROGRAMS = src/main
166 src_main_SOURCES = src/main.c
167 src_main_LDADD = lib/libfeep.la
168
169 TESTS = src/main
170
171 check-local:
172         test -f src/main.$(OBJEXT)
173         test -f lib/feep.lo
174         test ! -f src/$(DEPDIR)/feep.Po
175 EOF
176
177 $ACLOCAL
178 $AUTOCONF
179 $AUTOMAKE
180 ./configure
181 $MAKE distcheck