1# -*- TCL -*-
2# Test-specific TCL procedures required by DejaGNU.
3# Copyright (C) 1994 Free Software Foundation, Inc.
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19# Modified by David MacKenzie <djm@gnu.ai.mit.edu> from the gcc files
20# written by Rob Savoye <rob@cygnus.com>.
21
22#
23# Called by runtest.
24# Extract and print the version number of autoconf.
25#
26proc autoconf_version {} {
27    global AUTOCONF
28    global AUTOCONFFLAGS
29
30    if {[which $AUTOCONF] != 0} then {
31	set tmp [ eval exec $AUTOCONF $AUTOCONFFLAGS --version /dev/null ]
32	regexp "version.*$" $tmp version
33	if [info exists version] then {
34	    clone_output "[which $AUTOCONF] $version\n"
35	} else {
36	    warning "cannot get version from $tmp."
37	}
38    } else {
39	warning "$AUTOCONF, program does not exist"
40    }
41}
42
43#
44# Compile a configure.in using autoconf.
45# Runs autoconf and leaves the output in $comp_output.
46# Called by individual test scripts.
47# Return 1 if ok, 0 if not.
48proc autoconf_start { configout } {
49    global verbose
50    global AUTOCONF
51    global AUTOCONFFLAGS
52    global comp_output
53
54    if {[which $AUTOCONF] == 0} then {
55	error "$AUTOCONF, program does not exist"
56	exit 1
57    }
58
59    set configin "$configout.in"
60
61    send_log "$AUTOCONF $AUTOCONFFLAGS $configin > $configout\n"
62    if $verbose>1 then {
63	send_user "Spawning \"$AUTOCONF $AUTOCONFFLAGS $configin > $configout\"\n"
64    }
65
66    catch "exec $AUTOCONF $AUTOCONFFLAGS $configin > $configout" comp_output
67    if ![string match "" $comp_output] then {
68	send_log "$comp_output\n"
69	if $verbose>1 then {
70	    send_user "$comp_output\n"
71	}
72    }
73    catch "exec chmod +x $configout"
74    return 1
75}
76
77#
78# Execute the configure script.
79# Leaves the output in $exec_output.
80# Called by individual test scripts.
81# Return 1 if successful so far, 0 if failure already.
82proc autoconf_load { args } {
83    global verbose
84    global exec_output
85
86    if ![file exists $args] then {
87	error "$args, configure script does not exist"
88	return 0
89    }
90
91    # Check whether m4 processing left any icky residue.
92    # The autoconf script does this already, pretty much.
93    # catch "exec sed -n -e /dnl/p -e /AC_/p $args" exec_output
94    # if $verbose>1 then {
95    #	send_user "Checked $args for unexpanded m4 macros\n"
96    # }
97    # if ![string match "" $exec_output] then {
98    #	fail "$args, unexpanded m4 macros"
99    #	send_log "$exec_output\n"
100    #	return 0
101    # }
102
103    # Capture only stderr in exec_output, not "creating Makefile" etc.
104    catch "exec ./$args --cache=/dev/null >/dev/null" exec_output
105    if $verbose>1 then {
106	send_user "Executed $args --cache=/dev/null\n"
107    }
108    if ![string match "" $exec_output] then {
109	fail "$args, problem with executing"
110	send_log "$exec_output\n"
111	return 0
112    } else {
113	return 1
114    }
115}
116
117#
118# Called by runtest.
119# Clean up (remove temporary files) before runtest exits.
120#
121proc autoconf_exit {} {
122}
123
124load_lib common.exp
125