tests: rename 'tests/' => 't/', '*.test' => '*.sh'
[platform/upstream/automake.git] / t / pr401b.sh
1 #! /bin/sh
2 # Copyright (C) 2005-2012 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 am_parallel_tests=no
21 required='cc libtoolize'
22 . ./defs || Exit 1
23
24 mkdir lib src
25
26 cat >lib/feep.c <<'EOF'
27 const char *feep (void)
28 {
29   return "feep";
30 }
31 EOF
32
33 cat >src/main.c <<'EOF'
34 #include <stdio.h>
35
36 extern const char *feep (void);
37
38 int main (void)
39 {
40   puts (feep ());
41   return 0;
42 }
43 EOF
44
45 cat >>configure.ac << 'EOF'
46 ## These lines are activated for later tests
47 #: AC_CONFIG_LIBOBJ_DIR([lib])
48 AC_PROG_CC
49 #x AM_PROG_CC_C_O
50 AC_LIBOBJ([feep])
51 AC_LIBSOURCE([feep.c])
52 AM_PROG_AR
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
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 if !CROSS_COMPILING
78 TESTS = main
79 endif
80 EOF
81
82 cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
83
84 libtoolize
85 $ACLOCAL
86 $AUTOCONF
87 $AUTOMAKE -a
88 ./configure
89 $MAKE distcheck
90
91 ## ----------------------------------------- ##
92 ## Traditional LTLIBOBJS with LIBOBJDIR set. ##
93 ## ----------------------------------------- ##
94
95 # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
96 # unrelated to Automake or Makefile.am layout.
97
98 sed 's/#: //' configure.ac >configure.int
99 mv -f configure.int configure.ac
100
101 $ACLOCAL
102 $AUTOCONF
103 $AUTOMAKE -a
104 ./configure
105 test ! -d lib/lib
106 $MAKE distcheck
107
108 ## -------------------------------------------- ##
109 ## Error message with usage in wrong directory. ##
110 ## -------------------------------------------- ##
111
112 mv -f src/Makefile.am src/t
113 sed 's/LDADD = .*/LDADD = @LTLIBOBJS@/' src/t > src/Makefile.am
114 AUTOMAKE_fails
115 grep 'cannot be used outside.*lib' stderr
116 mv -f src/t src/Makefile.am
117
118 ## ---------------------------------------------- ##
119 ## Test using LTLIBOBJS from a sibling directory. ##
120 ## ---------------------------------------------- ##
121
122 sed 's/#x //; s/lib\/Makefile //' configure.ac >configure.int
123 mv -f configure.int configure.ac
124
125 cat >Makefile.am <<'EOF'
126 SUBDIRS = src
127 EOF
128
129 cat > src/Makefile.am <<'EOF'
130 AUTOMAKE_OPTIONS = subdir-objects
131
132 noinst_LTLIBRARIES = libfeep.la
133 libfeep_la_SOURCES =
134 libfeep_la_LIBADD = $(LTLIBOBJS)
135
136 check_PROGRAMS = main
137 main_LDADD = libfeep.la
138
139 if !CROSS_COMPILING
140 TESTS = main
141 endif
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.ac >configure.int
160 mv -f configure.int configure.ac
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 if !CROSS_COMPILING
174 TESTS = src/main
175 endif
176
177 check-local:
178         test -f src/main.$(OBJEXT)
179         test -f lib/feep.lo
180         test ! -f src/$(DEPDIR)/feep.Po
181 EOF
182
183 $ACLOCAL
184 $AUTOCONF
185 $AUTOMAKE
186 ./configure
187 $MAKE distcheck
188
189 :