function ofc_oogmsh_install(varargin)
  v='0.0.14';
  v_fc_tools='0.0.17';
  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','',@ischar);
  p.parse(varargin{:});
  gmsh_bin=strtrim(p.Results.gmsh_bin);
  version=p.Results.version;
  fprintf('Parts of the GNU Octave <fc-oogmsh> package.\nCopyright (C) 2017 Francois Cuvelier <cuvelier@math.univ-paris13.fr>\n\n');

  fprintf('1- Downloading and extracting the packages\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> package\n');
  fprintf('   -> using "%s" binary for gmsh\n',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',gmsh_bin);
  cd(currentdir)
  fprintf('3- Using the <fc-oogmsh> package \n');
  fprintf('   Under Octave:\n')
  fprintf('     addpath(''%s'')\n',fc_oogmsh_dir)
  fprintf('     fc_oogmsh.init()\n')
  %logfile=[mfilename('fullpath'),'.log'];
  logfile=[currentdir,filesep,'ofc_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)
  file=sprintf('ofc-tools-%s.tar.gz',ver);
  urlfile=sprintf('http://www.math.univ-paris13.fr/~cuvelier/software/codes/fc-tools/%s/ofc-tools-%s.tar.gz',ver,ver);
  urlwrite(urlfile,file);
  try
    untar(file,dir)
  catch
    error('Unable to get :\n  -> %s\n',urlfile);
  end
  %fprintf('Getting <fctools>[%s] toolbox\n',ver)
  fulldir=fullfile(pwd,sprintf('%s%sofc-tools-%s',dir,filesep,ver));
end


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


