ó
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	 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