2 # Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
4 # This file is part of GNU Automake.
6 # GNU Automake is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
11 # GNU Automake is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Automake; see the file COPYING. If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 # Boston, MA 02110-1301, USA.
21 # Check support for AC_CONFIG_LIBOBJ_DIR vs ALLOCA.
22 # (pr401.test and pr401b.test do the same for LIBOBJS and LTLIBOBJS)
31 ac_cv_func_alloca_works=no
32 export ac_cv_func_alloca_works
34 cat >lib/alloca.c <<'EOF'
42 cat >src/main.c <<'EOF'
48 main (int argc, char **argv)
55 cat >>configure.in << 'EOF'
56 ## These lines are activated for later tests
57 #: AC_CONFIG_LIBOBJ_DIR([lib])
62 AC_CONFIG_FILES([lib/Makefile src/Makefile])
66 ## ----------------------------------------- ##
67 ## First a test of traditional ALLOCA usage. ##
68 ## ----------------------------------------- ##
70 cat >Makefile.am <<'EOF'
74 cat >lib/Makefile.am <<'EOF'
75 noinst_LIBRARIES = libfeep.a
77 libfeep_a_LIBADD = $(ALLOCA)
80 cat >src/Makefile.am <<'EOF'
82 main_LDADD = ../lib/libfeep.a
94 ## ------------------------------------------ ##
95 ## Traditional LIBOBJS with LIBOBJDIR set. ##
96 ## ------------------------------------------ ##
98 # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
99 # unrelated to Automake or Makefile.am layout.
101 sed 's/#: //' configure.in >configure.int
102 mv -f configure.int configure.in
111 ## -------------------------------------------- ##
112 ## Error message with usage in wrong directory. ##
113 ## -------------------------------------------- ##
115 mv -f src/Makefile.am src/t
116 sed 's/LDADD = .*/LDADD = @ALLOCA@/' src/t > src/Makefile.am
118 grep 'cannot be used outside.*lib' stderr
119 mv -f src/t src/Makefile.am
122 ## ------------------------------------------- ##
123 ## Test using ALLOCA from a sibling directory. ##
124 ## ------------------------------------------- ##
126 sed 's/#x //; s/lib\/Makefile //' configure.in >configure.int
127 mv -f configure.int configure.in
129 cat >Makefile.am <<'EOF'
133 cat > src/Makefile.am <<'EOF'
134 AUTOMAKE_OPTIONS = subdir-objects
136 noinst_LIBRARIES = libfeep.a
138 libfeep_a_LIBADD = $(ALLOCA) $(LIBOBJS) # Add LIBOBJS for fun
140 check_PROGRAMS = main
141 main_LDADD = libfeep.a
148 $AUTOMAKE --add-missing
152 test ! -d 'src/$(top_builddir)'
157 ## ---------------------------------------- ##
158 ## Test using ALLOCA from parent directory. ##
159 ## ---------------------------------------- ##
161 sed 's/^.*src\/Makefile.*$//' configure.in >configure.int
162 mv -f configure.int configure.in
164 cat >Makefile.am <<'EOF'
165 AUTOMAKE_OPTIONS = subdir-objects
167 noinst_LIBRARIES = lib/libfeep.a
168 lib_libfeep_a_SOURCES =
169 lib_libfeep_a_LIBADD = $(ALLOCA)
171 check_PROGRAMS = src/main
172 src_main_SOURCES = src/main.c
173 src_main_LDADD = lib/libfeep.a
178 test -f src/main.$(OBJEXT)
179 test -f lib/alloca.$(OBJEXT)
180 test ! -f src/$(DEPDIR)/alloca.Po