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