Merge branch 'msvc'
[platform/upstream/automake.git] / tests / cscope.test
1 #! /bin/sh
2 # Copyright (C) 2009, 2010 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 cscope functionality.
18
19 required=
20 . ./defs || Exit 1
21
22 set -e
23
24 cat >> configure.in << 'END'
25 AC_CONFIG_FILES([sub/Makefile])
26 AC_PROG_CC
27 AC_PROG_CXX
28 AC_PROG_FC
29 AM_PROG_GCJ
30 AM_PATH_LISPDIR
31 AC_OUTPUT
32 END
33
34 mkdir sub sub/subsub
35
36 cat >Makefile.am <<'END'
37 SUBDIRS = sub
38 bin_PROGRAMS = foo
39 foo_SOURCES = foo.c bar.cpp baz.f90
40 lisp_LISP = foo.el
41 EXTRA_DIST = foo.el
42 END
43
44 cat >sub/Makefile.am <<'END'
45 bin_PROGRAMS = bar
46 bar_SOURCES = subsub/dist.c
47 nodist_bar_SOURCES = subsub/gen.c
48 subsub/gen.c:
49         $(MKDIR_P) subsub
50         echo 'int generated_subsub () { return 0; }' > $@
51 CLEANFILES = subsub/gen.c
52 END
53
54 echo 'int foo_func () { return 0; }' > foo.c
55 echo 'int main () { return 0; }' > bar.cpp
56 cat > baz.f90 <<'END'
57       subroutine baz
58       end
59 END
60 : >foo.el
61 echo 'int main () { return 0; }' > sub/subsub/dist.c
62
63 $ACLOCAL
64 $AUTOCONF
65 $AUTOMAKE --add-missing
66
67 mkdir build
68 cd build
69 ../configure || Exit 77
70
71 $MAKE -n cscope
72
73 : ${CSCOPE=cscope}
74 ( $CSCOPE --version ) >/dev/null 2>&1 || Exit 77
75
76 $MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; }
77 cat stderr >&2
78 grep 'cannot find file' stderr && Exit 1
79
80 test -f cscope.files
81 $FGREP foo.c cscope.files
82 $FGREP bar.cpp cscope.files
83 $FGREP sub/subsub/dist.c cscope.files
84 $FGREP sub/subsub/gen.c cscope.files
85
86 cp cscope.files cscope.files1
87 $MAKE cscope
88 diff cscope.files cscope.files1
89
90 $MAKE distclean
91 test ! -f cscope.files
92 test ! -f cscope.out
93 test ! -f cscope.in.out
94 test ! -f cscope.po.out
95
96
97 `pwd`/../configure || Exit 77
98
99 $MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; }
100 cat stderr >&2
101 grep 'cannot find file' stderr && Exit 1
102 $MAKE || Exit 77
103 $MAKE distclean
104
105 cd ..
106 ./configure
107 $MAKE distcheck
108
109 :