//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_MODNUMSCI_path() //Input : nothing //Output : tt MODNUMSCI path (ex:/home/alan/modnum_3) function tt=def_MODNUMSCI_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, lines behavior and function protection sav_mode=mode(); mode(-1); sav_lines=lines(); sav_lines=sav_lines(2); lines(0); sav_prot=funcprot(); funcprot(0); //define MODNUMSCI path MODNUMSCI=def_MODNUMSCI_path(); clear def_MODNUMSCI_path; tt_path='MODNUMSCI'; //Search Scilab Version getf(MODNUMSCI+'/macros/build_util/find_scilab_ver.sci'); [ok]=find_scilab_ver(); if ~ok then printf("modnum toolbox source version only build with ScicosLab >=4.3\n"); abort end //open loader.sce file for writting ierror=execstr('u=mopen(MODNUMSCI+""/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(MODNUMSCI+'/macros/build_util/write_header.sci'); txt=write_header(u,'builer.sce',tt_path); ierr=execstr(txt,'errcatch'); //Build and load util macro library getf(MODNUMSCI+'/macros/build_util/build_lib.sci'); build_lib('/macros/build_util','modnum_build_util',tt_path); getf(MODNUMSCI+'/macros/build_util/write_inf_lib.sci'); txt=write_inf_lib(u,'/macros/build_util','modnum_build_util',1,tt_path); ierr=execstr(txt,'errcatch'); //Build and load all scilab library libs = ['find_file'; 'misc'; 'pll'; 'signal']; rep_lib = '/macros/'+libs; lib_name = 'modnum_'+libs; build_lib(rep_lib,lib_name); txt = write_inf_lib(u,rep_lib,lib_name,1,tt_path); ierr = execstr(txt,'errcatch'); //Build routines Library printf("Build modnum routines libraries\n"); //Build and load modnum_lib routines printf("Build modnum_lib C routines\n"); path='/../../src'; files=basename(listfiles(MODNUMSCI+path+'/*.c')); libnam="modnum_lib"; cflag="-DWITH_SCIFFT=1"; //update path of MODNUMSCI for ilib_for_link MODNUMSCI_path=MODNUMSCI; if MSDOS then MODNUMSCI_path=strsubst(MODNUMSCI,'\','\\'); end //Build modnum_lib rep=pwd(); if ~exists('Id_libmodnum_lib') then chdir(MODNUMSCI+path); ierr=execstr('ilib_for_link(files,files+''.o'',[],""c"",""Makelib"",""loader.sce"",libnam,"""",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 files, clear libnam; clear scifunc; clear intname; abort; end end txt=write_inf_rout_lib(u,'lib'+libnam,path,files,0,tt_path); ierr=execstr(txt,'errcatch'); //Build and load scilab interface of modnum_lib routines printf("Build Scilab interface of modnum_lib\n"); path='/gateway'; files=basename(listfiles(MODNUMSCI+path+'/*.c')); libnam="intmodnum_lib"; //set CFLAGS if MSDOS then cflag="-I"""+MODNUMSCI_path+"\\..\\..\\src"" -c"; else cflag="-I"""+MODNUMSCI_path+"/../../src"" -c"; end //set LDFLAGS if MSDOS then if fileinfo(MODNUMSCI+'/../../src/libmodnum_lib.ilib')<>[] then ldflag=" """+MODNUMSCI_path+"\\..\\..\\src\\libmodnum_lib.ilib""" else ldflag=" """+MODNUMSCI_path+"\\..\\..\\src\\libmodnum_lib.lib""" end else ldflag="" end //Build modnum_lib rep=pwd(); chdir(MODNUMSCI+path); ierr=execstr('ilib_for_link(files,files+''.o'',[],""c"",""Makelib"",""loader.sce"",libnam,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 files, clear libnam; clear scifunc; clear intname; abort; end //Define interfacing function scifunc=["autocorr";"awgn"; "demodpsk";"demodqam";"despread";"downsmpl"; "gengold";"genint";"genpn";"genrayl"; "intsym"; "modpsk";"modqam"; "nfilter"; "spread"; "upsmpl"]; intname="intmodnum_lib"; txt=write_addinter_line(u,'lib'+libnam,path,intname,scifunc); ierr=execstr(txt,'errcatch'); clear files, clear libnam; clear scifunc; clear intname; clear MODNUMSCI_path; clear files_c; clear libnam; clear rep; clear path; clear ierr; clear cflag; clear ldflag;clear i; //Build documentation and demos tt_help='myhelps=[MODNUMSCI+''/help/''+lang+''/htm'',... ""Modnum communication toolbox (Scilab)""];'; tt_demos=['add_demo(''Modnum (Scilab)'',... MODNUMSCI+''/demos/modnumsci.dem'');']; txt=write_inf_doc(u,tt_path,tt_help,tt_demos); ierr=execstr(txt,'errcatch'); //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(MODNUMSCI+'/loader.sce'); mputl(txt,MODNUMSCI+'/.scilab'); printf("Write a .scilab file\n"); end clear u; clear txt; clear ierr; clear ok; clear tt_help; clear tt_demos;clear tt_path; //retrieve original mode, lines behavior and function protection mode(sav_mode); lines(sav_lines); funcprot(sav_prot); clear sav_mode; clear sav_lines; clear sav_prot;