//builder.sce //build modnum_3 package for scilab-3.0 //both linux and windob(with lcc) //13-10-2004 Alan // //Modification : 4/4/2005 //builder rewritten with scilab function //Improvment : Build with VC++ // //Modif. : 13/09/2006 //routines building process reviewed. //works now with ilib_for_link. //rmk : building process no more supported // for scilab-3.0,3.1 // //Modif. : 14/04/2007 //review for windows compilation // // REVISION HISTORY : // $Log$ // //def_MODNUM_path() //Input : nothing //Output : tt MODNUM path (ex:/home/alan/modnum_3) function tt=def_MODNUM_path() tt=get_absolute_file_path('builder.sce'); end_char=part(tt,length(tt)); if end_char=='/'|end_char=='\' then tt=part(tt,1:length(tt)-1); end endfunction //change mode and lines behavior sav_mode=mode(); mode(-1); sav_lines=lines(); sav_lines=sav_lines(2); lines(0); //define MODNUM path MODNUM=def_MODNUM_path(); //Search Scilab Version getf(MODNUM+'/macros/build_util/find_scilab_ver.sci'); [ok]=find_scilab_ver(); if ~ok then printf("modnum toolbox source version only build with scilab >=4.0\n"); abort end //open loader.sce file for writting ierror=execstr('u=mopen(MODNUM+""/loader.sce"",""w"");','errcatch'); if ierror<>0 then printf("Can''t write loader file.\nVerify your writting access.\n"); end clear ierror; //write Header of loader.sce file getf(MODNUM+'/macros/build_util/write_header.sci'); write_header(u,'builer.sce') //Build and load util macro library getf(MODNUM+'/macros/build_util/build_lib.sci'); build_lib('/macros/build_util','modnum_build_util'); getf(MODNUM+'/macros/build_util/write_inf_lib.sci'); txt=write_inf_lib(u,'/macros/build_util','modnum_build_util',1); ierr=execstr(txt,'errcatch'); //Build and load all scilab library libs=['misc';'signal';'scicos_util';'find_file']; rep_lib='/macros/'+libs; lib_name='modnum_'+libs; build_lib(rep_lib,lib_name); txt=write_inf_lib(u,rep_lib,lib_name,1); ierr=execstr(txt,'errcatch'); //Build and load palette of scicos_blocks pal=['Communication';'Filter';'NonLinear';'Pll';'Sinks';'Sources';'Tools';'Old';'OldSinks']; rep_pal='/macros/scicos_blocks/'+pal; pal_name=['com';'filter';'nonlinear';'pll';'sinks';'sources';'tools';'old';'oldsinks']; pal_title='modnum_'+pal; lib_name='modnum_'+pal_name+'_pal'; build_lib(rep_pal,lib_name); fprintf(u,"%s\n",'//Load modnum scicos_blocks library'); txt=write_inf_lib(u,rep_pal,lib_name,0); ierr=execstr(txt,'errcatch'); //Generate palette of scicos_blocks for i=1:size(rep_pal,"*") files_sci=basename(listfiles(MODNUM+rep_pal(i)+"/*.sci")); //18/03/07 : patch to properly sort communication blocks if pal(i)=='Communication' then kk=[]; kk=[kk,find(files_sci=='MODQAM_f')] kk=[kk,find(files_sci=='DEMODQAM_f')] kk=[kk,find(files_sci=='MODPSK_f')] kk=[kk,find(files_sci=='DEMODPSK_f')] jj=find(files_sci<>'DEMODQAM_f'&... files_sci<>'DEMODPSK_f'&... files_sci<>'MODQAM_f'&... files_sci<>'MODPSK_f') files_sci=[files_sci(kk);files_sci(jj)]; clear kk; clear jj, end generate_palette(files_sci,MODNUM+'/macros/scicos_blocks/',pal(i)); end txt=write_inf_pal(u,rep_pal+'.cosf',pal_title); ierr=execstr(txt,'errcatch'); clear txt;clear pal_title;clear lib_name;clear rep;clear rep_pal; clear ierr;clear files_sci;clear i; clear pal; //Build routines Library printf("Build modnum routines libraries\n"); //Build and load modnum_lib routines printf("Build modnum_lib C routines\n"); path='/routines/modnum_lib'; files=basename(listfiles(MODNUM+path+'/*.c')); libnam="modnum_lib"; //Define interfacing function scifunc=["genint";"modpsk";"surecht"]; intname="intmodnum_lib"; //Build modnum_lib rep=pwd(); chdir(MODNUM+path); ierr=execstr('ilib_for_link(files,files+''.o'',[],""c"",""Makelib"",""loader.sce"",libnam);','errcatch') chdir(rep); if ierr<>0 then printf("\n Error during compilation inside scilab.\n"+... " Building process of modnum aborted.\n"); mclose(u); clear files, clear libnam; clear scifunc; clear intname; abort; end txt=write_inf_rout_lib(u,'lib'+libnam,path,files,0); ierr=execstr(txt,'errcatch'); txt=write_addinter_line(u,'lib'+libnam,path,intname,scifunc); ierr=execstr(txt,'errcatch'); clear files, clear libnam; clear scifunc; clear intname; //Build and load scicos C routines printf("Build scicos blocks C routines\n"); //def path of routines path=['/routines/scicos/communication'; '/routines/scicos/filter'; '/routines/scicos/nonlinear'; '/routines/scicos/old'; '/routines/scicos/other'; '/routines/scicos/pll'; '/routines/scicos/sinks'; '/routines/scicos/sources'; '/routines/scicos/tools']; //def name of libraries libnam=["modnum_comm_c"; "modnum_filt_c"; "modnum_nlin_c"; "modnum_old_c"; "modnum_oth_c"; "modnum_pll_c"; "modnum_sink_c"; "modnum_src_c"; "modnum_tool_c"]; //update path of MODNUM for ilib_for_link MODNUM_path=MODNUM; if MSDOS then MODNUM_path=strsubst(MODNUM,'\','\\'); end //loop on number of libraries for i=1:size(libnam,1) //get c function files/names files_c=basename(listfiles(MODNUM+path(i)+'/*.c')); //set CFLAGS if libnam(i)=="modnum_sink_c" then //special case for sinks (for NG) if MSDOS then cflag="-I"""+MODNUM_path+"\\routines\\modnum_lib"" "+... "-I""$(SCIDIR)\\routines\\scicos"" "+... "-I""$(SCIDIR)\\routines\\f2c"" "+... "-I""$(SCIDIR)\\routines\\graphics"" -c"; else cflag="-I"""+MODNUM_path+"/routines/modnum_lib"" "+... "-I""$(SCIDIR)/routines/scicos"" "+... "-I"""+MODNUM_path+"/routines/sci_headers/f2c"" "+... "-I"""+MODNUM_path+"/routines/sci_headers/graphics"" -c" end else if MSDOS then cflag="-I"""+MODNUM_path+"\\routines\\modnum_lib"" "+... "-I""$(SCIDIR)\\routines\\scicos"" "+... "-I""$(SCIDIR)\\routines\\f2c"" -c"; else cflag="-I"""+MODNUM_path+"/routines/modnum_lib"" "+... "-I""$(SCIDIR)/routines/scicos"" "+... "-I"""+MODNUM_path+"/routines/sci_headers/f2c"" -c"; end end //set LDFLAGS if MSDOS then if fileinfo(MODNUM+'/routines/modnum_lib/libmodnum_lib.ilib')<>[] then ldflag=" """+MODNUM_path+"\\routines\\modnum_lib\\libmodnum_lib.ilib""" else ldflag=" """+MODNUM_path+"\\routines\\modnum_lib\\libmodnum_lib.lib""" end else ldflag="" end chdir(MODNUM+path(i)); //run ilib_for_link ierr=execstr('ilib_for_link(files_c,files_c+''.o'',[],""c"",""Makelib"",""loader.sce"",libnam(i),ldflag,cflag);',... 'errcatch'); chdir(rep); if ierr<>0 then printf("\n Error during compilation inside scilab.\n"+... " Building process of modnum aborted.\n"); mclose(u); clear MODNUM_path; clear files_c; clear libnam; clear rep; clear path; clear ierr; clear cflag; clear ldflag;clear i; abort; end //write info for loading routines in loader.sce txt=write_inf_rout_lib(u,'lib'+libnam(i),path(i),files_c,1); ierr=execstr(txt,'errcatch'); end clear MODNUM_path; clear files_c; clear libnam; clear rep; clear path; clear ierr; clear cflag; clear ldflag;clear i; //Build documentation and demos txt=write_inf_doc(u); ierr=execstr(txt,'errcatch'); if ierr==0 then %helps=%helps; end //build_demo(); //flag_doc=build_doc(); //Close loader.sce mclose(u); printf("Write a loader.sce file\n"); //write a .scilab file if ~MSDOS then txt=mgetl(MODNUM+'/loader.sce'); mputl(txt,MODNUM+'/.scilab'); printf("Write a .scilab file\n"); end clear u; clear txt; clear ierr; clear ok; //retrieve original mode and lines behavior mode(sav_mode); lines(sav_lines); clear sav_mode; clear sav_lines;