Configure_ac.pm 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # Copyright (C) 2003-2017 Free Software Foundation, Inc.
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 2, or (at your option)
  5. # any later version.
  6. # This program is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. # GNU General Public License for more details.
  10. # You should have received a copy of the GNU General Public License
  11. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. ###############################################################
  13. # The main copy of this file is in Automake's git repository. #
  14. # Updates should be sent to automake-patches@gnu.org. #
  15. ###############################################################
  16. package Automake::Configure_ac;
  17. use 5.006;
  18. use strict;
  19. use Exporter;
  20. use Automake::Channels;
  21. use Automake::ChannelDefs;
  22. use vars qw (@ISA @EXPORT);
  23. @ISA = qw (Exporter);
  24. @EXPORT = qw (&find_configure_ac &require_configure_ac);
  25. =head1 NAME
  26. Automake::Configure_ac - Locate configure.ac or configure.in.
  27. =head1 SYNOPSIS
  28. use Automake::Configure_ac;
  29. # Try to locate configure.in or configure.ac in the current
  30. # directory. It may be absent. Complain if both files exist.
  31. my $file_name = find_configure_ac;
  32. # Likewise, but bomb out if the file does not exist.
  33. my $file_name = require_configure_ac;
  34. # Likewise, but in $dir.
  35. my $file_name = find_configure_ac ($dir);
  36. my $file_name = require_configure_ac ($dir);
  37. =over 4
  38. =back
  39. =head2 Functions
  40. =over 4
  41. =item C<$configure_ac = find_configure_ac ([$directory])>
  42. Find a F<configure.ac> or F<configure.in> file in C<$directory>,
  43. defaulting to the current directory. Complain if both files are present.
  44. Return the name of the file found, or the former if neither is present.
  45. =cut
  46. sub find_configure_ac (;@)
  47. {
  48. my ($directory) = @_;
  49. $directory ||= '.';
  50. my $configure_ac =
  51. File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.ac'));
  52. my $configure_in =
  53. File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.in'));
  54. if (-f $configure_in)
  55. {
  56. msg ('obsolete', "autoconf input should be named 'configure.ac'," .
  57. " not 'configure.in'");
  58. if (-f $configure_ac)
  59. {
  60. msg ('unsupported',
  61. "'$configure_ac' and '$configure_in' both present.\n"
  62. . "proceeding with '$configure_ac'");
  63. return $configure_ac
  64. }
  65. else
  66. {
  67. return $configure_in;
  68. }
  69. }
  70. return $configure_ac;
  71. }
  72. =item C<$configure_ac = require_configure_ac ([$directory])>
  73. Like C<find_configure_ac>, but fail if neither is present.
  74. =cut
  75. sub require_configure_ac (;$)
  76. {
  77. my $res = find_configure_ac (@_);
  78. fatal "'configure.ac' is required" unless -f $res;
  79. return $res
  80. }
  81. 1;
  82. ### Setup "GNU" style for perl-mode and cperl-mode.
  83. ## Local Variables:
  84. ## perl-indent-level: 2
  85. ## perl-continued-statement-offset: 2
  86. ## perl-continued-brace-offset: 0
  87. ## perl-brace-offset: 0
  88. ## perl-brace-imaginary-offset: 0
  89. ## perl-label-offset: -2
  90. ## cperl-indent-level: 2
  91. ## cperl-brace-offset: 0
  92. ## cperl-continued-brace-offset: 0
  93. ## cperl-label-offset: -2
  94. ## cperl-extra-newline-before-brace: t
  95. ## cperl-merge-trailing-else: nil
  96. ## cperl-continued-statement-offset: 2
  97. ## End: