Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / pr401b.test
1 #! /bin/sh
2 # Copyright (C) 2005, 2006, 2007, 2010 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 LTLIBOBJS.
18 # (pr401.test and pr401c.test do the same for LIBOBJS and ALLOCA)
19
20 parallel_tests=no
21 required='gcc libtoolize'
22 . ./defs || Exit 1
23
24 set -e
25
26 mkdir lib src
27
28 cat >lib/feep.c <<'EOF'
29 char *
30 feep ()
31 {
32   return "feep";
33 }
34 EOF
35
36 cat >src/main.c <<'EOF'
37 #include <stdio.h>
38
39 extern char *feep ();
40
41 int
42 main (int argc, char **argv)
43 {
44   puts (feep ());
45   return 0;
46 }
47 EOF
48
49 cat >>configure.in << 'EOF'
50 ## These lines are activated for later tests
51 #: AC_CONFIG_LIBOBJ_DIR([lib])
52 AC_PROG_CC
53 #x AM_PROG_CC_C_O
54 AC_LIBOBJ([feep])
55 AC_LIBSOURCE([feep.c])
56 AC_PROG_LIBTOOL
57 AC_CONFIG_FILES([lib/Makefile src/Makefile])
58 AC_OUTPUT
59 EOF
60
61 ## -------------------------------------------- ##
62 ## First a test of traditional LTLIBOBJS usage. ##
63 ## -------------------------------------------- ##
64
65 cat >Makefile.am <<'EOF'
66 SUBDIRS = lib src
67 EOF
68
69 cat >lib/Makefile.am <<'EOF'
70 noinst_LTLIBRARIES = libfeep.la
71 libfeep_la_SOURCES =
72 libfeep_la_LIBADD = $(LTLIBOBJS)
73 EOF
74
75 cat >src/Makefile.am <<'EOF'
76 check_PROGRAMS = main
77 main_LDADD = ../lib/libfeep.la
78
79 TESTS = main
80 EOF
81
82 libtoolize
83 $ACLOCAL
84 $AUTOCONF
85 $AUTOMAKE -Wno-extra-portability -a
86 ./configure
87 $MAKE distcheck
88
89
90 ## ------------------------------------------ ##
91 ## Traditional LIBOBJS with LIBOBJDIR set.    ##
92 ## ------------------------------------------ ##
93
94 # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
95 # unrelated to Automake or Makefile.am layout.
96
97 sed 's/#: //' configure.in >configure.int
98 mv -f configure.int configure.in
99
100 $ACLOCAL
101 $AUTOCONF
102 $AUTOMAKE -Wno-extra-portability -a
103 ./configure
104 test ! -d lib/lib
105 $MAKE distcheck
106
107 ## -------------------------------------------- ##
108 ## Error message with usage in wrong directory. ##
109 ## -------------------------------------------- ##
110
111 mv -f src/Makefile.am src/t
112 sed 's/LDADD = .*/LDADD = @LTLIBOBJS@/' src/t > src/Makefile.am
113 AUTOMAKE_fails -Wno-extra-portability
114 grep 'cannot be used outside.*lib' stderr
115 mv -f src/t src/Makefile.am
116
117 ## ---------------------------------------------- ##
118 ## Test using LTLIBOBJS from a sibling directory. ##
119 ## ---------------------------------------------- ##
120
121 sed 's/#x //; s/lib\/Makefile //' configure.in >configure.int
122 mv -f configure.int configure.in
123
124 cat >Makefile.am <<'EOF'
125 SUBDIRS = src
126 EOF
127
128 cat > src/Makefile.am <<'EOF'
129 AUTOMAKE_OPTIONS = subdir-objects
130
131 noinst_LTLIBRARIES = libfeep.la
132 libfeep_la_SOURCES =
133 libfeep_la_LIBADD = $(LTLIBOBJS)
134
135 check_PROGRAMS = main
136 main_LDADD = libfeep.la
137
138 TESTS = main
139 EOF
140
141 $ACLOCAL
142 $AUTOCONF
143 $AUTOMAKE -Wno-extra-portability --add-missing
144 ./configure
145 test ! -d src/lib
146 test ! -d 'src/$(top_builddir)'
147 $MAKE
148 $MAKE check
149 $MAKE distclean
150
151
152 ## ------------------------------------------- ##
153 ## Test using LTLIBOBJS from parent directory. ##
154 ## ------------------------------------------- ##
155
156 sed 's/^.*src\/Makefile.*$//' configure.in >configure.int
157 mv -f configure.int configure.in
158
159 cat >Makefile.am <<'EOF'
160 AUTOMAKE_OPTIONS = subdir-objects
161
162 noinst_LTLIBRARIES = lib/libfeep.la
163 lib_libfeep_la_SOURCES =
164 lib_libfeep_la_LIBADD = $(LTLIBOBJS)
165
166 check_PROGRAMS = src/main
167 src_main_SOURCES = src/main.c
168 src_main_LDADD = lib/libfeep.la
169
170 TESTS = src/main
171
172 check-local:
173         test -f src/main.$(OBJEXT)
174         test -f lib/feep.lo
175         test ! -f src/$(DEPDIR)/feep.Po
176 EOF
177
178 $ACLOCAL
179 $AUTOCONF
180 $AUTOMAKE -Wno-extra-portability
181 ./configure
182 $MAKE distcheck
183
184 :