Revert Automake license to GPLv2+.
[platform/upstream/automake.git] / lib / Automake / Configure_ac.pm
1 # Copyright (C) 2003, 2005, 2006  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 CVS repository. #
18 # Updates should be sent to automake-patches@gnu.org.         #
19 ###############################################################
20
21 package Automake::Configure_ac;
22
23 use strict;
24 use Exporter;
25 use Automake::Channels;
26 use Automake::ChannelDefs;
27
28 use vars qw (@ISA @EXPORT);
29
30 @ISA = qw (Exporter);
31 @EXPORT = qw (&find_configure_ac &require_configure_ac);
32
33 =head1 NAME
34
35 Automake::Configure_ac - Locate configure.ac or configure.in.
36
37 =head1 SYNOPSIS
38
39   use Automake::Configure_ac;
40
41   # Try to locate configure.in or configure.ac in the current
42   # directory.  It may be absent.  Complain if both files exist.
43   my $file_name = find_configure_ac;
44
45   # Likewise, but bomb out if the file does not exist.
46   my $file_name = require_configure_ac;
47
48   # Likewise, but in $dir.
49   my $file_name = find_configure_ac ($dir);
50   my $file_name = require_configure_ac ($dir);
51
52 =cut
53
54 sub find_configure_ac (;@)
55 {
56   my ($directory) = @_;
57   $directory ||= '.';
58   my $configure_ac =
59     File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.ac'));
60   my $configure_in =
61     File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.in'));
62
63   if (-f $configure_ac)
64     {
65       if (-f $configure_in)
66         {
67           msg ('unsupported',
68                "`$configure_ac' and `$configure_in' both present.\n"
69                . "proceeding with `$configure_ac'.");
70         }
71       return $configure_ac
72     }
73   elsif (-f $configure_in)
74     {
75       return $configure_in;
76     }
77   return $configure_ac;
78 }
79
80
81 sub require_configure_ac (;$)
82 {
83   my $res = find_configure_ac (@_);
84   fatal "`configure.ac' or `configure.in' is required"
85     unless -f $res;
86   return $res
87 }
88
89 1;
90
91 ### Setup "GNU" style for perl-mode and cperl-mode.
92 ## Local Variables:
93 ## perl-indent-level: 2
94 ## perl-continued-statement-offset: 2
95 ## perl-continued-brace-offset: 0
96 ## perl-brace-offset: 0
97 ## perl-brace-imaginary-offset: 0
98 ## perl-label-offset: -2
99 ## cperl-indent-level: 2
100 ## cperl-brace-offset: 0
101 ## cperl-continued-brace-offset: 0
102 ## cperl-label-offset: -2
103 ## cperl-extra-newline-before-brace: t
104 ## cperl-merge-trailing-else: nil
105 ## cperl-continued-statement-offset: 2
106 ## End: