configure: remove an obsolete TODO comment
[platform/upstream/automake.git] / t / pr401c.sh
1 #! /bin/sh
2 # Copyright (C) 2005-2013 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.sh and pr401b.sh do the same for LIBOBJS and LTLIBOBJS)
19
20 required=cc
21 . test-init.sh
22
23 mkdir lib src
24
25 ac_cv_func_alloca_works=no; export ac_cv_func_alloca_works
26
27 cat >lib/alloca.c <<'EOF'
28 const char *feep (void)
29 {
30   return "feep";
31 }
32 EOF
33
34 cat >src/main.c <<'EOF'
35 #include <stdio.h>
36
37 extern const char *feep (void);
38
39 int main (void)
40 {
41   puts (feep ());
42   return 0;
43 }
44 EOF
45
46 cat >>configure.ac << 'EOF'
47 ## These lines are activated for later tests.
48 #: AC_CONFIG_LIBOBJ_DIR([lib])
49 AC_PROG_CC
50 #x AM_PROG_CC_C_O
51 AM_PROG_AR
52 AC_PROG_RANLIB
53 AC_FUNC_ALLOCA
54 AC_CONFIG_FILES([lib/Makefile src/Makefile])
55 AM_CONDITIONAL([CROSS_COMPILING], [test $cross_compiling = yes])
56 AC_OUTPUT
57 EOF
58
59 ## ----------------------------------------- ##
60 ## First a test of traditional ALLOCA usage. ##
61 ## ----------------------------------------- ##
62
63 cat >Makefile.am <<'EOF'
64 SUBDIRS = lib src
65 EOF
66
67 cat >lib/Makefile.am <<'EOF'
68 noinst_LIBRARIES = libfeep.a
69 libfeep_a_SOURCES =
70 libfeep_a_LIBADD = $(ALLOCA)
71 EOF
72
73 cat >src/Makefile.am <<'EOF'
74 check_PROGRAMS = main
75 main_LDADD = ../lib/libfeep.a
76
77 if !CROSS_COMPILING
78 TESTS = main
79 endif
80 EOF
81
82 cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
83
84 $ACLOCAL
85 $AUTOCONF
86 $AUTOMAKE -a
87 ./configure
88 $MAKE distcheck
89
90
91 ## --------------------------------------- ##
92 ## Traditional ALLOCA 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.ac >configure.tmp
99 mv -f configure.tmp configure.ac
100
101 $ACLOCAL
102 $AUTOCONF
103 $AUTOMAKE
104 ./configure
105 test ! -e 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
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.ac >configure.tmp
124 mv -f configure.tmp configure.ac
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 if !CROSS_COMPILING
141 TESTS = main
142 endif
143 EOF
144
145 $ACLOCAL
146 $AUTOCONF
147 $AUTOMAKE --add-missing
148 ./configure
149 $MAKE
150 test ! -e src/lib
151 test ! -e 'src/$(top_builddir)'
152 $MAKE check
153 $MAKE distclean
154
155
156 ## ---------------------------------------- ##
157 ## Test using ALLOCA from parent directory. ##
158 ## ---------------------------------------- ##
159
160 sed 's/^.*src\/Makefile.*$//' configure.ac >configure.tmp
161 mv -f configure.tmp configure.ac
162
163 cat >Makefile.am <<'EOF'
164 AUTOMAKE_OPTIONS = subdir-objects
165
166 noinst_LIBRARIES = lib/libfeep.a
167 lib_libfeep_a_SOURCES =
168 lib_libfeep_a_LIBADD = $(ALLOCA)
169
170 check_PROGRAMS = src/main
171 src_main_SOURCES = src/main.c
172 src_main_LDADD = lib/libfeep.a
173
174 if !CROSS_COMPILING
175 TESTS = src/main
176 endif
177
178 check-local:
179         test -f src/main.$(OBJEXT)
180         test -f lib/alloca.$(OBJEXT)
181         test ! -f src/$(DEPDIR)/alloca.Po
182 EOF
183
184 $ACLOCAL
185 $AUTOCONF
186 $AUTOMAKE
187 ./configure
188 $MAKE distcheck
189
190 :