* lib/Automake/Configure_ac.pm
[platform/upstream/automake.git] / lib / Automake / Configure_ac.pm
1 # Copyright (C) 2003  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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
16 # 02111-1307, USA.
17
18 package Automake::Configure_ac;
19
20 use strict;
21 use Exporter;
22 use Automake::Channels;
23 use Automake::ChannelDefs;
24
25 use vars qw (@ISA @EXPORT);
26
27 @ISA = qw (Exporter);
28 @EXPORT = qw ($configure_ac &find_configure_ac &require_configure_ac);
29
30 =head1 NAME
31
32 Automake::Configure_ac - Locate configure.ac or configure.in.
33
34 =head1 SYNOPSIS
35
36   use Automake::Configure_ac;
37
38   # Try to locate configure.in or configure.ac in the current
39   # directory.  It may be absent.  Complain if both files exist.
40   my $filename = find_configure_ac;
41
42   # Likewise, but bomb out if the file does not exist.
43   my $filename = require_configure_ac;
44
45 In both cases, the name of the file found is also put in the
46 C<$configure_ac> global variable.
47
48 =cut
49
50 use vars '$configure_ac';
51
52 sub find_configure_ac ()
53 {
54   if (-f 'configure.ac')
55     {
56       if (-f 'configure.in')
57         {
58           msg ('unsupported',
59                "`configure.ac' and `configure.in' both present.\n"
60                . "proceeding with `configure.ac'.");
61         }
62       $configure_ac = 'configure.ac';
63     }
64   elsif (-f 'configure.in')
65     {
66       $configure_ac = 'configure.in';
67     }
68   return $configure_ac;
69 }
70
71 sub require_configure_ac ()
72 {
73   fatal "`configure.ac' or `configure.in' is required"
74     unless find_configure_ac;
75   return $configure_ac;
76 }
77
78 1;
79
80 ### Setup "GNU" style for perl-mode and cperl-mode.
81 ## Local Variables:
82 ## perl-indent-level: 2
83 ## perl-continued-statement-offset: 2
84 ## perl-continued-brace-offset: 0
85 ## perl-brace-offset: 0
86 ## perl-brace-imaginary-offset: 0
87 ## perl-label-offset: -2
88 ## cperl-indent-level: 2
89 ## cperl-brace-offset: 0
90 ## cperl-continued-brace-offset: 0
91 ## cperl-label-offset: -2
92 ## cperl-extra-newline-before-brace: t
93 ## cperl-merge-trailing-else: nil
94 ## cperl-continued-statement-offset: 2
95 ## End: