File Coverage

blib/lib/auto/share/dist/Alien-autoconf/share/autoconf/Autom4te/Configure_ac.pm
Criterion Covered Total %
statement 17 31 54.8
branch 0 6 0.0
condition 0 2 0.0
subroutine 6 8 75.0
pod 2 2 100.0
total 25 49 51.0


line stmt bran cond sub pod time code
1             # Copyright (C) 2003-2023 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 .
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              
21             package Autom4te::Configure_ac;
22              
23 4     4   65 use 5.006;
  4         44  
24 4     4   22 use strict;
  4         34  
  4         120  
25 4     4   19 use warnings FATAL => 'all';
  4         7  
  4         218  
26              
27 4     4   21 use Exporter;
  4         5  
  4         200  
28              
29 4     4   21 use Autom4te::ChannelDefs;
  4         5  
  4         566  
30 4     4   27 use Autom4te::Channels;
  4         19  
  4         1974  
31              
32             our @ISA = qw (Exporter);
33             our @EXPORT = qw (&find_configure_ac &require_configure_ac);
34              
35             =head1 NAME
36              
37             Autom4te::Configure_ac - Locate configure.ac or configure.in.
38              
39             =head1 SYNOPSIS
40              
41             use Autom4te::Configure_ac;
42              
43             # Try to locate configure.in or configure.ac in the current
44             # directory. It may be absent. Complain if both files exist.
45             my $file_name = find_configure_ac;
46              
47             # Likewise, but bomb out if the file does not exist.
48             my $file_name = require_configure_ac;
49              
50             # Likewise, but in $dir.
51             my $file_name = find_configure_ac ($dir);
52             my $file_name = require_configure_ac ($dir);
53              
54             =over 4
55              
56             =back
57              
58             =head2 Functions
59              
60             =over 4
61              
62             =item C<$configure_ac = find_configure_ac ([$directory])>
63              
64             Find a F or F file in C<$directory>,
65             defaulting to the current directory. Complain if both files are present.
66             Return the name of the file found, or the former if neither is present.
67              
68             =cut
69              
70             sub find_configure_ac (;@)
71             {
72 0     0 1   my ($directory) = @_;
73 0   0       $directory ||= '.';
74 0           my $configure_ac =
75             File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.ac'));
76 0           my $configure_in =
77             File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.in'));
78              
79 0 0         if (-f $configure_in)
80             {
81 0           msg ('obsolete', "autoconf input should be named 'configure.ac'," .
82             " not 'configure.in'");
83 0 0         if (-f $configure_ac)
84             {
85 0           msg ('unsupported',
86             "'$configure_ac' and '$configure_in' both present.\n"
87             . "proceeding with '$configure_ac'");
88 0           return $configure_ac
89             }
90             else
91             {
92 0           return $configure_in;
93             }
94             }
95 0           return $configure_ac;
96             }
97              
98              
99             =item C<$configure_ac = require_configure_ac ([$directory])>
100              
101             Like C, but fail if neither is present.
102              
103             =cut
104              
105             sub require_configure_ac (;$)
106             {
107 0     0 1   my $res = find_configure_ac (@_);
108 0 0         fatal "'configure.ac' is required" unless -f $res;
109 0           return $res
110             }
111              
112             1;