2 # Copyright (C) 2005-2013 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 LIBOBJS.
18 # (pr401b.sh and pr401c.sh do the same for LTLIBOBJS and ALLOCA)
25 cat >lib/feep.c <<'EOF'
26 const char *feep (void)
32 cat >src/main.c <<'EOF'
35 extern const char *feep (void);
44 cat >>configure.ac << 'EOF'
45 ## These lines are activated for later tests
46 #: AC_CONFIG_LIBOBJ_DIR([lib])
49 AC_LIBSOURCE([feep.c])
52 AC_CONFIG_FILES([lib/Makefile src/Makefile])
53 AM_CONDITIONAL([CROSS_COMPILING], [test $cross_compiling = yes])
57 ## ------------------------------------------ ##
58 ## First a test of traditional LIBOBJS usage. ##
59 ## ------------------------------------------ ##
61 cat >Makefile.am <<'EOF'
65 cat >lib/Makefile.am <<'EOF'
66 noinst_LIBRARIES = libfeep.a
68 libfeep_a_LIBADD = $(LIBOBJS)
71 cat >src/Makefile.am <<'EOF'
73 main_LDADD = ../lib/libfeep.a
80 cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
88 ## ------------------------------------------ ##
89 ## Traditional LIBOBJS with LIBOBJDIR set. ##
90 ## ------------------------------------------ ##
92 # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
93 # unrelated to Automake or Makefile.am layout.
95 sed 's/#: //' configure.ac >configure.tmp
96 mv -f configure.tmp configure.ac
105 ## -------------------------------------------- ##
106 ## Error message with usage in wrong directory. ##
107 ## -------------------------------------------- ##
109 mv -f src/Makefile.am src/t
110 sed 's/LDADD = .*/LDADD = @LIBOBJS@/' src/t > src/Makefile.am
112 grep 'cannot be used outside.*lib' stderr
113 mv -f src/t src/Makefile.am
116 ## -------------------------------------------- ##
117 ## Test using LIBOBJS from a sibling directory. ##
118 ## -------------------------------------------- ##
120 sed 's/lib\/Makefile //' configure.ac >configure.tmp
121 mv -f configure.tmp configure.ac
123 cat >Makefile.am <<'EOF'
127 cat > src/Makefile.am <<'EOF'
128 AUTOMAKE_OPTIONS = subdir-objects
130 noinst_LIBRARIES = libfeep.a
132 libfeep_a_LIBADD = $(LIBOBJS)
134 check_PROGRAMS = main
135 main_LDADD = libfeep.a
144 $AUTOMAKE --add-missing
147 test ! -e 'src/$(top_builddir)'
153 ## ----------------------------------------- ##
154 ## Test using LIBOBJS from parent directory. ##
155 ## ----------------------------------------- ##
157 sed 's/^.*src\/Makefile.*$//' configure.ac >configure.tmp
158 mv -f configure.tmp configure.ac
160 cat >Makefile.am <<'EOF'
161 AUTOMAKE_OPTIONS = subdir-objects
163 noinst_LIBRARIES = lib/libfeep.a
164 lib_libfeep_a_SOURCES =
165 lib_libfeep_a_LIBADD = $(LIBOBJS)
167 check_PROGRAMS = src/main
168 src_main_SOURCES = src/main.c
169 src_main_LDADD = lib/libfeep.a
176 test -f src/main.$(OBJEXT)
177 test -f lib/feep.$(OBJEXT)
178 test ! -f src/$(DEPDIR)/feep.Po