summaryrefslogtreecommitdiff
path: root/t/subobj-libtool.sh
blob: 71b5427f5569271dfd622e711a67d5fe4965b7f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#! /bin/sh
# Copyright (C) 1999-2015 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Test of subdir objects with libtool.

required='cc libtoolize'
. test-init.sh

cat >> configure.ac << 'END'
AC_PROG_CC
AM_PROG_AR
AC_PROG_LIBTOOL
AC_OUTPUT
END

cat > Makefile.am << 'END'
noinst_LTLIBRARIES = libs/libfoo.la
libs_libfoo_la_SOURCES = generic/1.c generic/2.c sub/subsub/3.c

.PHONY: remake-single-object
remake-single-object:
	rm -rf generic
	$(MAKE) generic/1.lo
	test -f generic/1.lo
	test ! -f generic/2.lo
	rm -rf generic
	$(MAKE) generic/2.lo
	test ! -f generic/1.lo
	test -f generic/2.lo
	rm -rf sub generic
	$(MAKE) sub/subsub/3.lo
	test -f sub/subsub/3.lo
	test ! -d generic
END

mkdir generic sub sub/subsub
echo 'int one (void) { return 1; }' > generic/1.c
echo 'int two (void) { return 2; }' > generic/2.c
echo 'int three (void) { return 3; }' > sub/subsub/3.c

libtoolize
$ACLOCAL

# Make sure compile is installed, and that Automake says so.
rm -f compile
$AUTOMAKE --add-missing 2>stderr || { cat stderr >&2; exit 1; }
cat stderr >&2
grep '^configure\.ac:4:.*install.*compile' stderr
test -f compile

grep '[^/][123]\.lo' Makefile.in && exit 1

$AUTOCONF

mkdir build
cd build
../configure
$MAKE

test -d libs
test -d generic
test -d sub/subsub

# The libraries and executables are not uselessly remade.
: > xstamp
$sleep
echo dummy > libs/change-dir-timestamp
echo dummy > generic/change-dir-timestamp
echo dummy > sub/change-dir-timestamp
echo dummy > sub/subsub/change-dir-timestamp
$MAKE
is_newest xstamp libs/libfoo.la

$MAKE remake-single-object

# VPATH builds must work also with dependency tracking disabled.
# Also sanity check the distribution.
$MAKE distcheck DISTCHECK_CONFIGURE_FLAGS=--disable-dependency-tracking

: