150276Speterextproc perl -S -w 250276Speter 3166124Srafan# $Id: convert_configure.pl,v 1.3 2006/04/22 23:04:06 tom Exp $ 4166124Srafan############################################################################## 5166124Srafan# Copyright (c) 1998-2000,2006 Free Software Foundation, Inc. # 6166124Srafan# # 7166124Srafan# Permission is hereby granted, free of charge, to any person obtaining a # 8166124Srafan# copy of this software and associated documentation files (the "Software"), # 9166124Srafan# to deal in the Software without restriction, including without limitation # 10166124Srafan# the rights to use, copy, modify, merge, publish, distribute, distribute # 11166124Srafan# with modifications, sublicense, and/or sell copies of the Software, and to # 12166124Srafan# permit persons to whom the Software is furnished to do so, subject to the # 13166124Srafan# following conditions: # 14166124Srafan# # 15166124Srafan# The above copyright notice and this permission notice shall be included in # 16166124Srafan# all copies or substantial portions of the Software. # 17166124Srafan# # 18166124Srafan# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # 19166124Srafan# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # 20166124Srafan# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # 21166124Srafan# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # 22166124Srafan# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # 23166124Srafan# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # 24166124Srafan# DEALINGS IN THE SOFTWARE. # 25166124Srafan# # 26166124Srafan# Except as contained in this notice, the name(s) of the above copyright # 27166124Srafan# holders shall not be used in advertising or otherwise to promote the sale, # 28166124Srafan# use or other dealings in this Software without prior written # 29166124Srafan# authorization. # 30166124Srafan############################################################################## 31166124Srafan 3250276Speter# The converted script is written to stdout, so run this script as 3350276Speter# convert_configure configure > configure.cmd 3450276Speter# 3550276Speter# When the converted script runs, it expects that /tmp dir is 3650276Speter# available (so we create it). 3750276Speter# 3850276Speter# run the result like this: 3950276Speter# .\configure 4050276Speter 4166963Speter# Some frequent manual intervention: 4266963Speter# a) Some makefiles hardwire SHELL = /bin/sh ==> change to: sh 4366963Speter# b) Some makefiles recognize that exe files terminate on .exe 4466963Speter# You need to give this script -no-zexe option... 4566963Speter 4666963Spetershift, $no_zexe = 1 if @ARGV and $ARGV[0] eq '-no-zexe'; 4766963Speter 4850276Spetermkdir '/tmp', 0777 unless -d '/tmp'; 4950276Speter 5050276Speterprint <<EOF; 5150276Speterextproc sh 5250276Speter 5366963SpeterEOF 5466963Speter 5566963Speterprint <<EOF unless $no_zexe; 5650276Speter# Make sensible defaults: 5766963SpeterCC="gcc -Zexe -Zmt" 5850276Speterexport CC 5966963SpeterCXX="gcc -Zexe -Zmt" 6066963Speterexport CXX 6150276Speter#GCCOPT="$GCCOPT -Zexe" 6250276Speter#export GCCOPT 6366963SpeterEOF 6466963Speter 6566963Speterprint <<EOF; 6650276SpeterCONFIG_SHELL=sh 6766963Speterexport CONFIG_SHELL 6850276Speter 6966963Speter# Optimization (GNU make 3.74 cannot be loaded :-(): 7066963Speteremxload -m 30 sh.exe ls.exe tr.exe id.exe sed.exe # make.exe 7166963Speteremxload -m 30 grep.exe egrep.exe fgrep.exe cat.exe rm.exe mv.exe cp.exe 7266963Speteremxload -m 30 uniq.exe basename.exe sort.exe awk.exe echo.exe 7366963Speter 7466963Speter 7550276SpeterEOF 7650276Speter 7750276Speter$checking_path = 0; 7850276Speter 7950276Speterwhile (<>) { 8066963Speter if (/for\s+(\w+)\s+in\s*\$(PATH|ac_dummy)\s*;/) { 8150276Speter $checking_path = 1; 8250276Speter $varname = $1; 8350276Speter $subst= <<EOS 8450276Speter$varname="`echo -E \\"\$$varname\\" | tr \\\\\\\\\\\\\\\\ / `" 8550276SpeterEOS 8650276Speter } 8766963Speter if (/if\s+test\s+-z\s+\"\$INSTALL\"/) { 8866963Speter $checking_install = 1; 8966963Speter } 9066963Speter $checking_install = $checking_path = 0 if /^\s*done\s*$/; 9150276Speter # We want to create an extra line like this one: 9250276Speter# ac_dir="`echo -E \"$ac_dir\" | tr \\\\\\\\ / `" 9350276Speter s{^((\s*)if\s+test)\s*-f\s*(\$$varname/\S+)\s*;} 9466963Speter {$2$subst$1 -f $3 -o -f $3.exe ;} 9550276Speter if $checking_path; # Checking for executables 9666963Speter # change |/usr/sbin/*| to |/usr/sbin/*|?:[\\/]os2[\\/]install[\\/]*| 9766963Speter # in the list of things to skip (with both cases) 9866963Speter s{\Q|/usr/sbin/*|} 9966963Speter {|/usr/sbin/*|?:[\\\\/]os2[\\\\/]install[\\\\/]*|?:[\\\\/]OS2[\\\\/]INSTALL[\\\\/]*|} 10066963Speter if $checking_install; # Do not accept d:/os2/install/install.exe 10166963Speter s/^(host|build)=NONE$/$1=x86-emx-os2/; # Make default host/build 10250276Speter s/"\$\{IFS}:"$/"\${IFS};"/; # Fix IFS line 10366963Speter s/\bIFS=\":\"$/IFS=";"/; # Fix another IFS line 10450276Speter s/\btest\s+-s\s+conftest\b/test -f conftest/g; # Fix exe test 10550276Speter # This one is needed for curses: 10666963Speter s/^\s*host=`.*\$ac_config_sub \$host_alias`/$&\nif test -z "\$host"; then host=\$host_alias; fi/; 10750276Speter s,/bin/sh(?![/\w]),sh,g; 10866963Speter s,^(\s*/usr/sbin/sendmail\s*)\\$,$1 "`whence sendmail | tr '\\\\\\\\' / `" \\,; 10950276Speter print; 11050276Speter} 11150276Speter 11250276Speter__END__ 11350276Speter 11466963SpeterChanges: 98/11 : support check for executables in ncurses. 11566963Speter 99/2 : support INSTALL, 11666963Speter new IFS=':' style 11766963Speter 99/11 : find sendmail 11866963Speter 00/01 : export CONFIG_SHELL 11966963Speter 00/10 : new syntax for host=`...` line 120