Ńň
$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	 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  i |  | | |  t   \ } } |  i d | | f  | t j	 o |  i d d | d  n t   \ |  _ |  _ |  i |  i	 d |  i |  i f  |  i
 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.6/distutils/emxccompiler.pyR   *   s"    	c         C   s   | d j o? y |  i  d d | g  Wq t j
 o } t |  q XnK y) |  i  |  i | | d | g |  Wn t j
 o } 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.6/distutils/emxccompiler.pyt   _compileM   s    c         C   s  t  i  |
 p g   }
 t  i  | p g   } t  i  | p g   } | i |  i  | d  j	 oâ | |  i j oŇ t i i | d  } t i i t i i	 |   \ } } t i i
 | | d  } d t i i t i i	 |   d d d g } x | D] } | i d |  qř W|  i t | | f d |  | i |  n |	 p |
 i d  n t i |  | | | | | | | 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.6/distutils/emxccompiler.pyR7   [   sH    		 	 	t    c         C   sř   | d  j o
 d } n g  } xÔ | D]Ě } t i i t i i |   \ } } | |  i d g j o t d | | f  n | o t i i |  } n | d j o' | i t i i	 | | |  i
   q$ | i t i i	 | | |  i   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.6/distutils/emxccompiler.pyt   object_filenamesś   s$     
 $c   
      C   s˝   d | } d | } y t  i d i d  } Wn t j
 o g  } n Xxl | | D]` } t  i i | |  } t  i i | |  }	 t  i i |  o | St  i i |	  o |	 SqU 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.6/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.6/distutils/emxccompiler.pyR      s2    	P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	   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.6/distutils/emxccompiler.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 } | | 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.6/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.6/distutils/emxccompiler.pyt   <module>   s   $Ď	2