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