ABI defaults

Niels Möller nisse at lysator.liu.se
Thu Nov 18 16:19:16 CET 2010


Torbjorn Granlund <tg at gmplib.org> writes:

> nisse at lysator.liu.se (Niels Möller) writes:
>
>   Might need cpu type and operating system too? No matter if it's a
>   separate script or inlined in configure, I guess a
>   
>      case "$host_cpu:$host_os:$longlong_size:$long_size:$int_size"
>   
>   should get you quite far.
>   
> Yep.  Let us now when you're ready.  :-)

I'm appending a close to trivial config.abi which handles the most basic
choice between 32-bit and 64-bit. I'm not familiar at all with the more
obscure cases, so I haven't tried adding them to the case construction
(they should clearly be added early in the sequence of patterns).

If you think this is going in the right direction, I can check it in
(and I'd suggest the name config.abi, to be somewhat consistent with the
naming of other autoconf helper scripts).

Regards,
/Niels

#! /bin/sh

# Copyright 2010 Free Software # Foundation, Inc.
#
# This file is part of the GNU MP Library.
#
# The GNU MP Library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# The GNU MP Library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.


# Usage: config.abi CONFIG-TUPLE SIZEOF-INT SIZEOF-LING SIZEOF-LONGLOLG SIZEOF-VOIDPTR
#
# Prints the name of the used ABI, or "unknown".

if [ $# -ne 5 ] ; then
  echo 1>&2 Usage: config.abi CONFIG-TUPLE SIZEOF-INT SIZEOF-LONG SIZEOF-LONGLONG SIZEOF-VOIDPTR
  exit 1
fi

host=$1
sizeof_int=$2
sizeof_long=$3
sizeof_longlong=$4
sizeof_voidptr=$5

case "$host:$sizeof_int:$sizeof_long:$sizeof_longlong:$sizeof_voidptr" in
    # The most common cases of 32-bit and 64-bit ABIs. Should be
    # correct for all known sparc* and x86*-environments except
    # possibly M$ windows on x86_64.
    *:4:4:8:4)
      abi=32
    ;;
    *:4:8:8:8)
      abi=64
    ;;
    *)
      abi=unknown
    ;;
esac

echo $abi


-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list