function mfc_oogmsh_install(varargin)
  v='0.0.17';
  v_fc_tools='0.0.20';
  p = inputParser; 
  p.addParamValue('version', v, @ischar ); % default - dim=-1 has
  p.addParamValue('dir', './fc-oogmsh-full', @ischar );
  p.addParamValue('fc_tools',v_fc_tools , @ischar ); % fc_tools version
  p.addParamValue('verbose', 1, @(x) ismember(x,0:2) ); % level of verbosity 
  p.addParamValue('gmsh_bin','',@ischar);
  p.parse(varargin{:});
  gmsh_bin=strtrim(p.Results.gmsh_bin);
  version=p.Results.version;
  verbose=p.Results.verbose;
  
  vprintf(verbose,1,'Parts of the Matlab <fc-oogmsh> toolbox.\nCopyright (C) 2017 Francois Cuvelier <cuvelier@math.univ-paris13.fr>\n\n');
  vprintf(verbose,1,'1- Downloading and extracting the toolboxes\n');
  vprintf(verbose,2,'   -> <fc-tools>[%s] ...',p.Results.fc_tools)
  fc_tools_dir=get_inst_fc_gen('tools',p.Results.fc_tools,p.Results.dir);
  vprintf(verbose,2,' OK\n');
  vprintf(verbose,2,'   -> <fc-oogmsh>[%s] ...',p.Results.version)
  fc_oogmsh_dir=get_inst_fc_gen('oogmsh',p.Results.version,p.Results.dir);
  vprintf(verbose,2,' OK\n');
  
  currentdir=pwd;
  cd(fc_oogmsh_dir)
  vprintf(verbose,1,'2- Setting the <fc-oogmsh> toolbox\n');
  mkdir(fc_oogmsh_dir,'meshes');
  if length(gmsh_bin)>0
    vprintf(verbose,2,'   -> using "%s" binary for gmsh\n',gmsh_bin);
  end
  vprintf(verbose,2,'      run fc_oogmsh.configure(''gmsh_bin'',''<PATH>/gmsh'') to change\n')
  fc_oogmsh.configure('fc_tools_dir',fc_tools_dir,'gmsh_bin',gmsh_bin);
  cd(currentdir)
  
  vprintf(verbose,1,'3- Using toolboxes :\n');
  vprintf(verbose,1,'   -> %20s : %s\n','fc-tools',p.Results.fc_tools)
  vprintf(verbose,1,'   -> %20s : %s\n','fc-oogmsh',p.Results.version)
  vprintf(verbose,1,'*** Using instructions \n');
  vprintf(verbose,1,'   To use the <fc-oogmsh> toolbox:\n');
  vprintf(verbose,1,'   addpath(''%s'')\n',fc_oogmsh_dir);
  vprintf(verbose,1,'   fc_oogmsh.init()\n');
  
  logfile=[currentdir,filesep,'mfc_oogmsh_set.m'];
  vprintf(verbose,1,'\n   See %s\n',logfile);
  fid=fopen(logfile,'w');
  fprintf(fid,'addpath(''%s'')\n',fc_oogmsh_dir);
  fprintf(fid,'fc_oogmsh.init()\n');
  fclose(fid);
end


function vprintf(verbose,level,varargin)
  if verbose>=level, fprintf(varargin{:});end
end

function fulldir=get_inst_fc_gen(name,ver,dir)
  file=sprintf('mfc-%s-%s.tar.gz',name,ver);
  urlfile=sprintf('http://www.math.univ-paris13.fr/~cuvelier/software/codes/Matlab/fc-%s/%s/fc_%s-%s.tar.gz',name,ver,name,ver);
  urlwrite(urlfile,file);
  try
    untar(file,dir)
  catch
    error('Unable to get :\n  -> %s\n',urlfile);
  end
  fulldir=fullfile(pwd,sprintf('%s%sfc_%s-%s',dir,filesep,name,ver));
end
