tests: cosmetic changes in t/extra-sources.sh
[platform/upstream/automake.git] / t / copy.sh
1 #! /bin/sh
2 # Copyright (C) 1999-2013 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 to make sure '-c' works.  Report from Andris Pavenis.
18 # See also the much more in-depth test 'add-missing'.
19
20 . test-init.sh
21
22 # We'll have to cater to systems like MSYS/MinGW where there are no
23 # true symlinks ('ln -s' behaves like 'cp -p'); see automake bug#10441.
24
25 echo dummy > foo
26 if ln -s foo bar && test -h bar; then
27   is_symlink () { test -h "$1"; }
28   is_not_symlink () { test ! -h "$1"; }
29 else
30   is_symlink () { return 0; } # Avoid spurious failures.
31   is_not_symlink () { return 0; }
32 fi
33 rm -f foo bar
34
35 # First a simple test, where the auxdir is automatically determined
36 # by automake.
37
38 : > Makefile.am
39 rm -f install-sh
40
41 $ACLOCAL
42 $AUTOMAKE -c -a
43 ls -l # For debugging.
44
45 test -f install-sh
46 is_not_symlink install-sh
47
48 # Let's do a couple of more elaborated tests, this time with the auxdir
49 # explicitly defined in configure.ac.
50
51 mkdir sub
52 cd sub
53
54 cat > configure.ac <<END
55 AC_INIT([$me], [1.0])
56 AC_CONFIG_AUX_DIR([auxdir])
57 AM_INIT_AUTOMAKE
58 AC_PROG_CC
59 AC_CONFIG_FILES([Makefile])
60 AC_OUTPUT
61 END
62
63 cat > Makefile.am <<END
64 bin_PROGRAMS = foo
65 END
66
67 $ACLOCAL
68
69 # 'automake -a' called without '-c' should create symlinks by default,
70 # even when there is already a non-symlinked required auxiliary file.
71
72 mkdir auxdir
73 echo FAKE-DEPCOMP > auxdir/depcomp
74 $AUTOMAKE -a
75 ls -l auxdir # For debugging.
76 test -f auxdir/install-sh
77 is_symlink auxdir/install-sh
78 test -f auxdir/depcomp
79 is_not_symlink auxdir/depcomp
80 test FAKE-DEPCOMP = "$(cat auxdir/depcomp)"
81
82 # 'automake -a -c' should not create symlinks, even when there are
83 # already symlinked required auxiliary files.
84
85 rm -rf auxdir
86 mkdir auxdir
87 cd auxdir
88 ln -s "$am_scriptdir/missing" "$am_scriptdir/install-sh" .
89 cd ..
90
91 $AUTOMAKE -a -c
92 ls -l auxdir # For debugging.
93 test -f auxdir/install-sh
94 is_symlink auxdir/install-sh
95 test -f auxdir/missing
96 is_symlink auxdir/missing
97 test -f auxdir/depcomp
98 is_not_symlink auxdir/depcomp
99 diff "$am_scriptdir"/depcomp auxdir/depcomp
100
101 :