Ñò
$8Zc           @   sï   d  Z  d Z d d k Z d d k Z d d k Z d d k l Z l Z d d k l	 Z	 d d k
 l Z d d k l Z l Z l Z d d k l Z d	 „  Z d
 e	 f d „  ƒ  YZ d e f d „  ƒ  YZ d Z d Z d Z d „  Z d „  Z d S(   s  distutils.cygwinccompiler

Provides the CygwinCCompiler class, a subclass of UnixCCompiler that
handles the Cygwin port of the GNU C compiler to Windows.  It also contains
the Mingw32CCompiler class which handles the mingw32 port of GCC (same as
cygwin in no-cygwin mode).
s   $Id$iÿÿÿÿN(   t   gen_preprocess_optionst   gen_lib_options(   t   UnixCCompiler(   t
   write_file(   t   DistutilsExecErrort   CompileErrort   UnknownFileError(   t   logc          C   s£   t  i i d ƒ }  |  d j o€ t  i |  d |  d !} | d j o d g S| d j o d g S| d	 j o d
 g S| d j o d g St d | ƒ ‚ n d S(   sa   Include the appropriate MSVC runtime library if Python was built
    with MSVC 7.0 or later.
    s   MSC v.iÿÿÿÿi   i
   t   1300t   msvcr70t   1310t   msvcr71t   1400t   msvcr80t   1500t   msvcr90s   Unknown MS Compiler version %s N(   t   syst   versiont   findt
   ValueError(   t   msc_post   msc_ver(    (    s/   /usr/lib/python2.6/distutils/cygwinccompiler.pyt	   get_msvcr;   s    t   CygwinCCompilerc           B   sƒ   e  Z d  Z d Z d Z d Z d Z d Z d Z d d d d „ Z	 d	 „  Z
 d d d d d d d d d d d
 „
 Z d d d „ Z RS(   t   cygwins   .os   .as   .dlls   lib%s%ss   %s%ss   .exei    c         C   s[  t  i |  | | | ƒ t ƒ  \ } } |  i d | | f ƒ | t j	 o |  i d | ƒ n t ƒ  \ |  _ |  _ |  _	 |  i |  i
 d |  i |  i |  i	 f ƒ |  i d j o d |  _ n
 d |  _ |  i d j o
 d } n d	 } |  i d
 d d d d d d d d d |  i | f ƒ |  i d j o d g |  _ |  i d ƒ n t ƒ  |  _ d  S(   Ns%   Python's GCC status: %s (details: %s)sƒ   Python's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.s   : gcc %s, ld %s, dllwrap %s
s   2.10.90t   gcct   dllwraps   2.13s   -shareds   -mdll -statict   compilers   gcc -mcygwin -O -Wallt   compiler_sos   gcc -mcygwin -mdll -O -Wallt   compiler_cxxs   g++ -mcygwin -O -Wallt
   linker_exes   gcc -mcygwint	   linker_sos   %s -mcygwin %ss   2.91.57t   msvcrts,   Consider upgrading to a newer version of gcc(   R   t   __init__t   check_config_ht   debug_printt   CONFIG_H_OKt   warnt   get_versionst   gcc_versiont
   ld_versiont   dllwrap_versiont   compiler_typet
   linker_dllt   set_executablest   dll_librariesR   (   t   selft   verboset   dry_runt   forcet   statust   detailst   shared_option(    (    s/   /usr/lib/python2.6/distutils/cygwinccompiler.pyR!   \   s<    		
c      	   C   s­   | d j p | d j oE y  |  i  d d | d | g ƒ Wq© t j
 o } t | ‚ q© XnK y) |  i  |  i | | d | g | ƒ Wn t j
 o } t | ‚ n Xd  S(   Ns   .rcs   .rest   windress   -is   -o(   t   spawnR   R   R   (   R.   t   objt   srct   extt   cc_argst   extra_postargst   pp_optst   msg(    (    s/   /usr/lib/python2.6/distutils/cygwinccompiler.pyt   _compileš   s     c         C   sá  t  i  |
 p g  ƒ }
 t  i  | p g  ƒ } t  i  | p g  ƒ } | i |  i ƒ | d  j	 o2| |  i j p |  i d j ot i i | d ƒ } t i i	 t i i
 | ƒ ƒ \ } } t i i | | d ƒ } t i i | d | d ƒ } d t i i
 | ƒ d g } x | D] } | i | ƒ qW|  i t | | f d | ƒ |  i d	 j o* |
 i d
 | g ƒ |
 i d | g ƒ q‘| i | ƒ n |	 p |
 i d ƒ n t i |  | | | | | | | d  |	 |
 | | | ƒ d  S(   NR   i    s   .deft   libs   .as
   LIBRARY %st   EXPORTSs
   writing %sR   s   --output-libs   --defs   -s(   t   copyt   extendR-   t   Nonet
   EXECUTABLER+   t   ost   patht   dirnamet   splitextt   basenamet   joint   appendt   executeR   R   t   link(   R.   t   target_desct   objectst   output_filenamet
   output_dirt	   librariest   library_dirst   runtime_library_dirst   export_symbolst   debugt   extra_preargsR;   t
   build_tempt   target_langt   temp_dirt   dll_namet   dll_extensiont   def_filet   lib_filet   contentst   sym(    (    s/   /usr/lib/python2.6/distutils/cygwinccompiler.pyRM   ¨   sL     			 	t    c         C   s  | d  j o
 d } n g  } xè | D]à } t i i t i i | ƒ ƒ \ } } | |  i d d g j o t d | | f ‚ n | o t i i | ƒ } n | d j p | d j o+ | i t i i	 | | | |  i
 ƒ ƒ q$ | i t i i	 | | |  i
 ƒ ƒ q$ W| S(   NRa   s   .rcs   .ress"   unknown file type '%s' (from '%s')(   RC   RE   RF   RH   t   normcaset   src_extensionsR   RI   RK   RJ   t   obj_extension(   R.   t   source_filenamest	   strip_dirRQ   t	   obj_namest   src_namet   baseR9   (    (    s/   /usr/lib/python2.6/distutils/cygwinccompiler.pyt   object_filenames  s$     
 $N(   t   __name__t
   __module__R*   Rd   t   static_lib_extensiont   shared_lib_extensiont   static_lib_formatt   shared_lib_formatt   exe_extensionR!   R>   RC   RM   Rj   (    (    (    s/   /usr/lib/python2.6/distutils/cygwinccompiler.pyR   R   s*   >	Xt   Mingw32CCompilerc           B   s    e  Z d  Z d d d d „ Z RS(   t   mingw32i    c         C   s§   t  i |  | | | ƒ |  i d j o
 d } n d } |  i d j o
 d } n d } |  i d d d	 d
 d d d d d d |  i | | f ƒ g  |  _ t ƒ  |  _ d  S(   Ns   2.13s   -shareds   -mdll -statics   2.91.57s   --entry _DllMain@12Ra   R   s   gcc -mno-cygwin -O -WallR   s   gcc -mno-cygwin -mdll -O -WallR   s   g++ -mno-cygwin -O -WallR   s   gcc -mno-cygwinR   s   %s -mno-cygwin %s %s(   R   R!   R(   R'   R,   R+   R-   R   (   R.   R/   R0   R1   R4   t   entry_point(    (    s/   /usr/lib/python2.6/distutils/cygwinccompiler.pyR!   -  s     

		(   Rk   Rl   R*   R!   (    (    (    s/   /usr/lib/python2.6/distutils/cygwinccompiler.pyRr   )  s   t   oks   not okt	   uncertainc          C   sÛ   d d k  l }  d d k } | i t i d ƒ d j o t d f S|  i ƒ  } y& t | ƒ } | i	 ƒ  } | i
 ƒ  Wn) t j
 o } t d | | i f f SX| i | d ƒ d j o t d	 | f St d
 | f Sd S(   s¡  Check if the current Python installation (specifically, pyconfig.h)
    appears amenable to building extensions with GCC.  Returns a tuple
    (status, details), where 'status' is one of the following constants:
      CONFIG_H_OK
        all is well, go ahead and compile
      CONFIG_H_NOTOK
        doesn't look good
      CONFIG_H_UNCERTAIN
        not sure -- unable to read pyconfig.h
    'details' is a human-readable string explaining the situation.

    Note there are two ways to conclude "OK": either 'sys.version' contains
    the string "GCC" (implying that this Python was built with GCC), or the
    installed "pyconfig.h" contains the string "__GNUC__".
    iÿÿÿÿ(   t	   sysconfigNt   GCCi    s   sys.version mentions 'GCC's   couldn't read '%s': %st   __GNUC__s   '%s' mentions '__GNUC__'s    '%s' does not mention '__GNUC__'(   t	   distutilsRw   t   stringR   R   R   R$   t   get_config_h_filenamet   opent   readt   closet   IOErrort   CONFIG_H_UNCERTAINt   strerrort   CONFIG_H_NOTOK(   Rw   R{   t   fnt   ft   st   exc(    (    s/   /usr/lib/python2.6/distutils/cygwinccompiler.pyR"   `  s    c          C   s¼  d d k  l }  d d k l } d d k } | d ƒ } | oh t i | d d ƒ } | i ƒ  } | i ƒ  | i	 d | ƒ } | o |  | i
 d	 ƒ ƒ } q­ d } n d } | d
 ƒ } | oh t i | d d ƒ } | i ƒ  } | i ƒ  | i	 d | ƒ } | o |  | i
 d	 ƒ ƒ }	 q.d }	 n d }	 | d ƒ }
 |
 oh t i |
 d d ƒ } | i ƒ  } | i ƒ  | i	 d | ƒ } | o |  | i
 d	 ƒ ƒ } q¯d } n d } | |	 | f S(   sj    Try to find out the versions of gcc, ld and dllwrap.
        If not possible it returns None for it.
    iÿÿÿÿ(   t   LooseVersion(   t   find_executableNR   s    -dumpversiont   rs   (\d+\.\d+(\.\d+)*)i   t   lds    -vR   s
    --versions    (\d+\.\d+(\.\d+)*)(   t   distutils.versionRˆ   t   distutils.spawnR‰   t   reRE   t   popenR~   R   t   searcht   groupRC   (   Rˆ   R‰   RŽ   t   gcc_exet   outt
   out_stringt   resultR'   t   ld_exeR(   t   dllwrap_exeR)   (    (    s/   /usr/lib/python2.6/distutils/cygwinccompiler.pyR&   “  sD    





(   t   __doc__t   __revision__RE   R   RA   t   distutils.ccompilerR    R   t   distutils.unixccompilerR   t   distutils.file_utilR   t   distutils.errorsR   R   R   Rz   R   R   R   Rr   R$   Rƒ   R   R"   R&   (    (    (    s/   /usr/lib/python2.6/distutils/cygwinccompiler.pyt   <module>   s   +$	×3	3