2 # Copyright (C) 2005-2012 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)
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 <http://www.gnu.org/licenses/>.
17 # Check support for AC_CONFIG_LIBOBJ_DIR vs ALLOCA.
18 # (pr401.test and pr401b.test do the same for LIBOBJS and LTLIBOBJS)
26 ac_cv_func_alloca_works=no
27 export ac_cv_func_alloca_works
29 cat >lib/alloca.c <<'EOF'
30 const char *feep (void)
36 cat >src/main.c <<'EOF'
39 extern const char *feep (void);
48 cat >>configure.ac << 'EOF'
49 ## These lines are activated for later tests.
50 #: AC_CONFIG_LIBOBJ_DIR([lib])
56 AC_CONFIG_FILES([lib/Makefile src/Makefile])
57 AM_CONDITIONAL([CROSS_COMPILING], [test $cross_compiling = yes])
61 ## ----------------------------------------- ##
62 ## First a test of traditional ALLOCA usage. ##
63 ## ----------------------------------------- ##
65 cat >Makefile.am <<'EOF'
69 cat >lib/Makefile.am <<'EOF'
70 noinst_LIBRARIES = libfeep.a
72 libfeep_a_LIBADD = $(ALLOCA)
75 cat >src/Makefile.am <<'EOF'
77 main_LDADD = ../lib/libfeep.a
84 cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
93 ## --------------------------------------- ##
94 ## Traditional ALLOCA with LIBOBJDIR set. ##
95 ## --------------------------------------- ##
97 # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
98 # unrelated to Automake or Makefile.am layout.
100 sed 's/#: //' configure.ac >configure.int
101 mv -f configure.int configure.ac
110 ## -------------------------------------------- ##
111 ## Error message with usage in wrong directory. ##
112 ## -------------------------------------------- ##
114 mv -f src/Makefile.am src/t
115 sed 's/LDADD = .*/LDADD = @ALLOCA@/' src/t > src/Makefile.am
117 grep 'cannot be used outside.*lib' stderr
118 mv -f src/t src/Makefile.am
121 ## ------------------------------------------- ##
122 ## Test using ALLOCA from a sibling directory. ##
123 ## ------------------------------------------- ##
125 sed 's/#x //; s/lib\/Makefile //' configure.ac >configure.int
126 mv -f configure.int configure.ac
128 cat >Makefile.am <<'EOF'
132 cat > src/Makefile.am <<'EOF'
133 AUTOMAKE_OPTIONS = subdir-objects
135 noinst_LIBRARIES = libfeep.a
137 libfeep_a_LIBADD = $(ALLOCA) $(LIBOBJS) # Add LIBOBJS for fun.
139 check_PROGRAMS = main
140 main_LDADD = libfeep.a
149 $AUTOMAKE --add-missing
153 test ! -d 'src/$(top_builddir)'
158 ## ---------------------------------------- ##
159 ## Test using ALLOCA from parent directory. ##
160 ## ---------------------------------------- ##
162 sed 's/^.*src\/Makefile.*$//' configure.ac >configure.int
163 mv -f configure.int configure.ac
165 cat >Makefile.am <<'EOF'
166 AUTOMAKE_OPTIONS = subdir-objects
168 noinst_LIBRARIES = lib/libfeep.a
169 lib_libfeep_a_SOURCES =
170 lib_libfeep_a_LIBADD = $(ALLOCA)
172 check_PROGRAMS = src/main
173 src_main_SOURCES = src/main.c
174 src_main_LDADD = lib/libfeep.a
181 test -f src/main.$(OBJEXT)
182 test -f lib/alloca.$(OBJEXT)
183 test ! -f src/$(DEPDIR)/alloca.Po