/*  Formed links        */ arg fn
fn=word(fn,1)
fi='b_' || fn || '.c'
say 'input file => ' fi
if lines(fi) = 0 then do
   say 'File <'fi'>not found'
   exit
end
fo=fn || '.lnk'
fd=fn || '.def'
say 'Create file ' fo ' and command => Link386 @'fi
/* say 'You can correct file ' fo '(change string for *.def)' */
'del' fo
s='/st:1048576/pm:vio/noi/a:16/e/bas:65536/nol +' ; r=lineout(fo,s)
s='b_' || fn || '.obj+'                           ; r=lineout(fo,s)
s=fn || '.obj+'                                   ; r=lineout(fo,s)
s=fn || 'DP.obj+'                                 ; r=lineout(fo,s)
s='d:\emx\lib\crt0.obj+ '                         ;r=lineout(fo,s)
/* s='d:\emx\lib\apiadd.obj+ '                       ;r=lineout(fo,s) */
do forever;     s=linein(fi);
   if pos('BEGIN',s)>0 then leave;
end;
ii=0;
do forever;     s=linein(fi); k=pos('.o',s);
   if k>0 then  s=substr(s,1,k) || 'obj';
   k=pos('./',s); if k=1 then s=substr(s,3);
   if pos('END',s)>0 then leave;
   ii=ii+1;
   s=s || '+' ;
   strout.ii = s;
end;
i=pos('+',strout.ii);  strout.ii = left(strout.ii,i-1);
do i=1 to ii;  r=lineout(fo,strout.i); end;
r=lineout(fo,fn);    /* EXE name  */
r=lineout(fo,fn);    /* MAP name  */
/*   -----------   Libraries       ------------------ */
s='d:\emx\lib\gnat305+'   ; r=lineout(fo,s);
s='d:\emx\lib\c_alias+'   ; r=lineout(fo,s);
s='d:\emx\lib\gcc+'       ; r=lineout(fo,s);
s='d:\emx\lib\mt\sys+'    ; r=lineout(fo,s);
s='d:\emx\lib\mt\c+'      ; r=lineout(fo,s);
s='d:\emx\lib\mt\c_app+'  ; r=lineout(fo,s);
s='d:\emx\lib\gsysoi1d+'  ; r=lineout(fo,s);  /* JBA library */
s='d:\emx\lib\jbainter+'  ; r=lineout(fo,s);  /* JBA library */
s='d:\emx\lib\os2'        ; r=lineout(fo,s);
s='type ' || fd || '>nul'
s
if rc=0 then s=fd; else s=' '
r=lineout(fo,s);
say 'Creating file ' fo
say '----- W A R N I N G ------  this file may be correct by adding *.obj files'
say 'pull any key'
pull answer;
s='link386 @'|| fo
s
exit
