ó
è¾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	 e	 f d
 „  ƒ  YZ d Z d Z d Z d „  Z d „  Z d S(   sŽ   distutils.emxccompiler

Provides the EMXCCompiler class, a subclass of UnixCCompiler that
handles the EMX port of the GNU C compiler to OS/2.
s   $Id$iÿÿÿÿN(   t   gen_preprocess_optionst   gen_lib_options(   t   UnixCCompiler(   t
   write_file(   t   DistutilsExecErrort   CompileErrort   UnknownFileError(   t   logt   EMXCCompilerc           B   s•   e  Z d  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 d d „ Z RS(   t   emxs   .objs   .libs   .dlls   %s%ss   .ress   .exei    c      	   C   sÏ   t  j |  | | | ƒ t ƒ  \ } } |  j d | | f ƒ | t k	 rd |  j d d | d ƒ n  t ƒ  \ |  _ |  _ |  j |  j	 d |  j |  j f ƒ |  j
 d d d d d	 d
 d d ƒ d g |  _ d  S(   Ns%   Python's GCC status: %s (details: %s)s<   Python's pyconfig.h doesn't seem to support your compiler.  s   Reason: %s.s<   Compiling may fail because of undefined preprocessor macros.s   : gcc %s, ld %s
t   compilers5   gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wallt   compiler_sot
   linker_exes   gcc -Zomf -Zmt -Zcrtdllt	   linker_sos   gcc -Zomf -Zmt -Zcrtdll -Zdllt   gcc(   R   t   __init__t   check_config_ht   debug_printt   CONFIG_H_OKt   warnt   get_versionst   gcc_versiont
   ld_versiont   compiler_typet   set_executablest   dll_libraries(   t   selft   verboset   dry_runt   forcet   statust   details(    (    s,   /usr/lib/python2.7/distutils/emxccompiler.pyR   *   s"    	c         C   s”   | d k rH y |  j  d d | g ƒ Wq t k
 rD } t | ‚ q XnH y) |  j  |  j | | d | g | ƒ Wn t k
 r } t | ‚ n Xd  S(   Ns   .rct   rcs   -rs   -o(   t   spawnR   R   R   (   R   t   objt   srct   extt   cc_argst   extra_postargst   pp_optst   msg(    (    s,   /usr/lib/python2.7/distutils/emxccompiler.pyt   _compileM   s    c         C   s‰  t  j  |
 p g  ƒ }
 t  j  | p$ g  ƒ } t  j  | p9 g  ƒ } | j |  j ƒ | d  k	 r;| |  j k r;t j j | d ƒ } t j j t j j	 | ƒ ƒ \ } } t j j
 | | d ƒ } d t j j t j j	 | ƒ ƒ d d d g } x | D] } | j d | ƒ qó W|  j t | | f d | ƒ | j | ƒ n  |	 sQ|
 j d ƒ n  t j |  | | | | | | | d  |	 |
 | | | ƒ d  S(	   Ni    s   .defs$   LIBRARY %s INITINSTANCE TERMINSTANCEs   DATA MULTIPLE NONSHAREDt   EXPORTSs     "%s"s
   writing %ss   -s(   t   copyt   extendR   t   Nonet
   EXECUTABLEt   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   contentst   sym(    (    s,   /usr/lib/python2.7/distutils/emxccompiler.pyR7   [   sF    		 		t    c         C   sð   | d  k r d } n  g  } xÎ | D]Æ } t j j t j j | ƒ ƒ \ } } | |  j d g k rx t d | | f ‚ n  | r“ t j j | ƒ } n  | d k rÅ | j t j j	 | | |  j
 ƒ ƒ q" | j t j j	 | | |  j ƒ ƒ q" W| S(   NRJ   s   .rcs"   unknown file type '%s' (from '%s')(   R-   R/   R0   R2   t   normcaset   src_extensionsR   R3   R5   R4   t   res_extensiont   obj_extension(   R   t   source_filenamest	   strip_dirR;   t	   obj_namest   src_namet   baseR$   (    (    s,   /usr/lib/python2.7/distutils/emxccompiler.pyt   object_filenames¶   s"     	$c   
      C   s·   d | } d | } y t  j d j d ƒ } Wn t k
 rG g  } n Xxh | | D]\ } t  j j | | ƒ } t  j j | | ƒ }	 t  j j | ƒ r™ | St  j j |	 ƒ rS |	 SqS Wd  S(   Ns   %s.libs	   lib%s.libt   LIBRARY_PATHt   ;(   R/   t   environt   splitt   KeyErrorR0   R4   t   existsR-   (
   R   t   dirst   libR@   t   shortlibt   longlibt   emx_dirst   dirt	   shortlibpt   longlibp(    (    s,   /usr/lib/python2.7/distutils/emxccompiler.pyt   find_library_fileÒ   s    


N(   t   __name__t
   __module__R   RN   t   static_lib_extensiont   shared_lib_extensiont   static_lib_formatt   shared_lib_formatRM   t   exe_extensionR   R)   R-   R7   RT   Rc   (    (    (    s,   /usr/lib/python2.7/distutils/emxccompiler.pyR      s2    	P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	   distutilsRm   t   stringt   findt   syst   versionR   t   get_config_h_filenamet   opent   readt   closet   IOErrort   CONFIG_H_UNCERTAINt   strerrort   CONFIG_H_NOTOK(   Rm   Rq   t   fnt   ft   st   exc(    (    s,   /usr/lib/python2.7/distutils/emxccompiler.pyR   ò   s     
c    	      C   sÁ   d d l  m }  d d l m } d d l } | d ƒ } | r« t j | d d ƒ } z | j ƒ  } Wd | j ƒ  X| j	 d | ƒ } | r¢ |  | j
 d	 ƒ ƒ } q± d } n d } d } | | f S(
   sa    Try to find out the versions of gcc and ld.
        If not possible it returns None for it.
    iÿÿÿÿ(   t   StrictVersion(   t   find_executableNR   s    -dumpversiont   rs   (\d+\.\d+\.\d+)i   (   t   distutils.versionR   t   distutils.spawnR‚   t   reR/   t   popenRw   Rx   t   searcht   groupR-   (	   R   R‚   R†   t   gcc_exet   outt
   out_stringt   resultR   R   (    (    s,   /usr/lib/python2.7/distutils/emxccompiler.pyR   &  s     	(   t   __doc__t   __revision__R/   Rs   R+   t   distutils.ccompilerR    R   t   distutils.unixccompilerR   t   distutils.file_utilR   t   distutils.errorsR   R   R   Rp   R   R   R   R|   Rz   R   R   (    (    (    s,   /usr/lib/python2.7/distutils/emxccompiler.pyt   <module>   s   $Ï	4