doc: update Vala documentation
[automake.git] / lib / Automake / Configure_ac.pm
blob825848f4ac6a24dca1124354774fdbe50c736807
1 # Copyright (C) 2003-2024 Free Software Foundation, Inc.
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.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 ##################################################################
17 # The master copy of this file is in Automake's source repository.
18 # Please send updates to automake-patches@gnu.org.
19 ##################################################################
21 package Automake::Configure_ac;
23 use 5.006;
24 use strict;
25 use warnings FATAL => 'all';
27 use Exporter;
29 use Automake::ChannelDefs;
30 use Automake::Channels;
32 our @ISA = qw (Exporter);
33 our @EXPORT = qw (&find_configure_ac &require_configure_ac);
35 =head1 NAME
37 Automake::Configure_ac - Locate configure.ac or configure.in.
39 =head1 SYNOPSIS
41 use Automake::Configure_ac;
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;
47 # Likewise, but bomb out if the file does not exist.
48 my $file_name = require_configure_ac;
50 # Likewise, but in $dir.
51 my $file_name = find_configure_ac ($dir);
52 my $file_name = require_configure_ac ($dir);
54 =over 4
56 =back
58 =head2 Functions
60 =over 4
62 =item C<$configure_ac = find_configure_ac ([$directory])>
64 Find a F<configure.ac> or F<configure.in> 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.
68 =cut
70 sub find_configure_ac (;@)
72 my ($directory) = @_;
73 $directory ||= '.';
74 my $configure_ac =
75 File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.ac'));
76 my $configure_in =
77 File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.in'));
79 if (-f $configure_in)
81 msg ('obsolete', "autoconf input should be named 'configure.ac'," .
82 " not 'configure.in'");
83 if (-f $configure_ac)
85 msg ('unsupported',
86 "'$configure_ac' and '$configure_in' both present.\n"
87 . "proceeding with '$configure_ac'");
88 return $configure_ac
90 else
92 return $configure_in;
95 return $configure_ac;
99 =item C<$configure_ac = require_configure_ac ([$directory])>
101 Like C<find_configure_ac>, but fail if neither is present.
103 =cut
105 sub require_configure_ac (;$)
107 my $res = find_configure_ac (@_);
108 fatal "'configure.ac' is required" unless -f $res;
109 return $res