I've been thinking along these lines, but I'd decided on a different approach. I think that it's better to keep the magic to a minimum. Rather than relying on extensions, I was thinking about having a different wrapper for each task:
- lib.pl: build static library from object files example: lib.pl --out=libfoo.a foo.o bar.o - shlib.pl: build dynamic library from object files and libraries example: shlib.pl --out=libfoo.so.1.1 --soname=libfoo.so.1 -Llib -llib foo.o bar.o - compile.pl: build .o file from .c file example: compile.pl --out=foo.o -DA=B -UC foo.c - link.pl: build executable from .o files and libraries example: link.pl --out=foo -Llib -llib foo.o bar.o These wrappers would add compiler-specific flags only, and would accept compiler-neutral options only. We'd not want to pass through arbitrary command line arguments to the underlying compiler, as that is bound to break somewhere. So IMHO the wrapper needs to have well-defined arguments that it accepts, so that it can rewrite them as needed for weird platforms. In the examples above, I used some familiar flags (-D, -L, -l), but I still would have the wrapper intercept and potentially rewrite them. Note that the wrappers would always add standard flags which control compiler behavior (for example warnings for gcc), but would NOT add things like extra libraries to link in or extra defines for compilation. Those should be passed on the command line for flexibility. That is, we shouldn't blindly tack on ccflags or ldflags in the wrappers. --Josh At 2:12 on 03/30/2002 PST, "Brent Dax" <[EMAIL PROTECTED]> wrote: > This patch adds a new utility to Parrot and modifies Makefile.in to use > it. The utility is for wrapping C compilers and other tools we use, so > we can avoid putting the logic in the Makefile and can potentially use > totally different commands on different platforms. > > The patch is by no means ready to be applied to the source tree--it > doesn't touch the shared lib stuff, an important test needs to be added > to Configure, and I haven't even tried it on a Unix. The ability to > create libraries, both static and dynamic, is missing. But you should > be able to build your basic Parrot with this. > > If you have a Unix box and ten spare minutes, please apply this to a > fresh checkout of Parrot, run 'make test', and tell me how well it > works. > > As for the tool itself: > > pccw.pl is a small script that implements a wrapper around several > tools. You use it like this: > > perl pccw.pl [--args="(arguments)"] (destination file) (source files) > > pccw.pl examines the extension of the destination file and uses that to > pick what to do. If the extension is '.c', then it examines the source > files and runs either ops2c or pmc2c as appropriate; otherwise it runs > the appropriate compiler or linker incantations. The --args argument is > used to pass additional flags to the tool. > > Patch is attached. Share and enjoy. > > --Brent Dax <[EMAIL PROTECTED]> > @roles=map {"Parrot $_"} qw(embedding regexen Configure) > > #define private public > --Spotted in a C++ program just before a #include >