libctf: skip the testsuite from inside dejagnu
authorNick Alcock <nick.alcock@oracle.com>
Mon, 14 Nov 2022 14:17:55 +0000 (14:17 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 12 Jan 2023 14:40:47 +0000 (14:40 +0000)
The libctf testsuite uses Tcl try/catch to trap run_output errors.  This
is only supported in reasonably recent Tcls, so we detect the lack of
try/catch and suppress the testsuite via an Automake conditional in its
absence.

But this turns out not to work: Automake produces a check-DEJAGNU target
regardless of the value of this conditional and sticks it in an
unconditionally-executed part of the makefile, so the testsuite gets
executed anyway, and fails with a nasty-looking syntax error.  We can't
disable it by taking "dejagnu" out of AUTOMAKE_OPTIONS, because if you
do that Automake stops you using RUNTEST, RUNTESTFLAGS and other
variables users would expect to work.

So move to disabling the testsuite from inside the testsuite itself,
importing the value of the former Automake conditional as a Tcl variable
and exiting very early in default.exp if it's false.

* configure.ac (TCL_TRY): No longer an Automake conditional.
Rename to...
(HAVE_TCL_TRY): ... this.
* Makefile.am: Drop TCL_TRY.
(development.exp): Set have_tcl_try.
* testsuite/config/default.exp: Exit if have_tcl_try is false.

* configure: Regenerated.
* Makefile.in: Likewise.

libctf/Makefile.am
libctf/Makefile.in
libctf/configure
libctf/configure.ac
libctf/testsuite/config/default.exp

index c4809f70bae0a42dc68687c7c3a000b735f3156f..c959b09e4924b55fc4f0a4c7dea79b91e079ee58 100644 (file)
@@ -72,7 +72,6 @@ EXPECT = expect
 RUNTEST = runtest
 RUNTESTFLAGS =
 
-if TCL_TRY
 CC_FOR_TARGET = ` \
   if [ -f $$r/../gcc/xgcc ] ; then \
     if [ -f $$r/../newlib/Makefile ] ; then \
@@ -105,6 +104,7 @@ check-DEJAGNU: site.exp development.exp
 development.exp: $(BFDDIR)/development.sh
        $(AM_V_GEN)$(EGREP) "(development|experimental)=" $(BFDDIR)/development.sh  \
          | $(AWK) -F= '{ print "set " $$1 " " $$2 }' > $@
+       echo "set have_tcl_try @HAVE_TCL_TRY@" >> $@
 
 # development.sh is used to determine -Werror default.
 CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh
@@ -112,6 +112,5 @@ CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh
 EXTRA_DEJAGNU_SITE_CONFIG = development.exp
 
 DISTCLEANFILES += site.exp development.exp
-endif
 
 include doc/local.mk
index f2b852e3fae33f7652f939ee11ae15ab832776ac..c6cb55c9768aa943ed0f585d455a0727e0ab7ad6 100644 (file)
@@ -127,10 +127,9 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 @NEED_CTF_QSORT_R_TRUE@am__append_1 = ctf-qsort_r.c
-@TCL_TRY_TRUE@am__append_2 = site.exp development.exp
-@BUILD_INFO_TRUE@am__append_3 = doc/ctf-spec.texi
-@BUILD_INFO_TRUE@am__append_4 = texput.log
-@BUILD_INFO_TRUE@am__append_5 = doc/ctf-spec.info
+@BUILD_INFO_TRUE@am__append_2 = doc/ctf-spec.texi
+@BUILD_INFO_TRUE@am__append_3 = texput.log
+@BUILD_INFO_TRUE@am__append_4 = doc/ctf-spec.info
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
@@ -312,7 +311,7 @@ DVIS = doc/ctf-spec.dvi
 PDFS = doc/ctf-spec.pdf
 PSS = doc/ctf-spec.ps
 HTMLS = doc/ctf-spec.html
-TEXINFOS = $(am__append_3)
+TEXINFOS = $(am__append_2)
 TEXI2DVI = texi2dvi
 TEXI2PDF = $(TEXI2DVI) --pdf --batch
 MAKEINFOHTML = $(MAKEINFO) --html
@@ -407,6 +406,7 @@ FGREP = @FGREP@
 GENCAT = @GENCAT@
 GMSGFMT = @GMSGFMT@
 GREP = @GREP@
+HAVE_TCL_TRY = @HAVE_TCL_TRY@
 INCINTL = @INCINTL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -522,9 +522,9 @@ ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd
 AUTOMAKE_OPTIONS = dejagnu foreign info-in-builddir no-texinfo.tex
 
 # Variables that we might accumulate conditionally or in subdirs.
-info_TEXINFOS = $(am__append_3)
-DISTCLEANFILES = $(am__append_2) $(am__append_4)
-MAINTAINERCLEANFILES = $(am__append_5)
+info_TEXINFOS = $(am__append_2)
+DISTCLEANFILES = site.exp development.exp $(am__append_3)
+MAINTAINERCLEANFILES = $(am__append_4)
 
 # This is where we get zlib from.  zlibdir is -L../zlib and zlibinc is
 # -I../zlib, unless we were configured with --with-system-zlib, in which
@@ -559,25 +559,25 @@ libctf_la_LDFLAGS = $(libctf_ldflags_nover) @VERSION_FLAGS@
 libctf_la_SOURCES = $(libctf_nobfd_la_SOURCES) ctf-open-bfd.c
 RUNTEST = runtest
 RUNTESTFLAGS = 
-@TCL_TRY_TRUE@CC_FOR_TARGET = ` \
-@TCL_TRY_TRUE@  if [ -f $$r/../gcc/xgcc ] ; then \
-@TCL_TRY_TRUE@    if [ -f $$r/../newlib/Makefile ] ; then \
-@TCL_TRY_TRUE@      echo $$r/../gcc/xgcc -B$$r/../gcc/ -idirafter $$r/../newlib/targ-include -idirafter $${srcroot}/../newlib/libc/include -nostdinc; \
-@TCL_TRY_TRUE@    else \
-@TCL_TRY_TRUE@      echo $$r/../gcc/xgcc -B$$r/../gcc/; \
-@TCL_TRY_TRUE@    fi; \
-@TCL_TRY_TRUE@  else \
-@TCL_TRY_TRUE@    if [ "@host@" = "@target@" ] ; then \
-@TCL_TRY_TRUE@      echo $(CC); \
-@TCL_TRY_TRUE@    else \
-@TCL_TRY_TRUE@      echo gcc | sed '$(transform)'; \
-@TCL_TRY_TRUE@    fi; \
-@TCL_TRY_TRUE@  fi`
+CC_FOR_TARGET = ` \
+  if [ -f $$r/../gcc/xgcc ] ; then \
+    if [ -f $$r/../newlib/Makefile ] ; then \
+      echo $$r/../gcc/xgcc -B$$r/../gcc/ -idirafter $$r/../newlib/targ-include -idirafter $${srcroot}/../newlib/libc/include -nostdinc; \
+    else \
+      echo $$r/../gcc/xgcc -B$$r/../gcc/; \
+    fi; \
+  else \
+    if [ "@host@" = "@target@" ] ; then \
+      echo $(CC); \
+    else \
+      echo gcc | sed '$(transform)'; \
+    fi; \
+  fi`
 
 
 # development.sh is used to determine -Werror default.
-@TCL_TRY_TRUE@CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh
-@TCL_TRY_TRUE@EXTRA_DEJAGNU_SITE_CONFIG = development.exp
+CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh
+EXTRA_DEJAGNU_SITE_CONFIG = development.exp
 @BUILD_INFO_TRUE@AM_MAKEINFOFLAGS = --no-split
 all: config.h
        $(MAKE) $(AM_MAKEFLAGS) all-am
@@ -1235,18 +1235,6 @@ cscopelist-am: $(am__tagged_files)
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
        -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
-
-@TCL_TRY_FALSE@check-DEJAGNU: site.exp
-@TCL_TRY_FALSE@        srcdir='$(srcdir)'; export srcdir; \
-@TCL_TRY_FALSE@        EXPECT=$(EXPECT); export EXPECT; \
-@TCL_TRY_FALSE@        if $(SHELL) -c "$(RUNTEST) --version" > /dev/null 2>&1; then \
-@TCL_TRY_FALSE@          exit_status=0; l='$(DEJATOOL)'; for tool in $$l; do \
-@TCL_TRY_FALSE@            if $(RUNTEST) $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \
-@TCL_TRY_FALSE@            then :; else exit_status=1; fi; \
-@TCL_TRY_FALSE@          done; \
-@TCL_TRY_FALSE@        else echo "WARNING: could not find '$(RUNTEST)'" 1>&2; :;\
-@TCL_TRY_FALSE@        fi; \
-@TCL_TRY_FALSE@        exit $$exit_status
 site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
        @echo 'Making a new site.exp file ...'
        @echo '## these variables are automatically generated by make ##' >site.tmp
@@ -1685,23 +1673,24 @@ uninstall-am: uninstall-dvi-am uninstall-html-am \
 .PRECIOUS: Makefile
 
 
-@TCL_TRY_TRUE@check-DEJAGNU: site.exp development.exp
-@TCL_TRY_TRUE@ srcroot=`cd $(srcdir) && pwd`; export srcroot; \
-@TCL_TRY_TRUE@ r=`pwd`; export r; \
-@TCL_TRY_TRUE@ LC_ALL=C; export LC_ALL; \
-@TCL_TRY_TRUE@ EXPECT=$(EXPECT); export EXPECT; \
-@TCL_TRY_TRUE@ runtest=$(RUNTEST); \
-@TCL_TRY_TRUE@ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
-@TCL_TRY_TRUE@   $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
-@TCL_TRY_TRUE@         CC="$(CC)" CC_FOR_TARGET="$(CC_FOR_TARGET)" \
-@TCL_TRY_TRUE@         CFLAGS="$(CFLAGS) -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/../bfd $(ZLIBINC)" \
-@TCL_TRY_TRUE@         LIBS="$(libctf_nobfd_la_LIBADD) $(LIBS)" $(RUNTESTFLAGS); \
-@TCL_TRY_TRUE@ else echo "WARNING: could not find \`runtest'" 1>&2; :;\
-@TCL_TRY_TRUE@ fi
-
-@TCL_TRY_TRUE@development.exp: $(BFDDIR)/development.sh
-@TCL_TRY_TRUE@ $(AM_V_GEN)$(EGREP) "(development|experimental)=" $(BFDDIR)/development.sh  \
-@TCL_TRY_TRUE@   | $(AWK) -F= '{ print "set " $$1 " " $$2 }' > $@
+check-DEJAGNU: site.exp development.exp
+       srcroot=`cd $(srcdir) && pwd`; export srcroot; \
+       r=`pwd`; export r; \
+       LC_ALL=C; export LC_ALL; \
+       EXPECT=$(EXPECT); export EXPECT; \
+       runtest=$(RUNTEST); \
+       if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
+         $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
+               CC="$(CC)" CC_FOR_TARGET="$(CC_FOR_TARGET)" \
+               CFLAGS="$(CFLAGS) -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/../bfd $(ZLIBINC)" \
+               LIBS="$(libctf_nobfd_la_LIBADD) $(LIBS)" $(RUNTESTFLAGS); \
+       else echo "WARNING: could not find \`runtest'" 1>&2; :;\
+       fi
+
+development.exp: $(BFDDIR)/development.sh
+       $(AM_V_GEN)$(EGREP) "(development|experimental)=" $(BFDDIR)/development.sh  \
+         | $(AWK) -F= '{ print "set " $$1 " " $$2 }' > $@
+       echo "set have_tcl_try @HAVE_TCL_TRY@" >> $@
 
 @BUILD_INFO_TRUE@html-local: doc/ctf-spec/index.html
 @BUILD_INFO_TRUE@doc/ctf-spec/index.html: doc/ctf-spec.texi doc/$(am__dirstamp)
index 17463a74ccac73b2340392701492843412438f8f..c22f7dffd2cf2ee37148f61369364cf80eb0081d 100755 (executable)
@@ -637,8 +637,7 @@ LTLIBOBJS
 LIBOBJS
 VERSION_FLAGS_NOBFD
 VERSION_FLAGS
-TCL_TRY_FALSE
-TCL_TRY_TRUE
+HAVE_TCL_TRY
 EXPECT
 CTF_LIBADD
 SHARED_LDFLAGS
@@ -11632,7 +11631,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11635 "configure"
+#line 11634 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11738,7 +11737,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11741 "configure"
+#line 11740 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -14975,12 +14974,10 @@ fi`
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libctf_tcl_try" >&5
 $as_echo "$ac_cv_libctf_tcl_try" >&6; }
