ó
čžbc           @   sř   d  Z  d Z d d l Z d d l Z d d l Z d d l m Z m Z d d l m	 Z	 d d l
 m Z d d l m Z m Z m Z d d l m Z d	   Z d
 e	 f d     YZ d e f d     YZ d Z 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  j j d  }  |  d k r t  j |  d |  d !} | d k rI d g S| d k r\ d g S| d	 k ro d
 g S| d k r d g St 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.7/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   sS  t  j |  | | |  t   \ } } |  j d | | f  | t k	 r\ |  j d |  n  t   \ |  _ |  _ |  _	 |  j |  j
 d |  j |  j |  j	 f  |  j d k rź d |  _ n	 d |  _ |  j d k rÝ d } n d	 } |  j d
 d d d d d d d d d |  j | f  |  j d k rCd g |  _ |  j 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.7/distutils/cygwinccompiler.pyR!   \   s<    			
c         C   sŚ   | d k s | d k rZ y  |  j  d d | d | g  Wq˘ t k
 rV } t |  q˘ XnH y) |  j  |  j | | d | g |  Wn t k
 rĄ } 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.7/distutils/cygwinccompiler.pyt   _compile   s     c         C   sÖ  t  j  |
 p g   }
 t  j  | p$ g   } t  j  | p9 g   } | j |  j  | d  k	 r| |  j k sy |  j d k rt j j | d  } t j j	 t j j
 |   \ } } t j j | | d  } t j j | d | d  } d t j j
 |  d g } x | D] } | j |  qW|  j t | | f d |  |  j d	 k rx|
 j d
 | g  |
 j d | g  q| j |  n  |	 s|
 j d  n  t j |  | | | | | | | 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.7/distutils/cygwinccompiler.pyRM   ¨   sJ    				t    c         C   s  | d  k r d } n  g  } xá | D]Ů } t j j t j j |   \ } } | |  j d d g k r{ t d | | f  n  | r t j j |  } n  | d k sŽ | d k rŘ | j t j j	 | | | |  j
   q" | j t j j	 | | |  j
   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.7/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.7/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  j |  | | |  |  j d k r. d } n d } |  j d k rL d } n d } |  j d k  sj t   rs d } n d } |  j d	 d
 | d d | d d | d d | d d |  j | | | f  g  |  _ t   |  _ d  S(   Ns   2.13s   -shareds   -mdll -statics   2.91.57s   --entry _DllMain@12Ra   t   4s    -mno-cygwinR   s   gcc%s -O -WallR   s   gcc%s -mdll -O -WallR   s   g++%s -O -WallR   s   gcc%sR   s
   %s%s %s %s(	   R   R!   R(   R'   t   is_cygwingccR,   R+   R-   R   (   R.   R/   R0   R1   R4   t   entry_pointt	   no_cygwin(    (    s/   /usr/lib/python2.7/distutils/cygwinccompiler.pyR!   -  s&    			


		(   Rk   Rl   R*   R!   (    (    (    s/   /usr/lib/python2.7/distutils/cygwinccompiler.pyRr   )  s   t   oks   not okt	   uncertainc          C   sÝ   d d l  m }  d d l } | j t j d  d k rA t d f S|  j   } y. t |  } z | j	   } Wd | j
   XWn' t k
 r¤ } t d | | j f f SX| j | d  d k rË t d	 | f St 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	   distutilsRz   t   stringR   R   R   R$   t   get_config_h_filenamet   opent   readt   closet   IOErrort   CONFIG_H_UNCERTAINt   strerrort   CONFIG_H_NOTOK(   Rz   R~   t   fnt   ft   st   exc(    (    s/   /usr/lib/python2.7/distutils/cygwinccompiler.pyR"   e  s     
c          C   s°  d d l  m }  d d l m } d d l } | d  } | rŁ t j | d d  } | j   } | j   | j	 d |  } | r |  | j
 d	   } qŠ d } n d } | d
  } | r t j | d d  } | j   } | j   | j	 d |  } | r|  | j
 d	   }	 q&d }	 n d }	 | d  }
 |
 rt j |
 d d  } | j   } | j   | j	 d |  } | r|  | j
 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.7/distutils/cygwinccompiler.pyR&     sD    
	
	
	c          C   s;   t  j d d  }  |  j   } |  j   | j   j d  S(   s>   Try to determine if the gcc that would be used is from cygwin.s   gcc -dumpmachineR   R   (   RE   R   R   R   t   stript   endswith(   R   R   (    (    s/   /usr/lib/python2.7/distutils/cygwinccompiler.pyRu   Č  s    
(   t   __doc__t   __revision__RE   R   RA   t   distutils.ccompilerR    R   t   distutils.unixccompilerR   t   distutils.file_utilR   t   distutils.errorsR   R   R   R}   R   R   R   Rr   R$   R   R   R"   R&   Ru   (    (    (    s/   /usr/lib/python2.7/distutils/cygwinccompiler.pyt   <module>   s    +$	×8	5	.