ó
lñc]c           @   s°   d  d l  Z  d  d l j Z d  d l Z d  d l Z d  d l m Z e j e j	 e
   Z d   Z e e d   Z d   Z e d d d d   Z e d d d   Z d S(	   iÿÿÿÿN(   t   confc         C   s,   |  j  d  }  |  j d d d  d d d  S(   Ns   ROOT Optionss   --with-roott   defaultt   helps   give ROOT installation location(   t   add_option_groupt
   add_optiont   None(   t   opt(    (    s   waftools/rootsys.pyt   options
   s    c         C   s  |  j  j } | rB | j   d k rB | r9 t d   n  d GHd  S|  j j d g 7_ t   } xQ t |  j  d d   t	 j
 d d   g D]( } | r | j t j | d	   q q Wt d
 |  } |  j d d d d | | d |  j k r| rt d   n  d GHd  S|  j d |  j d d d d d d d d |  |  j j d d d g 7_ |  j d d d d
 | d | |  j d d d d d |  d  S(    Nt   not   offt   falses/   ROOT is mandatory but disabled via command lines1   optional ROOT dependency disabled by command lines   -fPICt	   with_roott   ROOTSYSt   bint	   path_lists   root-configt   vars   ROOT-CONFIGt	   mandatorys'   root-config not found but ROOT requireds5   skipping non mandatory ROOT, use --with-root to forcet   patht   uselib_storet   argss   --cflags --libs --ldflagst   packaget    t   Minuit2t
   TreePlayert   EGt	   rootclingt	   ROOTCLINGt   header_names   Rtypes.ht   use(   R   R	   R
   (   R   R   t   lowert   RuntimeErrort   envt   CXXFLAGSt   listt   getattrR   t   ost   getenvt   appendt   ospt   joint   dictt   find_programt	   check_cfgt   LIB_ROOTSYSt	   check_cxx(   t   cfgR   t   instdirR   t   topdirt   kwargs(    (    s   waftools/rootsys.pyt
   check_root   s2    	. c         C   s   |  j    d  S(   N(   R1   (   R-   (    (    s   waftools/rootsys.pyt	   configure8   s    R   c      	   C   sÅ  t  j j |  d g } t  j j |  } x) | D]! } |  j d | } | | 7} q2 Wt   } xb | D]Z }	 |	 j d  r d |	 }
 n d |  j j |	  j   }
 |
 | k rg | j	 |
  qg qg Wd j
 |  } | d } d | d } d | d	 } | d
 } t |  t d  k r1|  j j |  } n  | | g } d j
 g  | D] } | j   ^ qK } d | | | f } |  d | d | | | g d | d |  |  j d |  |  j d |  d S(   sn   
    rootcling -f NAMEDict.cxx -rml libNAME.so -rmf libNAME.rootmap myHeader1.h myHeader2.h ... LinkDef.h
    R   t	   INCLUDES_t   /s   -I%st    s   Dict.cxxt   libs   .sos   .rootmaps   Dict_rdict.pcmR   sJ   ${ROOTCLING} -f ${TGT[0].abspath()} -rml %s -rmf ${TGT[1].abspath()} %s %st   sourcet   targett   ruleR   s   ${PREFIX}/lib/N(   t   waflibt   Utilst   to_listR   R!   t
   startswithR   t   find_dirt   abspathR%   R'   t   typet   find_resourcet   install_files(   t   bldt   namet   linkdeft   headerst   includesR   t   ut   moret   incst   inct   newinct   dict_srct   dict_libt   dict_mapt   dict_pcmt   source_nodest   xt   sourcesR9   (    (    s   waftools/rootsys.pyt   gen_rootcling_dict;   s6    	

(c   	   	   C   sô   t  j j |  } g  t  j j |  D]" } d |  j j |  j   ^ q% } d j |  } | d } |  d | | g d | d d |  |  j d | d | d d	 | d
 d  d | } |  d | g d | d d | | f  |  j d |  d S(   sq   Generate a rootcint dictionary, compile it to a shared lib,
    produce its rootmap file and install it all.
    s   -I%sR5   s   Dict.cxxR7   R8   R9   s"   ${ROOTCINT} -f ${TGT} -c %s ${SRC}t   DictRG   R   R   s   lib%sDict.rootmaps:   ${RLIBMAP} -o ${TGT} -l lib%sDict.so -d lib%s.so -c ${SRC}s   ${PREFIX}/lib/N(	   R:   R;   R<   R   R>   R?   R'   t   shlibRB   (	   RC   RD   RE   RF   RG   RR   RJ   RM   t   rootmap(    (    s   waftools/rootsys.pyt   gen_rootcint_dictn   s    ;


(   R#   t   os.pathR   R&   R:   t   waflib.Utilst   waflib.ConfigureR    t   dirnameR?   t   __file__t   _tooldirR   t   FalseR1   R2   RT   RX   (    (    (    s   waftools/rootsys.pyt   <module>   s   	'	2