diff -uNr pnet.orig/configure.in pnet/configure.in --- pnet.orig/configure.in 2004-01-14 21:02:29.000000000 -0600 +++ pnet/configure.in 2004-01-16 18:49:46.000000000 -0600 @@ -397,7 +397,7 @@ dnl Checks for library functions. AC_FUNC_MEMCMP -AC_CHECK_FUNCS(memset memcmp memchr memcpy memmove bcopy bzero bcmp) +AC_CHECK_FUNCS(memset memcmp memchr memcpy memmove bcopy bzero bcmp strtok) AC_CHECK_FUNCS(isnan isinf finite fmod strtod mmap munmap getpagesize) AC_CHECK_FUNCS(stat lstat vfprintf waitpid wait fork execv open gettimeofday) AC_CHECK_FUNCS(getpid qsort unlink remove getcwd getwd) @@ -488,6 +488,7 @@ cscc/vb/Makefile cscc/java/Makefile cscc/bf/Makefile +cscc/packages/Makefile resgen/Makefile ilstrip/Makefile ilranlib/Makefile diff -uNr pnet.orig/cscc/common/cc_options.c pnet/cscc/common/cc_options.c --- pnet.orig/cscc/common/cc_options.c 2003-11-10 05:25:58.000000000 -0600 +++ pnet/cscc/common/cc_options.c 2004-01-16 19:56:31.000000000 -0600 @@ -96,6 +96,9 @@ char **imacros_files = 0; int num_imacros_files = 0; +/* stored by CCParseCommandLine for pkgOption */ +char *package_dir = 0; + /* * Add a string to a list of strings. */ @@ -307,18 +310,120 @@ AddString(&libraries, &num_libraries, arg); } +#define PKG_READ_BLOCK_SIZE 4096 +/* + * Process a -pkg option. + * Currently, only -l options are supported. To effectively support + * other options, the option parser must be callable recursively, and + * a better (and portable) reentrant word splitter (e.g. wordexp) must + * be used. + */ +static void pkgOption(char *arg) +{ + char *pkgfile_name; +#ifdef HAVE_STAT + struct stat pkgfile_info; +#endif + FILE *pkgfile; + char *pkgfile_contents; + size_t bufsize; + size_t bufread = 0; +#ifdef HAVE_STRTOK + char *nextoption; +#endif + + /* build the package file name */ + if (!(pkgfile_name = ILExpandFilename(arg, package_dir))) + CCOutOfMemory(); + +#ifdef HAVE_STAT + /* get the file's size, allocate contents accordingly */ + if (stat(pkgfile_name, &pkgfile_info) + || pkgfile_info.st_size <= 0) /* error? */ + { + pkgfile_info.st_size = 0; + pkgfile_contents = ILMalloc(PKG_READ_BLOCK_SIZE + 1); + bufsize = PKG_READ_BLOCK_SIZE + 1; + } + else + { + pkgfile_contents = ILMalloc(pkgfile_info.st_size + 1); + bufsize = pkgfile_info.st_size + 1; + } +#else /* !defined(HAVE_STAT) */ + pkgfile_contents = ILMalloc(PKG_READ_BLOCK_SIZE + 1); + bufsize = PKG_READ_BLOCK_SIZE + 1; +#endif + if (!pkgfile_contents) + CCOutOfMemory(); + + if (!(pkgfile = fopen(pkgfile_name, "r"))) + { + fprintf(stderr, _("%s: Package `%s' unavailable\n"), progname, arg); + exit(1); + } + ILFree(pkgfile_name); + +#ifdef HAVE_STAT + if (pkgfile_info.st_size) + { + bufread = fread(pkgfile_contents, 1, pkgfile_info.st_size, pkgfile); + pkgfile_contents[bufread] = 0; /* null-terminate */ + if (ferror(pkgfile)) + { + fprintf(stderr, _("%s: Package `%s' unavailable\n"), progname, arg); + exit(1); + } + } else /* short-circuit the reader loop below */ +#endif /* defined(HAVE_STAT) */ + while (!feof(pkgfile)) + { + /* bufsize-bufread-1 should be 0 on every loop after the first. */ + if (bufsize - bufread - 1 < PKG_READ_BLOCK_SIZE) + { + pkgfile_contents = + ILRealloc(pkgfile_contents, bufread + PKG_READ_BLOCK_SIZE + 1); + if (!pkgfile_contents) + CCOutOfMemory(); + bufsize = bufread + PKG_READ_BLOCK_SIZE + 1; + } + bufread += fread(pkgfile_contents + bufread, 1, + PKG_READ_BLOCK_SIZE, pkgfile); + pkgfile_contents[bufread] = 0; + if (ferror(pkgfile)) + { + fprintf(stderr, _("%s: Package `%s' unavailable\n"), progname, arg); + exit(1); + } + } + fclose(pkgfile); + +#ifdef HAVE_STRTOK + nextoption = strtok(pkgfile_contents, " \r\n\t\v"); + while (nextoption) + { + if (nextoption[0] == '-' && nextoption[1] == 'l') + lOption(nextoption + 2); + else + { + fprintf(stderr, _("%s: -pkg%s: Options other than -l unsupported\n"), progname, arg); + exit(1); + } + nextoption = strtok(0, " \r\n\t\v"); + } +#else /* !defined(HAVE_STRTOK) */ + fprintf(stderr, _("Unused contents of package %s: %s\n"), + arg, pkgfile_contents); +#endif + ILFree(pkgfile_contents); +} + /* * Process a -gtk option. */ static void gtkOption(char *arg) { - lOption("gtk-sharp"); - lOption("gdk-sharp"); - lOption("atk-sharp"); - lOption("pango-sharp"); - lOption("glib-sharp"); - lOption("System.Drawing"); - lOption("System"); + pkgOption("gtk"); } /* @@ -326,8 +431,7 @@ */ static void gnomeOption(char *arg) { - lOption("gnome-sharp"); - gtkOption(arg); + pkgOption("gnome"); } /* @@ -335,9 +439,7 @@ */ static void winformsOption(char *arg) { - lOption("System"); - lOption("System.Drawing"); - lOption("System.Windows.Forms"); + pkgOption("winforms"); } /* @@ -503,6 +605,8 @@ N_("-L