From: Stefano Lattarini Date: Wed, 15 Feb 2012 09:16:36 +0000 (+0100) Subject: cscope: is only expected to work with GNU make in VPATH setup X-Git-Tag: ng-0.5a~9^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de839e5b0f4a95242f03f731110ac07e72cf146c;p=thirdparty%2Fautomake.git cscope: is only expected to work with GNU make in VPATH setup The 'cscope' functionality does not properly handle VPATH rewrites; so we explicitly document that, for now, it is only ensured to work with GNU make when doing a VPATH build, and we adjust testsuite requirements accordingly. Issue revealed by a failure of 'cscope.test' with Solaris 10 CCS make. * doc/automake.texi (Tags): Document the limitations of the cscope support. Couple of fixlets to formatting since we are at it. * tests/cscope.test: Converted to TAP, and thus moved ... * tests/cscope.tap: ... here. Only run tests with VPATH builds when using GNU make. Adjust so that no C, C++, Fortran or Java compiler, nor any Emacs program, will be required to run this test. * tests/list-of-tests.mk: Adjust. --- diff --git a/doc/automake.texi b/doc/automake.texi index 9c148f90c..d1890a952 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -10350,10 +10350,10 @@ is the name of the program to invoke (by default @command{ctags}); @code{CTAGSFLAGS} can be used by the user to pass additional flags, and @code{AM_CTAGSFLAGS} can be used by the @file{Makefile.am}. +@trindex id Automake will also generate an @code{ID} rule that will run @command{mkid} on the source. This is only supported on a directory-by-directory basis. -@trindex id Similarly, the @code{cscope} rule will create a list of all the source files in the tree and run @command{cscope} to build an inverted index @@ -10361,7 +10361,11 @@ database. The variable @code{CSCOPE} is the name of the program to invoke (by default @command{cscope}); @code{CSCOPEFLAGS} and @code{CSCOPE_ARGS} can be used by the user to pass additional flags and file names respectively, while @code{AM_CSCOPEFLAGS} can be used by the -@file{Makefile.am}. +@file{Makefile.am}. Note that, currently, the Automake-provided +@code{cscope} support, when used in a VPATH build, might not work well +with non-GNU make implementations (especially with make implementations +performing @ref{Automatic Rule Rewriting, , VPATH rewrites, autoconf, +The Autoconf Manual}). Finally, Automake also emits rules to support the @uref{http://www.gnu.org/software/global/, GNU Global Tags program}. diff --git a/tests/cscope.tap b/tests/cscope.tap new file mode 100755 index 000000000..0269dffa4 --- /dev/null +++ b/tests/cscope.tap @@ -0,0 +1,168 @@ +#! /bin/sh +# Copyright (C) 2009, 2010, 2011, 2012 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 . + +# Test cscope functionality. + +. ./defs || Exit 1 + +plan_ 18 + +ocwd=`pwd` || fatal_ "getting top-level directory" + +cat >> configure.in << 'END' +AC_CONFIG_FILES([sub/Makefile]) +AC_SUBST([CC], [who-cares]) +AC_SUBST([CXX], [who-cares]) +AC_SUBST([FC], [who-cares]) +AC_SUBST([GCJ], [who-cares]) +AM_PATH_LISPDIR +AC_OUTPUT +END + +mkdir sub sub/subsub + +cat > Makefile.am <<'END' +SUBDIRS = sub +bin_PROGRAMS = foo +foo_SOURCES = foo.c bar.cpp baz.f90 +lisp_LISP = foo.el +EXTRA_DIST = foo.el +END + +cat > sub/Makefile.am <<'END' +bin_PROGRAMS = bar +bar_SOURCES = subsub/dist.c +nodist_bar_SOURCES = subsub/gen.c +subsub/gen.c: + $(MKDIR_P) subsub + echo 'int generated_subsub () { return 0; }' > $@ +CLEANFILES = subsub/gen.c +END + +echo 'int foo_func () { return 0; }' > foo.c +echo 'int main () { return 0; }' > bar.cpp +cat > baz.f90 <<'END' + subroutine baz + end +END +: > foo.el +echo 'int main () { return 0; }' > sub/subsub/dist.c + +$ACLOCAL || fatal_ "aclocal failed" +$AUTOCONF || fatal_ "autoconf failed" +$AUTOMAKE -i -a || fatal_ "automake -i -a failed" + +# Sun cscope is interactive without redirection. +if cscope --version stderr || r='not ok' + cat stderr >&2 + grep 'cannot find file' stderr && r='not ok' + rm -f stderr + result_ "$r" "[$pfx] make cscope" + + r=ok + test -f cscope.files \ + && $FGREP foo.c cscope.files \ + && $FGREP bar.cpp cscope.files \ + && $FGREP sub/subsub/dist.c cscope.files \ + && $FGREP sub/subsub/gen.c cscope.files \ + || r='not ok' + result_ "$r" "[$pfx] cscope.files looks correct" + + r=ok + # cscope.files might not exist of the earlier "make cscope" failed. + cp cscope.files cscope.files1 \ + && $MAKE cscope \ + && diff cscope.files cscope.files1 \ + || r='not ok' + rm -f cscope.files1 + result_ "$r" "[$pfx] second \"make cscope\" is consistent" +} + +my_configure () +{ + command_ok_ "[$pfx] configure" \ + "$1"/configure EMACS=no --with-lispdir=/who/cares +} + +if using_gmake; then + + cd "$ocwd" + pfx="relative VPATH" + mkdir build + cd build + my_configure .. + test_cscope + test_cleanup + + cd "$ocwd" + pfx="absolute VPATH" + mkdir build2 + cd build2 + my_configure "$ocwd" + test_cscope + test_cleanup + +else + + skip_row_ 12 -r "cscope in VPATH required GNU make" + +fi + +cd "$ocwd" +pfx="in-tree build" +my_configure . +test_cscope +test_cleanup + +: diff --git a/tests/cscope.test b/tests/cscope.test deleted file mode 100755 index 859653b2d..000000000 --- a/tests/cscope.test +++ /dev/null @@ -1,107 +0,0 @@ -#! /bin/sh -# Copyright (C) 2009, 2010, 2011 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 . - -# Test cscope functionality. - -required= -. ./defs || Exit 1 - -cat >> configure.in << 'END' -AC_CONFIG_FILES([sub/Makefile]) -AC_PROG_CC -AC_PROG_CXX -AC_PROG_FC -AM_PROG_GCJ -AM_PATH_LISPDIR -AC_OUTPUT -END - -mkdir sub sub/subsub - -cat >Makefile.am <<'END' -SUBDIRS = sub -bin_PROGRAMS = foo -foo_SOURCES = foo.c bar.cpp baz.f90 -lisp_LISP = foo.el -EXTRA_DIST = foo.el -END - -cat >sub/Makefile.am <<'END' -bin_PROGRAMS = bar -bar_SOURCES = subsub/dist.c -nodist_bar_SOURCES = subsub/gen.c -subsub/gen.c: - $(MKDIR_P) subsub - echo 'int generated_subsub () { return 0; }' > $@ -CLEANFILES = subsub/gen.c -END - -echo 'int foo_func () { return 0; }' > foo.c -echo 'int main () { return 0; }' > bar.cpp -cat > baz.f90 <<'END' - subroutine baz - end -END -: >foo.el -echo 'int main () { return 0; }' > sub/subsub/dist.c - -$ACLOCAL -$AUTOCONF -$AUTOMAKE --add-missing - -mkdir build -cd build -../configure || Exit 77 - -$MAKE -n cscope - -: ${CSCOPE=cscope} -( $CSCOPE --version ) >/dev/null 2>&1 || Exit 77 - -$MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; } -cat stderr >&2 -grep 'cannot find file' stderr && Exit 1 - -test -f cscope.files -$FGREP foo.c cscope.files -$FGREP bar.cpp cscope.files -$FGREP sub/subsub/dist.c cscope.files -$FGREP sub/subsub/gen.c cscope.files - -cp cscope.files cscope.files1 -$MAKE cscope -diff cscope.files cscope.files1 - -$MAKE distclean -test ! -f cscope.files -test ! -f cscope.out -test ! -f cscope.in.out -test ! -f cscope.po.out - - -`pwd`/../configure || Exit 77 - -$MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; } -cat stderr >&2 -grep 'cannot find file' stderr && Exit 1 -$MAKE || Exit 77 -$MAKE distclean - -cd .. -./configure -$MAKE distcheck - -: diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk index c726bde32..05264d7b9 100644 --- a/tests/list-of-tests.mk +++ b/tests/list-of-tests.mk @@ -287,7 +287,7 @@ confsub.test \ confvar.test \ confvar2.test \ copy.test \ -cscope.test \ +cscope.tap \ cscope2.test \ cscope3.test \ cxx.test \