Hi,

attached patch adds the getopt tool to crossgcc. In case it doesn't
exist in the system (eg. mingw), it's compiled and added to the path.

The getopt implementation is taken from dragonflybsd, thus cleanly
sublicensable to GPL, given that it's 3-clause BSD licensed.
Besides, it's never linked to any other code in our tree.

I wouldn't mind to have some GNU implementation, but I just didn't find
one in my short search.


Signed-off-by: Patrick Georgi <patrick.geo...@coresystems.de>
Property changes on: util\crossgcc
___________________________________________________________________
Added: svn:ignore
   + getopt
getopt.exe
tarballs
xgcc


Index: util/crossgcc/getopt.c
===================================================================
--- util/crossgcc/getopt.c      (revision 0)
+++ util/crossgcc/getopt.c      (revision 0)
@@ -0,0 +1,32 @@
+/* $FreeBSD: src/usr.bin/getopt/getopt.c,v 1.4.2.2 2001/07/30 10:16:38 dd Exp 
$ */
+/* $DragonFly: src/usr.bin/getopt/getopt.c,v 1.4 2004/10/23 13:33:36 eirikn 
Exp $ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+main(int argc, char **argv)
+{
+       int c;
+       int status = 0;
+
+       optind = 2;     /* Past the program name and the option letters. */
+       while ((c = getopt(argc, argv, argv[1])) != -1)
+               switch (c) {
+               case '?':
+                       status = 1;     /* getopt routine gave message */
+                       break;
+               default:
+                       if (optarg != NULL)
+                               printf(" -%c %s", c, optarg);
+                       else
+                               printf(" -%c", c);
+                       break;
+               }
+       printf(" --");
+       for (; optind < argc; optind++)
+               printf(" %s", argv[optind]);
+       printf("\n");
+       return(status);
+}
Index: util/crossgcc/buildgcc
===================================================================
--- util/crossgcc/buildgcc      (revision 5060)
+++ util/crossgcc/buildgcc      (working copy)
@@ -132,6 +132,10 @@
 
 printf "${blue}Welcome to the ${red}coresystems${blue} cross toolchain builder 
v$CROSSGCC_VERSION ($CROSSGCC_DATE)${NC}\n\n"
 
+# Look if we have getopt. If not, build it.
+export PATH=$PATH:.
+getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c
+
 # parse parameters.. try to find out whether we're running GNU getopt
 getoptbrand="`getopt -V`"
 if [ "${getoptbrand:0:6}" == "getopt" ]; then
@@ -205,7 +209,7 @@
                for patch in patches/${!dir}_*.patch; do
                        test -r $patch || continue
                        printf "   o `basename $patch`\n"
-                       patch -s -N -p0 < `echo $patch`
+                       $PATCH -s -N -p0 < `echo $patch`
                done
        )
 done
-- 
coreboot mailing list: coreboot@coreboot.org
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to