gnu-configize 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. #! /usr/bin/env perl
  2. # -*- perl -*-
  3. eval 'case $# in 0) exec /usr/bin/env perl -S "$0";; *) exec /usr/bin/env perl -S "$0" "$@";; esac'
  4. if 0;
  5. # gnu-configize - install the GNU config.guess / config.sub in a directory tree
  6. # Based on autoreconf:
  7. # Copyright (C) 1994, 1999, 2000, 2001, 2002, 2003
  8. # Free Software Foundation, Inc.
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 2, or (at your option)
  12. # any later version.
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  20. # 02111-1307, USA.
  21. BEGIN
  22. {
  23. my $datadir = $ENV{'autom4te_perllibdir'} || '/opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/linux-devkit/sysroots/x86_64-arago-linux/usr/share/autoconf';
  24. # '/home/kergoth/code/build-arm/tmp/staging/share/autoconf';
  25. unshift @INC, $datadir;
  26. # Override SHELL. On DJGPP SHELL may not be set to a shell
  27. # that can handle redirection and quote arguments correctly,
  28. # e.g.: COMMAND.COM. For DJGPP always use the shell that configure
  29. # has detected.
  30. $ENV{'SHELL'} = '/bin/sh' if ($^O eq 'dos');
  31. }
  32. use Autom4te::ChannelDefs;
  33. use Autom4te::Channels;
  34. use Autom4te::Configure_ac;
  35. use Autom4te::FileUtils;
  36. use Autom4te::General;
  37. use Autom4te::XFile;
  38. # Do not use Cwd::chdir, since it might hang.
  39. use Cwd 'cwd';
  40. use strict;
  41. ## ----------- ##
  42. ## Variables. ##
  43. ## ----------- ##
  44. # $HELP
  45. # -----
  46. $help = "Usage: $0 [OPTION] ... [CONFIGURE-AC or DIRECTORY] ...
  47. Install the GNU config.sub and config.guess scripts in the
  48. DIRECTORIES or the directory trees driven by CONFIGURE-AC
  49. (defaulting to `.').
  50. Operation modes:
  51. -h, --help print this help, then exit
  52. -V, --version print version number, then exit
  53. -v, --verbose verbosely report processing
  54. -f, --force consider all files obsolete
  55. -s, --symlink install symbolic links instead of copies
  56. -W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax]
  57. " . Autom4te::ChannelDefs::usage . "
  58. The environment variable \`WARNINGS\' is honored. Some subtools might
  59. support other warning types, using \`all' is encouraged.
  60. ";
  61. # $VERSION
  62. # --------
  63. $version = "gnu-configize 1.0
  64. Copyright (C) 2004 Chris Larson
  65. This is free software; see the source for copying conditions. There is NO
  66. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  67. ";
  68. my $configdir = '/opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/linux-devkit/sysroots/x86_64-arago-linux/usr/share/gnu-config';
  69. #'/home/kergoth/code/build-arm/tmp/staging/i686-linux/share/gnu-config';
  70. my $autoconf = $ENV{'AUTOCONF'} || 'autoconf';
  71. # use symlinks instead.
  72. my $symlink = 0;
  73. my $configure_ac;
  74. my $rm = "rm -f";
  75. my $ln_s = "ln -sf";
  76. my $cp = "cp -f";
  77. my $mkdir = "mkdir";
  78. my $chmod = "chmod";
  79. ## ---------- ##
  80. ## Routines. ##
  81. ## ---------- ##
  82. # parse_args ()
  83. # -------------
  84. # Process any command line arguments.
  85. sub parse_args ()
  86. {
  87. my $srcdir;
  88. getopt ('s|symlink' => \$symlink);
  89. # Even if the user specified a configure.ac, trim to get the
  90. # directory, and look for configure.ac again. Because (i) the code
  91. # is simpler, and (ii) we are still able to diagnose simultaneous
  92. # presence of configure.ac and configure.in.
  93. @ARGV = map { /configure\.(ac|in)$/ ? dirname ($_) : $_ } @ARGV;
  94. push @ARGV, '.' unless @ARGV;
  95. }
  96. # &gnu_configize_current_directory
  97. # -----------------------------
  98. sub gnu_configize_current_directory ()
  99. {
  100. my $configure_ac = require_configure_ac;
  101. # ---------------------- #
  102. # Is it using Autoconf? #
  103. # ---------------------- #
  104. my $uses_autoconf;
  105. my $uses_gettext;
  106. my $configure_ac_file = new Autom4te::XFile $configure_ac;
  107. while ($_ = $configure_ac_file->getline)
  108. {
  109. s/#.*//;
  110. s/dnl.*//;
  111. $uses_autoconf = 1 if /AC_INIT/;
  112. }
  113. if (!$uses_autoconf)
  114. {
  115. verb "$configure_ac: not using Autoconf";
  116. return;
  117. }
  118. my $aux_dir;
  119. my @subdir;
  120. my $cmd;
  121. my $dest;
  122. verb "$configure_ac: tracing";
  123. my $traces = new Autom4te::XFile
  124. ("$autoconf"
  125. . join (' --trace=', '',
  126. # If you change this list, update the
  127. # `Autoreconf-preselections' section of autom4te.in.
  128. 'AC_CONFIG_AUX_DIR:AC_CONFIG_AUX_DIR:\$1',
  129. 'AC_CONFIG_SUBDIRS:AC_CONFIG_SUBDIRS:\$1',
  130. 'AC_INIT',
  131. )
  132. . ' |');
  133. while ($_ = $traces->getline)
  134. {
  135. $aux_dir = $1 if /AC_CONFIG_AUX_DIR:(.*)/;
  136. $uses_autoconf = 1 if /AC_INIT/;
  137. push @subdir, split (' ', $1) if /AC_CONFIG_SUBDIRS:(.*)/;
  138. }
  139. # The subdirs are *optional*, they may not exist.
  140. foreach (@subdir)
  141. {
  142. if (-d)
  143. {
  144. verb "$configure_ac: subdirectory $_ to gnu-configize";
  145. gnu_configize ($_);
  146. }
  147. else
  148. {
  149. verb "$configure_ac: subdirectory $_ not present";
  150. }
  151. }
  152. $dest = ".";
  153. if (defined $aux_dir)
  154. {
  155. $dest = $aux_dir;
  156. if (! -d $aux_dir)
  157. {
  158. verb "$configure_ac: creating directory $aux_dir";
  159. mkdir $aux_dir
  160. or error "cannot create $aux_dir: $!";
  161. }
  162. }
  163. if (!$symlink)
  164. {
  165. $cmd = $cp;
  166. }
  167. else
  168. {
  169. $cmd = $ln_s;
  170. }
  171. xsystem ("$cmd $configdir/config.guess $dest/");
  172. xsystem ("$chmod u+x $dest/config.guess");
  173. xsystem ("$cmd $configdir/config.sub $dest/");
  174. xsystem ("$chmod u+x $dest/config.sub");
  175. }
  176. # &gnu_configize ($DIRECTORY)
  177. # ------------------------
  178. # Reconf the $DIRECTORY.
  179. sub gnu_configize ($)
  180. {
  181. my ($directory) = @_;
  182. my $cwd = cwd;
  183. # The format for this message is not free: taken from Emacs, itself
  184. # using GNU Make's format.
  185. verb "Entering directory `$directory'";
  186. chdir $directory
  187. or error "cannot chdir to $directory: $!";
  188. gnu_configize_current_directory;
  189. # The format is not free: taken from Emacs, itself using GNU Make's
  190. # format.
  191. verb "Leaving directory `$directory'";
  192. chdir $cwd
  193. or error "cannot chdir to $cwd: $!";
  194. }
  195. ## ------ ##
  196. ## Main. ##
  197. ## ------ ##
  198. parse_args;
  199. # Autoreconf all the given configure.ac. A while loop, not a for,
  200. # since the list can change at runtime because of AC_CONFIG_SUBDIRS.
  201. for my $directory (@ARGV)
  202. {
  203. gnu_configize ($directory);
  204. }
  205. ### Setup "GNU" style for perl-mode and cperl-mode.
  206. ## Local Variables:
  207. ## perl-indent-level: 2
  208. ## perl-continued-statement-offset: 2
  209. ## perl-continued-brace-offset: 0
  210. ## perl-brace-offset: 0
  211. ## perl-brace-imaginary-offset: 0
  212. ## perl-label-offset: -2
  213. ## cperl-indent-level: 2
  214. ## cperl-brace-offset: 0
  215. ## cperl-continued-brace-offset: 0
  216. ## cperl-label-offset: -2
  217. ## cperl-extra-newline-before-brace: t
  218. ## cperl-merge-trailing-else: nil
  219. ## cperl-continued-statement-offset: 2
  220. ## End: