% Make static version of mdsipmex from latest libraries
% Basil P. DUVAL SPC/EPFL, February 2021, Lausanne, Switzerland
% (Use Shared flag to employ distribution in /usr/local/mdsplus and then link statically)
%Note: for mdsconnect('ssh://XyZ') to function, mdsip-client-ssh must be put into $PATH
%clear all;setenv('MDSPLUS',[getenv('HOME'),'/PLAY/mdsplus']);make_mdsipmex_static
%clear all;setenv('MDSPLUS',[getenv('HOME'),'/NoTivoli/mdsplus']);make_mdsipmex_static
% cp /usr/lib64/libc.a ./
% ar dv libc.a getpwuid.o getaddrinfo.o malloc.o inet_ntoa.o getsrvbynm.o
%
MDSPLUS=getenv('MDSPLUS');dirs='/';
if(length(MDSPLUS)==0);MDSPLUS='/usr/local/mdsplus';end

r={'libMdsIpShr.a','libTreeShr.a','libMdsShr.a'};

%
comm = sprintf('mex -g -DPASSWD -DSHARED -DNODL mdsipmex.c LoadIo.c xmlbits.c %s%smdstcpip/IoRoutinesTcp.c -I%s%sinclude -I%s%smdstcpip ',...
       MDSPLUS,dirs,MDSPLUS,dirs,MDSPLUS,dirs);

% add all the routines using the given path
for(i=1:length(r))
   comm = sprintf('%s %s/lib/%s',comm,MDSPLUS,char(r(i)));end
%comm = [comm,' -ldl'];
comm = [comm,' libc.a'];
disp(comm);eval(comm);
