Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / ltconv.test
1 #!/bin/sh
2 # Copyright (C) 2003, 2004, 2007  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 # Test for libtool convenience libraries.
18 # This example is taken from the manual.
19
20 required='libtoolize gcc'
21 . ./defs || Exit 1
22
23 set -e
24
25 cat >>configure.in <<'END'
26 AC_PROG_CC
27 AM_PROG_AR
28 AC_PROG_LIBTOOL
29 AC_CONFIG_FILES(sub1/Makefile
30                 sub2/Makefile
31                 sub2/sub21/Makefile
32                 sub2/sub22/Makefile)
33 AC_OUTPUT
34 END
35
36 mkdir sub1
37 mkdir sub2
38 mkdir sub2/sub21
39 mkdir sub2/sub22
40 mkdir empty
41
42 cat >Makefile.am <<'END'
43 SUBDIRS = sub1 sub2
44 lib_LTLIBRARIES = libtop.la
45 libtop_la_SOURCES =
46 libtop_la_LIBADD = \
47   sub1/libsub1.la \
48   sub2/libsub2.la
49
50 bin_PROGRAMS = ltconvtest
51 ltconvtest_SOURCES = test.c
52 ltconvtest_LDADD = libtop.la
53
54 check-local:
55         ./ltconvtest$(EXEEXT)
56         : > check-ok
57 installcheck-local:
58         $(bindir)/ltconvtest$(EXEEXT)
59         : > installcheck-ok
60 END
61
62 cat >sub1/Makefile.am <<'END'
63 noinst_LTLIBRARIES = libsub1.la
64 libsub1_la_SOURCES = sub1.c
65 END
66
67 echo 'int sub1 () { return 1; }' > sub1/sub1.c
68
69 cat >sub2/Makefile.am <<'END'
70 SUBDIRS = sub21 sub22
71 noinst_LTLIBRARIES = libsub2.la
72 libsub2_la_SOURCES = sub2.c
73 libsub2_la_LIBADD = \
74   sub21/libsub21.la \
75   sub22/libsub22.la
76 END
77
78 echo 'int sub2 () { return 2; }' > sub2/sub2.c
79
80 cat >sub2/sub21/Makefile.am <<'END'
81 noinst_LTLIBRARIES = libsub21.la
82 libsub21_la_SOURCES = sub21.c
83 END
84
85 echo 'int sub21 () { return 21; }' > sub2/sub21/sub21.c
86
87 cat >sub2/sub22/Makefile.am <<'END'
88 noinst_LTLIBRARIES = libsub22.la
89 libsub22_la_SOURCES = sub22.c
90 END
91
92 echo 'int sub22 () { return 22; }' > sub2/sub22/sub22.c
93
94 cat >test.c <<EOF
95 #include <stdio.h>
96 int main ()
97 {
98   if (1 != sub1 ())
99     return 1;
100   if (2 != sub2 ())
101     return 2;
102   if (21 != sub21 ())
103     return 3;
104   if (22 != sub22 ())
105     return 4;
106   return 0;
107 }
108 EOF
109
110 libtoolize
111 $ACLOCAL
112 $AUTOCONF
113 $AUTOMAKE --add-missing
114
115 # Install libraries in lib/, programs in bin/, and the rest in empty/.
116 # (in fact there is no "rest", so as the name imply empty/ is
117 # expected to remain empty).
118 ./configure "--prefix=`pwd`/empty" "--libdir=`pwd`/lib" "--bindir=`pwd`/bin"
119
120 $MAKE
121 test -f libtop.la
122 test -f sub1/libsub1.la
123 test -f sub2/libsub2.la
124 test -f sub2/sub21/libsub21.la
125 test -f sub2/sub22/libsub22.la
126 $MAKE check
127 test -f check-ok
128 rm -f check-ok
129
130 $MAKE install
131 test -f lib/libtop.la
132 $MAKE installcheck
133 test -f installcheck-ok
134 rm -f installcheck-ok
135
136 find empty -type f -print > empty.lst
137 cat empty.lst
138 test 0 = `wc -l < empty.lst`
139
140 $MAKE clean
141 test ! -f libtop.la
142 test ! -f sub1/libsub1.la
143 test ! -f sub2/libsub2.la
144 test ! -f sub2/sub21/libsub21.la
145 test ! -f sub2/sub22/libsub22.la
146 test ! -f ltconvtest
147
148 $MAKE installcheck
149 test -f installcheck-ok
150 rm -f installcheck-ok
151
152 $MAKE uninstall
153 find lib -type f -print > lib.lst
154 test 0 = `wc -l < lib.lst`
155 find bin -type f -print > bin.lst
156 test 0 = `wc -l < bin.lst`