How with some assembly support
authorWerner Koch <wk@gnupg.org>
Wed, 26 Nov 1997 22:02:28 +0000 (22:02 +0000)
committerWerner Koch <wk@gnupg.org>
Wed, 26 Nov 1997 22:02:28 +0000 (22:02 +0000)
23 files changed:
Makefile.am
Makefile.in
cipher/Makefile.am
cipher/Makefile.in
cipher/random.c
configure.in
g10/Makefile.am
g10/Makefile.in
g10/compress.c
g10/encode.c
g10/g10.c
g10/mainproc.c
g10/pubkey-enc.c
g10/sig-check.c
include/Makefile.am [new file with mode: 0644]
include/mpi.h
mpi/Makefile.am
mpi/Makefile.in
mpi/mpih-shift.c [deleted file]
scripts/config.guess [new file with mode: 0755]
scripts/config.sub [new file with mode: 0755]
util/argparse.c
util/memory.c

index cfa9abb..11d469c 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = util mpi cipher tools g10
+SUBDIRS = scripts include util mpi cipher tools g10
 EXTRA_DIST =
 
 
index 63295c4..8c81c6e 100644 (file)
@@ -38,7 +38,7 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 transform = @program_transform_name@
 
-SUBDIRS = util mpi cipher tools g10
+SUBDIRS = scripts include util mpi cipher tools g10
 EXTRA_DIST =
 ACCONFIG = acconfig.h
 CONFIG_HEADER_IN = config.h.in
index becf3a1..b994cbe 100644 (file)
@@ -5,6 +5,7 @@ INCLUDES = -I$(top_srcdir)/include
 noinst_LIBRARIES = cipher
 
 
+# please add "rsa.c" and "rsa.h" manually in Makefile.am
 cipher_SOURCES = blowfish.c    \
                 blowfish.h     \
                 elgamal.c      \
@@ -15,12 +16,10 @@ cipher_SOURCES = blowfish.c \
                 md5.h          \
                 primegen.c     \
                 random.c       \
-                ripemd.h       \
                 rmd.h          \
                 rmd160.c       \
-                rsa.c          \
-                rsa.h          \
                 smallprime.c
 
+cipher_LIBADD = rsa.o
 
 
index 16da110..0daff11 100644 (file)
@@ -42,6 +42,7 @@ INCLUDES = -I$(top_srcdir)/include
 
 noinst_LIBRARIES = cipher
 
+# please add "rsa.c" and "rsa.h" manually in Makefile.am
 cipher_SOURCES = blowfish.c    \
                 blowfish.h     \
                 elgamal.c      \
@@ -52,12 +53,11 @@ cipher_SOURCES = blowfish.c \
                 md5.h          \
                 primegen.c     \
                 random.c       \
-                ripemd.h       \
                 rmd.h          \
                 rmd160.c       \
-                rsa.c          \
-                rsa.h          \
                 smallprime.c
+
+cipher_LIBADD = rsa.o
 mkinstalldirs = $(top_srcdir)/scripts/mkinstalldirs
 CONFIG_HEADER = ../config.h
 LIBRARIES = $(noinst_LIBRARIES)
@@ -76,9 +76,8 @@ LIBS = @LIBS@
 
 COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
 LINK = $(CC) $(LDFLAGS) -o $@
-cipher_LIBADD =
 cipher_OBJECTS = blowfish.o elgamal.o gost.o md5.o primegen.o random.o \
-rmd160.o rsa.o smallprime.o
+rmd160.o smallprime.o
 EXTRA_cipher_SOURCES =
 LIBFILES =  libcipher.a
 AR = ar
@@ -97,7 +96,7 @@ DEP_DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \
 TAR = tar
 DEP_FILES = $(srcdir)/.deps/blowfish.P $(srcdir)/.deps/elgamal.P \
 $(srcdir)/.deps/gost.P $(srcdir)/.deps/md5.P $(srcdir)/.deps/primegen.P \
-$(srcdir)/.deps/random.P $(srcdir)/.deps/rmd160.P $(srcdir)/.deps/rsa.P \
+$(srcdir)/.deps/random.P $(srcdir)/.deps/rmd160.P \
 $(srcdir)/.deps/smallprime.P
 SOURCES = $(cipher_SOURCES)
 OBJECTS = $(cipher_OBJECTS)
index 73a9a3e..b4abbdd 100644 (file)
@@ -43,6 +43,7 @@ randomize_buffer( byte *buffer, size_t length, int level )
 
     if( level == 2 )
        level = 1; /* 2 is much too slow */
+    /* FIXME: do a stat and check that we have the correct device numbers*/
     fp = fopen(level < 2? "/dev/urandom":"/dev/random", "r");
     if( !fp )
        log_fatal("can't open random device: %s\n", strerror(errno) );
index 6b27eb2..2f77c06 100644 (file)
@@ -21,6 +21,22 @@ if test "$enableval" = y || test "$enableval" = yes; then
     CFLAGS="-g"
 fi
 
+dnl
+AC_CANONICAL_HOST
+AC_MSG_CHECKING(cached information)
+hostcheck="$host"
+AC_CACHE_VAL(ac_cv_mpi_hostcheck, [ ac_cv_mpi_hostcheck="$hostcheck" ])
+if test "$ac_cv_mpi_hostcheck" != "$hostcheck"; then
+    AC_MSG_RESULT(changed)
+    AC_MSG_WARN(config.cache exists!)
+    AC_MSG_ERROR(you must do 'make distclean' first to compile for
+different host or different parameters.)
+else
+    AC_MSG_RESULT(ok)
+fi
+
+
+
 dnl Checks for programs.
 
 AC_PROG_MAKE_SET
@@ -37,7 +53,11 @@ dnl Checks for libraries.
 dnl Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS(unistd.h)
-AC_CHECK_HEADERS(zlib.h)
+AC_CHECK_HEADERS(zlib.h,
+                [LIBS="$LIBS -lz"],
+                AC_MSG_WARN([zlib missing - creating without ZLIB support!])
+               )
+
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
@@ -48,7 +68,19 @@ dnl Checks for library functions.
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS(strerror strtol strtoul)
 
-dnl
+
+
+dnl setup assembler stuff
+
+
+
+
+
+dnl checking wether we have the RSA source
+dnl fixme: I found no way (aside of using Makefile.am.in)
+dnl       to add the requeired source int Makefile.am
+dnl I used: add_cipher_SOURCES="rsa.c rsa.h"
+dnl but of cource it can't work
 AC_MSG_CHECKING(wether we have the rsa source)
 if test -f cipher/rsa.c && test -f cipher/rsa.h; then
     AC_DEFINE(HAVE_RSA_CIPHER)
@@ -56,9 +88,12 @@ if test -f cipher/rsa.c && test -f cipher/rsa.h; then
 else
     AC_MSG_RESULT(no)
 fi
+AC_SUBST(add_cipher_SOURCES)
 
-AC_OUTPUT([ Makefile util/Makefile mpi/Makefile cipher/Makefile \
+AC_OUTPUT([ Makefile scripts/Makefile util/Makefile mpi/Makefile \
+           cipher/Makefile \
+           include/Makefile \
            g10/Makefile tools/Makefile ],
-         [echo timestamp > stamp-h ])
+         [echo timestamp > stamp-h ] )
 
 
index bb0b965..c636100 100644 (file)
@@ -34,7 +34,7 @@ g10_SOURCES = g10.c           \
              sig-check.c
 
 
-LDADD = -L ../cipher -L ../mpi -L ../util -lcipher -lmpi -lutil -lz
+LDADD = -L ../cipher -L ../mpi -L ../util -lcipher -lmpi -lutil
 
 
 $(PROGRAMS): ../cipher/libcipher.a ../mpi/libmpi.a
index 651fdf2..17a4df1 100644 (file)
@@ -71,7 +71,7 @@ g10_SOURCES = g10.c           \
              comment.c         \
              sig-check.c
 
-LDADD = -L ../cipher -L ../mpi -L ../util -lcipher -lmpi -lutil -lz
+LDADD = -L ../cipher -L ../mpi -L ../util -lcipher -lmpi -lutil
 mkinstalldirs = $(top_srcdir)/scripts/mkinstalldirs
 CONFIG_HEADER = ../config.h
 PROGRAMS = $(bin_PROGRAMS)
index 980f5f9..38d23ad 100644 (file)
@@ -27,8 +27,6 @@
 #include <errno.h>
 #ifdef HAVE_ZLIB_H
   #include <zlib.h>
-#else
-  #error You need ZLIB to compile this module
 #endif
 
 #include "util.h"
@@ -38,6 +36,7 @@
 #include "options.h"
 
 
+#ifdef HAVE_ZLIB_H
 static void
 init_compress( compress_filter_context_t *zfx, z_stream *zs )
 {
@@ -163,7 +162,6 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs,
     return rc;
 }
 
-
 int
 compress_filter( void *opaque, int control,
                 IOBUF a, byte *buf, size_t *ret_len)
@@ -228,6 +226,35 @@ compress_filter( void *opaque, int control,
        *(char**)buf = "compress_filter";
     return rc;
 }
+#else /* No ZLIB */
+int
+compress_filter( void *opaque, int control,
+                IOBUF a, byte *buf, size_t *ret_len)
+{
+    size_t size = *ret_len;
+    compress_filter_context_t *zfx = opaque;
+    int c, rc=0;
+    size_t n;
+
+    if( control == IOBUFCTRL_UNDERFLOW ) {
+       for( n=0; n < size; n++ ) {
+           if( (c=iobuf_get(a)) == -1 )
+               break;
+           buf[n] = c & 0xff;
+       }
+       if( !n )
+           rc = -1;
+       *ret_len = n;
+    }
+    else if( control == IOBUFCTRL_FLUSH ) {
+       if( iobuf_write( a, buf, size ) )
+           rc = G10ERR_WRITE_FILE;
+    }
+    else if( control == IOBUFCTRL_DESC )
+       *(char**)buf = "dummy compress_filter";
+    return rc;
+}
+#endif /*no ZLIB*/
 
 /****************
  * Handle a compressed packet
index eb4875d..75764fe 100644 (file)
@@ -251,6 +251,7 @@ encode_crypt( const char *filename, STRLIST remusr )
                m_free(ustr);
            }
        }
+      #ifdef HAVE_RSA_CIPHER
        else if( enc->pubkey_algo == PUBKEY_ALGO_RSA ) {
            RSA_public_key pkey;
 
@@ -270,6 +271,7 @@ encode_crypt( const char *filename, STRLIST remusr )
                m_free(ustr);
            }
        }
+      #endif/*HAVE_RSA_CIPHER*/
        else {
            last_rc = rc = G10ERR_PUBKEY_ALGO;
            log_error("skipped '%s': %s\n", remusr->d, g10_errstr(rc) );
index 5235d0f..882f84c 100644 (file)
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -33,6 +33,7 @@
 #include "cipher.h"
 #include "filter.h"
 
+static void do_test(void);
 
 const char *
 strusage( int level )
@@ -41,7 +42,7 @@ strusage( int level )
     switch( level ) {
       case 10:
       case 0:  p = "g10 - v" VERSION "; "
-                   "Copyright 1997 Werner Koch (dd9jn)" ; break;
+                   "Copyright 1997 Werner Koch (dd9jn)\n" ; break;
       case 13: p = "g10"; break;
       case 14: p = VERSION; break;
       case 1:
@@ -49,18 +50,25 @@ strusage( int level )
                break;
       case 2:
       case 12: p =
-    "\nSyntax: g10 [options] [files]\n"
+    "Syntax: g10 [options] [files]\n"
     "sign, check, encrypt or decrypt\n"
-    "default operation depends on the input data\n"
+    "default operation depends on the input data\n"; break;
+
+      case 26:
+       p = "Please report bugs to <g10-bugs@isil.d.shuttle.de>.\n";
+       break;
+
+      case 30: p = ""
+  #ifndef HAVE_ZLIB_H
+    "   NOTE: This version is compiled without ZLIB support;\n"
+    "         you are not able to process compresssed data!\n"
+  #endif
   #ifdef HAVE_RSA_CIPHER
     "WARNING: This version has RSA support! Your are not allowed to\n"
     "         use it inside the Unites States until Sep 30, 2000!\n"
   #endif
        ;
        break;
-      case 26:
-       p = "Please report bugs to <g10-bugs@isil.d.shuttle.de>.\n";
-       break;
       default: p = default_strusage(level);
     }
     return p;
@@ -96,7 +104,7 @@ main( int argc, char **argv )
     { 'o', "output",    2, "use as output file" },
     { 501, "yes",       0, "assume yes on most questions"},
     { 502, "no",        0, "assume no on most questions"},
-    { 503, "make-key",  0, "generate a new key pair" },
+    { 503, "gen-key",   0, "generate a new key pair" },
     { 504, "add-key",   0, "add key to the public keyring" },
     { 505, "delete-key",0, "remove key from public keyring" },
     { 506, "sign-key"  ,0, "make a signature on a key in the keyring" },
@@ -112,18 +120,20 @@ main( int argc, char **argv )
     { 510, "debug"     ,4|16, "set debugging flags" },
     { 511, "debug-all" ,0, "enable full debugging"},
     { 512, "cache-all" ,0, "hold everything in memory"},
-    { 513, "gen-prime" , 1, "generate a prime of length n" },
-    { 514, "gen-key"   , 0, "generate a key pair" },
+    { 513, "gen-prime" , 1, "\rgenerate a prime of length n" },
+    { 514, "test"      , 0, "\rdevelopment usage" },
     {0} };
     ARGPARSE_ARGS pargs = { &argc, &argv, 0 };
     IOBUF a;
     int rc;
     enum { aNull, aSym, aStore, aEncr, aPrimegen, aKeygen, aSign, aSignEncr,
+          aTest,
     } action = aNull;
     const char *fname, *fname_print;
     STRLIST sl, remusr= NULL, locusr=NULL;
     int nrings=0;
     armor_filter_context_t afx;
+    const char *s;
 
     opt.compress = -1; /* defaults to default compression level */
     while( arg_parse( &pargs, opts) ) {
@@ -155,6 +165,7 @@ main( int argc, char **argv )
            break;
          case 501: opt.answer_yes = 1; break;
          case 502: opt.answer_no = 1; break;
+         case 503: action = aKeygen; break;
          case 507: action = aStore; break;
          case 508: opt.check_sigs = 1; break;
          case 509: add_keyring(pargs.r.ret_str); nrings++; break;
@@ -162,13 +173,18 @@ main( int argc, char **argv )
          case 511: opt.debug = ~0; break;
          case 512: opt.cache_all = 1; break;
          case 513: action = aPrimegen; break;
-         case 514: action = aKeygen; break;
+         case 514: action = aTest; break;
          default : pargs.err = 2; break;
        }
     }
     set_debug();
     if( opt.verbose > 1 )
        set_packet_list_mode(1);
