³ò
Ÿ›\Kc           @   sÛ   d  Z  d 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 d d k l Z l Z l Z d d	 k l Z l Z l Z l Z d d
 k l Z d „  Z d e f d „  ƒ  YZ d S(   s9  distutils.unixccompiler

Contains the UnixCCompiler class, a subclass of CCompiler that handles
the "typical" Unix-style command-line C compiler:
  * macros defined with -Dname[=value]
  * macros undefined with -Uname
  * include search directories specified with -Idir
  * libraries specified with -lllib
  * library search directories specified with -Ldir
  * compile handled by 'cc' (or similar) executable with -c option:
    compiles .c to .o
  * link static library handled by 'ar' command (possibly with 'ranlib')
  * link shared library handled by 'cc -shared'
s?   $Id: unixccompiler.py 54954 2007-04-25 06:42:41Z neal.norwitz $iÿÿÿÿN(   t
   StringTypet   NoneType(   t   copy(   t	   sysconfig(   t   newer(   t	   CCompilert   gen_preprocess_optionst   gen_lib_options(   t   DistutilsExecErrort   CompileErrort   LibErrort	   LinkError(   t   logc   	      C   sŸ  d } } t  |  ƒ }  t i ƒ  d } t | i d ƒ d ƒ } | d j  o t } } n d | j } d | j } | oB x? y! |  i d ƒ } |  | | d 5Wq| t j
 o Pq| Xq| n | o; y! |  i d ƒ } |  | | d 5Wqý t j
 o qý Xn d
 } d | j o! | i d ƒ } | | d } n/ d |  j o! |  i d ƒ } |  | d } n | o5 t i	 i
 | ƒ o! t i d | ƒ t i d	 ƒ n |  S(   se  
    This function will strip '-isysroot PATH' and '-arch ARCH' from the
    compile flags if the user has specified one them in extra_compile_flags.

    This is needed because '-arch ARCH' adds another architecture to the
    build, without a way to remove an architecture. Furthermore GCC will
    barf if multiple '-isysroot' arguments are present.
    i    i   t   .i   s   -archs	   -isysrooti   s4   Compiling with an SDK that doesn't seem to exist: %ss$   Please check your Xcode installationN(   t   listt   ost   unamet   intt   splitt   Truet   indext
   ValueErrort   Nonet   patht   isdirR   t   warn(	   t   compiler_sot   cc_argst	   stripArcht   stripSysroott   kernel_versiont   major_versionR   t   sysroott   idx(    (    s-   /usr/lib/python2.5/distutils/unixccompiler.pyt   _darwin_compiler_fixup-   sB    	
		t   UnixCCompilerc           B   sr  e  Z d  Z h  d% d <d g d <d g d <d g d <d d g d <d g d <d	 d
 g d <d% d <Z e i d  d j o d g e d <n d d d d d d g Z d Z d Z	 d Z
 d Z d Z Z Z e i d j o
 d Z n d% d% d% d% d% d „ Z d „  Z d% d d% d „ Z d% d% d% d% d% d d% d% d% d% d  „
 Z d! „  Z d" „  Z d# „  Z d d$ „ Z RS(&   t   unixt   preprocessort   cct   compilerR   t   compiler_cxxs   -sharedt	   linker_sot
   linker_exet   ars   -crt   archivert   ranlibi   t   darwins   .cs   .Cs   .ccs   .cxxs   .cpps   .ms   .os   .as   .sos   .dylibs   lib%s%st   cygwins   .exec         C   s  |  i  d  | | ƒ \ } } } t | | ƒ } |  i | }	 | o |	 i d | g ƒ n | o | |	 d *n | o |	 i | ƒ n |	 i | ƒ |  i p | d  j p t | | ƒ oZ | o |  i t	 i
 i | ƒ ƒ n y |  i |	 ƒ Wqt j
 o }
 t |
 ‚ qXn d  S(   Ns   -oi    (   t   _fix_compile_argsR   R   R%   t   extendt   appendt   forceR   t   mkpathR   R   t   dirnamet   spawnR   R	   (   t   selft   sourcet   output_filet   macrost   include_dirst   extra_preargst   extra_postargst   ignoret   pp_optst   pp_argst   msg(    (    s-   /usr/lib/python2.5/distutils/unixccompiler.pyt
   preprocess   s"    'c   	      C   s{   |  i  } t i d j o t | | | ƒ } n y& |  i | | | d | g | ƒ Wn t j
 o } t | ‚ n Xd  S(   NR.   s   -o(   R   t   syst   platformR"   R6   R   R	   (	   R7   t   objt   srct   extR   R=   R?   R   RA   (    (    s-   /usr/lib/python2.5/distutils/unixccompiler.pyt   _compile¨   s    	i    c         C   sÝ   |  i  | | ƒ \ } } |  i | d | ƒ} |  i | | ƒ o‰ |  i t i i | ƒ ƒ |  i |  i | g | |  i	 ƒ |  i
 o@ y |  i |  i
 | g ƒ WqÅ t j
 o } t | ‚ qÅ XqÙ n t i d | ƒ d  S(   Nt
   output_dirs   skipping %s (up-to-date)(   t   _fix_object_argst   library_filenamet
   _need_linkR4   R   R   R5   R6   R,   t   objectsR-   R   R
   R   t   debug(   R7   RM   t   output_libnameRI   RN   t   target_langt   output_filenameRA   (    (    s-   /usr/lib/python2.5/distutils/unixccompiler.pyt   create_static_lib²   s    
c         C   sœ  |  i  | | ƒ \ } } |  i | | | ƒ \ } } } g  } | D] } | d j o | | qA qA ~ } g  } | D] } | d j o | | qs qs ~ } t |  | | | ƒ } t | ƒ t t f j o t d ‚ n | d  j	 o t i	 i
 | | ƒ } n |  i | | ƒ oz| |  i | d | g } |	 o d g | d *n |
 o |
 | d *n | o | i | ƒ n |  i t i	 i | ƒ ƒ yÜ | t i j o |  i } n |  i } | d	 j oo |  i oe d } t i	 i | d ƒ d
 j o- d } x$ d | | j o | d } qõWn |  i | | | <n t i d j o t | | ƒ } n |  i | | ƒ Wq˜t j
 o } t | ‚ q˜Xn t i d | ƒ d  S(   Ns   /libs   /lib64s   /usr/libs
   /usr/lib64s%   'output_dir' must be a string or Nones   -os   -gi    s   c++t   envi   t   =R.   s   skipping %s (up-to-date)(   s   /libs   /lib64s   /usr/libs
   /usr/lib64(   s   /libs   /lib64s   /usr/libs
   /usr/lib64(   RJ   t   _fix_lib_argsR   t   typeR    R   t	   TypeErrorR   R   R   t   joinRL   RM   R1   R4   R5   R   t
   EXECUTABLER*   R)   R(   t   basenameRC   RD   R"   R6   R   R   R   RN   (   R7   t   target_descRM   RQ   RI   t	   librariest   library_dirst   runtime_library_dirst   export_symbolsRN   R<   R=   t
   build_tempRP   t   _[1]t   dirt   _[2]t   lib_optst   ld_argst   linkert   iRA   (    (    s-   /usr/lib/python2.5/distutils/unixccompiler.pyt   linkÌ   sN    !!	
 c         C   s   d | S(   Ns   -L(    (   R7   Rb   (    (    s-   /usr/lib/python2.5/distutils/unixccompiler.pyt   library_dir_option  s    c         C   sË   t  i i t i d ƒ ƒ } t i d  d j o d | Sn t i d  d j o d | Snm t i d  d	 j p t i d  d
 j o d | g Sn7 | d  d j p | d  d j o d | Sn	 d | Sd  S(   Nt   CCi   R.   s   -Li   s   hp-uxs   +s -Li   t   irix646t   osf1V5s   -rpathi   t   gccs   g++s   -Wl,-Rs   -R(   R   R   RZ   R   t   get_config_varRC   RD   (   R7   Rb   R'   (    (    s-   /usr/lib/python2.5/distutils/unixccompiler.pyt   runtime_library_dir_option  s    ("c         C   s   d | S(   Ns   -l(    (   R7   t   lib(    (    s-   /usr/lib/python2.5/distutils/unixccompiler.pyt   library_option(  s    c         C   sä   |  i  | d d ƒ} |  i  | d d ƒ} |  i  | d d ƒ} xž | D]– } t i i | | ƒ } t i i | | ƒ }	 t i i | | ƒ }
 t i i |	 ƒ o |	 SqF t i i | ƒ o | SqF t i i |
 ƒ o |
 SqF qF Wd  S(   Nt   lib_typet   sharedt   dylibt   static(   RK   R   R   RX   t   existsR   (   R7   t   dirsRp   RN   t   shared_ft   dylib_ft   static_fRb   Rs   Rt   Ru   (    (    s-   /usr/lib/python2.5/distutils/unixccompiler.pyt   find_library_file+  s     N(   t   __name__t
   __module__t   compiler_typeR   t   executablesRC   RD   t   src_extensionst   obj_extensiont   static_lib_extensiont   shared_lib_extensiont   dylib_lib_extensiont   static_lib_formatt   shared_lib_formatt   dylib_lib_formatt   exe_extensionRB   RH   RR   Rh   Ri   Ro   Rq   R{   (    (    (    s-   /usr/lib/python2.5/distutils/unixccompiler.pyR#   g   s>   
			;			(   t   __doc__t   __revision__R   RC   t   typesR    R   R   t	   distutilsR   t   distutils.dep_utilR   t   distutils.ccompilerR   R   R   t   distutils.errorsR   R	   R
   R   R   R"   R#   (    (    (    s-   /usr/lib/python2.5/distutils/unixccompiler.pys   <module>   s   "	: