Index: cpp/_nlist.c =================================================================== RCS file: /cvs/tools/soltools/cpp/_nlist.c,v retrieving revision 1.3 retrieving revision 1.3.16.1 diff -u -r1.3 -r1.3.16.1 --- cpp/_nlist.c 20 Jun 2006 05:06:54 -0000 1.3 +++ cpp/_nlist.c 19 Sep 2006 20:57:49 -0000 1.3.16.1 @@ -1,9 +1,9 @@ #include #include #include +#include #include "cpp.h" -extern int getopt(int, char *const *, const char *); extern char *optarg; extern int optind; extern int Cplusplus; Index: cpp/_unix.c =================================================================== RCS file: /cvs/tools/soltools/cpp/_unix.c,v retrieving revision 1.4 retrieving revision 1.4.16.1 diff -u -r1.4 -r1.4.16.1 --- cpp/_unix.c 20 Jun 2006 05:07:17 -0000 1.4 +++ cpp/_unix.c 19 Sep 2006 20:57:49 -0000 1.4.16.1 @@ -9,10 +9,10 @@ #else #include #endif +#include #include "cpp.h" -extern int getopt(int, char *const *, const char *); extern char *optarg, rcsid[]; extern int optind; Index: cpp/makefile.mk =================================================================== RCS file: /cvs/tools/soltools/cpp/makefile.mk,v retrieving revision 1.9 retrieving revision 1.9.34.1 diff -u -r1.9 -r1.9.34.1 --- cpp/makefile.mk 8 Sep 2005 07:23:35 -0000 1.9 +++ cpp/makefile.mk 19 Sep 2006 20:57:49 -0000 1.9.34.1 @@ -54,7 +54,6 @@ OBJFILES= \ $(OBJ)$/_cpp.obj \ $(OBJ)$/_eval.obj \ - $(OBJ)$/_getopt.obj \ $(OBJ)$/_include.obj \ $(OBJ)$/_lex.obj \ $(OBJ)$/_macro.obj \ @@ -62,6 +61,16 @@ $(OBJ)$/_nlist.obj \ $(OBJ)$/_tokens.obj \ $(OBJ)$/_unix.obj + +.IF "$(HAVE_GETOPT)"!="YES" +.IF "$(OS)" == "WNT" +APP1STDLIBS+= gnu_getopt.lib +.ELSE +APP1STDLIBS+= -lgnu_getopt +.ENDIF +.ELSE +CDEFS+= -DHAVE_GETOPT +.ENDIF APP1TARGET = $(TARGET) APP1STACK = 1000000 Index: javadep/javadep.c =================================================================== RCS file: /cvs/tools/soltools/javadep/javadep.c,v retrieving revision 1.8 retrieving revision 1.8.16.1 diff -u -r1.8 -r1.8.16.1 --- javadep/javadep.c 20 Jun 2006 05:08:14 -0000 1.8 +++ javadep/javadep.c 19 Sep 2006 20:57:49 -0000 1.8.16.1 @@ -62,6 +62,8 @@ #define ntohs(x) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)) #endif +#include + /* max. length of line in response file */ #define RES_FILE_BUF 65536 @@ -144,13 +146,6 @@ void err_quit(const char *, ...); void silent_quit(void); -/* poor man's getopt() */ -int simple_getopt(char *pargv[], const char *poptstring); -char *optarg = NULL; -int optind = 1; -int optopt = 0; -int opterr = 0; - uint8 read_uint8(const file_t *pfile) { @@ -774,45 +769,6 @@ pprogname); } -/* my very simple minded implementation of getopt() - * it's to sad that getopt() is not available everywhere - * note: this is not a full POSIX conforming getopt() - */ -int simple_getopt(char *pargv[], const char *poptstring) -{ - char *parg = pargv[optind]; - - /* skip all response file arguments */ - if ( parg ) { - while ( *parg == '@' ) - parg = pargv[++optind]; - - if ( parg[0] == '-' && parg[1] != '\0' ) { - char *popt; - int c = parg[1]; - if ( (popt = strchr(poptstring, c)) == NULL ) { - optopt = c; - if ( opterr ) - fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt); - return '?'; - } - if ( *(++popt) == ':') { - if ( parg[2] != '\0' ) { - optarg = ++parg; - } else { - optarg = pargv[++optind]; - } - } else { - optarg = NULL; - } - ++optind; - return c; - } - } - return -1; -} - - int CDECL main(int argc, char *argv[]) { @@ -860,7 +816,7 @@ opterr = 0; pincs = allocate_growable(); - while( (c = simple_getopt(pall_argv, ":i:I:s:S:o:OhHvV")) != -1 ) { + while( (c = getopt(nall_argc, pall_argv, ":i:I:s:S:o:OhHvV")) != -1 ) { switch(c) { case 'i': case 'I': Index: javadep/makefile.mk =================================================================== RCS file: /cvs/tools/soltools/javadep/makefile.mk,v retrieving revision 1.7 retrieving revision 1.7.34.1 diff -u -r1.7 -r1.7.34.1 --- javadep/makefile.mk 8 Sep 2005 07:27:39 -0000 1.7 +++ javadep/makefile.mk 19 Sep 2006 20:57:49 -0000 1.7.34.1 @@ -49,6 +49,16 @@ UWINAPILIB=$(0) LIBSALCPPRT=$(0) +.IF "$(HAVE_GETOPT)"=="YES" +CDEFS+=-DHAVE_GETOPT +.ELSE +.IF "$(OS)" == "WNT" +APP1STDLIBS+= gnu_getopt.lib +.ELSE +APP1STDLIBS+=-lgnu_getopt +.ENDIF +.ENDIF + # --- Files -------------------------------------------------------- APP1TARGET = javadep