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