+    if( !opt.batch && *(s=strusage(10))  )
+       fputs(s, stderr);
+    if( !opt.batch && *(s=strusage(30))  )
+       fputs(s, stderr);
+
 
     if( !nrings ) { /* add default rings */
        add_keyring("../keys/ring.pgp");
@@ -230,6 +246,8 @@ main( int argc, char **argv )
        generate_keypair();
        break;
 
+      case aTest: do_test(); break;
+
       default:
        if( argc > 1 )
            usage(1);
@@ -250,3 +268,36 @@ main( int argc, char **argv )
 }
 
 
+
+static void
+do_test()
+{
+    MPI t = mpi_alloc( 50 );
+    MPI m = mpi_alloc( 50 );
+    MPI a = mpi_alloc( 50 );
+    MPI b = mpi_alloc( 50 );
+    MPI p = mpi_alloc( 50 );
+    MPI x = mpi_alloc( 50 );
+    mpi_fromstr(a, "0xef45678343589854354a4545545454554545455"
+                  "aaaaaaaaaaaaa44444fffdecb33434343443331" );
+    mpi_fromstr(b, "0x8765765589854354a4545545454554545455"
+                  "aaaaaaa466577778decb36666343443331" );
+    mpi_fromstr(p, "0xcccddd456700000012222222222222254545455"
+                  "aaaaaaaaaaaaa44444fffdecb33434343443337" );
+    mpi_fromstr(x, "0x100004545543656456656545545454554545455"
+                   "aaa33aaaa465456544fffdecb33434bbbac3331" );
+
+    /* output = b/(a^x) mod p */
+    log_debug("powm ..\n");
+    mpi_powm( t, a, x, p );
+    log_debug("invm ..\n");
+    mpi_invm( t, t, p );
+    log_debug("mulm ..\n");
+    mpi_mulm( m, b, t, p );
+
+
+    m_check(NULL);
+
+}
+
+
index 6c7e32f..c056ac0 100644 (file)
 #include "main.h"
 
 static int opt_list=1; /* and list the data packets to stdout */
