function mfc_graphics4mesh_install(varargin)
  v='0.0.2';
  v_fc_tools='0.0.19';
  p = inputParser; 
  p.addParamValue('version', v, @ischar ); % default - dim=-1 has
  p.addParamValue('dir', './fc-graphics4mesh-full', @ischar );
  p.addParamValue('fc_tools',v_fc_tools , @ischar ); % fc_tools version
  p.parse(varargin{:});
  version=p.Results.version;
  
  fprintf('1- Downloading and extracting the toolboxes\n');
  fprintf('   -> <fc-tools>[%s] ...',p.Results.fc_tools)
  fc_tools_dir=get_inst_fc_gen('tools',p.Results.fc_tools,p.Results.dir);
  fprintf(' OK\n');
  fprintf('   -> <fc-graphics4mesh>[%s] ...',p.Results.version)
  fc_graphics4mesh_dir=get_inst_fc_gen('graphics4mesh',p.Results.version,p.Results.dir);
  fprintf(' OK\n');
  currentdir=pwd;
  cd(fc_graphics4mesh_dir)
  fprintf('2- Setting the <fc-graphics4mesh> toolbox\n');
  fc_graphics4mesh.configure('fc_tools_dir',fc_tools_dir);
  cd(currentdir)
  fprintf('3- Using the <fc-graphics4mesh> toolbox \n');
  fprintf('   Under Matlab:\n')
  fprintf('     addpath(''%s'')\n',fc_graphics4mesh_dir)
  fprintf('     fc_graphics4mesh.init()\n')
  %logfile=[mfilename('fullpath'),'.log'];
  logfile=[currentdir,filesep,'mfc_graphics4mesh_set.m'];
  fprintf('\n   See %s\n',logfile);
  fid=fopen(logfile,'w');
  fprintf(fid,'addpath(''%s'')\n',fc_graphics4mesh_dir);
  fprintf(fid,'fc_graphics4mesh.init()\n');
  fclose(fid);
end

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

