doc: typos in test file.
[automake.git] / t / ltconv.sh
blob288da58726828a437d3fee51fe825cb95b8b683f
1 #!/bin/sh
2 # Copyright (C) 2003-2024 Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Test for libtool convenience libraries.
18 # This example is taken from the manual.
20 required='cc native libtoolize'
21 . test-init.sh
23 cat >>configure.ac <<'END'
24 AC_PROG_CC
25 AM_PROG_AR
26 AC_PROG_LIBTOOL
27 AC_CONFIG_FILES([sub1/Makefile
28 sub2/Makefile
29 sub2/sub21/Makefile
30 sub2/sub22/Makefile])
31 AC_OUTPUT
32 END
34 mkdir sub1
35 mkdir sub2
36 mkdir sub2/sub21
37 mkdir sub2/sub22
38 mkdir empty
40 cat >Makefile.am <<'END'
41 SUBDIRS = sub1 sub2
42 lib_LTLIBRARIES = libtop.la
43 libtop_la_SOURCES =
44 libtop_la_LIBADD = \
45 sub1/libsub1.la \
46 sub2/libsub2.la
48 bin_PROGRAMS = ltconvtest
49 ltconvtest_SOURCES = test.c
50 ltconvtest_LDADD = libtop.la
52 check-local:
53 ./ltconvtest$(EXEEXT)
54 : > check-ok
55 installcheck-local:
56 $(bindir)/ltconvtest$(EXEEXT)
57 : > installcheck-ok
58 END
60 cat >sub1/Makefile.am <<'END'
61 noinst_LTLIBRARIES = libsub1.la
62 libsub1_la_SOURCES = sub1.c
63 END
65 echo 'int sub1 () { return 1; }' > sub1/sub1.c
67 cat >sub2/Makefile.am <<'END'
68 SUBDIRS = sub21 sub22
69 noinst_LTLIBRARIES = libsub2.la
70 libsub2_la_SOURCES = sub2.c
71 libsub2_la_LIBADD = \
72 sub21/libsub21.la \
73 sub22/libsub22.la
74 END
76 echo 'int sub2 () { return 2; }' > sub2/sub2.c
78 cat >sub2/sub21/Makefile.am <<'END'
79 noinst_LTLIBRARIES = libsub21.la
80 libsub21_la_SOURCES = sub21.c
81 END
83 echo 'int sub21 () { return 21; }' > sub2/sub21/sub21.c
85 cat >sub2/sub22/Makefile.am <<'END'
86 noinst_LTLIBRARIES = libsub22.la
87 libsub22_la_SOURCES = sub22.c
88 END
90 echo 'int sub22 () { return 22; }' > sub2/sub22/sub22.c
92 cat >test.c <<'EOF'
93 #include <stdio.h>
95 extern int sub1 (void);
96 extern int sub2 (void);
97 extern int sub21 (void);
98 extern int sub22 (void);
100 int main ()
102 if (1 != sub1 ())
103 return 1;
104 if (2 != sub2 ())
105 return 2;
106 if (21 != sub21 ())
107 return 3;
108 if (22 != sub22 ())
109 return 4;
110 return 0;
114 libtoolize
115 $ACLOCAL
116 $AUTOCONF
117 $AUTOMAKE --add-missing
119 cwd=$(pwd) || fatal_ "getting current working directory"
121 # Install libraries in lib/, programs in bin/, and the rest in empty/.
122 # (in fact there is no "rest", so as the name imply empty/ is
123 # expected to remain empty).
124 ./configure --prefix="$cwd/empty" --libdir="$cwd/lib" --bindir="$cwd/bin"
126 $MAKE
127 test -f libtop.la
128 test -f sub1/libsub1.la
129 test -f sub2/libsub2.la
130 test -f sub2/sub21/libsub21.la
131 test -f sub2/sub22/libsub22.la
132 $MAKE check
133 test -f check-ok
134 rm -f check-ok
136 $MAKE install
137 test -f lib/libtop.la
138 $MAKE installcheck
139 test -f installcheck-ok
140 rm -f installcheck-ok
142 find empty -type f -print > empty.lst
143 test -s empty.lst && { cat empty.lst; exit 1; }
145 $MAKE clean
146 test ! -e libtop.la
147 test ! -e sub1/libsub1.la
148 test ! -e sub2/libsub2.la
149 test ! -e sub2/sub21/libsub21.la
150 test ! -e sub2/sub22/libsub22.la
151 test ! -e ltconvtest
153 $MAKE installcheck
154 test -f installcheck-ok
155 rm -f installcheck-ok
157 $MAKE uninstall
158 for d in lib bin; do
159 find $d -type f -print > $d.lst
160 test -s $d.lst && { cat $d.lst; exit 1; }
161 : For shells with busted 'set -e'.
162 done