U
    ®8df  ã                   @   s<   d Z ddlZddlmZ ddlmZ d
dd„Zddd	„ZdS )aã  
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>].
é    N)Údebugc                 C   sœ   |  ¡ }|  d| ¡} | jd| dd d| d� |d ks@t|ƒrX| jd| dd| d� |d ksht|ƒr˜| jd	| dd
| d� | jd| dd| d� d S )Nz
%s Optionsz	--with-%sÚstringzgive %s installation location)ÚtypeÚdefaultÚhelpz--with-%s-includez%give %s include installation location)r   r   z--with-%s-libz!give %s lib installation locationz--with-%s-libszlist %s link libraries)ÚlowerÚadd_option_groupÚ
add_optionÚlen)ÚoptÚnameÚincsÚlibsr   © r   ú3/home/yuhw/wc/larsoft925/src/pr-199/waft/generic.pyÚ_options*   s"    ÿÿÿÿr   r   Tc                 C   sð  |  ¡ }| ¡ }	|d kr|}t|ƒ}t| jd| d ƒ}
t| jd| d ƒ}t| jd| d ƒ}t| jd| d ƒ}|ršt| jd| d ƒ}|ršdd„ | d¡D ƒ}td	||
||||ƒ |rÈ|
rî|
  ¡ d
ksît‚n&|
rî|
  ¡ d
krîtd|||f ƒ d S t|
|||gƒ�r|
�rr|
  ¡ dk�rr|  	d| ¡ d}|�r4|d7 }| j
||	||d� d|	 | jk�rb|  d¡ n|  d¡ d S n¨|�rª|�s�|
�r�t |
d¡}|�rªt| jd|	 |gƒ |�râ|�sÈ|
�rÈt |
d¡}|�rât| jd|	 |gƒ |�r|�s |
�r t |
d¡}|�rt| jd|	 |gƒ |�rì|  	d|f ¡ |D ](}| j|d|	 d |	g| |	|d� �q4|  tt| jd|	 d ƒƒ¡ |  	d|	 ¡ t| jd|	 d ƒ}|  t|ƒ¡ |  d|	 d ¡�rÜd| jd|	 < td ||	f ƒ ntd!||	f ƒ |�r’|  	d"| ¡ |D ](}| j|d|	 d# |	g| |	|d$� �qt| jd|	 d ƒ}|  t|ƒ¡ |  d|	 d# ¡�r‚d| jd|	 < td%||	f ƒ ntd&||	f ƒ |�rì|  	d'| ¡ tƒ }|D ],}| j|| ¡ |d(� || j| ¡  7 }�q°|  t|ƒ¡ d S ))NZwith_zwith_%s_includezwith_%s_libzwith_%s_binzwith_%s_libsc                 S   s   g | ]}|  ¡ r|  ¡ ‘qS r   )Ústrip)Ú.0Úsr   r   r   Ú
<listcomp>G   s      z_configure.<locals>.<listcomp>ú,Z	CONFIGURE)ÚnoÚoffZfalsezA%s: skipping non mandatory %s, use --with-%s=[yes|<dir>] to force)ÚyesÚonÚtruez"Checking for %s in PKG_CONFIG_PATHz--cflagsz --libs)ÚpackageÚuselib_storeÚargsÚ	mandatoryÚHAVE_zlocated by pkg-configzmissing from pkg-configZincludeZ	INCLUDES_ÚlibZLIBPATH_ÚbinZPATH_zLocation for %s libsZ_LIB)r!   Údefine_nameÚuser   r   zLibs for %sÚLIB_é   z%s: HAVE %s libsz%s: NO %s libszLocation for %s headersZ_INC)Úheader_namer#   r$   r   r   z%s: HAVE %s includesz%s: NO %s includeszBins for %s)Úvarr   )r   ÚupperÚlistÚgetattrÚoptionsÚsplitr   ÚAssertionErrorÚanyÚ	start_msgZ	check_cfgÚenvÚend_msgÚospÚjoinÚsetattrÚ	check_cxxÚstrÚ
is_definedÚfind_program)Úctxr   r   r   ZbinsÚpcnamer   Úextusesr   ZUPPERÚinstdirZincdirÚlibdirÚbindirÚmayber   ZtrylZ	have_libsZtryhZ	have_incsZ
found_binsZtrybr   r   r   Ú
_configure9   sª    & ÿ
  ÿ
  ÿ
rA   )NN)r   r   r   NTr   )	Ú__doc__ÚsysÚos.pathÚpathr3   Úwaflib.Logsr   r   rA   r   r   r   r   Ú<module>   s
   $
