tests: make 'lzip.test' executable
[automake.git] / tests / pr401.test
blob88f773380a9629d2d1f69e34273fe7fc84f91ce3
1 #! /bin/sh
2 # Copyright (C) 2005, 2006, 2007, 2010 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 <http://www.gnu.org/licenses/>.
17 # Check support for AC_CONFIG_LIBOBJ_DIR vs LIBOBJS.
18 # (pr401b.test and pr401c.test do the same for LTLIBOBJS and ALLOCA)
20 parallel_tests=no
21 required=gcc
22 . ./defs || Exit 1
24 set -e
26 mkdir lib src
28 cat >lib/feep.c <<'EOF'
29 char *
30 feep ()
32 return "feep";
34 EOF
36 cat >src/main.c <<'EOF'
37 #include <stdio.h>
39 extern char *feep ();
41 int
42 main (int argc, char **argv)
44 puts (feep ());
45 return 0;
47 EOF
49 cat >>configure.in << 'EOF'
50 ## These lines are activated for later tests
51 #: AC_CONFIG_LIBOBJ_DIR([lib])
52 AC_PROG_CC
53 #x AM_PROG_CC_C_O
54 AC_LIBOBJ([feep])
55 AC_LIBSOURCE([feep.c])
56 AC_PROG_RANLIB
57 AC_CONFIG_FILES([lib/Makefile src/Makefile])
58 AC_OUTPUT
59 EOF
61 ## ------------------------------------------ ##
62 ## First a test of traditional LIBOBJS usage. ##
63 ## ------------------------------------------ ##
65 cat >Makefile.am <<'EOF'
66 SUBDIRS = lib src
67 EOF
69 cat >lib/Makefile.am <<'EOF'
70 noinst_LIBRARIES = libfeep.a
71 libfeep_a_SOURCES =
72 libfeep_a_LIBADD = $(LIBOBJS)
73 EOF
75 cat >src/Makefile.am <<'EOF'
76 check_PROGRAMS = main
77 main_LDADD = ../lib/libfeep.a
79 TESTS = main
80 EOF
82 $ACLOCAL
83 $AUTOCONF
84 $AUTOMAKE
85 ./configure
86 $MAKE distcheck
88 ## ------------------------------------------ ##
89 ## Traditional LIBOBJS with LIBOBJDIR set. ##
90 ## ------------------------------------------ ##
92 # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
93 # unrelated to Automake or Makefile.am layout.
95 sed 's/#: //' configure.in >configure.int
96 mv -f configure.int configure.in
98 $ACLOCAL
99 $AUTOCONF
100 $AUTOMAKE
101 ./configure
102 test ! -d lib/lib
103 $MAKE distcheck
105 ## -------------------------------------------- ##
106 ## Error message with usage in wrong directory. ##
107 ## -------------------------------------------- ##
109 mv -f src/Makefile.am src/t
110 sed 's/LDADD = .*/LDADD = @LIBOBJS@/' src/t > src/Makefile.am
111 AUTOMAKE_fails
112 grep 'cannot be used outside.*lib' stderr
113 mv -f src/t src/Makefile.am
116 ## -------------------------------------------- ##
117 ## Test using LIBOBJS from a sibling directory. ##
118 ## -------------------------------------------- ##
120 sed 's/#x //; s/lib\/Makefile //' configure.in >configure.int
121 mv -f configure.int configure.in
123 cat >Makefile.am <<'EOF'
124 SUBDIRS = src
127 cat > src/Makefile.am <<'EOF'
128 AUTOMAKE_OPTIONS = subdir-objects
130 noinst_LIBRARIES = libfeep.a
131 libfeep_a_SOURCES =
132 libfeep_a_LIBADD = $(LIBOBJS)
134 check_PROGRAMS = main
135 main_LDADD = libfeep.a
137 TESTS = main
140 $ACLOCAL
141 $AUTOCONF
142 $AUTOMAKE --add-missing
143 ./configure
144 test ! -d src/lib
145 test ! -d 'src/$(top_builddir)'
146 $MAKE
147 $MAKE check
148 $MAKE distclean
151 ## ----------------------------------------- ##
152 ## Test using LIBOBJS from parent directory. ##
153 ## ----------------------------------------- ##
155 sed 's/^.*src\/Makefile.*$//' configure.in >configure.int
156 mv -f configure.int configure.in
158 cat >Makefile.am <<'EOF'
159 AUTOMAKE_OPTIONS = subdir-objects
161 noinst_LIBRARIES = lib/libfeep.a
162 lib_libfeep_a_SOURCES =
163 lib_libfeep_a_LIBADD = $(LIBOBJS)
165 check_PROGRAMS = src/main
166 src_main_SOURCES = src/main.c
167 src_main_LDADD = lib/libfeep.a
169 TESTS = src/main
171 check-local:
172 test -f src/main.$(OBJEXT)
173 test -f lib/feep.$(OBJEXT)
174 test ! -f src/$(DEPDIR)/feep.Po
177 $ACLOCAL
178 $AUTOCONF
179 $AUTOMAKE
180 ./configure
181 $MAKE distcheck