test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / instdir-no-empty.sh
1 #! /bin/sh
2 # Copyright (C) 2012-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 # An empty "foo_PRIMARY" declaration should *not* cause "make install"
18 # to create directory $(foodir).  See automake bug#10997 and bug#11030.
19
20 . test-init.sh
21
22 cat >> configure.ac <<'END'
23 AC_SUBST([CC], [whatever])
24 AC_SUBST([JAVAC], [whatever])
25 AM_PATH_PYTHON(,,:)
26 AC_OUTPUT
27 END
28
29 cat > Makefile.am << 'END'
30 AUTOMAKE_OPTIONS = no-dependencies
31 mydir = $(prefix)/my
32 myexecdir = $(prefix)/myexec
33 javadir = $(prefix)/java
34 END
35
36 # Write Makefile.am.
37 {
38
39   for dir in sbin bin libexec pkglibexec myexec; do
40     for dst in '' dist_ nodist_; do
41       echo "${dst}${dir}_SCRIPTS ="
42     done
43     echo "${dir}_PROGRAMS ="
44   done
45
46   for dir in lib pkglib myexec my; do
47     echo "${dir}_LIBRARIES ="
48     echo "${dir}_LTLIBRARIES ="
49   done
50
51   for p1 in '' notrans_; do
52     for p2 in '' dist_ nodist_; do
53       for s in '' 1 2 3 4 5 6 7 8 9; do
54         echo "${p1}${p2}man${s}_MANS ="
55       done
56     done
57   done
58
59   for dst in '' dist_ nodist_; do
60     for dir in dataroot data pkgdata doc lisp my; do
61       echo "${dst}${dir}_DATA ="
62     done
63     for dir in include pkginclude oldinclude my; do
64       echo "${dst}${dir}_HEADERS ="
65     done
66     for dir in python my; do
67       echo "${dst}${dir}_PYTHON ="
68     done
69     for dir in info my; do
70       echo "${dst}${dir}_TEXINFOS ="
71     done
72     for dir in java my; do
73       echo "${dst}${dir}_JAVA ="
74     done
75     for dir in lisp my; do
76       echo "${dst}${dir}_LISP ="
77     done
78   done
79
80 } > t
81
82 cat t >> Makefile.am
83 sed 's/^/nobase_/' t >> Makefile.am
84 rm -f t
85
86 cat Makefile.am # For debugging.
87
88 # Sanity check.
89 grep '^oldinclude_HEADERS =' Makefile.am \
90   && grep '^nodist_my_PYTHON =' Makefile.am \
91   && grep '^notrans_dist_man5_MANS =' Makefile.am \
92   || fatal_ "creating Makefile.am"
93
94 $ACLOCAL
95 $AUTOCONF
96 $AUTOMAKE -a
97
98 cwd=$(pwd) || fatal_ "getting current working directory"
99
100 doinst ()
101 {
102   run_make install install-pdf install-ps install-dvi ${1+"$@"}
103 }
104
105 : > foo.sh
106
107 ./configure --prefix="$cwd/inst"
108 doinst
109 test ! -e inst || { find inst; exit 1; }
110 $MAKE uninstall
111 doinst bin_SCRIPTS=foo.sh
112 test -f inst/bin/foo.sh
113
114 # Explicitly pass prefix to avoid spurious influences from
115 # global config.site scripts.
116 ./configure --prefix="/usr/local"
117 test ! -e dest || { find dest; exit 1; }
118 $MAKE uninstall
119 doinst DESTDIR="$cwd/dest" bin_SCRIPTS=foo.sh
120 test -f dest/usr/local/bin/foo.sh
121
122 :