tests: work around strangeness in MSYS
[automake.git] / tests / pr401b.test
blob961f6381c9d578a538b678efed7d077e29213a4e
1 #! /bin/sh
2 # Copyright (C) 2005, 2006, 2007, 2010, 2011 Free Software Foundation,
3 # Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Check support for AC_CONFIG_LIBOBJ_DIR vs LTLIBOBJS.
19 # (pr401.test and pr401c.test do the same for LIBOBJS and ALLOCA)
21 am_parallel_tests=no
22 required='cc libtoolize'
23 . ./defs || Exit 1
25 mkdir lib src
27 cat >lib/feep.c <<'EOF'
28 const char *feep (void)
30 return "feep";
32 EOF
34 cat >src/main.c <<'EOF'
35 #include <stdio.h>
37 extern const char *feep (void);
39 int main (void)
41 puts (feep ());
42 return 0;
44 EOF
46 cat >>configure.in << '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 AC_LIBOBJ([feep])
52 AC_LIBSOURCE([feep.c])
53 AC_PROG_LIBTOOL
54 AC_CONFIG_FILES([lib/Makefile src/Makefile])
55 AM_CONDITIONAL([CROSS_COMPILING], [test $cross_compiling = yes])
56 AC_OUTPUT
57 EOF
59 ## -------------------------------------------- ##
60 ## First a test of traditional LTLIBOBJS usage. ##
61 ## -------------------------------------------- ##
63 cat >Makefile.am <<'EOF'
64 SUBDIRS = lib src
65 EOF
67 cat >lib/Makefile.am <<'EOF'
68 noinst_LTLIBRARIES = libfeep.la
69 libfeep_la_SOURCES =
70 libfeep_la_LIBADD = $(LTLIBOBJS)
71 EOF
73 cat >src/Makefile.am <<'EOF'
74 check_PROGRAMS = main
75 main_LDADD = ../lib/libfeep.la
77 if !CROSS_COMPILING
78 TESTS = main
79 endif
80 EOF
82 libtoolize
83 $ACLOCAL
84 $AUTOCONF
85 $AUTOMAKE -Wno-extra-portability -a
86 ./configure
87 $MAKE distcheck
89 ## ----------------------------------------- ##
90 ## Traditional LTLIBOBJS with LIBOBJDIR set. ##
91 ## ----------------------------------------- ##
93 # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
94 # unrelated to Automake or Makefile.am layout.
96 sed 's/#: //' configure.in >configure.int
97 mv -f configure.int configure.in
99 $ACLOCAL
100 $AUTOCONF
101 $AUTOMAKE -Wno-extra-portability -a
102 ./configure
103 test ! -d lib/lib
104 $MAKE distcheck
106 ## -------------------------------------------- ##
107 ## Error message with usage in wrong directory. ##
108 ## -------------------------------------------- ##
110 mv -f src/Makefile.am src/t
111 sed 's/LDADD = .*/LDADD = @LTLIBOBJS@/' src/t > src/Makefile.am
112 AUTOMAKE_fails -Wno-extra-portability
113 grep 'cannot be used outside.*lib' stderr
114 mv -f src/t src/Makefile.am
116 ## ---------------------------------------------- ##
117 ## Test using LTLIBOBJS from a sibling directory. ##
118 ## ---------------------------------------------- ##
120 sed 's/#x //; s/lib\/Makefile //' configure.in >configure.int
121 mv -f configure.int configure.in
123 cat >Makefile.am <<'EOF'
124 SUBDIRS = src
127 cat > src/Makefile.am <<'EOF'
128 AUTOMAKE_OPTIONS = subdir-objects
130 noinst_LTLIBRARIES = libfeep.la
131 libfeep_la_SOURCES =
132 libfeep_la_LIBADD = $(LTLIBOBJS)
134 check_PROGRAMS = main
135 main_LDADD = libfeep.la
137 if !CROSS_COMPILING
138 TESTS = main
139 endif
142 $ACLOCAL
143 $AUTOCONF
144 $AUTOMAKE -Wno-extra-portability --add-missing
145 ./configure
146 test ! -d src/lib
147 test ! -d 'src/$(top_builddir)'
148 $MAKE
149 $MAKE check
150 $MAKE distclean
153 ## ------------------------------------------- ##
154 ## Test using LTLIBOBJS from parent directory. ##
155 ## ------------------------------------------- ##
157 sed 's/^.*src\/Makefile.*$//' configure.in >configure.int
158 mv -f configure.int configure.in
160 cat >Makefile.am <<'EOF'
161 AUTOMAKE_OPTIONS = subdir-objects
163 noinst_LTLIBRARIES = lib/libfeep.la
164 lib_libfeep_la_SOURCES =
165 lib_libfeep_la_LIBADD = $(LTLIBOBJS)
167 check_PROGRAMS = src/main
168 src_main_SOURCES = src/main.c
169 src_main_LDADD = lib/libfeep.la
171 if !CROSS_COMPILING
172 TESTS = src/main
173 endif
175 check-local:
176 test -f src/main.$(OBJEXT)
177 test -f lib/feep.lo
178 test ! -f src/$(DEPDIR)/feep.Po
181 $ACLOCAL
182 $AUTOCONF
183 $AUTOMAKE -Wno-extra-portability
184 ./configure
185 $MAKE distcheck