Ticket #3637: ghc-configure-args.diff

File ghc-configure-args.diff, 6.6 KB (added by asuffield, 6 years ago)
  • aclocal.m4

    diff -rN -u old-ghc/aclocal.m4 new-ghc/aclocal.m4
    old new  
    12351235esac
    12361236])
    12371237
     1238# GHC_CONVERT_CPU(cpu, target_var)
     1239# --------------------------------
     1240# converts cpu from gnu to ghc naming, and assigns the result to $target_var
     1241AC_DEFUN([GHC_CONVERT_CPU],[
     1242case "$1" in
     1243  alpha*)
     1244    $2="alpha"
     1245    ;;
     1246  arm*)
     1247    $2="arm"
     1248    ;;
     1249  hppa1.1*)
     1250    $2="hppa1_1"
     1251    ;;
     1252  hppa*)
     1253    $2="hppa"
     1254    ;;
     1255  i386)
     1256    $2="i386"
     1257    ;;
     1258  ia64)
     1259    $2="ia64"
     1260    ;;
     1261  m68k*)
     1262    $2="m68k"
     1263    ;;
     1264  mipseb*)
     1265    $2="mipseb"
     1266    ;;
     1267  mipsel*)
     1268    $2="mipsel"
     1269    ;;
     1270  mips*)
     1271    $2="mips"
     1272    ;;
     1273  powerpc64*)
     1274    $2="powerpc64"
     1275    ;;
     1276  powerpc*)
     1277    $2="powerpc"
     1278    ;;
     1279  rs6000)
     1280    $2="rs6000"
     1281    ;;
     1282  s390*)
     1283    $2="s390"
     1284    ;;
     1285  sparc64*)
     1286    $2="sparc64"
     1287    ;;
     1288  sparc*)
     1289    $2="sparc"
     1290    ;;
     1291  vax)
     1292    $2="vax"
     1293    ;;
     1294  x86_64)
     1295    $2="x86_64"
     1296    ;;
     1297  *)
     1298    echo "Unknown CPU $1"
     1299    exit 1
     1300    ;;
     1301  esac
     1302])
     1303
     1304# GHC_CONVERT_VENDOR(vendor, target_var)
     1305# --------------------------------
     1306# converts vendor from gnu to ghc naming, and assigns the result to $target_var
     1307AC_DEFUN([GHC_CONVERT_VENDOR],[
     1308$2="$1"
     1309])
     1310
     1311# GHC_CONVERT_OS(os, target_var)
     1312# --------------------------------
     1313# converts os from gnu to ghc naming, and assigns the result to $target_var
     1314AC_DEFUN([GHC_CONVERT_OS],[
     1315case "$1" in
     1316  linux-*|linux)
     1317    $2="linux"
     1318    ;;
     1319  # As far as I'm aware, none of these have relevant variants
     1320  freebsd|netbsd|openbsd|dragonfly|osf1|osf3|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|cygwin32|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|irix|aix|haiku)
     1321    $2="$1"
     1322    ;;
     1323  *)
     1324    echo "Unknown OS $1"
     1325    exit 1
     1326    ;;
     1327  esac
     1328])
     1329
    12381330# LocalWords:  fi
  • configure.ac

    diff -rN -u old-ghc/configure.ac new-ghc/configure.ac
    old new  
    208208  --host=HOST       cross-compile to build programs to run on HOST [guessed]
    209209  --target=TARGET   configure for building compilers for TARGET [guessed]]])dnl
    210210
    211 if test "$build" = ""
     211if test "${WithGhc}" != ""
     212then
     213        bootstrap_host=`"${WithGhc}" +RTS --info | grep '^ ,("Host platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
     214        bootstrap_target=`"${WithGhc}" +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
     215        if test "$bootstrap_host" != "$bootstrap_target"
     216        then
     217                echo "Bootstrapping GHC is a cross compiler. This probably isn't going to work"
     218        fi
     219fi
     220
     221# We have to run these unconditionally, but we may discard their
     222# results in the following code
     223AC_CANONICAL_BUILD
     224AC_CANONICAL_HOST
     225AC_CANONICAL_TARGET
     226
     227# If no argument was given for a configuration variable, then discard
     228# the guessed canonical system and use the configuration of the
     229# bootstrapping ghc. If an argument was given, map it from gnu format
     230# to ghc format.
     231
     232if test "$build_alias" = ""
    212233then
    213234    if test "${WithGhc}" != ""
    214235    then
    215         build=`"${WithGhc}" +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
     236        build=$bootstrap_target
    216237        echo "Build platform inferred as: $build"
    217238    else
    218239        echo "Can't work out build platform"
    219240        exit 1
    220241    fi
     242
     243    BuildArch=`echo "$build" | sed 's/-.*//'`
     244    BuildVendor=`echo "$build" | sed -e 's/.*-\(.*\)-.*/\1/'`
     245    BuildOS=`echo "$build" | sed 's/.*-//'`
     246else
     247    GHC_CONVERT_CPU([$build_cpu], [BuildArch])
     248    GHC_CONVERT_VENDOR([$build_vendor], [BuildVendor])
     249    GHC_CONVERT_OS([$build_os], [BuildOS])
    221250fi
    222251
    223 if test "$host" = ""
     252if test "$host_alias" = ""
    224253then
    225254    if test "${WithGhc}" != ""
    226255    then
    227         host=`"${WithGhc}" +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
     256        host=$bootstrap_target
    228257        echo "Host platform inferred as: $host"
    229258    else
    230259        echo "Can't work out host platform"
    231260        exit 1
    232261    fi
     262
     263    HostArch=`echo "$host" | sed 's/-.*//'`
     264    HostVendor=`echo "$host" | sed -e 's/.*-\(.*\)-.*/\1/'`
     265    HostOS=`echo "$host" | sed 's/.*-//'`
     266else
     267    GHC_CONVERT_CPU([$host_cpu], [HostArch])
     268    GHC_CONVERT_VENDOR([$host_vendor], [HostVendor])
     269    GHC_CONVERT_OS([$host_os], [HostOS])
    233270fi
    234271
    235 if test "$target" = ""
     272if test "$target_alias" = ""
    236273then
    237274    if test "${WithGhc}" != ""
    238275    then
    239         target=`"${WithGhc}" +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
     276        target=$bootstrap_target
    240277        echo "Target platform inferred as: $target"
    241278    else
    242279        echo "Can't work out target platform"
    243280        exit 1
    244281    fi
     282
     283    TargetArch=`echo "$target" | sed 's/-.*//'`
     284    TargetVendor=`echo "$target" | sed -e 's/.*-\(.*\)-.*/\1/'`
     285    TargetOS=`echo "$target" | sed 's/.*-//'`
     286else
     287    GHC_CONVERT_CPU([$target_cpu], [TargetArch])
     288    GHC_CONVERT_VENDOR([$target_vendor], [TargetVendor])
     289    GHC_CONVERT_OS([$target_os], [TargetOS])
    245290fi
    246291
    247292exeext=''
     
    305350    esac
    306351}
    307352
    308 BuildPlatform=$build
    309 BuildArch=`echo "$build" | sed 's/-.*//'`
    310 BuildVendor=`echo "$build" | sed -e 's/.*-\(.*\)-.*/\1/'`
    311 BuildOS=`echo "$build" | sed 's/.*-//'`
     353BuildPlatform="$BuildArch-$BuildVendor-$BuildOS"
    312354BuildPlatform_CPP=`echo "$BuildPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
    313355BuildArch_CPP=`    echo "$BuildArch"     | sed -e 's/\./_/g' -e 's/-/_/g'`
    314356BuildVendor_CPP=`  echo "$BuildVendor"   | sed -e 's/\./_/g' -e 's/-/_/g'`
     
    318360checkVendor "$BuildVendor"
    319361checkOS "$BuildOS"
    320362
    321 HostPlatform=$host
    322 HostArch=`echo "$host" | sed 's/-.*//'`
    323 HostVendor=`echo "$host" | sed -e 's/.*-\(.*\)-.*/\1/'`
    324 HostOS=`echo "$host" | sed 's/.*-//'`
     363HostPlatform="$HostArch-$HostVendor-$HostOS"
    325364HostPlatform_CPP=`echo "$HostPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
    326365HostArch_CPP=`    echo "$HostArch"     | sed -e 's/\./_/g' -e 's/-/_/g'`
    327366HostVendor_CPP=`  echo "$HostVendor"   | sed -e 's/\./_/g' -e 's/-/_/g'`
     
    331370checkVendor "$HostVendor"
    332371checkOS "$HostOS"
    333372
    334 TargetPlatform=$target
    335 TargetArch=`echo "$target" | sed 's/-.*//'`
    336 TargetVendor=`echo "$target" | sed -e 's/.*-\(.*\)-.*/\1/'`
    337 TargetOS=`echo "$target" | sed 's/.*-//'`
     373TargetPlatform="$TargetArch-$TargetVendor-$TargetOS"
    338374TargetPlatform_CPP=`echo "$TargetPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
    339375TargetArch_CPP=`    echo "$TargetArch"     | sed -e 's/\./_/g' -e 's/-/_/g'`
    340376TargetVendor_CPP=`  echo "$TargetVendor"   | sed -e 's/\./_/g' -e 's/-/_/g'`