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