PageRenderTime 58ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/build/autoconf/acoutput-fast.pl

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
Perl | 202 lines | 115 code | 12 blank | 75 comment | 20 complexity | 7c46111b2b9270b22223185136a55d61 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. #! /usr/bin/env perl
  2. #
  3. # ***** BEGIN LICENSE BLOCK *****
  4. # Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5. #
  6. # The contents of this file are subject to the Mozilla Public License Version
  7. # 1.1 (the "License"); you may not use this file except in compliance with
  8. # the License. You may obtain a copy of the License at
  9. # http://www.mozilla.org/MPL/
  10. #
  11. # Software distributed under the License is distributed on an "AS IS" basis,
  12. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. # for the specific language governing rights and limitations under the
  14. # License.
  15. #
  16. # The Original Code is mozilla.org code.
  17. #
  18. # The Initial Developer of the Original Code is
  19. # Netscape Communications Corporation.
  20. # Portions created by the Initial Developer are Copyright (C) 1999
  21. # the Initial Developer. All Rights Reserved.
  22. #
  23. # Contributor(s):
  24. #
  25. # Alternatively, the contents of this file may be used under the terms of
  26. # either of the GNU General Public License Version 2 or later (the "GPL"),
  27. # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. # in which case the provisions of the GPL or the LGPL are applicable instead
  29. # of those above. If you wish to allow use of your version of this file only
  30. # under the terms of either the GPL or the LGPL, and not to allow others to
  31. # use your version of this file under the terms of the MPL, indicate your
  32. # decision by deleting the provisions above and replace them with the notice
  33. # and other provisions required by the GPL or the LGPL. If you do not delete
  34. # the provisions above, a recipient may use your version of this file under
  35. # the terms of any one of the MPL, the GPL or the LGPL.
  36. #
  37. # ***** END LICENSE BLOCK *****
  38. # acoutput-fast.pl - Quickly create makefiles that are in a common format.
  39. #
  40. # Most of the makefiles in mozilla only refer to two configure variables:
  41. # @srcdir@
  42. # @top_srcdir@
  43. # However, configure does not know any better and it runs sed on each file
  44. # with over 150 replacement rules (slow as molasses).
  45. #
  46. # This script takes a list of makefiles as input. For example,
  47. #
  48. # echo $MAKEFILES | acoutput-fast.pl
  49. #
  50. # The script creates each Makefile that only references @srcdir@ and
  51. # @top_srcdir@. For other files, it lists them in a shell command that is
  52. # printed to stdout:
  53. #
  54. # CONFIG_FILES="unhandled_files..."; export CONFIG_FILES
  55. #
  56. # This command can be used to have config.status create the unhandled
  57. # files. For example,
  58. #
  59. # eval "echo $MAKEFILES | acoutput-fast.pl"
  60. # AC_OUTPUT($MAKEFILES)
  61. #
  62. # Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com).
  63. #use File::Basename;
  64. sub dirname {
  65. my $dir = $_[0];
  66. return '.' if not $dir =~ m%/%;
  67. $dir =~ s%/[^/][^/]*$%%;
  68. return $dir;
  69. }
  70. # Create one directory. Assumes it doesn't already exist.
  71. # Will create parent(s) if needed.
  72. sub create_directory {
  73. my $dir = $_[0];
  74. my $parent = dirname($dir);
  75. create_directory($parent) if not -d $parent;
  76. mkdir "$dir",0777;
  77. }
  78. # Create all the directories at once.
  79. # This can be much faster than calling mkdir() for each one.
  80. sub create_directories {
  81. my @makefiles = @_;
  82. my @dirs = ();
  83. my $ac_file;
  84. foreach $ac_file (@makefiles) {
  85. push @dirs, dirname($ac_file);
  86. }
  87. # Call mkdir with the directories sorted by subdir count (how many /'s)
  88. if (@dirs) {
  89. foreach $dir (@dirs) {
  90. if (not -d $dir) {
  91. print STDERR "Creating directory $dir\n";
  92. create_directory($dir);
  93. }
  94. }
  95. }
  96. }
  97. while($arg = shift) {
  98. if ($arg =~ /^--srcdir=/) {
  99. $ac_given_srcdir = (split /=/, $arg)[1];
  100. }
  101. if ($arg =~ /^--cygwin-srcdir/) {
  102. $ac_cygwin_srcdir = (split /=/, $arg)[1];
  103. }
  104. }
  105. if (!$ac_given_srcdir) {
  106. $ac_given_srcdir = $0;
  107. $ac_given_srcdir =~ s|/?build/autoconf/.*$||;
  108. $ac_given_srcdir = '.' if $ac_given_srcdir eq '';
  109. }
  110. if (!$ac_cygwin_srcdir) {
  111. $ac_cygwin_srcdir = $ac_given_srcdir;
  112. }
  113. # Read list of makefiles from the stdin or,
  114. # from files listed on the command-line.
  115. #
  116. @makefiles=();
  117. push @makefiles, split while (<STDIN>);
  118. # Create all the directories at once.
  119. # This can be much faster than calling mkdir() for each one.
  120. create_directories(@makefiles);
  121. # Output the makefiles.
  122. #
  123. @unhandled=();
  124. foreach $ac_file (@makefiles) {
  125. if (not $ac_file =~ /Makefile$/ or $ac_file =~ /:/) {
  126. push @unhandled, $ac_file;
  127. next;
  128. }
  129. $ac_file_in = "$ac_given_srcdir/$ac_file.in";
  130. $ac_dir = dirname($ac_file);
  131. if ($ac_dir eq '.') {
  132. $ac_dir_suffix = '';
  133. $ac_dots = '';
  134. } else {
  135. $ac_dir_suffix = "/$ac_dir";
  136. $ac_dir_suffix =~ s%^/\./%/%;
  137. $ac_dots = $ac_dir_suffix;
  138. $ac_dots =~ s%/[^/]*%../%g;
  139. }
  140. if ($ac_given_srcdir eq '.') {
  141. $srcdir = '.';
  142. if ($ac_dots eq '') {
  143. $top_srcdir = '.'
  144. } else {
  145. $top_srcdir = $ac_dots;
  146. $top_srcdir =~ s%/$%%;
  147. }
  148. } elsif ($ac_cygwin_srcdir =~ m%^/% or $ac_cygwin_srcdir =~ m%^.:/%) {
  149. $srcdir = "$ac_cygwin_srcdir$ac_dir_suffix";
  150. $top_srcdir = "$ac_cygwin_srcdir";
  151. } else {
  152. $srcdir = "$ac_dots$ac_cygwin_srcdir$ac_dir_suffix";
  153. $top_srcdir = "$ac_dots$ac_cygwin_srcdir";
  154. }
  155. if (-e $ac_file) {
  156. next if -M _ < -M $ac_file_in;
  157. print STDERR "updating $ac_file\n";
  158. } else {
  159. print STDERR "creating $ac_file\n";
  160. }
  161. open (INFILE, "<$ac_file_in")
  162. or ( warn "can't read $ac_file_in: No such file or directory\n" and next);
  163. open (OUTFILE, ">$ac_file")
  164. or ( warn "Unable to create $ac_file\n" and next);
  165. while (<INFILE>) {
  166. #if (/\@[_a-zA-Z]*\@.*\@[_a-zA-Z]*\@/) {
  167. # warn "Two defines on a line:$ac_file:$.:$_";
  168. # push @unhandled, $ac_file;
  169. # last;
  170. #}
  171. s/\@srcdir\@/$srcdir/g;
  172. s/\@top_srcdir\@/$top_srcdir/g;
  173. if (/\@[_a-zA-Z]*\@/) {
  174. warn "Unknown variable:$ac_file:$.:$_";
  175. push @unhandled, $ac_file;
  176. last;
  177. }
  178. print OUTFILE;
  179. }
  180. close INFILE;
  181. close OUTFILE;
  182. }
  183. # Print the shell command to be evaluated by configure.
  184. #
  185. print "CONFIG_FILES=\"".join(' ', @unhandled)."\"; export CONFIG_FILES\n";