- if test "${ac_cv_libctf_tcl_try}" = yes; then
-  TCL_TRY_TRUE=
-  TCL_TRY_FALSE='#'
-else
-  TCL_TRY_TRUE='#'
-  TCL_TRY_FALSE=
+
+HAVE_TCL_TRY=false
+if test "${ac_cv_libctf_tcl_try}" = "yes"; then
+    HAVE_TCL_TRY=true
 fi
 
 
@@ -15208,10 +15205,6 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then
   as_fn_error $? "conditional \"BUILD_INFO\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
-if test -z "${TCL_TRY_TRUE}" && test -z "${TCL_TRY_FALSE}"; then
-  as_fn_error $? "conditional \"TCL_TRY\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
 
 : "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0
index a0148a4c328675894f76a7e3797584b2f07d5914..1d0cf4d0fa57cb8921b392f7f6b1b421469e73ae 100644 (file)
@@ -241,7 +241,12 @@ if @<:@llength @<:@info commands try@:>@@:>@ then { puts yes } else { puts no }
 EOF
 fi`
 ])
-AM_CONDITIONAL(TCL_TRY, test "${ac_cv_libctf_tcl_try}" = yes)
+
+HAVE_TCL_TRY=false
+if test "${ac_cv_libctf_tcl_try}" = "yes"; then
+    HAVE_TCL_TRY=true
+fi
+AC_SUBST(HAVE_TCL_TRY)
 
 # Use a version script, if possible, or an -export-symbols-regex otherwise.
 decommented_version_script=
index 4bac9c4281c005a4cbc468f44e5e75cdfd96c1d7..357c4ee57f1b672905d6888386a263cde2720c17 100644 (file)
 # Written by Jeffrey Wheat (cassidy@cygnus.com)
 #
 
+# Don't run anything if Tcl is too old to have try / catch.
+if { ! $have_tcl_try } {
+    log_and_exit
+}
+
 if ![info exists ld] then {
     set ld [findfile $base_dir/../ld/ld-new $base_dir/../ld/ld-new [transform ld]]
 }