+#if 0
+static void
+do_free_last_user_id( CTX c )
+{
+    if( c->last_user_id ) {
+       free_user_id( c->last_user_id );
+       c->last_user_id = NULL;
+    }
+}
+static void
+do_free_last_pubkey( CTX c )
+{
+    if( c->last_pubkey ) {
+       free_pubkey_cert( c->last_pubkey );
+       c->last_pubkey = NULL;
+    }
+}
+static void
+do_free_last_seckey( CTX c )
+{
+    if( c->last_seckey ) {
+       free_seckey_cert( c->last_seckey );
+       c->last_seckey = NULL;
+    }
+}
+
+static void
+proc_pubkey_cert( CTX c, PACKET *pkt )
+{
+    do_free_last_user_id( c );
+    do_free_last_seckey( c );
+    if( opt.check_sigs ) {
+       char *ustr = get_user_id_string(sig->keyid); /* sig ???? */
+       printstr(lvl0, "pub: %s\n", ustr );
+       m_free(ustr);
+    }
+    else
+       fputs( "pub: [Public Key Cerificate]\n", stdout );
+    c->last_pubkey = pkt->pkt.pubkey_cert;
+    pkt->pkt.pubkey_cert = NULL;
+    free_packet(pkt);
+    pkt->pkc_parent = c->last_pubkey; /* set this as parent */
+}
+
+
+static void
+proc_seckey_cert( CTX c, PACKET *pkt )
+{
+    int rc;
+
+    do_free_last_user_id( c );
+    do_free_last_pubkey( c );
+    if( opt_list )
+       fputs( "sec: (secret key certificate)\n", stdout );
+    rc = check_secret_key( pkt->pkt.seckey_cert );
+    if( opt_list ) {
+       if( !rc )
+           fputs( "     Secret key is good", stdout );
+       else
+           fputs( g10_errstr(rc), stdout);
+       putchar('\n');
+    }
+    else if( rc )
+       log_error("secret key certificate error: %s\n", g10_errstr(rc));
+    c->last_seckey = pkt->pkt.seckey_cert;
+    pkt->pkt.seckey_cert = NULL;
+    free_packet(pkt);
+    pkt->skc_parent = c->last_seckey; /* set this as parent */
+}
+
+
+
+
+
+int
+proc_packets( IOBUF a )
+{
+    PACKET *pkt;
+    PKT_pubkey_cert *last_pubkey = NULL;
+    PKT_seckey_cert *last_seckey = NULL;
+    PKT_user_id     *last_user_id = NULL;
+    DEK *dek = NULL;
+    PKT_signature *sig; /* CHECK: "might be used uninitialied" */
+    int rc, result;
+    MD_HANDLE md_handle; /* union to pass handles */
+    char *ustr;
+    int lvl0, lvl1;
+    int last_was_pubkey_enc = 0;
+    u32 keyid[2];
+    md_filter_context_t mfx;
+
+    memset( &mfx, 0, sizeof mfx );
+    lvl0 = opt.check_sigs? 1:0; /* stdout or /dev/null */
+    lvl1 = opt.check_sigs? 1:3; /* stdout or error */
+    pkt = m_alloc( sizeof *pkt );
+    init_packet(pkt);
+    while( (rc=parse_packet(a, pkt)) != -1 ) {
+       /* cleanup if we have an illegal data structure */
+       if( dek && pkt->pkttype != PKT_ENCR_DATA ) {
+           log_error("oops: valid pubkey enc packet not followed by data\n");
+           m_free(dek); dek = NULL; /* burn it */
+       }
+
+       if( rc ) {
+           free_packet(pkt);
+           continue;
+       }
+       switch( pkt->pkttype ) {
+         case PKT_PUBKEY_CERT: proc_pubkey_cert( c, pkt ); break;
+         case PKT_SECKEY_CERT: proc_seckey_cert( c, pkt ); break;
+         case PKT_USER_ID:
+           if( last_user_id ) {
+               free_user_id( last_user_id );
+               last_user_id = NULL;
+           }
+           if( opt_list ) {
+                printf("uid: '%.*s'\n", pkt->pkt.user_id->len,
+                                        pkt->pkt.user_id->name );
+                if( !pkt->pkc_parent && !pkt->skc_parent )
+                    puts("      (orphaned)");
+           }
+           if( pkt->pkc_parent ) {
+               if( pkt->pkc_parent->pubkey_algo == PUBKEY_ALGO_ELGAMAL
+                   || pkt->pkc_parent->pubkey_algo == PUBKEY_ALGO_RSA ) {
+                   keyid_from_pkc( pkt->pkc_parent, keyid );
+                   cache_user_id( pkt->pkt.user_id, keyid );
+               }
+           }
+
+           last_user_id = pkt->pkt.user_id;  /* save */
+           pkt->pkt.user_id = NULL;
+           free_packet(pkt);   /* fixme: free_packet is not a good name */
+           pkt->user_parent = last_user_id;  /* and set this as user */
+           break;
+
+         case PKT_SIGNATURE:
+           sig = pkt->pkt.signature;
+           ustr = get_user_id_string(sig->keyid);
+           result = -1;
+           if( sig->sig_class == 0x00 ) {
+               if( mfx.rmd160 )
+                   result = 0;
+               else
+                   printstr(lvl1,"sig?: %s: no plaintext for signature\n",
+                                                       ustr);
+           }
+           else if( sig->sig_class != 0x10 )
+               printstr(lvl1,"sig?: %s: unknown signature class %02x\n",
+                                       ustr, sig->sig_class);
+           else if( !pkt->pkc_parent || !pkt->user_parent )
+               printstr(lvl1,"sig?: %s: orphaned encoded packet\n", ustr);
+           else
+               result = 0;
+
+           if( result )
+               ;
+           else if( !opt.check_sigs && sig->sig_class != 0x00 ) {
+               result = -1;
+               printstr(lvl0, "sig: from %s\n", ustr );
+           }
+           else if(sig->pubkey_algo == PUBKEY_ALGO_ELGAMAL ) {
+               md_handle.algo = sig->d.elg.digest_algo;
+               if( sig->d.elg.digest_algo == DIGEST_ALGO_RMD160 ) {
+                   if( sig->sig_class == 0x00 )
+                       md_handle.u.rmd = rmd160_copy( mfx.rmd160 );
+                   else {
+                       md_handle.u.rmd = rmd160_copy(pkt->pkc_parent->mfx.rmd160);
+                       rmd160_write(md_handle.u.rmd, pkt->user_parent->name,
+                                                     pkt->user_parent->len);
+                   }
+                   result = signature_check( sig, md_handle );
+                   rmd160_close(md_handle.u.rmd);
+               }
+               else if( sig->d.elg.digest_algo == DIGEST_ALGO_MD5
+                        && sig->sig_class != 0x00 ) {
+                   md_handle.u.md5 = md5_copy(pkt->pkc_parent->mfx.md5);
+                   md5_write(md_handle.u.md5, pkt->user_parent->name,
+                                              pkt->user_parent->len);
+                   result = signature_check( sig, md_handle );
+                   md5_close(md_handle.u.md5);
+               }
+               else
+                   result = G10ERR_DIGEST_ALGO;
+           }
+           else if(sig->pubkey_algo == PUBKEY_ALGO_RSA ) {
+               md_handle.algo = sig->d.rsa.digest_algo;
+               if( sig->d.rsa.digest_algo == DIGEST_ALGO_RMD160 ) {
+                   if( sig->sig_class == 0x00 )
+                       md_handle.u.rmd = rmd160_copy( mfx.rmd160 );
+                   else {
+                       md_handle.u.rmd = rmd160_copy(pkt->pkc_parent->mfx.rmd160);
+                       rmd160_write(md_handle.u.rmd, pkt->user_parent->name,
+                                                     pkt->user_parent->len);
+                   }
+                   result = signature_check( sig, md_handle );
+                   rmd160_close(md_handle.u.rmd);
+               }
+               else if( sig->d.rsa.digest_algo == DIGEST_ALGO_MD5
+                        && sig->sig_class != 0x00 ) {
+                   md_handle.u.md5 = md5_copy(pkt->pkc_parent->mfx.md5);
+                   md5_write(md_handle.u.md5, pkt->user_parent->name,
+                                              pkt->user_parent->len);
+                   result = signature_check( sig, md_handle );
+                   md5_close(md_handle.u.md5);
+               }
+               else
+                   result = G10ERR_DIGEST_ALGO;
+           }
+           else
+               result = G10ERR_PUBKEY_ALGO;
+
+           if( result == -1 )
+               ;
+           else if( !result && sig->sig_class == 0x00 )
+               printstr(1,    "sig: good signature from %s\n", ustr );
+           else if( !result )
+               printstr(lvl0, "sig: good signature from %s\n", ustr );
+           else
+               printstr(lvl1, "sig? %s: %s\n", ustr, g10_errstr(result));
+           free_packet(pkt);
+           m_free(ustr);
+           break;
+
+         case PKT_PUBKEY_ENC:
+           PKT_pubkey_enc *enc;
+
+           last_was_pubkey_enc = 1;
+           result = 0;
+           enc = pkt->pkt.pubkey_enc;
+           printf("enc: encrypted by a pubkey with keyid %08lX\n",
+                                                       enc->keyid[1] );
+           if( enc->pubkey_algo == PUBKEY_ALGO_ELGAMAL
+               || enc->pubkey_algo == PUBKEY_ALGO_RSA  ) {
+               m_free(dek ); /* paranoid: delete a pending DEK */
+               dek = m_alloc_secure( sizeof *dek );
+               if( (result = get_session_key( enc, dek )) ) {
+                   /* error: delete the DEK */
+                   m_free(dek); dek = NULL;
+               }
+           }
+           else
+               result = G10ERR_PUBKEY_ALGO;
+
+           if( result == -1 )
+               ;
+           else if( !result )
+               fputs(  "     DEK is good", stdout );
+           else
+               printf( "     %s", g10_errstr(result));
+           putchar('\n');
+           free_packet(pkt);
+           break;
+
+         case PKT_ENCR_DATA:
+           result = 0;
+           printf("dat: %sencrypted data\n", dek?"":"conventional ");
+           if( !dek && !last_was_pubkey_enc ) {
+               /* assume this is conventional encrypted data */
+               dek = m_alloc_secure( sizeof *dek );
+               dek->algo = DEFAULT_CIPHER_ALGO;
+               result = make_dek_from_passphrase( dek, 0 );
+           }
+           else if( !dek )
+               result = G10ERR_NO_SECKEY;
+           if( !result )
+               result = decrypt_data( pkt->pkt.encr_data, dek );
+           m_free(dek); dek = NULL;
+           if( result == -1 )
+               ;
+           else if( !result )
+               fputs(  "     encryption okay",stdout);
+           else
+               printf( "     %s", g10_errstr(result));
+           putchar('\n');
+           free_packet(pkt);
+           last_was_pubkey_enc = 0;
+           break;
+
+         case PKT_PLAINTEXT:
+           PKT_plaintext *pt = pkt->pkt.plaintext;
+           printf("txt: plain text data name='%.*s'\n", pt->namelen, pt->name);
+           free_md_filter_context( &mfx );
+           mfx.rmd160 = rmd160_open(0);
+           result = handle_plaintext( pt, &mfx );
+           if( !result )
+               fputs(  "     okay",stdout);
+           else
+               printf( "     %s", g10_errstr(result));
+           putchar('\n');
+           free_packet(pkt);
+           last_was_pubkey_enc = 0;
+           break;
+
+         case PKT_COMPR_DATA:
+           PKT_compressed *zd = pkt->pkt.compressed;
+           printf("zip: compressed data packet\n");
+           result = handle_compressed( zd );
+           if( !result )
+               fputs(  "     okay",stdout);
+           else
+               printf( "     %s", g10_errstr(result));
+           putchar('\n');
+           free_packet(pkt);
+           last_was_pubkey_enc = 0;
+           break;
+
+         default:
+           free_packet(pkt);
+       }
+    }
+
+    if( last_user_id )
+       free_user_id( last_user_id );
+    if( last_seckey )
+       free_seckey_cert( last_seckey );
+    if( last_pubkey )
+       free_pubkey_cert( last_pubkey );
+    m_free(dek);
+    free_packet( pkt );
+    m_free( pkt );
+    free_md_filter_context( &mfx );
+    return 0;
+}
 
+#else /* old */
 int
 proc_packets( IOBUF a )
 {
@@ -317,5 +641,5 @@ proc_packets( IOBUF a )
     free_md_filter_context( &mfx );
     return 0;
 }
-
+#endif
 
index 58da1ae..183d919 100644 (file)
@@ -61,6 +61,7 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek )
        elg_decipher( dek_frame, k->d.elg.a, k->d.elg.b, &skey );
        memset( &skey, 0, sizeof skey );
     }
+  #ifdef HAVE_RSA_CIPHER
     else if( k->pubkey_algo == PUBKEY_ALGO_RSA ) {
        RSA_secret_key skey;
 
@@ -76,6 +77,7 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek )
        rsa_secret( dek_frame, k->d.rsa.rsa_integer, &skey );
        memset( &skey, 0, sizeof skey );
     }
+  #endif/*HAVE_RSA_CIPHER*/
     else {
        rc = G10ERR_PUBKEY_ALGO; /* unsupported algorithm */
        goto leave;
index ff21258..fb3b409 100644 (file)
@@ -66,7 +66,7 @@ signature_check( PKT_signature *sig, MD_HANDLE digest )
            dp = rmd160_final( digest.u.rmd );
            result = encode_rmd160_value( dp, 20, mpi_get_nbits(pkc->d.elg.p));
        }
