ó
8Þ	Pc           @   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 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 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   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.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	   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.7/distutils/cygwinccompiler.pyR"   `  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    
	
	
	(   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.7/distutils/cygwinccompiler.pyt   <module>   s   +$	×3	5