File Coverage

File:/tmp/automake/lib/Automake/Configure_ac.pm
Coverage:97.9%

linestmtbrancondsubpodtimecode
1# Copyright (C) 2003, 2005, 2006, 2009, 2010 Free Software Foundation,
2# Inc.
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17###############################################################
18# The main copy of this file is in Automake's git repository. #
19# Updates should be sent to automake-patches@gnu.org. #
20###############################################################
21
22package Automake::Configure_ac;
23
24
2200
2200
2200
7568
2950
9765
use strict;
25
2200
2200
2200
7713
2248
7470
use Exporter;
26
2200
2200
2200
15787
2572
9762
use Automake::Channels;
27
2200
2200
2200
12594
2908
9839
use Automake::ChannelDefs;
28
29
2200
2200
2200
8822
2387
8475
use vars qw (@ISA @EXPORT);
30
31@ISA = qw (Exporter);
32@EXPORT = qw (&find_configure_ac &require_configure_ac);
33
34 - 67
=head1 NAME

Automake::Configure_ac - Locate configure.ac or configure.in.

=head1 SYNOPSIS

  use Automake::Configure_ac;

  # Try to locate configure.in or configure.ac in the current
  # directory.  It may be absent.  Complain if both files exist.
  my $file_name = find_configure_ac;

  # Likewise, but bomb out if the file does not exist.
  my $file_name = require_configure_ac;

  # Likewise, but in $dir.
  my $file_name = find_configure_ac ($dir);
  my $file_name = require_configure_ac ($dir);

=over 4

=back

=head2 Functions

=over 4

=item C<$configure_ac = find_configure_ac ([$directory])>

Find a F<configure.ac> or F<configure.in> file in C<$directory>,
defaulting to the current directory.  Complain if both files are present.
Return the name of the file found, or the former if neither is present.

=cut
68
69sub find_configure_ac (;@)
70{
71
2726
1
6628
  my ($directory) = @_;
72
2726
9475
  $directory ||= '.';
73
2726
44347
  my $configure_ac =
74    File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.ac'));
75
2726
11972
  my $configure_in =
76    File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.in'));
77
78
2726
37144
  if (-f $configure_ac)
79    {
80
13
69
      if (-f $configure_in)
81        {
82
4
27
          msg ('unsupported',
83               "`$configure_ac' and `$configure_in' both present.\n"
84               . "proceeding with `$configure_ac'");
85        }
86
13
37
      return $configure_ac
87    }
88  elsif (-f $configure_in)
89    {
90
2711
7963
      return $configure_in;
91    }
92
2
5
  return $configure_ac;
93}
94
95
96 - 100
=item C<$configure_ac = require_configure_ac ([$directory])>

Like C<find_configure_ac>, but fail if neither is present.

=cut
101
102sub require_configure_ac (;$)
103{
104
2164
1
7006
  my $res = find_configure_ac (@_);
105
2164
8861
  fatal "`configure.ac' or `configure.in' is required"
106    unless -f $res;
107
2162
6732
  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: