*** /home/bga/src/python.orig/dist/src/Lib/distutils/uslccompiler.py Thu Aug 16 21:53:23 2001 --- Lib/distutils/uslccompiler.py Sun Aug 19 23:32:20 2001 *************** *** 0 **** --- 1,91 ---- + """distutils.uslccompiler + + Contains the UslCCompiler class, a subclass of UnixCCompiler that handles + the "Unix System Labratory" style command-line C compiler: + * macros defined with -Dname[=value] + * macros undefined with -Uname + * include search directories specified with -Idir + * libraries specified with -llib + * library search directories specified with -Ldir + * compile handled by 'cc' (or similar) executable with -c option: + compiles .c to .o + * link static library handled by 'ar' command (possibly with 'ranlib') + * link shared library handled by 'cc -G -dy -Bdynamic -Wl,-Bexport' + * search path for dynamic libraries handled with -Rpath:path:... + """ + + # created 2001/10/15 by Billy G. Allie + + __revision__ = "$Id: $" + + import string, re, os + from types import * + from copy import copy + from distutils.dep_util import newer + from distutils.unixccompiler import UnixCCompiler + from distutils.errors import \ + DistutilsExecError, CompileError, LibError, LinkError + + # XXX Things not currently handled: + # * optimization/debug/warning flags; we just use whatever's in Python's + # Makefile and live with it. Is this adequate? If not, we might + # have to have a bunch of subclasses GNUCCompiler, SGICCompiler, + # SunCCompiler, and I suspect down that road lies madness. + # * even if we don't know a warning flag from an optimization flag, + # we need some way for outsiders to feed preprocessor/compiler/linker + # flags in to us -- eg. a sysadmin might want to mandate certain flags + # via a site config file, or a user might want to set something for + # compiling this module distribution only via the setup.py command + # line, whatever. As long as these options come from something on the + # current system, they can be as system-dependent as they like, and we + # should just happily stuff them into the preprocessor/compiler/linker + # options and carry on. + + + class USLCCompiler (UnixCCompiler): + + compiler_type = 'uslc' + + # These are used by CCompiler in two places: the constructor sets + # instance attributes 'preprocessor', 'compiler', etc. from them, and + # 'set_executable()' allows any of these to be set. The defaults here + # are pretty generic; they will probably have to be set by an outsider + # (eg. using information discovered by the sysconfig about building + # Python extensions). + executables = {'preprocessor' : None, + 'compiler' : ["cc"], + 'compiler_so' : ["cc", "-KPIC"], + 'linker_so' : ["cc", "-G", "-dy", "-Bdynamic", + "-Wl,-Bexport"], + 'linker_exe' : ["cc"], + 'archiver' : ["ar", "-cr"], + 'ranlib' : None, + } + + # Needed for the filename generation methods provided by the base + # class, CCompiler. NB. whoever instantiates/uses a particular + # UnixCCompiler instance should set 'shared_lib_ext' -- we set a + # reasonable common default here, but it's not necessarily used on all + # Unices! + + src_extensions = [".c",".C",".cc",".cxx",".cpp",".m"] + obj_extension = ".o" + static_lib_extension = ".a" + shared_lib_extension = ".so" + static_lib_format = shared_lib_format = "lib%s%s" + + + + def __init__ (self, + verbose=0, + dry_run=0, + force=0): + UnixCCompiler.__init__ (self, verbose, dry_run, force) + + def runtime_library_dir_option (self, dirs): + # Return a single -R option containing a colon seperated list of + # directories. + + return [ "-R" + reduce(lambda x, y: x + ":" + y, dirs) ] + + # class USLCCompiler