tests: rename 'tests/' => 't/', '*.test' => '*.sh'
[platform/upstream/automake.git] / t / ltcond.sh
1 #!/bin/sh
2 # Copyright (C) 2003-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 # Test for conditional libtool libraries.
18 # This combines two examples from the manual.
19
20 required='cc libtoolize'
21 . ./defs || Exit 1
22
23 cat >>configure.ac <<'END'
24 AM_CONDITIONAL([WANT_LIBFOO], [true])
25 AM_CONDITIONAL([WANT_LIBBAR], [false])
26 AC_SUBST([WANTEDLIBS], ['lib1foo.la lib1bar.la'])
27 AC_PROG_CC
28 AM_PROG_AR
29 AC_PROG_LIBTOOL
30 AC_OUTPUT
31 END
32
33 cat >Makefile.am <<'END'
34 EXTRA_LTLIBRARIES = lib1foo.la lib1bar.la lib3bar.la
35 lib_LTLIBRARIES = $(WANTEDLIBS)
36 lib1foo_la_SOURCES = foo.c
37 lib1foo_la_LDFLAGS = -rpath '$(libdir)'
38 lib1bar_la_SOURCES = bar.c
39 lib1bar_la_LDFLAGS = -rpath '$(libdir)'
40 lib3bar_la_SOURCES = bar.c
41
42 if WANT_LIBFOO
43 lib_LTLIBRARIES += lib2foo.la
44 check_LTLIBRARIES = lib3foo.la
45 endif
46 if WANT_LIBBAR
47 lib_LTLIBRARIES += lib2bar.la
48 endif
49 lib2foo_la_SOURCES = foo.c
50 lib2bar_la_SOURCES = bar.c
51 lib3foo_la_SOURCES = foo.c
52 END
53
54 echo 'int one () { return 1; }' >foo.c
55 echo 'int two () { return 2; }' >bar.c
56
57 mkdir empty
58
59 libtoolize
60 $ACLOCAL
61 $AUTOCONF
62 $AUTOMAKE --add-missing
63
64 # Install libraries in lib/, and the rest in empty/.
65 # (in fact there is no "rest", so as the name imply empty/ is
66 # expected to remain empty).
67 ./configure "--prefix=`pwd`/empty" "--libdir=`pwd`/lib"
68
69 $MAKE
70 test -f lib1foo.la
71 test -f lib1bar.la
72 test -f lib2foo.la
73 test ! -f lib2bar.la
74 test ! -f lib3foo.la
75 test ! -f lib3bar.la
76
77 $MAKE check
78 test ! -f lib2bar.la
79 test -f lib3foo.la
80 test ! -f lib3bar.la
81
82 $MAKE install
83 test -f lib/lib1foo.la
84 test -f lib/lib1bar.la
85 test -f lib/lib2foo.la
86 test ! -f lib/lib3foo.la
87 find empty -type f -print > empty.lst
88 cat empty.lst
89 test 0 = `wc -l < empty.lst`
90
91 $MAKE uninstall
92 find lib -type f -print > lib.lst
93 test 0 = `wc -l < lib.lst`
94 test -f lib1foo.la
95 test -f lib1bar.la
96 test -f lib2foo.la
97 test -f lib3foo.la
98
99 $MAKE clean
100 test ! -f lib1foo.la
101 test ! -f lib1bar.la
102 test ! -f lib2foo.la
103 test ! -f lib3foo.la
104
105 :