-       else if( sig->d.rsa.digest_algo == DIGEST_ALGO_MD5 ) {
+       else if( sig->d.elg.digest_algo == DIGEST_ALGO_MD5 ) {
            md5_putchar( digest.u.md5, sig->sig_class );
            {   u32 a = sig->timestamp;
                md5_putchar( digest.u.md5, (a >> 24) & 0xff );
@@ -89,6 +89,7 @@ signature_check( PKT_signature *sig, MD_HANDLE digest )
        if( !elg_verify( sig->d.elg.a, sig->d.elg.b, result, &pkey ) )
            rc = G10ERR_BAD_SIGN;
     }
+ #ifdef HAVE_RSA_CIPHER
     else if( pkc->pubkey_algo == PUBKEY_ALGO_RSA ) {
        RSA_public_key pkey;
 
@@ -214,6 +215,7 @@ signature_check( PKT_signature *sig, MD_HANDLE digest )
            goto leave;
        }
     }
+  #endif/*HAVE_RSA_CIPHER*/
     else {
        log_debug("signature_check: unsupported pubkey algo %d\n",
                        pkc->pubkey_algo );
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100644 (file)
index 0000000..bee6367
--- /dev/null
@@ -0,0 +1,5 @@
+## Process this file with automake to produce Makefile.in
+
+EXTRA_DIST = cipher.h errors.h iobuf.h memory.h mpi.h ttyio.h types.h \
+            util.h
+
index 25fa696..9c5da63 100644 (file)
@@ -1,5 +1,6 @@
 /* mpi.h  -  Multi Precision Integers
  *     Copyright (c) 1997 by Werner Koch (dd9jn)
+ *     Copyright (C) 1994, 1996 Free Software Foundation, Inc.
  *
  * This file is part of G10.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ *      Actually it's the same code with only minor changes in the
+ *      way the data is stored; this is to support the abstraction
+ *      of an optional secure memory allocation which may be used
+ *      to avoid revealing of sensitive data due to paging etc.
+ *      The GNU MP Library itself is published under the LGPL;
+ *      however I decided to publish this code under the plain GPL.
  */
 
 #ifndef G10_MPI_H
index 353ab23..f05972c 100644 (file)
@@ -3,8 +3,10 @@
 INCLUDES =  -I$(top_srcdir)/include
 CFLAGS += -O2
 
-noinst_LIBRARIES = mpi
+SUFFIXES = .S .s
 
+noinst_LIBRARIES = mpi
+noinst_HEADERS  = sysdep.h
 
 mpi_SOURCES = longlong.h     \
              mpi-add.c      \
@@ -19,18 +21,28 @@ mpi_SOURCES = longlong.h     \
              mpi-pow.c      \
              mpi-scan.c     \
              mpicoder.c     \
-             mpih-add.c     \
              mpih-cmp.c     \
+             mpih-add.c     \
+             mpih-sub.c     \
              mpih-div.c     \
              mpih-mul.c     \
-             mpih-shift.c   \
-             mpih-sub.c     \
-             mpih-mul1.S    \
-             mpih-mul2.S    \
-             mpih-add1.S    \
-             mpih-mul3.S    \
-             mpih-sub1.S    \
-             mpih-shift.S   \
-             mpih-add.S     \
              mpiutil.c
 
+mpi_LIBADD =  mpih-mul1.o    \
+             mpih-mul2.o    \
+             mpih-mul3.o    \
+             mpih-add1.o    \
+             mpih-sub1.o    \
+             mpih-shift.o
+
+#mpi_DEPENDENCIES = mpih-mul1.S    \
+#                  mpih-mul2.S    \
+#                  mpih-mul3.S    \
+#                  mpih-add1.S    \
+#                  mpih-sub1.S    \
+#                  mpih-shift.S
+#
+
+##DISTCLEANFILES = @MPI_DISTCLEANFILES@
+
+
index 4f493a8..d51dcd0 100644 (file)
@@ -40,27 +40,37 @@ transform = @program_transform_name@
 
 INCLUDES =  -I$(top_srcdir)/include
 
-noinst_LIBRARIES = mpi
+SUFFIXES = .S .s
 
-mpi_SOURCES = longlong.h       \
-             mpi-add.c         \
-             mpi-bit.c         \
-             mpi-cmp.c         \
-             mpi-div.c         \
-             mpi-gcd.c         \
-             mpi-internal.h    \
-             mpi-inv.c         \
-             mpi-mul.c         \
-             mpi-pow.c         \
-             mpi-scan.c        \
-             mpicoder.c        \
-             mpihelp-add.c     \
-             mpihelp-cmp.c     \
-             mpihelp-div.c     \
-             mpihelp-mul.c     \
-             mpihelp-shift.c   \
-             mpihelp-sub.c     \
+noinst_LIBRARIES = mpi
+noinst_HEADERS  = sysdep.h
+
+mpi_SOURCES = longlong.h     \
+             mpi-add.c      \
+             mpi-bit.c      \
+             mpi-cmp.c      \
+             mpi-div.c      \
+             mpi-gcd.c      \
+             mpi-internal.h \
+             mpi-inline.h   \
+             mpi-inv.c      \
+             mpi-mul.c      \
+             mpi-pow.c      \
+             mpi-scan.c     \
+             mpicoder.c     \
+             mpih-cmp.c     \
+             mpih-add.c     \
+             mpih-sub.c     \
+             mpih-div.c     \
+             mpih-mul.c     \
              mpiutil.c
+
+mpi_LIBADD =  mpih-mul1.o    \
+             mpih-mul2.o    \
+             mpih-mul3.o    \
+             mpih-add1.o    \
+             mpih-sub1.o    \
+             mpih-shift.o
 mkinstalldirs = $(top_srcdir)/scripts/mkinstalldirs
 CONFIG_HEADER = ../config.h
 LIBRARIES = $(noinst_LIBRARIES)
@@ -79,15 +89,15 @@ LIBS = @LIBS@
 
 COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
 LINK = $(CC) $(LDFLAGS) -o $@
-mpi_LIBADD =
 mpi_OBJECTS = mpi-add.o mpi-bit.o mpi-cmp.o mpi-div.o mpi-gcd.o \
-mpi-inv.o mpi-mul.o mpi-pow.o mpi-scan.o mpicoder.o mpihelp-add.o \
-mpihelp-cmp.o mpihelp-div.o mpihelp-mul.o mpihelp-shift.o mpihelp-sub.o \
-mpiutil.o
+mpi-inv.o mpi-mul.o mpi-pow.o mpi-scan.o mpicoder.o mpih-cmp.o \
+mpih-add.o mpih-sub.o mpih-div.o mpih-mul.o mpiutil.o
 EXTRA_mpi_SOURCES =
 LIBFILES =  libmpi.a
 AR = ar
 RANLIB = @RANLIB@
+HEADERS = $(noinst_HEADERS)
+
 DIST_COMMON = Makefile.am Makefile.in
 
 
@@ -105,10 +115,9 @@ $(srcdir)/.deps/mpi-cmp.P $(srcdir)/.deps/mpi-div.P \
 $(srcdir)/.deps/mpi-gcd.P $(srcdir)/.deps/mpi-inv.P \
 $(srcdir)/.deps/mpi-mul.P $(srcdir)/.deps/mpi-pow.P \
 $(srcdir)/.deps/mpi-scan.P $(srcdir)/.deps/mpicoder.P \
-$(srcdir)/.deps/mpihelp-add.P $(srcdir)/.deps/mpihelp-cmp.P \
-$(srcdir)/.deps/mpihelp-div.P $(srcdir)/.deps/mpihelp-mul.P \
-$(srcdir)/.deps/mpihelp-shift.P $(srcdir)/.deps/mpihelp-sub.P \
-$(srcdir)/.deps/mpiutil.P
+$(srcdir)/.deps/mpih-add.P $(srcdir)/.deps/mpih-cmp.P \
+$(srcdir)/.deps/mpih-div.P $(srcdir)/.deps/mpih-mul.P \
+$(srcdir)/.deps/mpih-sub.P $(srcdir)/.deps/mpiutil.P
 SOURCES = $(mpi_SOURCES)
 OBJECTS = $(mpi_OBJECTS)
 
@@ -218,7 +227,7 @@ install: install-exec install-data all
 
 uninstall: 
 
-all: $(LIBFILES) Makefile
+all: $(LIBFILES) $(HEADERS) Makefile
 
 install-strip:
        $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
@@ -263,8 +272,17 @@ install-exec install-data install uninstall all installdirs \
 mostlyclean-generic distclean-generic clean-generic \
 maintainer-clean-generic clean mostlyclean distclean maintainer-clean
 
+CFLAGS += -O2
+
+#mpi_DEPENDENCIES = mpih-mul1.S    \
+#                  mpih-mul2.S    \
+#                  mpih-mul3.S    \
+#                  mpih-add1.S    \
+#                  mpih-sub1.S    \
+#                  mpih-shift.S
+#
 .SUFFIXES:
-.SUFFIXES: .c .o
+.SUFFIXES: .c .o $(SUFFIXES)
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/mpi/mpih-shift.c b/mpi/mpih-shift.c
deleted file mode 100644 (file)
index a8fe26a..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/* mpihelp-shift.c  -  MPI helper functions
- *     Copyright (c) 1997 by Werner Koch (dd9jn)
- *
- * This file is part of G10.
- *
- * G10 is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * G10 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "mpi-internal.h"
-
-/* Shift U (pointed to by UP and USIZE digits long) CNT bits to the left
- * and store the USIZE least significant digits of the result at WP.
- * Return the bits shifted out from the most significant digit.
- *
- * Argument constraints:
- * 1. 0 < CNT < BITS_PER_MP_LIMB
- * 2. If the result is to be written over the input, WP must be >= UP.
- */
-
-mpi_limb_t
-mpihelp_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
-                                           unsigned int cnt)
-{
-    mpi_limb_t high_limb, low_limb;
-    unsigned sh_1, sh_2;
-    mpi_size_t i;
-    mpi_limb_t retval;
-
-    sh_1 = cnt;
-    wp += 1;
-    sh_2 = BITS_PER_MPI_LIMB - sh_1;
-    i = usize - 1;
-    low_limb = up[i];
-    retval = low_limb >> sh_2;
-    high_limb = low_limb;
-    while( --i >= 0 ) {
-       low_limb = up[i];
-       wp[i] = (high_limb << sh_1) | (low_limb >> sh_2);
-       high_limb = low_limb;
-    }
-    wp[i] = high_limb << sh_1;
-
-    return retval;
-}
-
-
-/* Shift U (pointed to by UP and USIZE limbs long) CNT bits to the right
- * and store the USIZE least significant limbs of the result at WP.
- * The bits shifted out to the right are returned.
- *
- * Argument constraints:
- * 1. 0 < CNT < BITS_PER_MP_LIMB
- * 2. If the result is to be written over the input, WP must be <= UP.
- */
-
-mpi_limb_t
-mpihelp_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned cnt)
-{
-    mpi_limb_t high_limb, low_limb;
-    unsigned sh_1, sh_2;
-    mpi_size_t i;
-    mpi_limb_t retval;
-
-    sh_1 = cnt;
-    wp -= 1;
-    sh_2 = BITS_PER_MPI_LIMB - sh_1;
-    high_limb = up[0];
-    retval = high_limb << sh_2;
-    low_limb = high_limb;
-    for( i=1; i < usize; i++) {
-       high_limb = up[i];
-       wp[i] = (low_limb >> sh_1) | (high_limb << sh_2);
-       low_limb = high_limb;
-    }
-    wp[i] = low_limb >> sh_1;
-
-    return retval;
-}
-
diff --git a/scripts/config.guess b/scripts/config.guess
new file mode 100755 (executable)
index 0000000..b6f37c9
--- /dev/null
@@ -0,0 +1,737 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Written by Per Bothner <bothner@cygnus.com>.
+# The master version of this file is at the FSF in /home/gd/gnu/lib.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit system type (host/target name).
+#
+# Only a few systems have been added to this list; please add others
+# (but try to keep the structure clean).
+#
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 8/24/94.)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+       PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    alpha:OSF1:*:*)
+       # A Vn.n version is a released version.
+       # A Tn.n version is a released field test version.
+       # A Xn.n version is an unreleased experimental baselevel.
+       # 1.2 uses "1.2" for uname -r.
+       echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//'`
+       exit 0 ;;
+    21064:Windows_NT:50:3)
+       echo alpha-dec-winnt3.5
+       exit 0 ;;
+    Amiga*:UNIX_System_V:4.0:*)
+       echo m68k-cbm-sysv4
+       exit 0;;
+    amiga:NetBSD:*:*)
+      echo m68k-cbm-netbsd${UNAME_RELEASE}
+      exit 0 ;;
+    amiga:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    arc64:OpenBSD:*:*)
+       echo mips64el-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    arc:OpenBSD:*:*)
+       echo mipsel-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    hkmips:OpenBSD:*:*)
+       echo mips-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    pmax:OpenBSD:*:*)
+       echo mipsel-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    sgi:OpenBSD:*:*)
+       echo mips-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    wgrisc:OpenBSD:*:*)
+       echo mipsel-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+       echo arm-acorn-riscix${UNAME_RELEASE}
+       exit 0;;
+    SR2?01:HI-UX/MPP:*:*)
+       echo hppa1.1-hitachi-hiuxmpp
+       exit 0;;
+    Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
+       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+       if test "`(/bin/universe) 2>/dev/null`" = att ; then
+               echo pyramid-pyramid-sysv3
+       else
+               echo pyramid-pyramid-bsd
+       fi
+       exit 0 ;;
+    NILE:*:*:dcosx)
+       echo pyramid-pyramid-svr4
+       exit 0 ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    i86pc:SunOS:5.*:*)
+       echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    sun4*:SunOS:6*:*)
+       # According to config.sub, this is the proper way to canonicalize
+       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+       # it's likely to be more like Solaris than SunOS4.
+       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    sun4*:SunOS:*:*)
+       case "`/usr/bin/arch -k`" in
+           Series*|S4*)
+               UNAME_RELEASE=`uname -v`
+               ;;
+       esac
+       # Japanese Language versions have a version number like `4.1.3-JL'.
+       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       exit 0 ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit 0 ;;
+    aushp:SunOS:*:*)
+       echo sparc-auspex-sunos${UNAME_RELEASE}
+       exit 0 ;;
+    atari*:NetBSD:*:*)
+       echo m68k-atari-netbsd${UNAME_RELEASE}
+       exit 0 ;;
+    atari*:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    sun3*:NetBSD:*:*)
+       echo m68k-sun-netbsd${UNAME_RELEASE}
+       exit 0 ;;
+    sun3*:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    mac68k:NetBSD:*:*)
+       echo m68k-apple-netbsd${UNAME_RELEASE}
+       exit 0 ;;
+    mac68k:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    mvme68k:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    mvme88k:OpenBSD:*:*)
+       echo m88k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    powerpc:machten:*:*)
+       echo powerpc-apple-machten${UNAME_RELEASE}
+       exit 0 ;;
+    RISC*:Mach:*:*)
+       echo mips-dec-mach_bsd4.3
+       exit 0 ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit 0 ;;
+    VAX*:ULTRIX*:*:*)
+       echo vax-dec-ultrix${UNAME_RELEASE}
+       exit 0 ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+       sed 's/^        //' << EOF >dummy.c
+       int main (argc, argv) int argc; char **argv; {
+       #if defined (host_mips) && defined (MIPSEB)
+       #if defined (SYSTYPE_SYSV)
+         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_SVR4)
+         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+       #endif
+       #endif
+         exit (-1);
+       }
+EOF
+       ${CC-cc} dummy.c -o dummy \
+         && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+         && rm dummy.c dummy && exit 0
+       rm -f dummy.c dummy
+       echo mips-mips-riscos${UNAME_RELEASE}
+       exit 0 ;;
+    Night_Hawk:Power_UNIX:*:*)
+       echo powerpc-harris-powerunix
+       exit 0 ;;
+    m88k:CX/UX:7*:*)
+       echo m88k-harris-cxux7
+       exit 0 ;;
+    m88k:*:4*:R4*)
+       echo m88k-motorola-sysv4
+       exit 0 ;;
+    m88k:*:3*:R3*)
+       echo m88k-motorola-sysv3
+       exit 0 ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+        if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
+       if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
+            -o ${TARGET_BINARY_INTERFACE}x = x ] ; then
+               echo m88k-dg-dgux${UNAME_RELEASE}
+       else
+               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+       fi
+        else echo i586-dg-dgux${UNAME_RELEASE}
+        fi
+       exit 0 ;;
+    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
+       echo m88k-dolphin-sysv3
+       exit 0 ;;
+    M88*:*:R3*:*)
+       # Delta 88k system running SVR3
+       echo m88k-motorola-sysv3
+       exit 0 ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+       echo m88k-tektronix-sysv3
+       exit 0 ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+       echo m68k-tektronix-bsd
+       exit 0 ;;
+    *:IRIX*:*:*)
+       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       exit 0 ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+       echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
+       exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
+    i?86:AIX:*:*)
+       echo i386-ibm-aix
+       exit 0 ;;
+    *:AIX:2:3)
+       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+               sed 's/^                //' << EOF >dummy.c
+               #include <sys/systemcfg.h>
+
+               main()
+                       {
+                       if (!__power_pc())
+                               exit(1);
+                       puts("powerpc-ibm-aix3.2.5");
+                       exit(0);
+                       }
+EOF
+               ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
+               rm -f dummy.c dummy
+               echo rs6000-ibm-aix3.2.5
+       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+               echo rs6000-ibm-aix3.2.4
+       else
+               echo rs6000-ibm-aix3.2
+       fi
+       exit 0 ;;
+    *:AIX:*:4)
+       if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
+               IBM_ARCH=rs6000
+       else
+               IBM_ARCH=powerpc
+       fi
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=4.${UNAME_RELEASE}
+       fi
+       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       exit 0 ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit 0 ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+       echo romp-ibm-bsd4.4
+       exit 0 ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC NetBSD and
+       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       exit 0 ;;                           # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+       echo rs6000-bull-bosx
+       exit 0 ;;
+    DPX/2?00:B.O.S.:*:*)
+       echo m68k-bull-sysv3
+       exit 0 ;;
+    9000/[34]??:4.3bsd:1.*:*)
+       echo m68k-hp-bsd
+       exit 0 ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+       echo m68k-hp-bsd4.4
+       exit 0 ;;
+    9000/[3478]??:HP-UX:*:*)
+       case "${UNAME_MACHINE}" in
+           9000/31? )            HP_ARCH=m68000 ;;
+           9000/[34]?? )         HP_ARCH=m68k ;;
+           9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;;
+           9000/8?? )            HP_ARCH=hppa1.0 ;;
+       esac
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       exit 0 ;;
+    3050*:HI-UX:*:*)
+       sed 's/^        //' << EOF >dummy.c
+       #include <unistd.h>
+       int
+       main ()
+       {
+         long cpu = sysconf (_SC_CPU_VERSION);
+         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+            results, however.  */
+         if (CPU_IS_PA_RISC (cpu))
+           {
+             switch (cpu)
+               {
+                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+                 default: puts ("hppa-hitachi-hiuxwe2"); break;
+               }
+           }
+         else if (CPU_IS_HP_MC68K (cpu))
+           puts ("m68k-hitachi-hiuxwe2");
+         else puts ("unknown-hitachi-hiuxwe2");
+         exit (0);
+       }
+EOF
+       ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
+       rm -f dummy.c dummy
+       echo unknown-hitachi-hiuxwe2
+       exit 0 ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+       echo hppa1.1-hp-bsd
+       exit 0 ;;
+    9000/8??:4.3bsd:*:*)
+       echo hppa1.0-hp-bsd
+       exit 0 ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+       echo hppa1.1-hp-osf
+       exit 0 ;;
+    hp8??:OSF1:*:*)
+       echo hppa1.0-hp-osf
+       exit 0 ;;
+    i?86:OSF1:*:*)
+       if [ -x /usr/sbin/sysversion ] ; then
+           echo ${UNAME_MACHINE}-unknown-osf1mk
+       else
+           echo ${UNAME_MACHINE}-unknown-osf1
+       fi
+       exit 0 ;;
+    parisc*:Lites*:*:*)
+       echo hppa1.1-hp-lites
+       exit 0 ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+       echo c1-convex-bsd
+        exit 0 ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+        exit 0 ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+       echo c34-convex-bsd
+        exit 0 ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+       echo c38-convex-bsd
+        exit 0 ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+       echo c4-convex-bsd
+        exit 0 ;;
+    CRAY*X-MP:*:*:*)
+       echo xmp-cray-unicos
+        exit 0 ;;
+    CRAY*Y-MP:*:*:*)
+       echo ymp-cray-unicos${UNAME_RELEASE}
+       exit 0 ;;
+    CRAY*[A-Z]90:*:*:*)
+       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+       exit 0 ;;
+    CRAY*TS:*:*:*)
+       echo t90-cray-unicos${UNAME_RELEASE}
+       exit 0 ;;
+    CRAY-2:*:*:*)
+       echo cray2-cray-unicos
+        exit 0 ;;
+    F300:UNIX_System_V:*:*)
+        FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit 0 ;;
+    F301:UNIX_System_V:*:*)
+       echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
+       exit 0 ;;
+    hp3[0-9][05]:NetBSD:*:*)
+       echo m68k-hp-netbsd${UNAME_RELEASE}
+       exit 0 ;;
+    hp300:OpenBSD:*:*)
+       echo m68k-unknown-openbsd${UNAME_RELEASE}
+       exit 0 ;;
+    i?86:BSD/386:*:* | *:BSD/OS:*:*)
+       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       exit 0 ;;
+    *:FreeBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit 0 ;;
+    *:NetBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+       exit 0 ;;
+    *:OpenBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+       exit 0 ;;
+    i*:CYGWIN*:*)
+       echo i386-pc-cygwin32
+       exit 0 ;;
+    p*:CYGWIN*:*)
+       echo powerpcle-unknown-cygwin32
+       exit 0 ;;
+    prep*:SunOS:5.*:*)
+       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    *:GNU:*:*)
+       echo `echo ${UNAME_MACHINE}|sed -e 's,-.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       exit 0 ;;
+    *:Linux:*:*)
+       # The BFD linker knows what the default object file format is, so
+       # first see if it will tell us.
+       ld_help_string=`ld --help 2>&1`
+       if echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf_i.86"; then
+         echo "${UNAME_MACHINE}-pc-linux-gnu" ; exit 0
+       elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86linux"; then
+         echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0
+       elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86coff"; then
+         echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0
+       elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68kelf"; then
+         echo "${UNAME_MACHINE}-unknown-linux-gnu" ; exit 0
+       elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68klinux"; then
+         echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0
+       elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf32ppc"; then
+         echo "powerpc-unknown-linux-gnu" ; exit 0
+       elif test "${UNAME_MACHINE}" = "alpha" ; then
+         echo alpha-unknown-linux-gnu ; exit 0
+       elif test "${UNAME_MACHINE}" = "sparc" ; then
+         echo sparc-unknown-linux-gnu ; exit 0
+       elif test "${UNAME_MACHINE}" = "mips" ; then
+         cat >dummy.c <<EOF
+main(argc, argv)
+int argc;
+char *argv[];
+{
+#ifdef __MIPSEB__
+  printf ("%s-unknown-linux-gnu\n", argv[1]);
+#endif
+#ifdef __MIPSEL__
+  printf ("%sel-unknown-linux-gnu\n", argv[1]);
+#endif
+  return 0;
+}
+EOF
+         ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
+         rm -f dummy.c dummy
+       else
+         # Either a pre-BFD a.out linker (linux-gnuoldld) or one that does not give us
+         # useful --help.  Gcc wants to distinguish between linux-gnuoldld and linux-gnuaout.
+         test ! -d /usr/lib/ldscripts/. \
+           && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
+         # Determine whether the default compiler is a.out or elf
+         cat >dummy.c <<EOF
+main(argc, argv)
+int argc;
+char *argv[];
+{
+#ifdef __ELF__
+  printf ("%s-pc-linux-gnu\n", argv[1]);
+#else
+  printf ("%s-pc-linux-gnuaout\n", argv[1]);
+#endif
+  return 0;
+}
+EOF
+         ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
+         rm -f dummy.c dummy
+       fi ;;
+# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  earlier versions
+# are messed up and put the nodename in both sysname and nodename.
+    i?86:DYNIX/ptx:4*:*)
+       echo i386-sequent-sysv4
+       exit 0 ;;
+    i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+               echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
+       else
+               echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+       fi
+       exit 0 ;;
+    i?86:*:3.2:*)
+       if test -f /usr/options/cb.name; then
+               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+       elif /bin/uname -X 2>/dev/null >/dev/null ; then
+               UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+               (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+               (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+                       && UNAME_MACHINE=i586
+               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+       else
+               echo ${UNAME_MACHINE}-pc-sysv32
+       fi
+       exit 0 ;;
+    Intel:Mach:3*:*)
+       echo i386-pc-mach3
+       exit 0 ;;
+    paragon:*:*:*)
+       echo i860-intel-osf1
+       exit 0 ;;
+    i860:*:4.*:*) # i860-SVR4
+       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+       else # Add other i860-SVR4 vendors below as they are discovered.
+         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+       fi
+       exit 0 ;;
+    mini*:CTIX:SYS*5:*)
+       # "miniframe"
+       echo m68010-convergent-sysv
+       exit 0 ;;
+    M68*:*:R3V[567]*:*)
+       test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+    3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+       OS_REL=''
+       test -r /etc/.relid \
+       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+         && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && echo i486-ncr-sysv4 && exit 0 ;;
+    m68*:LynxOS:2.*:*)
+       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    mc68030:UNIX_System_V:4.*:*)
+       echo m68k-atari-sysv4
+       exit 0 ;;
+    i?86:LynxOS:2.*:*)
+       echo i386-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    TSUNAMI:LynxOS:2.*:*)
+       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
+       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    SM[BE]S:UNIX_SV:*:*)
+       echo mips-dde-sysv${UNAME_RELEASE}
+       exit 0 ;;
+    RM*:SINIX-*:*:*)
+       echo mips-sni-sysv4
+       exit 0 ;;
+    *:SINIX-*:*:*)
+       if uname -p 2>/dev/null >/dev/null ; then
+               UNAME_MACHINE=`(uname -p) 2>/dev/null`
+               echo ${UNAME_MACHINE}-sni-sysv4
+       else
+               echo ns32k-sni-sysv
+       fi
+       exit 0 ;;
+    PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                           # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit 0 ;;
+    *:UNIX_System_V:4*:FTX*)
+       # From Gerald Hewes <hewes@openmarket.com>.
+       # How about differentiating between stratus architectures? -djm
+       echo hppa1.1-stratus-sysv4
+       exit 0 ;;
+    *:*:*:FTX*)
+       # From seanf@swdc.stratus.com.
+       echo i860-stratus-sysv4
+       exit 0 ;;
+    mc68*:A/UX:*:*)
+       echo m68k-apple-aux${UNAME_RELEASE}
+       exit 0 ;;
+    R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*)
+       if [ -d /usr/nec ]; then
+               echo mips-nec-sysv${UNAME_RELEASE}
+       else
+               echo mips-unknown-sysv${UNAME_RELEASE}
+       fi
+        exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+cat >dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+         ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+       printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+       printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+#if !defined (ultrix)
+  printf ("vax-dec-bsd\n"); exit (0);
+#else
+  printf ("vax-dec-ultrix\n"); exit (0);
+#endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
+rm -f dummy.c dummy
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+       echo c1-convex-bsd
+       exit 0 ;;
+    c2*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit 0 ;;
+    c34*)
+       echo c34-convex-bsd
+       exit 0 ;;
+    c38*)
+       echo c38-convex-bsd
+       exit 0 ;;
+    c4*)
+       echo c4-convex-bsd
+       exit 0 ;;
+    esac
+fi
+
+#echo '(Unable to guess system type)' 1>&2
+
+exit 1
diff --git a/scripts/config.sub b/scripts/config.sub
new file mode 100755 (executable)
index 0000000..fb43869
--- /dev/null
@@ -0,0 +1,1181 @@
+#! /bin/sh
+# Configuration validation subroutine script, version 1.1.
+#   Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#      CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+if [ x$1 = x ]
+then
+       echo Configuration name missing. 1>&2
+       echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
+       echo "or     $0 ALIAS" 1>&2
+       echo where ALIAS is a recognized configuration type. 1>&2
+       exit 1
+fi
+
+# First pass through any local machine types.
+case $1 in
+       *local*)
+               echo $1
+               exit 0
+               ;;
+       *)
+       ;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  linux-gnu*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+       -sun*os*)
+               # Prevent following clause from handling this invalid input.
+               ;;
+       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+       -apple)
+               os=
+               basic_machine=$1
+               ;;
+       -sim | -cisco | -oki | -wec | -winbond )        # CYGNUS LOCAL
+               os=
+               basic_machine=$1
+               ;;
+       -scout)                                         # CYGNUS LOCAL
+               ;;
+       -wrs)                                           # CYGNUS LOCAL
+               os=vxworks
+               basic_machine=$1
+               ;;
+        -hiuxmpp)
+                os=-hiuxmpp
+                ;;
+       -hiux*)
+               os=-hiuxwe2
+               ;;
+       -sco5)
+               os=sco3.2v5
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco4)
+               os=-sco3.2v4
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2.[4-9]*)
+               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2v[4-9]*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco*)
+               os=-sco3.2v2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -isc)
+               os=-isc2.2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -clix*)
+               basic_machine=clipper-intergraph
+               ;;
+       -isc*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -lynx*)
+               os=-lynxos
+               ;;
+       -ptx*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+               ;;
+       -windowsnt*)
+               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+               ;;
+       -psos*)
+               os=-psos
+               ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+       # Recognize the basic CPU types without company name.
+       # Some are omitted here because they have special meanings below.
+       tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arm \
+               | arme[lb] | pyramid | mn10300 \
+               | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
+               | alpha | we32k | ns16k | clipper | i370 | sh \
+               | powerpc | powerpcle | 1750a | dsp16xx | mips64 | mipsel \
+               | pdp11 | mips64el | mips64orion | mips64orionel \
+               | sparc | sparclet | sparclite | sparc64)
+               basic_machine=$basic_machine-unknown
+               ;;
+       m88110 | m680[01234]0 | m683?2 | m68360 | z8k | v70 | h8500 | w65) # CYGNUS LOCAL
+               basic_machine=$basic_machine-unknown
+               ;;
+       mips64vr4300 | mips64vr4300el) # CYGNUS LOCAL jsmith/vr4300
+               basic_machine=$basic_machine-unknown
+               ;;
+       mips64vr4100 | mips64vr4100el) # CYGNUS LOCAL jsmith/vr4100
+               basic_machine=$basic_machine-unknown
+               ;;
+       mips64vr5000 | mips64vr5000el) # CYGNUS LOCAL ian/vr5000
+               basic_machine=$basic_machine-unknown
+               ;;
+       mips16) # CYGNUS LOCAL krk/mips16
+               basic_machine=$basic_machine-unknown
+               ;;
+# CYGNUS LOCAL law
+       mn10200)
+               basic_machine=$basic_machine-unknown
+               ;;
+# END CYGNUS LOCAL
+       d10v)                           # CYGNUS LOCAL meissner/d10v
+               basic_machine=$basic_machine-unknown
+               ;;
+       mn10200)                        # CYGNUS LOCAL
+               basic_machine=$basic_machine-unknown
+               ;;
+       # We use `pc' rather than `unknown'
+       # because (1) that's what they normally are, and
+       # (2) the word "unknown" tends to confuse beginning users.
+       i[3456]86)
+         basic_machine=$basic_machine-pc
+         ;;
+       # Object if more than one company name word.
+       *-*-*)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+       # Recognize the basic CPU types with company name.
+       vax-* | tahoe-* | i[3456]86-* | i860-* | m32r-* | m68k-* | m68000-* \
+             | m88k-* | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \
+             | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \
+             | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
+             | hppa-* | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \
+             | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \
+             | pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \
+             | mips64el-* | mips64orion-* | mips64orionel-* | f301-*)
+               ;;
+       m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | h8500-* | d10v-*) # CYGNUS LOCAL
+               ;;
+       mips64vr4300-* | mips64vr4300el-*) # CYGNUS LOCAL jsmith/vr4300
+               ;;
+       mips64vr4100-* | mips64vr4100el-*) # CYGNUS LOCAL jsmith/vr4100
+               ;;
+       mips16-*) # CYGNUS LOCAL krk/mips16
+               ;;
+       # Recognize the various machine names and aliases which stand
+       # for a CPU type and a company and sometimes even an OS.
+       386bsd)                                         # CYGNUS LOCAL
+               basic_machine=i386-unknown
+               os=-bsd
+               ;;
+       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+               basic_machine=m68000-att
+               ;;
+       3b*)
+               basic_machine=we32k-att
+               ;;
+       a29khif)                                        # CYGNUS LOCAL
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       adobe68k)                                       # CYGNUS LOCAL
+               basic_machine=m68010-adobe
+               os=-scout
+               ;;
+       alliant | fx80)
+               basic_machine=fx80-alliant
+               ;;
+       altos | altos3068)
+               basic_machine=m68k-altos
+               ;;
+       am29k)
+               basic_machine=a29k-none
+               os=-bsd
+               ;;
+       amdahl)
+               basic_machine=580-amdahl
+               os=-sysv
+               ;;
+       amiga | amiga-*)
+               basic_machine=m68k-cbm
+               ;;
+       amigados)
+               basic_machine=m68k-cbm
+               os=-amigados
+               ;;
+       amigaunix | amix)
+               basic_machine=m68k-cbm
+               os=-sysv4
+               ;;
+       apollo68)
+               basic_machine=m68k-apollo
+               os=-sysv
+               ;;
+       apollo68bsd)                                    # CYGNUS LOCAL
+               basic_machine=m68k-apollo
+               os=-bsd
+               ;;
+       aux)
+               basic_machine=m68k-apple
+               os=-aux
+               ;;
+       balance)
+               basic_machine=ns32k-sequent
+               os=-dynix
+               ;;
+       convex-c1)
+               basic_machine=c1-convex
+               os=-bsd
+               ;;
+       convex-c2)
+               basic_machine=c2-convex
+               os=-bsd
+               ;;
+       convex-c32)
+               basic_machine=c32-convex
+               os=-bsd
+               ;;
+       convex-c34)
+               basic_machine=c34-convex
+               os=-bsd
+               ;;
+       convex-c38)
+               basic_machine=c38-convex
+               os=-bsd
+               ;;
+       cray | ymp)
+               basic_machine=ymp-cray
+               os=-unicos
+               ;;
+       cray2)
+               basic_machine=cray2-cray
+               os=-unicos
+               ;;
+       [ctj]90-cray)
+               basic_machine=c90-cray
+               os=-unicos
+               ;;
+       crds | unos)
+               basic_machine=m68k-crds
+               ;;
+       da30 | da30-*)
+               basic_machine=m68k-da30
+               ;;
+       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+               basic_machine=mips-dec
+               ;;
+       delta | 3300 | motorola-3300 | motorola-delta \
+             | 3300-motorola | delta-motorola)
+               basic_machine=m68k-motorola
+               ;;
+       delta88)
+               basic_machine=m88k-motorola
+               os=-sysv3
+               ;;
+       dpx20 | dpx20-*)
+               basic_machine=rs6000-bull
+               os=-bosx
+               ;;
+       dpx2* | dpx2*-bull)
+               basic_machine=m68k-bull
+               os=-sysv3
+               ;;
+       ebmon29k)
+               basic_machine=a29k-amd
+               os=-ebmon
+               ;;
+       elxsi)
+               basic_machine=elxsi-elxsi
+               os=-bsd
+               ;;
+       encore | umax | mmax)
+               basic_machine=ns32k-encore
+               ;;
+       es1800 | OSE68k | ose68k | ose | OSE)           # CYGNUS LOCAL
+               basic_machine=m68k-ericsson
+               os=-ose
+               ;;
+       fx2800)
+               basic_machine=i860-alliant
+               ;;
+       genix)
+               basic_machine=ns32k-ns
+               ;;
+       gmicro)
+               basic_machine=tron-gmicro
+               os=-sysv
+               ;;
+        hiuxmpp)
+                basic_machine=hppa1.1-hitachi
+                os=-hiuxmpp
+                ;;
+       h3050r* | hiux*)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       h8300hms)
+               basic_machine=h8300-hitachi
+               os=-hms
+               ;;
+       h8300xray)                                      # CYGNUS LOCAL
+               basic_machine=h8300-hitachi
+               os=-xray
+               ;;
+       h8500hms)                                       # CYGNUS LOCAL
+               basic_machine=h8500-hitachi
+               os=-hms
+               ;;
+       harris)
+               basic_machine=m88k-harris
+               os=-sysv3
+               ;;
+       hp300-*)
+               basic_machine=m68k-hp
+               ;;
+       hp300bsd)
+               basic_machine=m68k-hp
+               os=-bsd
+               ;;
+       hp300hpux)
+               basic_machine=m68k-hp
+               os=-hpux
+               ;;
+        w89k-*)                                                # CYGNUS LOCAL
+                basic_machine=hppa1.1-winbond
+                os=-proelf
+                ;;
+        op50n-*)                                       # CYGNUS LOCAL
+                basic_machine=hppa1.1-oki
+                os=-proelf
+                ;;
+        op60c-*)                                       # CYGNUS LOCAL
+                basic_machine=hppa1.1-oki
+                os=-proelf
+                ;;
+        hppro)                                         # CYGNUS LOCAL
+                basic_machine=hppa1.1-hp
+                os=-proelf
+                ;;
+       hp9k2[0-9][0-9] | hp9k31[0-9])
+               basic_machine=m68000-hp
+               ;;
+       hp9k3[2-9][0-9])
+               basic_machine=m68k-hp
+               ;;
+       hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][0-9] | hp8[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hppa-next)
+               os=-nextstep3
+               ;;
+       hppaosf)                                        # CYGNUS LOCAL
+               basic_machine=hppa1.1-hp
+               os=-osf
+               ;;
+       i370-ibm* | ibm*)
+               basic_machine=i370-ibm
+               os=-mvs
+               ;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+       i[3456]86v32)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv32
+               ;;
+       i[3456]86v4*)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv4
+               ;;
+       i[3456]86v)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv
+               ;;
+       i[3456]86sol2)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-solaris2
+               ;;
+       i386mach)                                       # CYGNUS LOCAL
+               basic_machine=i386-mach
+               os=-mach
+               ;;
+       i386-vsta | vsta)                               # CYGNUS LOCAL
+               basic_machine=i386-unknown
+               os=-vsta
+               ;;
+       i386-go32 | go32)                               # CYGNUS LOCAL
+               basic_machine=i386-unknown
+               os=-go32
+               ;;
+       iris | iris4d)
+               basic_machine=mips-sgi
+               case $os in
+                   -irix*)
+                       ;;
+                   *)
+                       os=-irix4
+                       ;;
+               esac
+               ;;
+       isi68 | isi)
+               basic_machine=m68k-isi
+               os=-sysv
+               ;;
+       m88k-omron*)
+               basic_machine=m88k-omron
+               ;;
+       magnum | m3230)
+               basic_machine=mips-mips
+               os=-sysv
+               ;;
+       merlin)
+               basic_machine=ns32k-utek
+               os=-sysv
+               ;;
+       miniframe)
+               basic_machine=m68000-convergent
+               ;;
+       mipsel*-linux*)
+               basic_machine=mipsel-unknown
+               os=-linux
+               ;;
+       mips*-linux*)
+               basic_machine=mips-unknown
+               os=-linux
+               ;;
+       mips3*-*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               ;;
+       mips3*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+               ;;
+       monitor)                                        # CYGNUS LOCAL
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       msdos)                                          # CYGNUS LOCAL
+               basic_machine=i386-unknown      
+               os=-msdos
+               ;;
+       ncr3000)
+               basic_machine=i486-ncr
+               os=-sysv4
+               ;;
+       netbsd386)
+               basic_machine=i386-unknown              # CYGNUS LOCAL
+               os=-netbsd
+               ;;
+       news | news700 | news800 | news900)
+               basic_machine=m68k-sony
+               os=-newsos
+               ;;
+       news1000)
+               basic_machine=m68030-sony
+               os=-newsos
+               ;;
+       news-3600 | risc-news)
+               basic_machine=mips-sony
+               os=-newsos
+               ;;
+       necv70)                                         # CYGNUS LOCAL
+               basic_machine=v70-nec
+               os=-sysv
+               ;;
+       next | m*-next )
+               basic_machine=m68k-next
+               case $os in
+                   -nextstep* )
+                       ;;
+                   -ns2*)
+                     os=-nextstep2
+                       ;;
+                   *)
+                     os=-nextstep3
+                       ;;
+               esac
+               ;;
+       nh3000)
+               basic_machine=m68k-harris
+               os=-cxux
+               ;;
+       nh[45]000)
+               basic_machine=m88k-harris
+               os=-cxux
+               ;;
+       nindy960)
+               basic_machine=i960-intel
+               os=-nindy
+               ;;
+       mon960)                                         # CYGNUS LOCAL
+               basic_machine=i960-intel
+               os=-mon960
+               ;;
+       np1)
+               basic_machine=np1-gould
+               ;;
+       OSE68000 | ose68000)                            # CYGNUS LOCAL
+               basic_machine=m68000-ericsson
+               os=-ose
+               ;;
+       os68k)                                          # CYGNUS LOCAL
+               basic_machine=m68k-none
+               os=-os68k
+               ;;
+       pa-hitachi)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       paragon)
+               basic_machine=i860-intel
+               os=-osf
+               ;;
+       pbd)
+               basic_machine=sparc-tti
+               ;;
+       pbb)
+               basic_machine=m68k-tti
+               ;;
+        pc532 | pc532-*)
+               basic_machine=ns32k-pc532
+               ;;
+       pentium | p5)
+               basic_machine=i586-intel
+               ;;
+       pentiumpro | p6)
+               basic_machine=i686-intel
+               ;;
+       pentium-* | p5-*)
+               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumpro-* | p6-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       k5)
+               # We don't have specific support for AMD's K5 yet, so just call it a Pentium
+               basic_machine=i586-amd
+               ;;
+       nexen)
+               # We don't have specific support for Nexgen yet, so just call it a Pentium
+               basic_machine=i586-nexgen
+               ;;
+       pn)
+               basic_machine=pn-gould
+               ;;
+       power)  basic_machine=rs6000-ibm
+               ;;
+       ppc)    basic_machine=powerpc-unknown
+               ;;
+       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppcle | powerpclittle | ppc-le | powerpc-little)
+               basic_machine=powerpcle-unknown
+               ;;
+       ppcle-* | powerpclittle-*)
+               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ps2)
+               basic_machine=i386-ibm
+               ;;
+       rom68k)                                         # CYGNUS LOCAL
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       rm[46]00)
+               basic_machine=mips-siemens
+               ;;
+       rtpc | rtpc-*)
+               basic_machine=romp-ibm
+               ;;
+       sa29200)                                        # CYGNUS LOCAL
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       sequent)
+               basic_machine=i386-sequent
+               ;;
+       sh)
+               basic_machine=sh-hitachi
+               os=-hms
+               ;;
+       sparclite-wrs)                                  # CYGNUS LOCAL
+               basic_machine=sparclite-wrs
+               os=-vxworks
+               ;;
+       sps7)
+               basic_machine=m68k-bull
+               os=-sysv2
+               ;;
+       spur)
+               basic_machine=spur-unknown
+               ;;
+       st2000)                                         # CYGNUS LOCAL
+               basic_machine=m68k-tandem
+               ;;
+       stratus)                                        # CYGNUS LOCAL
+               basic_machine=i860-stratus
+               os=-sysv4
+               ;;
+       sun2)
+               basic_machine=m68000-sun
+               ;;
+       sun2os3)
+               basic_machine=m68000-sun
+               os=-sunos3
+               ;;
+       sun2os4)
+               basic_machine=m68000-sun
+               os=-sunos4
+               ;;
+       sun3os3)
+               basic_machine=m68k-sun
+               os=-sunos3
+               ;;
+       sun3os4)
+               basic_machine=m68k-sun
+               os=-sunos4
+               ;;
+       sun4os3)
+               basic_machine=sparc-sun
+               os=-sunos3
+               ;;
+       sun4os4)
+               basic_machine=sparc-sun
+               os=-sunos4
+               ;;
+       sun4sol2)
+               basic_machine=sparc-sun
+               os=-solaris2
+               ;;
+       sun3 | sun3-*)
+               basic_machine=m68k-sun
+               ;;
+       sun4)
+               basic_machine=sparc-sun
+               ;;
+       sun386 | sun386i | roadrunner)
+               basic_machine=i386-sun
+               ;;
+       symmetry)
+               basic_machine=i386-sequent
+               os=-dynix
+               ;;
+       tower | tower-32)
+               basic_machine=m68k-ncr
+               ;;
+       udi29k)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       ultra3)
+               basic_machine=a29k-nyu
+               os=-sym1
+               ;;
+       v810 | necv810)                                 # CYGNUS LOCAL
+               basic_machine=v810-nec
+               os=-none
+               ;;
+       vaxv)
+               basic_machine=vax-dec
+               os=-sysv
+               ;;
+       vms)
+               basic_machine=vax-dec
+               os=-vms
+               ;;
+       vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+       vxworks960)
+               basic_machine=i960-wrs
+               os=-vxworks
+               ;;
+       vxworks68)
+               basic_machine=m68k-wrs
+               os=-vxworks
+               ;;
+       vxworks29k)
+               basic_machine=a29k-wrs
+               os=-vxworks
+               ;;
+       w65*)                                           # CYGNUS LOCAL
+               basic_machine=w65-wdc
+               os=-none
+               ;;
+       xmp)
+               basic_machine=xmp-cray
+               os=-unicos
+               ;;
+        xps | xps100)
+               basic_machine=xps100-honeywell
+               ;;
+       z8k-*-coff)                                     # CYGNUS LOCAL
+               basic_machine=z8k-unknown
+               os=-sim
+               ;;
+       none)
+               basic_machine=none-none
+               os=-none
+               ;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+       w89k)                                           # CYGNUS LOCAL
+               basic_machine=hppa1.1-winbond
+               ;;
+       op50n)                                          # CYGNUS LOCAL
+               basic_machine=hppa1.1-oki
+               ;;
+       op60c)                                          # CYGNUS LOCAL
+               basic_machine=hppa1.1-oki
+               ;;
+       mips)
+               if [ x$os = x-linux ]; then
+                       basic_machine=mips-unknown
+               else
+                       basic_machine=mips-mips
+               fi
+               ;;
+       romp)
+               basic_machine=romp-ibm
+               ;;
+       rs6000)
+               basic_machine=rs6000-ibm
+               ;;
+       vax)
+               basic_machine=vax-dec
+               ;;
+       pdp11)
+               basic_machine=pdp11-dec
+               ;;
+       we32k)
+               basic_machine=we32k-att
+               ;;
+       sparc)
+               basic_machine=sparc-sun
+               ;;
+        cydra)
+               basic_machine=cydra-cydrome
+               ;;
+       orion)
+               basic_machine=orion-highlevel
+               ;;
+       orion105)
+               basic_machine=clipper-highlevel
+               ;;
+       mac | mpw | mac-mpw)                            # CYGNUS LOCAL
+               basic_machine=m68k-apple
+               ;;
+       pmac | pmac-mpw)                                # CYGNUS LOCAL
+               basic_machine=powerpc-apple
+               ;;
+       *)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+       *-digital*)
+               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               ;;
+       *-commodore*)
+               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               ;;
+       *)
+               ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+       # -solaris* is a basic system type, with this one exception.
+       -solaris1 | -solaris1.*)
+               os=`echo $os | sed -e 's|solaris1|sunos4|'`
+               ;;
+       -solaris)
+               os=-solaris2
+               ;;
+       -unixware* | svr4*)
+               os=-sysv4
+               ;;
+       -gnu/linux*)
+               os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+               ;;
+       # First accept the basic system types.
+       # The portable systems comes first.
+       # Each alternative MUST END IN A *, to match a version number.
+       # -sysv* is not here because it comes later, after sysvr4.
+       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+             | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+             | -amigados* | -msdos* | -newsos* | -unicos* | -aof* | -aos* \
+             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+             | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+             | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
+             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+             | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+               | -linux-gnu* | -uxpv* | -mingw32* )
+       # Remember, each alternative MUST END IN *, to match a version number.
+               ;;
+       # CYGNUS LOCAL
+       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+             | -windows* | -osx | -abug |  -netware* | -os9* | -beos* \
+             | -macos* | -mpw* | -magic* | -mon960* | -lnews* )
+               ;;
+       -mac*)
+               os=`echo $os | sed -e 's|mac|macos|'`
+               ;;
+       # END CYGNUS LOCAL
+       -linux*)
+               os=`echo $os | sed -e 's|linux|linux-gnu|'`
+               ;;
+       -sunos5*)
+               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+               ;;
+       -sunos6*)
+               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+               ;;
+       -osfrose*)
+               os=-osfrose
+               ;;
+       -osf*)
+               os=-osf
+               ;;
+       -utek*)
+               os=-bsd
+               ;;
+       -dynix*)
+               os=-bsd
+               ;;
+       -acis*)
+               os=-aos
+               ;;
+       -386bsd)                                        # CYGNUS LOCAL
+               os=-bsd
+               ;;
+       -ctix* | -uts*)
+               os=-sysv
+               ;;
+       -ns2 )
+               os=-nextstep2
+               ;;
+       # Preserve the version number of sinix5.
+       -sinix5.*)
+               os=`echo $os | sed -e 's|sinix|sysv|'`
+               ;;
+       -sinix*)
+               os=-sysv4
+               ;;
+       -triton*)
+               os=-sysv3
+               ;;
+       -oss*)
+               os=-sysv3
+               ;;
+       -svr4)
+               os=-sysv4
+               ;;
+       -svr3)
+               os=-sysv3
+               ;;
+       -sysvr4)
+               os=-sysv4
+               ;;
+       # This must come after -sysvr4.
+       -sysv*)
+               ;;
+       -ose*)                                          # CYGNUS LOCAL
+               os=-ose
+               ;;
+       -es1800*)                                       # CYGNUS LOCAL
+               os=-ose
+               ;;
+       -xenix)
+               os=-xenix
+               ;;
+       -none)
+               ;;
+       *)
+               # Get rid of the `-' at the beginning of $os.
+               os=`echo $os | sed 's/[^-]*-//'`
+               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+       *-acorn)
+               os=-riscix1.2
+               ;;
+       arm*-semi)
+               os=-aout
+               ;;
+        pdp11-*)
+               os=-none
+               ;;
+       *-dec | vax-*)
+               os=-ultrix4.2
+               ;;
+       m68*-apollo)
+               os=-domain
+               ;;
+       i386-sun)
+               os=-sunos4.0.2
+               ;;
+       m68000-sun)
+               os=-sunos3
+               # This also exists in the configure program, but was not the
+               # default.
+               # os=-sunos4
+               ;;
+       m68*-cisco)                                     # CYGNUS LOCAL
+               os=-aout
+               ;;
+       mips*-cisco)                                    # CYGNUS LOCAL
+               os=-elf
+               ;;
+        mips*-*)                                        # CYGNUS LOCAL
+                os=-elf
+                ;;
+       *-tti)  # must be before sparc entry or we get the wrong os.
+               os=-sysv3
+               ;;
+       sparc-* | *-sun)
+               os=-sunos4.1.1
+               ;;
+       *-be)                                           # CYGNUS LOCAL
+               os=-beos
+               ;;
+       *-ibm)
+               os=-aix
+               ;;
+       *-wec)                                          # CYGNUS LOCAL
+               os=-proelf
+               ;;
+       *-winbond)                                      # CYGNUS LOCAL
+               os=-proelf
+               ;;
+       *-oki)                                          # CYGNUS LOCAL
+               os=-proelf
+               ;;
+       *-hp)
+               os=-hpux
+               ;;
+       *-hitachi)
+               os=-hiux
+               ;;
+       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+               os=-sysv
+               ;;
+       *-cbm)
+               os=-amigados
+               ;;
+       *-dg)
+               os=-dgux
+               ;;
+       *-dolphin)
+               os=-sysv3
+               ;;
+       m68k-ccur)
+               os=-rtu
+               ;;
+       m88k-omron*)
+               os=-luna
+               ;;
+       *-next )
+               os=-nextstep
+               ;;
+       *-sequent)
+               os=-ptx
+               ;;
+       *-crds)
+               os=-unos
+               ;;
+       *-ns)
+               os=-genix
+               ;;
+       i370-*)
+               os=-mvs
+               ;;
+       *-next)
+               os=-nextstep3
+               ;;
+        *-gould)
+               os=-sysv
+               ;;
+        *-highlevel)
+               os=-bsd
+               ;;
+       *-encore)
+               os=-bsd
+               ;;
+        *-sgi)
+               os=-irix
+               ;;
+        *-siemens)
+               os=-sysv4
+               ;;
+       *-masscomp)
+               os=-rtu
+               ;;
+       f301-fujitsu)
+               os=-uxpv
+               ;;
+       *-rom68k)                                       # CYGNUS LOCAL
+               os=-coff
+               ;;
+       *-*bug)                                         # CYGNUS LOCAL
+               os=-coff
+               ;;
+       *-apple)                                        # CYGNUS LOCAL
+               os=-macos
+               ;;
+       *)
+               os=-none
+               ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+       *-unknown)
+               case $os in
+                       -riscix*)
+                               vendor=acorn
+                               ;;
+                       -sunos*)
+                               vendor=sun
+                               ;;
+                       -aix*)
+                               vendor=ibm
+                               ;;
+                       -beos*)                                         # CYGNUS LOCAL
+                               vendor=be
+                               ;;
+                       -hpux*)
+                               vendor=hp
+                               ;;
+                       -hiux*)
+                               vendor=hitachi
+                               ;;
+                       -unos*)
+                               vendor=crds
+                               ;;
+                       -dgux*)
+                               vendor=dg
+                               ;;
+                       -luna*)
+                               vendor=omron
+                               ;;
+                       -genix*)
+                               vendor=ns
+                               ;;
+                       -mvs*)
+                               vendor=ibm
+                               ;;
+                       -ptx*)
+                               vendor=sequent
+                               ;;
+                       -vxsim* | -vxworks*)
+                               vendor=wrs
+                               ;;
+                       -aux*)
+                               vendor=apple
+                               ;;
+                       -hms*)                          # CYGNUS LOCAL
+                               vendor=hitachi
+                               ;;
+                       -mpw* | -macos*)                # CYGNUS LOCAL
+                               vendor=apple
+                               ;;
+               esac
+               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               ;;
+esac
+
+echo $basic_machine$os
index 89e6b26..2f733eb 100644 (file)
@@ -349,7 +349,10 @@ show_help( ARGPARSE_OPTS *opts, unsigned flags )
 {
     const char *s;
 
-    puts( strusage(10) );
+    s = strusage(10);
+    fputs( s, stdout );
+    if( *s && s[strlen(s)-1] != '\n' )
+       putchar( '\n' );
     s = strusage(12);
     if( *s == '\n' )
        s++;
@@ -366,6 +369,9 @@ show_help( ARGPARSE_OPTS *opts, unsigned flags )
        indent += 10;
        puts("Options:");
        for(i=0; opts[i].short_opt; i++ ) {
+           s = opts[i].description;
+           if( s && *s== '\r' ) /* hide this line */
+               continue;
            if( opts[i].short_opt < 256 )
                printf(" -%c", opts[i].short_opt );
            else
@@ -376,7 +382,7 @@ show_help( ARGPARSE_OPTS *opts, unsigned flags )
                                          opts[i].long_opt );
            for(;j < indent; j++ )
                putchar(' ');
-           if( (s = opts[i].description) ) {
+           if( s ) {
                for(; *s; s++ ) {
                    if( *s == '\n' ) {
                        if( s[1] ) {
@@ -398,6 +404,10 @@ show_help( ARGPARSE_OPTS *opts, unsigned flags )
        putchar('\n');
        fputs(s, stdout);
     }
+    if( *(s=strusage(30)) ) {  /* special notes */
+       putchar('\n');
+       fputs(s, stdout);
+    }
     fflush(stdout);
     exit(0);
 }
@@ -497,7 +507,7 @@ default_strusage( int level )
    "it under the terms of the GNU General Public License as published by\n"
    "the Free Software Foundation; either version 2 of the License, or\n"
    "(at your option) any later version.\n\n"
-   "WkLib is distributed in the hope that it will be useful,\n"
+   "It is distributed in the hope that it will be useful,\n"
    "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
    "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
    "GNU General Public License for more details.\n\n"
@@ -537,6 +547,7 @@ default_strusage( int level )
            p = "UnknownOS";
          #endif
            break;
+      case 30: p = ""; break;
       case 31: p =
     "This program comes with ABSOLUTELY NO WARRANTY.\n"
     "This is free software, and you are welcome to redistribute it\n"
index 6ad57f9..683f042 100644 (file)
@@ -63,10 +63,10 @@ const void membug( const char *fmt, ... );
   #define FNAME(a)  m_ ##a
   #define FNAMEPRT
   #define FNAMEARG
-  #define store_len(p,n,m) do { ((byte*))p[0] = n;                 \
-                               ((byte*))p[2] = n >> 8 ;            \
-                               ((byte*))p[3] = n >> 16 ;           \
-                               ((byte*))p[4] = m? MAGIC_SEC_BYTE   \
+  #define store_len(p,n,m) do { ((byte*)p)[0] = n;                 \
+                               ((byte*)p)[1] = n >> 8 ;            \
+                               ((byte*)p)[2] = n >> 16 ;           \
+                               ((byte*)p)[3] = m? MAGIC_SEC_BYTE   \
                                                 : MAGIC_NOR_BYTE;  \
                              } while(0)
 #endif
@@ -213,8 +213,6 @@ check_mem( const byte *p, const char *info )
        membug("memory at %p corrupted: underflow=%02x (%s)\n", p+4, p[3], info );
     if( p[4+e->user_n] != MAGIC_END_BYTE )
        membug("memory at %p corrupted: overflow=%02x (%s)\n", p+4, p[4+e->user_n], info );
-    if( e->info->count > 20000 )
-       membug("memory at %p corrupted: count too high (%s)\n", p+4, info );
     return e;
 }
 
@@ -444,9 +442,9 @@ m_size( const void *a )
   #ifdef M_DEBUG
     n = check_mem(p-4, "m_size")->user_n;
   #else
-    n  = ((byte*)p[-4];
-    n |= ((byte*)p[-3] << 8;
-    n |= ((byte*)p[-2] << 16;
+    n  = ((byte*)p)[-4];
+    n |= ((byte*)p)[-3] << 8;
+    n |= ((byte*)p)[-2] << 16;
   #endif
     return n;
 }