function mfc_oogmsh_install(varargin)
  v='0.0.11';
  v_fc_tools='0.0.14';
  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('gmsh_bin','/usr/bin/gmsh',@ischar);
  p.parse(varargin{:});
  version=p.Results.version;
  fprintf('Parts of the Matlab <fc-oogmsh> toolbox.\nCopyright (C) 2016 Francois Cuvelier <cuvelier@math.univ-paris13.fr>\n\n');
  fprintf('1- Downloading and extracting the toolboxes\n');
  fprintf('   -> <fc-tools>[%s] ...',p.Results.fc_tools)
  fc_tools_dir=get_inst_fc_tools(p.Results.fc_tools,p.Results.dir);
  fprintf(' OK\n');
  fprintf('   -> <fc-oogmsh>[%s] ...',p.Results.version)
  fc_oogmsh_dir=get_inst_fc_oogmsh(p.Results.version,p.Results.dir);
  fprintf(' OK\n');
  currentdir=pwd;
  cd(fc_oogmsh_dir)
  fprintf('2- Setting the <fc-oogmsh> toolbox\n');
  mkdir(fc_oogmsh_dir,'meshes');
  fprintf('   -> using "%s" binary for gmsh\n',p.Results.gmsh_bin);
  fprintf('      run fc_oogmsh.configure(''gmsh_bin'',''<PATH>/gmsh'') to change\n')
  fc_oogmsh.configure('fc_tools_dir',fc_tools_dir,'gmsh_bin',strtrim(p.Results.gmsh_bin));
  cd(currentdir)
  fprintf('3- Using the <fc-oogmsh> toolbox \n');
  fprintf('   Under Matlab:\n')
  fprintf('     addpath(''%s'')\n',fc_oogmsh_dir)
  fprintf('     fc_oogmsh.init()\n')
  %logfile=[mfilename('fullpath'),'.log'];
  logfile=[currentdir,filesep,'mfc_oogmsh_set.m'];
  fprintf('\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 fulldir=get_inst_fc_tools(ver,dir)
  urlfile=sprintf('http://www.math.univ-paris13.fr/~cuvelier/software/codes/fc-tools/%s/mfc-tools-%s.tar.gz',ver,ver);
  try
    untar(urlfile,dir)
  catch
    error('Unable to get :\n  -> %s\n',urlfile);
  end
  %fprintf('Getting <fctools>[%s] toolbox\n',ver)
  fulldir=fullfile(pwd,sprintf('%s%smfc-tools-%s',dir,filesep,ver));
end


function fulldir=get_inst_fc_oogmsh(ver,dir)
  urlfile=sprintf('http://www.math.univ-paris13.fr/~cuvelier/software/codes/fc-oogmsh/%s/mfc-oogmsh-%s.tar.gz',ver,ver);
  try
    untar(urlfile,dir)
  catch
    error('Unable to get :\n  -> %s\n',urlfile);
  end
  %fprintf('Getting <fc-oogmsh>[%s] toolbox\n',ver)
  fulldir=fullfile(pwd,sprintf('%s%smfc-oogmsh-%s',dir,filesep,ver));
end


