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