From 185dc07f9f0be58bb94b8a7aec09f2e7a21a095d Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Wed, 4 Jun 2003 20:18:36 +0000 Subject: [PATCH] * automake.in (process_option_list): Record the location of ansi2knr's definition. (handle_compile): Use it. * tests/ansi3.test: Make sure the location appears correctly. Update to use set -e. * tests/ansi3b.test: New file. * tests/Makefile.am (TESTS): Add ansi3b.test. --- ChangeLog | 8 ++++++ automake.in | 24 ++++++++++-------- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/ansi3.test | 16 +++++++----- tests/ansi3b.test | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 97 insertions(+), 17 deletions(-) create mode 100755 tests/ansi3b.test diff --git a/ChangeLog b/ChangeLog index 401efd20..c2fa9373 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2003-06-04 Alexandre Duret-Lutz + * automake.in (process_option_list): Record the location + of ansi2knr's definition. + (handle_compile): Use it. + * tests/ansi3.test: Make sure the location appears correctly. + Update to use set -e. + * tests/ansi3b.test: New file. + * tests/Makefile.am (TESTS): Add ansi3b.test. + * tests/alpha.test: Really run $MAKE. Augment to test subdirectories, and check-news report. * tests/alpha2.test: New file. Bug report from Akim Demaille. diff --git a/automake.in b/automake.in index cfe589bb..177df8b5 100755 --- a/automake.in +++ b/automake.in @@ -1400,7 +1400,7 @@ sub process_option_list # An option like "../lib/ansi2knr" is allowed. With no # path prefix, we assume the required programs are in this # directory. We save the actual option for later. - $options{'ansi2knr'} = $_; + $options{'ansi2knr'} = [$_, $where]; } elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo' || $_ eq 'dist-shar' || $_ eq 'dist-zip' @@ -2820,25 +2820,27 @@ sub handle_compile () # Check for automatic de-ANSI-fication. if (defined $options{'ansi2knr'}) { - require_variables_for_variable ('AUTOMAKE_OPTIONS', - "option `ansi2knr' is used", - "ANSI2KNR", "U"); + my ($ansi2knr_filename, $ansi2knr_where) = @{$options{'ansi2knr'}}; + my $ansi2knr_dir = ''; + + require_variables ($ansi2knr_where, "option `ansi2knr' is used", + TRUE, "ANSI2KNR", "U"); # topdir is where ansi2knr should be. - if ($options{'ansi2knr'} eq 'ansi2knr') + if ($ansi2knr_filename eq 'ansi2knr') { # Only require ansi2knr files if they should appear in # this directory. - require_file_with_macro (TRUE, 'AUTOMAKE_OPTIONS', FOREIGN, - 'ansi2knr.c', 'ansi2knr.1'); + require_file ($ansi2knr_where, FOREIGN, + 'ansi2knr.c', 'ansi2knr.1'); # ansi2knr needs to be built before subdirs, so unshift it. unshift (@all, '$(ANSI2KNR)'); } - - my $ansi2knr_dir = ''; - $ansi2knr_dir = dirname ($options{'ansi2knr'}) - if $options{'ansi2knr'} ne 'ansi2knr'; + else + { + $ansi2knr_dir = dirname ($ansi2knr_filename); + } $output_rules .= &file_contents ('ansi2knr', new Automake::Location, diff --git a/tests/Makefile.am b/tests/Makefile.am index 030d8692..c0da6c6a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -26,6 +26,7 @@ ammissing.test \ ansi.test \ ansi2.test \ ansi3.test \ +ansi3b.test \ ansi4.test \ ansi5.test \ ansi6.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index f192399d..dec5c154 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -137,6 +137,7 @@ ammissing.test \ ansi.test \ ansi2.test \ ansi3.test \ +ansi3b.test \ ansi4.test \ ansi5.test \ ansi6.test \ diff --git a/tests/ansi3.test b/tests/ansi3.test index 2bc57042..7823cc65 100755 --- a/tests/ansi3.test +++ b/tests/ansi3.test @@ -24,6 +24,8 @@ required=gcc . ./defs || exit 1 +set -e + cat > configure.in << 'END' AC_INIT(hello.c) AM_INIT_AUTOMAKE(hello,0.23) @@ -53,9 +55,11 @@ export CFLAGS # We use gcc and not gcc -traditional as the latter fails on some # Linux boxes (Red Hat 5.1 in particular). -$ACLOCAL \ - && $AUTOCONF \ - && $AUTOMAKE -a \ - && CC='gcc' ./configure \ - && ANSI2KNR=./ansi2knr U=_ $MAKE -e \ - && ./hello +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a 2>stderr +cat stderr +grep 'Makefile.am:1:.*ansi2knr\.c' stderr +CC='gcc' ./configure +ANSI2KNR=./ansi2knr U=_ $MAKE -e +./hello diff --git a/tests/ansi3b.test b/tests/ansi3b.test new file mode 100755 index 00000000..9bb18cb0 --- /dev/null +++ b/tests/ansi3b.test @@ -0,0 +1,64 @@ +#! /bin/sh +# Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake 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. +# +# GNU Automake 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 autoconf; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Actual test of ansi2knr functionality. Relies on existence +# of working gcc. Same as ansi3.test, but with AUTOMAKE_OPTIONS +# defined in configure.in. + +required=gcc +. ./defs || exit 1 + +set -e + +cat > configure.in << 'END' +AC_INIT([hello], [0.24]) +AM_INIT_AUTOMAKE([ansi2knr no-dependencies]) +AC_PROG_CC +AM_C_PROTOTYPES +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +END + +echo 'bin_PROGRAMS = hello' > Makefile.am + +cat > hello.c << 'END' +#include +int +main (int argc, char *argv[]) +{ + printf ("yeah, yeah\n"); + return 0; +} +END + +# Ignore user CFLAGS. +CFLAGS= +export CFLAGS + +# We use gcc and not gcc -traditional as the latter fails on some +# Linux boxes (Red Hat 5.1 in particular). +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a 2>stderr +cat stderr +grep 'configure.in:2:.*ansi2knr\.1' stderr +CC='gcc' ./configure +ANSI2KNR=./ansi2knr U=_ $MAKE -e +./hello -- 2.43.5