1# Copyright (C) 2003-2012 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 2, or (at your option) 6# any later version. 7 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16############################################################### 17# The main copy of this file is in Automake's git repository. # 18# Updates should be sent to automake-patches@gnu.org. # 19############################################################### 20 21package Autom4te::Configure_ac; 22 23use 5.006; 24use strict; 25use Exporter; 26use Autom4te::Channels; 27use Autom4te::ChannelDefs; 28 29use vars qw (@ISA @EXPORT); 30 31@ISA = qw (Exporter); 32@EXPORT = qw (&find_configure_ac &require_configure_ac); 33 34=head1 NAME 35 36Autom4te::Configure_ac - Locate configure.ac or configure.in. 37 38=head1 SYNOPSIS 39 40 use Autom4te::Configure_ac; 41 42 # Try to locate configure.in or configure.ac in the current 43 # directory. It may be absent. Complain if both files exist. 44 my $file_name = find_configure_ac; 45 46 # Likewise, but bomb out if the file does not exist. 47 my $file_name = require_configure_ac; 48 49 # Likewise, but in $dir. 50 my $file_name = find_configure_ac ($dir); 51 my $file_name = require_configure_ac ($dir); 52 53=over 4 54 55=back 56 57=head2 Functions 58 59=over 4 60 61=item C<$configure_ac = find_configure_ac ([$directory])> 62 63Find a F<configure.ac> or F<configure.in> file in C<$directory>, 64defaulting to the current directory. Complain if both files are present. 65Return the name of the file found, or the former if neither is present. 66 67=cut 68 69sub find_configure_ac (;@) 70{ 71 my ($directory) = @_; 72 $directory ||= '.'; 73 my $configure_ac = 74 File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.ac')); 75 my $configure_in = 76 File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.in')); 77 78 if (-f $configure_ac) 79 { 80 if (-f $configure_in) 81 { 82 msg ('unsupported', 83 "'$configure_ac' and '$configure_in' both present.\n" 84 . "proceeding with '$configure_ac'"); 85 } 86 return $configure_ac 87 } 88 elsif (-f $configure_in) 89 { 90 return $configure_in; 91 } 92 return $configure_ac; 93} 94 95 96=item C<$configure_ac = require_configure_ac ([$directory])> 97 98Like C<find_configure_ac>, but fail if neither is present. 99 100=cut 101 102sub require_configure_ac (;$) 103{ 104 my $res = find_configure_ac (@_); 105 fatal "'configure.ac' or 'configure.in' is required" 106 unless -f $res; 107 return $res 108} 109 1101; 111 112### Setup "GNU" style for perl-mode and cperl-mode. 113## Local Variables: 114## perl-indent-level: 2 115## perl-continued-statement-offset: 2 116## perl-continued-brace-offset: 0 117## perl-brace-offset: 0 118## perl-brace-imaginary-offset: 0 119## perl-label-offset: -2 120## cperl-indent-level: 2 121## cperl-brace-offset: 0 122## cperl-continued-brace-offset: 0 123## cperl-label-offset: -2 124## cperl-extra-newline-before-brace: t 125## cperl-merge-trailing-else: nil 126## cperl-continued-statement-offset: 2 127## End: 128