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