Refactored enums handling

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@11186 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Maciej Drwal 2009-04-11 10:46:13 +00:00
commit da5ade3143
4 changed files with 158 additions and 222 deletions

View file

@ -43,7 +43,7 @@
%typemap(ctype) SWIGTYPE * [ANY], SWIGTYPE ** "SwigObj **" %typemap(ctype) SWIGTYPE * [ANY], SWIGTYPE ** "SwigObj **"
%typemap(ctype) SWIGTYPE * [ANY][ANY], SWIGTYPE *** "SwigObj ***" %typemap(ctype) SWIGTYPE * [ANY][ANY], SWIGTYPE *** "SwigObj ***"
%typemap(ctype) SWIGTYPE *& "SwigObj **" %typemap(ctype) SWIGTYPE *& "SwigObj **"
%typemap(ctype) enum SWIGTYPE "$1_type" %typemap(ctype) enum SWIGTYPE "int"
%fragment("stdbool_inc", "proxy_header") {#include <stdbool.h>} %fragment("stdbool_inc", "proxy_header") {#include <stdbool.h>}
%typemap(ctype, fragment="stdbool_inc") bool, bool *, bool **, const bool, const bool *, bool * [ANY] "$1_type" %typemap(ctype, fragment="stdbool_inc") bool, bool *, bool **, const bool, const bool *, bool * [ANY] "$1_type"
@ -154,7 +154,7 @@
%typemap(couttype) SWIGTYPE [ANY] "SwigObj **" %typemap(couttype) SWIGTYPE [ANY] "SwigObj **"
%typemap(couttype) SWIGTYPE * [ANY], SWIGTYPE ** "SwigObj **" %typemap(couttype) SWIGTYPE * [ANY], SWIGTYPE ** "SwigObj **"
%typemap(couttype) SWIGTYPE * [ANY][ANY], SWIGTYPE *** "SwigObj ***" %typemap(couttype) SWIGTYPE * [ANY][ANY], SWIGTYPE *** "SwigObj ***"
%typemap(couttype) enum SWIGTYPE "$1_type" %typemap(couttype) enum SWIGTYPE "int"
%typemap(couttype, fragment="stdbool_inc") bool, bool *, const bool, const bool * "$1_type" %typemap(couttype, fragment="stdbool_inc") bool, bool *, const bool, const bool * "$1_type"
%typemap(couttype, fragment="stdbool_inc") bool & "$1_basetype*" %typemap(couttype, fragment="stdbool_inc") bool & "$1_basetype*"

View file

@ -28,12 +28,9 @@ class C:public Language {
String *empty_string; String *empty_string;
String *int_string; String *int_string;
String *enum_values;
String *create_object; String *create_object;
String *destroy_object; String *destroy_object;
int enum_id;
bool proxy_flag; bool proxy_flag;
bool except_flag; bool except_flag;
@ -46,10 +43,8 @@ public:
C() : C() :
empty_string(NewString("")), empty_string(NewString("")),
int_string(NewString("int")), int_string(NewString("int")),
enum_values(0),
create_object(0), create_object(0),
destroy_object(0), destroy_object(0),
enum_id(1),
proxy_flag(true), proxy_flag(true),
except_flag(true) { except_flag(true) {
} }
@ -258,8 +253,6 @@ public:
return SWIG_OK; return SWIG_OK;
String *name = Getattr(n, "name"); String *name = Getattr(n, "name");
SwigType *type = Getattr(n, "type"); SwigType *type = Getattr(n, "type");
if (SwigType_isenum(type))
type = make_enum_type(n, type);
String *type_str = Copy(SwigType_str(type, 0)); String *type_str = Copy(SwigType_str(type, 0));
if (SwigType_isarray(type)) { if (SwigType_isarray(type)) {
String *dims = Strchr(type_str, '['); String *dims = Strchr(type_str, '[');
@ -397,35 +390,6 @@ ready:
return result; return result;
} }
/* ----------------------------------------------------------------------
* make_enum_type()
*
* given C++ enum type this function returns its C representation
* ---------------------------------------------------------------------- */
String *make_enum_type(Node *n, SwigType *enumtype) {
Symtab *symtab = Getattr(n, "sym:symtab");
String *unnamed = Getattr(n, "unnamed");
String *newtype = 0;
String *query = 0;
if (!unnamed)
query = Swig_scopename_last(SwigType_str(enumtype, 0));
else {
Replaceall(unnamed, "$unnamed", "enum");
Replaceall(unnamed, "$", "");
query = unnamed;
}
Node *node = Swig_symbol_clookup(query, symtab);
if (node)
newtype = NewStringf("enum %s", Getattr(node, "name"));
else
newtype = SwigType_str(enumtype, 0);
return newtype;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
* functionWrapper() * functionWrapper()
* ---------------------------------------------------------------------- */ * ---------------------------------------------------------------------- */
@ -534,10 +498,6 @@ ready:
if (Cmp(Getattr(n, "c:objstruct"), "1") == 0) { if (Cmp(Getattr(n, "c:objstruct"), "1") == 0) {
Printv(return_type, SwigType_str(type, 0), NIL); Printv(return_type, SwigType_str(type, 0), NIL);
} }
else if (SwigType_isenum(type)) {
type = return_type = make_enum_type(n, type);
Setattr(n, "type", return_type);
}
else if ((tm = Swig_typemap_lookup("couttype", n, "", 0))) { else if ((tm = Swig_typemap_lookup("couttype", n, "", 0))) {
String *ctypeout = Getattr(n, "tmap:couttype:out"); String *ctypeout = Getattr(n, "tmap:couttype:out");
if (ctypeout) if (ctypeout)
@ -662,18 +622,9 @@ ready:
String *arg_name = NewString(""); String *arg_name = NewString("");
Printf(arg_name, "c%s", lname); Printf(arg_name, "c%s", lname);
bool dont_apply_tmap = false;
// set the appropriate type for parameter // set the appropriate type for parameter
if (SwigType_isenum(type)) { if ((tm = Getattr(p, "tmap:ctype"))) {
c_parm_type = make_enum_type(n, type);
if (Getattr(n, "unnamed")) {
type = int_string;
Setattr(p, "type", type);
dont_apply_tmap = true;
}
}
else if ((tm = Getattr(p, "tmap:ctype"))) {
Printv(c_parm_type, tm, NIL); Printv(c_parm_type, tm, NIL);
} }
else { else {
@ -699,14 +650,9 @@ ready:
p = Getattr(p, "tmap:in:next"); p = Getattr(p, "tmap:in:next");
} }
else if ((tm = Getattr(p, "tmap:in"))) { else if ((tm = Getattr(p, "tmap:in"))) {
if (dont_apply_tmap) { Replaceall(tm, "$input", arg_name);
Printv(wrapper->code, lname, " = ", arg_name, ";\n", NIL); Setattr(p, "emit:input", arg_name);
} Printf(wrapper->code, "%s\n", tm);
else {
Replaceall(tm, "$input", arg_name);
Setattr(p, "emit:input", arg_name);
Printf(wrapper->code, "%s\n", tm);
}
p = Getattr(p, "tmap:in:next"); p = Getattr(p, "tmap:in:next");
} }
else { else {
@ -1321,82 +1267,10 @@ ready:
/* --------------------------------------------------------------------- /* ---------------------------------------------------------------------
* enumDeclaration() * enumDeclaration()
*
* for enums declared inside class we create global enum declaration
* and change enum parameter and return value names
* --------------------------------------------------------------------- */ * --------------------------------------------------------------------- */
virtual int enumDeclaration(Node *n) { virtual int enumDeclaration(Node *n) {
if (!proxy_flag) return Language::enumDeclaration(n);
return SWIG_OK;
String *newclassname = Getattr(Swig_methodclass(n), "sym:name");
String *name = Getattr(n, "sym:name");
String *code = NewString("");
String *tdname = Getattr(n, "tdname");
if (tdname) {
Printf(code, "typedef ");
name = Getattr(n, "name");
String *td_def_name = NewStringf("enum %s", name);
SwigType_typedef(td_def_name, name);
Delete(td_def_name);
SwigType_istypedef(name);
}
Symtab *symtab = Getattr(n, "sym:symtab");
String *newname = newclassname ? NewStringf("%s_", newclassname) : Copy(name);
Printf(code, "enum ");
if (!name) {
String *anonymous_name = NewStringf("enum%d ", enum_id++);
Setattr(n, "sym:name", anonymous_name);
Setattr(n, "unnamed", "1");
name = Getattr(n, "sym:name");
Delete(anonymous_name);
}
if (Delattr(n, "unnamed")) {
// unnamed enum declaration: create new symbol
Replaceall(name, "$unnamed", "enum");
Delitem(name, DOH_END);
Node *entry = NewHash();
set_nodeType(entry, "enum");
Setattr(entry, "name", name);
Setattr(entry, "sym:name", name);
Setattr(entry, "sym:symtab", symtab);
Swig_symbol_add(name, entry);
}
if (newclassname) {
if (symtab) {
Node *node = Swig_symbol_clookup(name, symtab);
if (node)
Append(newname, name);
}
else
Append(newname, "enum");
Setattr(n, "name", newname);
}
else {
Delete(newname);
newname = name;
}
Printv(code, newname ? newname : "", " {\n$enumvalues\n} ", tdname ? tdname : "", ";\n\n", NIL);
emit_children(n);
if (enum_values) {
Replaceall(code, "$enumvalues", enum_values);
Append(f_proxy_header, code);
if (newclassname)
Append(f_header, code);
Delete(enum_values);
enum_values = 0;
}
Delete(newname);
Delete(code);
return SWIG_OK;
} }
/* --------------------------------------------------------------------- /* ---------------------------------------------------------------------
@ -1404,55 +1278,14 @@ ready:
* --------------------------------------------------------------------- */ * --------------------------------------------------------------------- */
virtual int enumvalueDeclaration(Node *n) { virtual int enumvalueDeclaration(Node *n) {
String *name = Getattr(n, "sym:name"); if (Cmp(Getattr(n, "ismember"), "1") == 0 && Cmp(Getattr(n, "access"), "public") != 0)
String *enumvalue = Getattr(n, "enumvalue"); return SWIG_NOWRAP;
String *init = 0; Swig_require("enumvalueDeclaration", n, "*value", "?enumvalueex", "?enumvalue", NIL);
if (enumvalue) { String *name = Getattr(n, "value");
char *value_repr = Char(enumvalue); String *value = Getattr(n, "enumvalueex");
if (value_repr) value = value ? value : Getattr(n, "enumvalue");
if (!isdigit(*value_repr) && *value_repr != '+' && *value_repr != '-') { Printv(f_proxy_header, "#define ", Swig_name_mangle(name), " ", value, "\n", NIL);
init = NewStringf(" = '%c'", *value_repr); Swig_restore(n);
}
else
init = NewStringf(" = %s", enumvalue);
}
String *newclassname = Getattr(Swig_methodclass(parentNode(n)), "sym:name");
String *newname = NewStringf("%s_%s", newclassname, name);
int gencomma = 1;
if (!enum_values) {
enum_values = NewString("");
gencomma = 0;
}
Printv(enum_values, gencomma ? ",\n " : " ", newclassname ? newname : name, enumvalue ? init : "", NIL);
Delete(newname);
if (init)
Delete(init);
return SWIG_OK;
}
/* ---------------------------------------------------------------------
* typedefHandler()
* --------------------------------------------------------------------- */
virtual int typedefHandler(Node *n) {
if (!proxy_flag)
return SWIG_OK;
String *name = Getattr(n, "sym:name");
String *type = Getattr(n, "type");
char *c = Char(SwigType_str(type, 0));
if (!name)
name = Getattr(n, "name");
if (strncmp(c, "enum", 4) != 0) {
if (name && type) {
String *code = NewStringf("typedef %s %s;\n\n", name, type);
Append(f_proxy_header, code);
Delete(code);
SwigType_typedef(type, name);
}
}
return SWIG_OK; return SWIG_OK;
} }

View file

@ -1,10 +1,10 @@
#! /bin/sh #! /bin/sh
# Attempt to guess a canonical system name. # Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
# Inc. # Free Software Foundation, Inc.
timestamp='2006-07-02' timestamp='2008-11-15'
# This file is free software; you can redistribute it and/or modify it # This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by # under the terms of the GNU General Public License as published by
@ -56,8 +56,8 @@ version="\
GNU config.guess ($timestamp) GNU config.guess ($timestamp)
Originally written by Per Bothner. Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
Free Software Foundation, Inc. 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -161,6 +161,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
arm*) machine=arm-unknown ;; arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;; sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;; sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac esac
# The Operating System including object format, if it has switched # The Operating System including object format, if it has switched
@ -329,8 +330,21 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;; exit ;;
i86pc:SunOS:5.*:*) i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` eval $set_cc_for_build
SUN_ARCH="i386"
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if echo '\n#ifdef __amd64\nIS_64BIT_ARCH\n#endif' | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
SUN_ARCH="x86_64"
fi
fi
echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;; exit ;;
sun4*:SunOS:6*:*) sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize # According to config.sub, this is the proper way to canonicalize
@ -531,7 +545,7 @@ EOF
echo rs6000-ibm-aix3.2 echo rs6000-ibm-aix3.2
fi fi
exit ;; exit ;;
*:AIX:*:[45]) *:AIX:*:[456])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000 IBM_ARCH=rs6000
@ -780,7 +794,7 @@ EOF
i*:CYGWIN*:*) i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin echo ${UNAME_MACHINE}-pc-cygwin
exit ;; exit ;;
i*:MINGW*:*) *:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32 echo ${UNAME_MACHINE}-pc-mingw32
exit ;; exit ;;
i*:windows32*:*) i*:windows32*:*)
@ -790,12 +804,18 @@ EOF
i*:PW*:*) i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32 echo ${UNAME_MACHINE}-pc-pw32
exit ;; exit ;;
x86:Interix*:[3456]*) *:Interix*:[3456]*)
echo i586-pc-interix${UNAME_RELEASE} case ${UNAME_MACHINE} in
exit ;; x86)
EM64T:Interix*:[3456]*) echo i586-pc-interix${UNAME_RELEASE}
echo x86_64-unknown-interix${UNAME_RELEASE} exit ;;
exit ;; EM64T | authenticamd | genuineintel)
echo x86_64-unknown-interix${UNAME_RELEASE}
exit ;;
IA64)
echo ia64-unknown-interix${UNAME_RELEASE}
exit ;;
esac ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks echo i${UNAME_MACHINE}-pc-mks
exit ;; exit ;;
@ -829,7 +849,14 @@ EOF
echo ${UNAME_MACHINE}-pc-minix echo ${UNAME_MACHINE}-pc-minix
exit ;; exit ;;
arm*:Linux:*:*) arm*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo ${UNAME_MACHINE}-unknown-linux-gnu
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
fi
exit ;; exit ;;
avr32*:Linux:*:*) avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-gnu
@ -921,6 +948,9 @@ EOF
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
exit ;; exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-gnu
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*) parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level # Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
@ -950,6 +980,9 @@ EOF
x86_64:Linux:*:*) x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu echo x86_64-unknown-linux-gnu
exit ;; exit ;;
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
i*86:Linux:*:*) i*86:Linux:*:*)
# The BFD linker knows what the default object file format is, so # The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent # first see if it will tell us. cd to the root directory to prevent
@ -968,9 +1001,6 @@ EOF
a.out-i386-linux) a.out-i386-linux)
echo "${UNAME_MACHINE}-pc-linux-gnuaout" echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit ;; exit ;;
coff-i386)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
exit ;;
"") "")
# Either a pre-BFD a.out linker (linux-gnuoldld) or # Either a pre-BFD a.out linker (linux-gnuoldld) or
# one that does not give us useful --help. # one that does not give us useful --help.
@ -1199,6 +1229,9 @@ EOF
BePC:BeOS:*:*) # BeOS running on Intel PC compatible. BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
echo i586-pc-beos echo i586-pc-beos
exit ;; exit ;;
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
SX-4:SUPER-UX:*:*) SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE} echo sx4-nec-superux${UNAME_RELEASE}
exit ;; exit ;;
@ -1208,6 +1241,15 @@ EOF
SX-6:SUPER-UX:*:*) SX-6:SUPER-UX:*:*)
echo sx6-nec-superux${UNAME_RELEASE} echo sx6-nec-superux${UNAME_RELEASE}
exit ;; exit ;;
SX-7:SUPER-UX:*:*)
echo sx7-nec-superux${UNAME_RELEASE}
exit ;;
SX-8:SUPER-UX:*:*)
echo sx8-nec-superux${UNAME_RELEASE}
exit ;;
SX-8R:SUPER-UX:*:*)
echo sx8r-nec-superux${UNAME_RELEASE}
exit ;;
Power*:Rhapsody:*:*) Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE} echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit ;; exit ;;
@ -1458,9 +1500,9 @@ This script, last modified $timestamp, has failed to recognize
the operating system you are using. It is advised that you the operating system you are using. It is advised that you
download the most up to date version of the config scripts from download the most up to date version of the config scripts from
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
and and
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
If the version you run ($0) is already up to date, please If the version you run ($0) is already up to date, please
send the following data and any information you think might be send the following data and any information you think might be

View file

@ -1,10 +1,10 @@
#! /bin/sh #! /bin/sh
# Configuration validation subroutine script. # Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
# Inc. # Free Software Foundation, Inc.
timestamp='2006-09-20' timestamp='2008-09-08'
# This file is (in principle) common to ALL GNU software. # This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software # The presence of a machine in this file suggests that SOME GNU software
@ -72,8 +72,8 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\ version="\
GNU config.sub ($timestamp) GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
Free Software Foundation, Inc. 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -245,17 +245,19 @@ case $basic_machine in
| bfin \ | bfin \
| c4x | clipper \ | c4x | clipper \
| d10v | d30v | dlx | dsp16xx \ | d10v | d30v | dlx | dsp16xx \
| fr30 | frv \ | fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \ | i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \ | ip2k | iq2000 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \ | m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore \ | maxq | mb | microblaze | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \ | mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \ | mips16 \
| mips64 | mips64el \ | mips64 | mips64el \
| mips64vr | mips64vrel \ | mips64octeon | mips64octeonel \
| mips64orion | mips64orionel \ | mips64orion | mips64orionel \
| mips64r5900 | mips64r5900el \
| mips64vr | mips64vrel \
| mips64vr4100 | mips64vr4100el \ | mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \ | mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \ | mips64vr5000 | mips64vr5000el \
@ -286,7 +288,7 @@ case $basic_machine in
| v850 | v850e \ | v850 | v850e \
| we32k \ | we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k) | z8k | z80)
basic_machine=$basic_machine-unknown basic_machine=$basic_machine-unknown
;; ;;
m6811 | m68hc11 | m6812 | m68hc12) m6811 | m68hc11 | m6812 | m68hc12)
@ -324,19 +326,21 @@ case $basic_machine in
| clipper-* | craynv-* | cydra-* \ | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \ | d10v-* | d30v-* | dlx-* \
| elxsi-* \ | elxsi-* \
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \ | h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \ | i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \ | ip2k-* | iq2000-* \
| m32c-* | m32r-* | m32rle-* \ | m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \ | mips16-* \
| mips64-* | mips64el-* \ | mips64-* | mips64el-* \
| mips64vr-* | mips64vrel-* \ | mips64octeon-* | mips64octeonel-* \
| mips64orion-* | mips64orionel-* \ | mips64orion-* | mips64orionel-* \
| mips64r5900-* | mips64r5900el-* \
| mips64vr-* | mips64vrel-* \
| mips64vr4100-* | mips64vr4100el-* \ | mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \ | mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \ | mips64vr5000-* | mips64vr5000el-* \
@ -364,14 +368,18 @@ case $basic_machine in
| sparclite-* \ | sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \ | tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
| tron-* \ | tron-* \
| v850-* | v850e-* | vax-* \ | v850-* | v850e-* | vax-* \
| we32k-* \ | we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
| xstormy16-* | xtensa-* \ | xstormy16-* | xtensa*-* \
| ymp-* \ | ymp-* \
| z8k-*) | z8k-* | z80-*)
;;
# Recognize the basic CPU types without company name, with glob match.
xtensa*)
basic_machine=$basic_machine-unknown
;; ;;
# Recognize the various machine names and aliases which stand # Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS. # for a CPU type and a company and sometimes even an OS.
@ -443,10 +451,22 @@ case $basic_machine in
basic_machine=ns32k-sequent basic_machine=ns32k-sequent
os=-dynix os=-dynix
;; ;;
blackfin)
basic_machine=bfin-unknown
os=-linux
;;
blackfin-*)
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
c90) c90)
basic_machine=c90-cray basic_machine=c90-cray
os=-unicos os=-unicos
;; ;;
cegcc)
basic_machine=arm-unknown
os=-cegcc
;;
convex-c1) convex-c1)
basic_machine=c1-convex basic_machine=c1-convex
os=-bsd os=-bsd
@ -475,8 +495,8 @@ case $basic_machine in
basic_machine=craynv-cray basic_machine=craynv-cray
os=-unicosmp os=-unicosmp
;; ;;
cr16c) cr16)
basic_machine=cr16c-unknown basic_machine=cr16-unknown
os=-elf os=-elf
;; ;;
crds | unos) crds | unos)
@ -514,6 +534,10 @@ case $basic_machine in
basic_machine=m88k-motorola basic_machine=m88k-motorola
os=-sysv3 os=-sysv3
;; ;;
dicos)
basic_machine=i686-pc
os=-dicos
;;
djgpp) djgpp)
basic_machine=i586-pc basic_machine=i586-pc
os=-msdosdjgpp os=-msdosdjgpp
@ -668,6 +692,14 @@ case $basic_machine in
basic_machine=m68k-isi basic_machine=m68k-isi
os=-sysv os=-sysv
;; ;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
;;
m68knommu-*)
basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
m88k-omron*) m88k-omron*)
basic_machine=m88k-omron basic_machine=m88k-omron
;; ;;
@ -683,6 +715,10 @@ case $basic_machine in
basic_machine=i386-pc basic_machine=i386-pc
os=-mingw32 os=-mingw32
;; ;;
mingw32ce)
basic_machine=arm-unknown
os=-mingw32ce
;;
miniframe) miniframe)
basic_machine=m68000-convergent basic_machine=m68000-convergent
;; ;;
@ -809,6 +845,14 @@ case $basic_machine in
basic_machine=i860-intel basic_machine=i860-intel
os=-osf os=-osf
;; ;;
parisc)
basic_machine=hppa-unknown
os=-linux
;;
parisc-*)
basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
pbd) pbd)
basic_machine=sparc-tti basic_machine=sparc-tti
;; ;;
@ -925,6 +969,9 @@ case $basic_machine in
basic_machine=sh-hitachi basic_machine=sh-hitachi
os=-hms os=-hms
;; ;;
sh5el)
basic_machine=sh5le-unknown
;;
sh64) sh64)
basic_machine=sh64-unknown basic_machine=sh64-unknown
;; ;;
@ -1014,6 +1061,10 @@ case $basic_machine in
basic_machine=tic6x-unknown basic_machine=tic6x-unknown
os=-coff os=-coff
;; ;;
tile*)
basic_machine=tile-unknown
os=-linux-gnu
;;
tx39) tx39)
basic_machine=mipstx39-unknown basic_machine=mipstx39-unknown
;; ;;
@ -1089,6 +1140,10 @@ case $basic_machine in
basic_machine=z8k-unknown basic_machine=z8k-unknown
os=-sim os=-sim
;; ;;
z80-*-coff)
basic_machine=z80-unknown
os=-sim
;;
none) none)
basic_machine=none-none basic_machine=none-none
os=-none os=-none
@ -1209,7 +1264,7 @@ case $os in
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* \ | -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \ | -uxpv* | -beos* | -mpeix* | -udk* \
@ -1219,7 +1274,7 @@ case $os in
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers*) | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
# Remember, each alternative MUST END IN *, to match a version number. # Remember, each alternative MUST END IN *, to match a version number.
;; ;;
-qnx*) -qnx*)
@ -1349,6 +1404,9 @@ case $os in
-zvmoe) -zvmoe)
os=-zvmoe os=-zvmoe
;; ;;
-dicos*)
os=-dicos
;;
-none) -none)
;; ;;
*) *)
@ -1414,6 +1472,9 @@ case $basic_machine in
m68*-cisco) m68*-cisco)
os=-aout os=-aout
;; ;;
mep-*)
os=-elf
;;
mips*-cisco) mips*-cisco)
os=-elf os=-elf
;; ;;