ó
ÍCe]c           @   s:   d  Z  d d l j Z d „  Z d d d d e d „ Z d S(   sã  
This is NOT a waf tool but generic functions to be called from a waf
tool, in particular by wcb.py.

There's probably a wafier way to do this.

The interpretation of options are very specific so don't change them
unless you really know all the use cases.  The rules are:

If package is optional:

    - omitting all --with-NAME* options will omit use the package

    - explicitly using --with-NAME=false (or "no" or "off") will omit
      use of the package.

If package is mandatory:

    - omitting all --with-NAME* options will use pkg-config to find
      the package.

    - explicitly using --with-NAME=false (or "no" or "off") will
      assert.

In either case:

    - explicitly using --with-NAME=true (or "yes" or "on") will use
      pkg-config to find the package.

    - using --with-NAME* with a path will attempt to locate the
      package without using pkg-config

Note, actually, pgk-config fails often to do its job.  Best to always
use explicit --with-NAME=[<bool>|<dir>].
iÿÿÿÿNc      	   C   sŒ   | j  ƒ  } |  j d | ƒ }  |  j d | d d d d  d d | ƒ|  j d | d d d d	 | ƒ|  j d
 | d d d d | ƒd  S(   Ns
   %s Optionss	   --with-%st   typet   stringt   defaultt   helps   give %s installation locations   --with-%s-includes%   give %s include installation locations   --with-%s-libs!   give %s lib installation location(   t   lowert   add_option_groupt
   add_optiont   None(   t   optt   nameR   (    (    s   waftools/generic.pyt   _options'   s    c      
   C   s8  | j  ƒ  } | j ƒ  } | d  k r- | } n  t |  j d | d  ƒ }	 t |  j d | d  ƒ }
 t |  j d | d  ƒ } t |  j d | d  ƒ } | r» |	 rÿ |	 j  ƒ  d$ k s¸ t ‚ qÿ nD t |	 |
 | g ƒ sã d | | f GHd  S|	 rÿ |	 j  ƒ  d% k rÿ d  St |	 |
 | | g ƒ s0|	 r³|	 j  ƒ  d& k r³|  j d | ƒ d } | rZ| d 7} n  |  j d | d | d | d | ƒ d | |  j	 k rŸ|  j
 d ƒ q�|  j
 d ƒ d  Snê | r|
 rÛ|	 rÛt j |	 d ƒ }
 n  |
 rt |  j	 d | |
 g ƒ qn  | rO| r)|	 r)t j |	 d ƒ } n  | rOt |  j	 d | | g ƒ qOn  | r�| rw|	 rwt j |	 d ƒ } n  | r�t |  j	 d | | g ƒ q�n  | r|  j d | ƒ x0 | D]( } |  j d | d | d | d | ƒ q»W|  j
 t t |  j	 d | d  ƒ ƒ ƒ n  | r·|  j d | ƒ x0 | D]( } |  j d | d | d | d | ƒ q.W|  j
 t t |  j	 d | d  ƒ ƒ ƒ |  j d  | ƒ |  j
 t t |  j	 d! | ƒ ƒ ƒ n  | r4|  j d" | ƒ t ƒ  } xD | D]< } |  j | d# | j ƒ  d | ƒ| |  j	 | j ƒ  7} qÞW|  j
 t | ƒ ƒ n  d  S('   Nt   with_s   with_%s_includes   with_%s_libs   with_%s_bint   not   offt   falses=   skipping non mandatory %s, use --with-%s=[yes|<dir>] to forcet   yest   ont   trues"   Checking for %s in PKG_CONFIG_PATHs   --cflagss    --libst   packaget   uselib_storet   argst	   mandatoryt   HAVE_t   foundt   failedt   includet	   INCLUDES_t   libt   LIBPATH_t   bint   PATH_s   Location for %s headerst   header_namet   uses   Location for %s libss   Libs for %st   LIB_s   Bins for %st   var(   R   R   R   (   R   R   R   (   R   R   R   (   R   t   upperR   t   getattrt   optionst   AssertionErrort   anyt	   start_msgt	   check_cfgt   envt   end_msgt   ospt   joint   setattrt	   check_cxxt   strt   listt   find_program(   t   ctxR	   t   incst   libst   binst   pcnameR   R   t   UPPERt   instdirt   incdirt   libdirt   bindirR   t   tryht   trylt
   found_binst   tryb(    (    s   waftools/generic.pyt
   _configure2   s~    	1   )&&	(    (    (    (   t   __doc__t   os.patht   pathR,   R
   R   t   TrueRA   (    (    (    s   waftools/generic.pyt   <module>$   s   	