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"), N_("Add to the library link path")}, {"-l", 2, 0, 0, lOption, N_("-l"), N_("Link against the library ")}, + {"-pkg", 4, 0, 0, pkgOption, + N_("-pkg"), N_("Link against the package ")}, {"-gtk", 0, 0, 0, gtkOption, N_("-gtk"), N_("Link against the Gtk# libraries")}, {"-gnome", 0, 0, 0, gnomeOption, @@ -626,6 +730,10 @@ progname = argv[0]; version_name = versname; + /* Save the package directory */ + if (!(package_dir = ILGetStandardLibraryPath("cscc/packages"))) + CCOutOfMemory(); + /* Expand response file references in the command-line */ ILCmdLineExpand(&argc, &argv); diff -uNr pnet.orig/cscc/Makefile.am pnet/cscc/Makefile.am --- pnet.orig/cscc/Makefile.am 2003-11-10 05:25:50.000000000 -0600 +++ pnet/cscc/Makefile.am 2004-01-15 23:20:52.000000000 -0600 @@ -1,5 +1,5 @@ -SUBDIRS = common csharp c vb java bf +SUBDIRS = common csharp c vb java bf packages noinst_PROGRAMS = cscc-cs cscc-c-s cscc-vb cscc-java cscc csdoc cscc-bf man_MANS = cscc.1 csdoc.1 diff -uNr pnet.orig/cscc/packages/gnome pnet/cscc/packages/gnome --- pnet.orig/cscc/packages/gnome 1969-12-31 18:00:00.000000000 -0600 +++ pnet/cscc/packages/gnome 2004-01-16 19:23:22.000000000 -0600 @@ -0,0 +1,2 @@ +-lgnome-sharp -lgtk-sharp -lgdk-sharp -latk-sharp -lpango-sharp +-lglib-sharp -lSystem.Drawing -lSystem diff -uNr pnet.orig/cscc/packages/gtk pnet/cscc/packages/gtk --- pnet.orig/cscc/packages/gtk 1969-12-31 18:00:00.000000000 -0600 +++ pnet/cscc/packages/gtk 2004-01-15 23:24:23.000000000 -0600 @@ -0,0 +1,2 @@ +-lgtk-sharp -lgdk-sharp -latk-sharp -lpango-sharp -lglib-sharp +-lSystem.Drawing -lSystem diff -uNr pnet.orig/cscc/packages/Makefile.am pnet/cscc/packages/Makefile.am --- pnet.orig/cscc/packages/Makefile.am 1969-12-31 18:00:00.000000000 -0600 +++ pnet/cscc/packages/Makefile.am 2004-01-15 23:27:33.000000000 -0600 @@ -0,0 +1,4 @@ +csccpkgdir = $(libdir)/cscc/packages + +csccpkg_DATA = gtk gnome winforms +EXTRA_DIST = gtk gnome winforms diff -uNr pnet.orig/cscc/packages/winforms pnet/cscc/packages/winforms --- pnet.orig/cscc/packages/winforms 1969-12-31 18:00:00.000000000 -0600 +++ pnet/cscc/packages/winforms 2004-01-15 23:25:15.000000000 -0600 @@ -0,0 +1 @@ +-lSystem -lSystem.Drawing -lSystem.Windows.Forms diff -uNr pnet.orig/doc/pnettools.texi pnet/doc/pnettools.texi --- pnet.orig/doc/pnettools.texi 2004-01-16 20:25:55.000000000 -0600 +++ pnet/doc/pnettools.texi 2004-01-16 19:06:10.000000000 -0600 @@ -241,7 +241,8 @@ @example -e ENTRYPOINT -LDIR -nostdlib -lLIBRARY -shared -static -m32bit-only -fresources=RESFILE --mcui-subsystem -mgui-subsystem -gtk -gnome +-mcui-subsystem -mgui-subsystem -pkgPACKAGE +-gtk -gnome -winforms @end example @item Other Options @@ -695,17 +696,27 @@ Tag the output file so that it can run within the GUI subsystem under Windows. +@cindex -pkg option (cscc) +@item -pkg@var{package} +Link against all libraries in @var{package}. The package files are +installed in @file{/usr/local/lib/cscc/packages} or similar, depending +on your install location. A package file should consist of only +literal @option{-l} options, separated by whitespace. + @cindex -gtk option (cscc) @item -gtk Link against all of the libraries that are necessary to use Gtk#. +Same as @option{-pkggtk}. @cindex -gnome option (cscc) @item -gnome Link against all of the libraries that are necessary to use Gnome#. +Same as @option{-pkggnome}. @cindex -winforms option (cscc) @item -winforms Link against all of the libraries that are necessary to use WinForms. +Same as @option{-pkgwinforms}. @end table @c -----------------------------------------------------------------------