SubDir TOP plugins behaviourlayer python ;

if $(PYTHON.AVAILABLE) = yes
{
  #--------
  # Swig-generated files.
  #--------
  local blcelcpp = blcel.cpp ;
  local blcelpy = [ DoSourceGrist blcelc.py ] ;
  MakeLocate $(blcelpy) : $(LOCATE.TARGETS) ;

  if ! [ Property build : projgen ]
  {
    blcelcpp = [ DoSourceGrist $(blcelcpp) ] ;

    if $(CMD.SWIG)
    {
      Swig $(blcelcpp) $(blcelpy) :
        [ DoSourceGrist blcel.i ] :
        python :
	-c++ -shadow :
	[ ConcatDirs $(TOP) include ] $(CRYSTAL.INCLUDE_DIR) :
	:
	$(SEARCH_SOURCE) [ ConcatDirs $(TOP) scripts ] :
	blcel :
	[ on $(blcelpy) GetVar LOCATE ] ;
      Depends blpythonclean : blcelswigclean ;
    }
    else
    {
      SEARCH on $(blcelcpp) = $(SEARCH_SOURCE) ;
      local frozenpy = $(blcelpy:G=frozenblcelpy) ;
      SEARCH on $(frozenpy) = [ ConcatDirs $(TOP) scripts ] ;
      Copy $(blcelpy) : $(frozenpy) ;
      Depends $(blcelpy) : $(frozenpy) ;
    }
  }
  Clean blpythonclean : $(blcelpy) ;

  rule InstallCelPythonPY
  {
    # Temporary override for InstallData.
    local SUBDIR = [ on $(<) GetVar LOCATE ] ;
    InstallData $(<) : $(>) ;
  }
  InstallCelPythonPY $(blcelpy) : bindings python ;


  #--------
  # blpython plugin.
  #--------
  Plugin blpython : $(blcelcpp) blpython.cpp blpython.h pytocel.cpp ;
  LinkWith blpython : celtool ;
  ExternalLibs blpython : PYTHON CRYSTAL ;
  CFlags blpython :
    $(COMPILER.C++FLAGS.WARNING.NO_UNUSED) 
    $(COMPILER.C++FLAGS.WARNING.NO_UNINITIALIZED) ;
}
