Support more C++ file extensions for MSVC in the compile script.
[platform/upstream/automake.git] / tests / pr401.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 LIBOBJS.
18 # (pr401b.test and pr401c.test do the same for LTLIBOBJS and ALLOCA)
19
20 required=gcc
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_RANLIB
56 AC_CONFIG_FILES([lib/Makefile src/Makefile])
57 AC_OUTPUT
58 EOF
59
60 ## ------------------------------------------ ##
61 ## First a test of traditional LIBOBJS usage. ##
62 ## ------------------------------------------ ##
63
64 cat >Makefile.am <<'EOF'
65 SUBDIRS = lib src
66 EOF
67
68 cat >lib/Makefile.am <<'EOF'
69 noinst_LIBRARIES = libfeep.a
70 libfeep_a_SOURCES =
71 libfeep_a_LIBADD = $(LIBOBJS)
72 EOF
73
74 cat >src/Makefile.am <<'EOF'
75 check_PROGRAMS = main
76 main_LDADD = ../lib/libfeep.a
77
78 TESTS = main
79 EOF
80
81 $ACLOCAL
82 $AUTOCONF
83 $AUTOMAKE
84 ./configure
85 $MAKE distcheck
86
87 ## ------------------------------------------ ##
88 ## Traditional LIBOBJS with LIBOBJDIR set.    ##
89 ## ------------------------------------------ ##
90
91 # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
92 # unrelated to Automake or Makefile.am layout.
93
94 sed 's/#: //' configure.in >configure.int
95 mv -f configure.int configure.in
96
97 $ACLOCAL
98 $AUTOCONF
99 $AUTOMAKE
100 ./configure
101 test ! -d lib/lib
102 $MAKE distcheck
103
104 ## -------------------------------------------- ##
105 ## Error message with usage in wrong directory. ##
106 ## -------------------------------------------- ##
107
108 mv -f src/Makefile.am src/t
109 sed 's/LDADD = .*/LDADD = @LIBOBJS@/' src/t > src/Makefile.am
110 AUTOMAKE_fails
111 grep 'cannot be used outside.*lib' stderr
112 mv -f src/t src/Makefile.am
113
114
115 ## -------------------------------------------- ##
116 ## Test using LIBOBJS from a sibling directory. ##
117 ## -------------------------------------------- ##
118
119 sed 's/#x //; s/lib\/Makefile //' configure.in >configure.int
120 mv -f configure.int configure.in
121
122 cat >Makefile.am <<'EOF'
123 SUBDIRS = src
124 EOF
125
126 cat > src/Makefile.am <<'EOF'
127 AUTOMAKE_OPTIONS = subdir-objects
128
129 noinst_LIBRARIES = libfeep.a
130 libfeep_a_SOURCES =
131 libfeep_a_LIBADD = $(LIBOBJS)
132
133 check_PROGRAMS = main
134 main_LDADD = libfeep.a
135
136 TESTS = main
137 EOF
138
139 $ACLOCAL
140 $AUTOCONF
141 $AUTOMAKE --add-missing
142 ./configure
143 test ! -d src/lib
144 test ! -d 'src/$(top_builddir)'
145 $MAKE
146 $MAKE check
147 $MAKE distclean
148
149
150 ## ----------------------------------------- ##
151 ## Test using LIBOBJS from parent directory. ##
152 ## ----------------------------------------- ##
153
154 sed 's/^.*src\/Makefile.*$//' configure.in >configure.int
155 mv -f configure.int configure.in
156
157 cat >Makefile.am <<'EOF'
158 AUTOMAKE_OPTIONS = subdir-objects
159
160 noinst_LIBRARIES = lib/libfeep.a
161 lib_libfeep_a_SOURCES =
162 lib_libfeep_a_LIBADD = $(LIBOBJS)
163
164 check_PROGRAMS = src/main
165 src_main_SOURCES = src/main.c
166 src_main_LDADD = lib/libfeep.a
167
168 TESTS = src/main
169
170 check-local:
171         test -f src/main.$(OBJEXT)
172         test -f lib/feep.$(OBJEXT)
173         test ! -f src/$(DEPDIR)/feep.Po
174 EOF
175
176 $ACLOCAL
177 $AUTOCONF
178 $AUTOMAKE
179 ./configure
180 $MAKE distcheck