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