;
Ñâ"Ic               @   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 Gd	 „  d
 e	 ƒ Z d Z d Z d Z d „  Z d „  Z d S(   uŽ   distutils.emxccompiler

Provides the EMXCCompiler class, a subclass of UnixCCompiler that
handles the EMX port of the GNU C compiler to OS/2.
u@   $Id: emxccompiler.py 65860 2008-08-19 17:56:33Z antoine.pitrou $i    N(   u   gen_preprocess_optionsu   gen_lib_options(   u   UnixCCompiler(   u
   write_file(   u   DistutilsExecErroru   CompileErroru   UnknownFileError(   u   logc             B   s›   |  Ee  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 d S(   u   emxu   .obju   .libu   .dllu   %s%su   .resu   .exei    c          	   C   sÑ   t  j |  | | | ƒ t ƒ  \ } } |  j d | | f ƒ | t k	 o |  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(   Nu%   Python's GCC status: %s (details: %s)u<   Python's pyconfig.h doesn't seem to support your compiler.  u   Reason: %s.u<   Compiling may fail because of undefined preprocessor macros.u   : gcc %s, ld %s
u   compileru5   gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wallu   compiler_sou
   linker_exeu   gcc -Zomf -Zmt -Zcrtdllu	   linker_sou   gcc -Zomf -Zmt -Zcrtdll -Zdllu   gcc(   u   UnixCCompileru   __init__u   check_config_hu   debug_printu   CONFIG_H_OKu   warnu   get_versionsu   gcc_versionu
   ld_versionu   compiler_typeu   set_executablesu   dll_libraries(   u   selfu   verboseu   dry_runu   forceu   statusu   details(    (    u3   /mit/python/lib/python3.0/distutils/emxccompiler.pyu   __init__*   s"    	c             C   sÄ   | d k oT y |  j  d d | g ƒ WqÀ t k
 o' } z t | ƒ ‚ WYd  d  } ~ XqÀ Xn` y) |  j  |  j | | d | g | ƒ Wn3 t k
 o' } z t | ƒ ‚ WYd  d  } ~ Xn Xd  S(   Nu   .rcu   rcu   -ru   -o(   u   spawnu   DistutilsExecErroru   CompileErroru   compiler_so(   u   selfu   obju   srcu   extu   cc_argsu   extra_postargsu   pp_optsu   msg(    (    u3   /mit/python/lib/python3.0/distutils/emxccompiler.pyu   _compileM   s    $c             C   s‘  t  j  |
 p g  ƒ }
 t  j  | p g  ƒ } t  j  | p g  ƒ } | j |  j ƒ | d  k	 oâ | |  j k oÒ 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 |	 p |
 j d ƒ n t j |  | | | | | | | d  |	 |
 | | | ƒ d  S(	   Ni    u   .defu$   LIBRARY %s INITINSTANCE TERMINSTANCEu   DATA MULTIPLE NONSHAREDu   EXPORTSu     "%s"u
   writing %su   -s(   u   copyu   extendu   dll_librariesu   Noneu
   EXECUTABLEu   osu   pathu   dirnameu   splitextu   basenameu   joinu   appendu   executeu
   write_fileu   UnixCCompileru   link(   u   selfu   target_descu   objectsu   output_filenameu
   output_diru	   librariesu   library_dirsu   runtime_library_dirsu   export_symbolsu   debugu   extra_preargsu   extra_postargsu
   build_tempu   target_langu   temp_diru   dll_nameu   dll_extensionu   def_fileu   contentsu   sym(    (    u3   /mit/python/lib/python3.0/distutils/emxccompiler.pyu   link[   sH    		 	 	u    c             C   sû   | d  k o
 d } n g  } x× | D]Ï } t j j t j j | ƒ ƒ \ } } | |  j d g k o t d | | f ƒ ‚ n | o t j j | ƒ } n | d k o' | j t j j	 | | |  j
 ƒ ƒ q$ | j t j j	 | | |  j ƒ ƒ q$ W| S(   Nu    u   .rcu"   unknown file type '%s' (from '%s')(   u   Noneu   osu   pathu   splitextu   normcaseu   src_extensionsu   UnknownFileErroru   basenameu   appendu   joinu   res_extensionu   obj_extension(   u   selfu   source_filenamesu	   strip_diru
   output_diru	   obj_namesu   src_nameu   baseu   ext(    (    u3   /mit/python/lib/python3.0/distutils/emxccompiler.pyu   object_filenames¶   s"     
 $c       
   
   C   s¾   d | } d | } y t  j d j d ƒ } Wn t k
 o g  } Yn Xxl | | D]` } t  j j | | ƒ } t  j j | | ƒ }	 t  j j | ƒ o | St  j j |	 ƒ o |	 SqV Wd  S(   Nu   %s.libu	   lib%s.libu   LIBRARY_PATHu   ;(   u   osu   environu   splitu   KeyErroru   pathu   joinu   existsu   None(
   u   selfu   dirsu   libu   debugu   shortlibu   longlibu   emx_dirsu   diru	   shortlibpu   longlibp(    (    u3   /mit/python/lib/python3.0/distutils/emxccompiler.pyu   find_library_fileÑ   s    

 	N(   u   __name__u
   __module__u   compiler_typeu   obj_extensionu   static_lib_extensionu   shared_lib_extensionu   static_lib_formatu   shared_lib_formatu   res_extensionu   exe_extensionu   __init__u   _compileu   Noneu   linku   object_filenamesu   find_library_file(   u
   __locals__(    (    u3   /mit/python/lib/python3.0/distutils/emxccompiler.pyu   EMXCCompiler   s2   
 	Pu   EMXCCompileru   oku   not oku	   uncertainc              C   sÞ   d d l  m }  t j j d ƒ d k o t d f S|  j ƒ  } y& t | ƒ } | j ƒ  } | j	 ƒ  Wn> t
 k
 o2 } z t d | | j f f SWYd d } ~ Xn5 X| j d ƒ d k o t d | f St d	 | f Sd S(
   u¡  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    (   u	   sysconfigu   GCCu   sys.version mentions 'GCC'u   couldn't read '%s': %sNu   __GNUC__u   '%s' mentions '__GNUC__'u    '%s' does not mention '__GNUC__'(   u	   distutilsu	   sysconfigu   sysu   versionu   findu   CONFIG_H_OKu   get_config_h_filenameu   openu   readu   closeu   IOErroru   CONFIG_H_UNCERTAINu   strerroru   CONFIG_H_NOTOK(   u	   sysconfigu   fnu   fu   su   exc(    (    u3   /mit/python/lib/python3.0/distutils/emxccompiler.pyu   check_config_hñ   s    (c        	      C   sÃ   d d l  m }  d d l m } d d l } | d ƒ } | on t j | d d ƒ } | j ƒ  } | j ƒ  | j	 d | | j
 ƒ } | o |  | j d	 ƒ ƒ } q³ d } n d } d } | | f S(
   ua    Try to find out the versions of gcc and ld.
        If not possible it returns None for it.
    i    (   u   StrictVersion(   u   find_executableNu   gccu    -dumpversionu   ru   (\d+\.\d+\.\d+)i   (   u   distutils.versionu   StrictVersionu   distutils.spawnu   find_executableu   reu   osu   popenu   readu   closeu   searchu   ASCIIu   groupu   None(	   u   StrictVersionu   find_executableu   reu   gcc_exeu   outu
   out_stringu   resultu   gcc_versionu
   ld_version(    (    u3   /mit/python/lib/python3.0/distutils/emxccompiler.pyu   get_versions"  s    

(   u   __doc__u   __revision__u   osu   sysu   copyu   distutils.ccompileru   gen_preprocess_optionsu   gen_lib_optionsu   distutils.unixccompileru   UnixCCompileru   distutils.file_utilu
   write_fileu   distutils.errorsu   DistutilsExecErroru   CompileErroru   UnknownFileErroru	   distutilsu   logu   EMXCCompileru   CONFIG_H_OKu   CONFIG_H_NOTOKu   CONFIG_H_UNCERTAINu   check_config_hu   get_versions(    (    (    u3   /mit/python/lib/python3.0/distutils/emxccompiler.pyu   <module>   s   $Î	1