convert_configure.pl 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. extproc perl -S -w
  2. # $Id: convert_configure.pl,v 1.3 2006/04/22 23:04:06 tom Exp $
  3. ##############################################################################
  4. # Copyright (c) 1998-2000,2006 Free Software Foundation, Inc. #
  5. # #
  6. # Permission is hereby granted, free of charge, to any person obtaining a #
  7. # copy of this software and associated documentation files (the "Software"), #
  8. # to deal in the Software without restriction, including without limitation #
  9. # the rights to use, copy, modify, merge, publish, distribute, distribute #
  10. # with modifications, sublicense, and/or sell copies of the Software, and to #
  11. # permit persons to whom the Software is furnished to do so, subject to the #
  12. # following conditions: #
  13. # #
  14. # The above copyright notice and this permission notice shall be included in #
  15. # all copies or substantial portions of the Software. #
  16. # #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
  18. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
  19. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
  20. # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
  21. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
  22. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
  23. # DEALINGS IN THE SOFTWARE. #
  24. # #
  25. # Except as contained in this notice, the name(s) of the above copyright #
  26. # holders shall not be used in advertising or otherwise to promote the sale, #
  27. # use or other dealings in this Software without prior written #
  28. # authorization. #
  29. ##############################################################################
  30. # The converted script is written to stdout, so run this script as
  31. # convert_configure configure > configure.cmd
  32. #
  33. # When the converted script runs, it expects that /tmp dir is
  34. # available (so we create it).
  35. #
  36. # run the result like this:
  37. # .\configure
  38. # Some frequent manual intervention:
  39. # a) Some makefiles hardwire SHELL = /bin/sh ==> change to: sh
  40. # b) Some makefiles recognize that exe files terminate on .exe
  41. # You need to give this script -no-zexe option...
  42. shift, $no_zexe = 1 if @ARGV and $ARGV[0] eq '-no-zexe';
  43. mkdir '/tmp', 0777 unless -d '/tmp';
  44. print <<EOF;
  45. extproc sh
  46. EOF
  47. print <<EOF unless $no_zexe;
  48. # Make sensible defaults:
  49. CC="gcc -Zexe -Zmt"
  50. export CC
  51. CXX="gcc -Zexe -Zmt"
  52. export CXX
  53. #GCCOPT="$GCCOPT -Zexe"
  54. #export GCCOPT
  55. EOF
  56. print <<EOF;
  57. CONFIG_SHELL=sh
  58. export CONFIG_SHELL
  59. # Optimization (GNU make 3.74 cannot be loaded :-():
  60. emxload -m 30 sh.exe ls.exe tr.exe id.exe sed.exe # make.exe
  61. emxload -m 30 grep.exe egrep.exe fgrep.exe cat.exe rm.exe mv.exe cp.exe
  62. emxload -m 30 uniq.exe basename.exe sort.exe awk.exe echo.exe
  63. EOF
  64. $checking_path = 0;
  65. while (<>) {
  66. if (/for\s+(\w+)\s+in\s*\$(PATH|ac_dummy)\s*;/) {
  67. $checking_path = 1;
  68. $varname = $1;
  69. $subst= <<EOS
  70. $varname="`echo -E \\"\$$varname\\" | tr \\\\\\\\\\\\\\\\ / `"
  71. EOS
  72. }
  73. if (/if\s+test\s+-z\s+\"\$INSTALL\"/) {
  74. $checking_install = 1;
  75. }
  76. $checking_install = $checking_path = 0 if /^\s*done\s*$/;
  77. # We want to create an extra line like this one:
  78. # ac_dir="`echo -E \"$ac_dir\" | tr \\\\\\\\ / `"
  79. s{^((\s*)if\s+test)\s*-f\s*(\$$varname/\S+)\s*;}
  80. {$2$subst$1 -f $3 -o -f $3.exe ;}
  81. if $checking_path; # Checking for executables
  82. # change |/usr/sbin/*| to |/usr/sbin/*|?:[\\/]os2[\\/]install[\\/]*|
  83. # in the list of things to skip (with both cases)
  84. s{\Q|/usr/sbin/*|}
  85. {|/usr/sbin/*|?:[\\\\/]os2[\\\\/]install[\\\\/]*|?:[\\\\/]OS2[\\\\/]INSTALL[\\\\/]*|}
  86. if $checking_install; # Do not accept d:/os2/install/install.exe
  87. s/^(host|build)=NONE$/$1=x86-emx-os2/; # Make default host/build
  88. s/"\$\{IFS}:"$/"\${IFS};"/; # Fix IFS line
  89. s/\bIFS=\":\"$/IFS=";"/; # Fix another IFS line
  90. s/\btest\s+-s\s+conftest\b/test -f conftest/g; # Fix exe test
  91. # This one is needed for curses:
  92. s/^\s*host=`.*\$ac_config_sub \$host_alias`/$&\nif test -z "\$host"; then host=\$host_alias; fi/;
  93. s,/bin/sh(?![/\w]),sh,g;
  94. s,^(\s*/usr/sbin/sendmail\s*)\\$,$1 "`whence sendmail | tr '\\\\\\\\' / `" \\,;
  95. print;
  96. }
  97. __END__
  98. Changes: 98/11 : support check for executables in ncurses.
  99. 99/2 : support INSTALL,
  100. new IFS=':' style
  101. 99/11 : find sendmail
  102. 00/01 : export CONFIG_SHELL
  103. 00/10 : new syntax for host=`...` line