diff options
author | jofret | 2010-06-21 06:24:38 +0000 |
---|---|---|
committer | jofret | 2010-06-21 06:24:38 +0000 |
commit | 8b44229ef44f0558ce045e46ff833fb44df913c9 (patch) | |
tree | 4fdd89b2258c18c905d2f17ef4bea8ea9cf32893 /macros/CCodeGeneration | |
parent | af0366230e14cc75d9e9a183375ee9cb69fb46b6 (diff) | |
download | scilab2c-release-2.0.tar.gz scilab2c-release-2.0.tar.bz2 scilab2c-release-2.0.zip |
Tagging the 2.0 release of scilab2crelease-2.0
Diffstat (limited to 'macros/CCodeGeneration')
27 files changed, 3385 insertions, 0 deletions
diff --git a/macros/CCodeGeneration/C_FinalizeCode.sci b/macros/CCodeGeneration/C_FinalizeCode.sci new file mode 100644 index 00000000..5c26dd85 --- /dev/null +++ b/macros/CCodeGeneration/C_FinalizeCode.sci @@ -0,0 +1,87 @@ +function C_FinalizeCode(FileInfo,SharedInfo) +// function C_FinalizeCode(FileInfo,SharedInfo) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +// --- Load File Info Structure. --- +load(FileInfoDatFile,'FileInfo'); + +// --- Load Shared Info Structure. --- +load(FileInfo.SharedInfoDatFile,'SharedInfo'); + +CPass2FileName = FileInfo.Funct(SharedInfo.NextSCIFunNumber).CPass2FileName; +FinalCFileName = FileInfo.Funct(SharedInfo.NextSCIFunNumber).FinalCFileName; +Pass1HeaderFileName = FileInfo.Funct(SharedInfo.NextSCIFunNumber).Pass1HeaderFileName; +FinalHeaderFileName = FileInfo.Funct(SharedInfo.NextSCIFunNumber).FinalHeaderFileName; +// #RNU_RES_B +PrintStringInfo('Generating the final C code in:'+FinalCFileName,... + FileInfo.Funct(SharedInfo.NextSCIFunNumber).ReportFileName,'file','y'); +// #RNU_RES_E +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// --------------------------------- +// --- Finalize the header file. --- +// --------------------------------- +PrintStringInfo('/*',Pass1HeaderFileName,'file','y'); +PrintStringInfo('** ---------------------------- ',Pass1HeaderFileName,'file','y'); +PrintStringInfo('** --- End USER2C Includes. --- ',Pass1HeaderFileName,'file','y'); +PrintStringInfo('** ---------------------------- ',Pass1HeaderFileName,'file','y'); +PrintStringInfo('*/',Pass1HeaderFileName,'file','y'); +PrintStringInfo('#endif',Pass1HeaderFileName,'file','y'); +// ------------------------------------- +// --- End Finalize the header file. --- +// ------------------------------------- + +[tmphdrpath,tmphdrname,tmphdrext] = fileparts(Pass1HeaderFileName); + +// #RNU_RES_B +// -------------------------------------------------- +// --- Copy the C code into the C code directory. --- +// -------------------------------------------------- +// #RNU_RES_E +C_SCI2CHeader(FinalCFileName); +PrintStringInfo('/*',FinalCFileName,'file','y'); +PrintStringInfo('** ----------------- ',FinalCFileName,'file','y'); +PrintStringInfo('** --- Includes. --- ',FinalCFileName,'file','y'); +PrintStringInfo('** ----------------- ',FinalCFileName,'file','y'); +PrintStringInfo('*/',FinalCFileName,'file','y'); +PrintStringInfo('#include ""'+tmphdrname+tmphdrext+'""',... + FinalCFileName,'file','y'); +PrintStringInfo('/*',FinalCFileName,'file','y'); +PrintStringInfo('** --------------------- ',FinalCFileName,'file','y'); +PrintStringInfo('** --- End Includes. --- ',FinalCFileName,'file','y'); +PrintStringInfo('** --------------------- ',FinalCFileName,'file','y'); +PrintStringInfo('*/',FinalCFileName,'file','y'); +PrintStringInfo(' ',FinalCFileName,'file','y'); +PrintStringInfo(' ',FinalCFileName,'file','y'); +PrintStringInfo(' ',FinalCFileName,'file','y'); +SCI2Ccopyfile(CPass2FileName,... + FinalCFileName,'append'); +SCI2Ccopyfile(Pass1HeaderFileName,... + FinalHeaderFileName,'append'); + + +endfunction diff --git a/macros/CCodeGeneration/C_ForExpression.sci b/macros/CCodeGeneration/C_ForExpression.sci new file mode 100644 index 00000000..4e75c066 --- /dev/null +++ b/macros/CCodeGeneration/C_ForExpression.sci @@ -0,0 +1,217 @@ +function SharedInfo = C_ForExpression(FileInfo,SharedInfo) +// function SharedInfo = C_ForExpression(FileInfo,SharedInfo) +// ----------------------------------------------------------------- +// Get function for a generic SCI2C table. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 15-Nov-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; + +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName; +CPass1ForProlFileName = FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level); +CDeclarationFileName = FileInfo.Funct(nxtscifunnumber).CDeclarationFileName; +CPass1ForEpilFileName = FileInfo.Funct(nxtscifunnumber).CPass1ForEpilFileName(SharedInfo.For.Level); + +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Generating C code***',ReportFileName,'file','y','n'); +// #RNU_RES_E +CCall =''; +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// ---------------------------- +// --- Generate the C call. --- +// ---------------------------- + +// ------------------------- +// --- Manage all cases. --- +// ------------------------- +if (SharedInfo.ForExpr.AssignmentFun == SharedInfo.CFunId.EqScalar) + // #RNU_RES_B + // --------------- + // --- Case 1. --- + // --------------- + PrintStringInfo(' Handling For Expression with scalar equal.',ReportFileName,'file','y'); + + // for a = 10 or for a = sin(tan(b)) where b is scalar: + // In this case non for loops are needed.--> Do nothing! + + // ------------------------------------------------------------------------------------- + // --- Generate Prologue and Epilogue -> Copy the first N-1 lines of the for.c code. --- + // ------------------------------------------------------------------------------------- + // #RNU_RES_E + [C_Strings,NumCStrings] = File2StringArray(FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level)); + C_Strings = stripblanks(C_Strings); + + for cntstr = 1:NumCStrings + // #RNU_RES_B + // Prologue + // #RNU_RES_E + PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+C_Strings(cntstr),CPass1FileName,'file','y'); + end + // #RNU_RES_B + // Epilogue + // #RNU_RES_E + PrintStringInfo(' ',CPass1ForEpilFileName ,'file','y'); + +elseif (SharedInfo.ForExpr.AssignmentFun == SharedInfo.CFunId.OpColon) + // #RNU_RES_B + // --------------- + // --- Case 2. --- + // --------------- + // for a = 1:10 + PrintStringInfo(' Handling For Expression with OpColon.',ReportFileName,'file','y'); + // #RNU_RES_E + + // #RNU_RES_B + // ------------------------------------------------------------------------------------- + // --- Generate Prologue and Epilogue -> Copy the first N-1 lines of the for.c code. --- + // ------------------------------------------------------------------------------------- + // #RNU_RES_E + [C_Strings,NumCStrings] = File2StringArray(FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level)); + C_Strings = stripblanks(C_Strings); + for cntstr = 1:NumCStrings + // #RNU_RES_B + // Prologue + // #RNU_RES_E + PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+C_Strings(cntstr),CPass1FileName,'file','y','n'); + // #RNU_RES_B + // Epilogue + // #RNU_RES_E + if (length(C_Strings(cntstr)) == 0) + C_Strings(cntstr) = ' '; // RNU for Bruno: If I don't do that I get a PrintStringInfo error related to mputstr. + // Function not defined for given argument type(s),
+ // check arguments or define function %0_mputstr for overloading. + end + PrintStringInfo(string(C_Strings(cntstr)),CPass1ForEpilFileName ,'file','y','n'); + end + // #RNU_RES_B + // ---------------------------------------- + // --- Insert "}" in the epilogue file. --- + // ---------------------------------------- + // #RNU_RES_E + PrintStringInfo('}',CPass1ForEpilFileName ,'file','y'); + + // #RNU_RES_B + // ------------------------------ + // --- Insert for expression. --- + // ------------------------------ + // #RNU_RES_E + CCall = 'for('+SharedInfo.ForExpr.SclValCntArg.Name+' = '+SharedInfo.ForExpr.OpColonInfoIn1+'; '... + +SharedInfo.ForExpr.SclValCntArg.Name+' <= '+SharedInfo.ForExpr.OpColonInfoIn3+'; '... + +SharedInfo.ForExpr.SclValCntArg.Name+' += '+SharedInfo.ForExpr.OpColonInfoIn2+')'; + PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + + // #RNU_RES_B + // ------------------- + // --- Insert "{". --- + // ------------------- + // #RNU_RES_E + CCall = '{'; + PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + + // --------------------------------- + // --- Update Indentation Level. --- + // --------------------------------- + SharedInfo.NIndent = SharedInfo.NIndent + 1; + +elseif (SharedInfo.ForExpr.AssignmentFun == SharedInfo.CFunId.EqMatrix | ... + SharedInfo.ForExpr.AssignmentFun == SharedInfo.CFunId.GenFunMtx) + // #RNU_RES_B + // --------------- + // --- Case 3. --- + // --------------- + PrintStringInfo(' Handling For Expression with Matrix Equal/Function.',ReportFileName,'file','y'); + + // for cnt = TMP where TMP is a matrix + // for cnt = fun(TMP) where TMP is a matrix + // Conversion is performed as shown in the following example: + // init code for temp vars --> copy all for.c code (up to last-1 line) into C pass1 code. + // intSCI2C __forcnt1; --> declaration file. + // replace in the last C line CntArg.Name with '__TmpVal'+CntArg.Name + // for (__forcnt1 = 0; __forcnt1 < CntArg.Size(1)*CntArg.Size(2); __forcnt1++) + // { + // CntArg.Name = '__TmpVal'+CntArg.Name[__forcnt1]; + // init code for temp vars + // } + + // ------------------------------------------------------------------------------------- + // --- Generate Prologue and Epilogue -> Copy the first N-1 lines of the for.c code. --- + // ------------------------------------------------------------------------------------- + // #RNU_RES_E + [C_Strings,NumCStrings] = File2StringArray(FileInfo.Funct(nxtscifunnumber).CPass1ForProlFileName(SharedInfo.For.Level)); + C_Strings = stripblanks(C_Strings); + + for cntstr = 1:NumCStrings + // Prologue + PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+C_Strings(cntstr),CPass1FileName,'file','y'); + // Epilogue + PrintStringInfo(C_Strings(cntstr),CPass1ForEpilFileName ,'file','y'); + end + + // #RNU_RES_B + // ---------------------------------------- + // --- Insert "}" in the epilogue file. --- + // ---------------------------------------- + // #RNU_RES_E + PrintStringInfo('}',CPass1ForEpilFileName ,'file','y'); + + // ------------------------------ + // --- Insert for expression. --- + // ------------------------------ + CCall = 'for('+SharedInfo.ForExpr.IntCntArg.Name+' = 0'+'; '+... + SharedInfo.ForExpr.IntCntArg.Name+' < '+SharedInfo.ForExpr.MtxValCntArg.Size(1)+'*'+SharedInfo.ForExpr.MtxValCntArg.Size(2)+'; '+... + SharedInfo.ForExpr.IntCntArg.Name+'++)'; + PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + + // ------------------- + // --- Insert "{". --- + // ------------------- + CCall = '{'; + PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + + // --------------------------------- + // --- Update Indentation Level. --- + // --------------------------------- + SharedInfo.NIndent = SharedInfo.NIndent + 1; + + // #RNU_RES_B + // ---------------------------------------------------- + // --- Add code to read the element of CntArg.Name. --- + // ---------------------------------------------------- + // #RNU_RES_E + CCall = SharedInfo.ForExpr.SclValCntArg.Name+' = '+SharedInfo.ForExpr.MtxValCntArg.Name+'['+SharedInfo.ForExpr.IntCntArg.Name+'];'; + PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + +else + // --------------- + // --- Case 5. --- + // --------------- + + SCI2Cerror('Could not manage the for expression.'); +end + +endfunction diff --git a/macros/CCodeGeneration/C_Funcall.sci b/macros/CCodeGeneration/C_Funcall.sci new file mode 100644 index 00000000..456fe1e4 --- /dev/null +++ b/macros/CCodeGeneration/C_Funcall.sci @@ -0,0 +1,395 @@ +function SharedInfo = C_Funcall(FunInfo,FileInfo,SharedInfo,FlagCall) +// function SharedInfo = C_Funcall(FunInfo,FileInfo,SharedInfo,FlagCall) +// ----------------------------------------------------------------- +// Get function for a generic SCI2C table. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),4,4); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; + +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName; +CPass1FreeFileName = FileInfo.Funct(nxtscifunnumber).CPass1FreeFileName; +HeaderFileName = FileInfo.Funct(nxtscifunnumber).Pass1HeaderFileName; +CDeclarationFileName = FileInfo.Funct(nxtscifunnumber).CDeclarationFileName; +CInitVarsFileName = FileInfo.Funct(nxtscifunnumber).CInitVarsFileName; +IndentLevel = SharedInfo.NIndent; +CCall = ''; + +// --- Extract Function Info. --- +FunctionName = FunInfo.SCIFunctionName; +CFunName = FunInfo.CFunctionName; +InArg = FunInfo.InArg; +NInArg = FunInfo.NInArg; +OutArg = FunInfo.OutArg; +NOutArg = FunInfo.NOutArg; +PosFirstOutScalar = FunInfo.PosFirstOutScalar; + +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Generating C code***',ReportFileName,'file','y'); +// #RNU_RES_E +// --------------------------- +// --- End Initialization. --- +// --------------------------- + + +// -------------------------------------------------- +// --- Manage anticipated exit from the function. --- +// -------------------------------------------------- +if (SharedInfo.SkipNextFun > 0) + SharedInfo.SkipNextFun = SharedInfo.SkipNextFun - 1; + return; +end + +// #RNU_RES_B +// Exit if the function is a precision specifier and the corresponding flag is 1. +// #RNU_RES_E +if ((sum(mtlb_strcmp(FunctionName,SharedInfo.Annotations.DataPrec)) > 0) & ... + (SharedInfo.SkipNextPrec == 1)) + // #RNU_RES_B + PrintStringInfo(' Skipping code generating because already generated in the previous function.',ReportFileName,'file','y'); + // #RNU_RES_E + SharedInfo.SkipNextPrec = SharedInfo.SkipNextPrec - 1; + return; +end + +// #RNU_RES_B +// Exit if the function is OpEqual and the corresponding skip flag is enabled. +// #RNU_RES_E +if ((mtlb_strcmp(FunctionName,'OpEqual')) & ... + (SharedInfo.SkipNextEqual == 1)) + // #RNU_RES_B + PrintStringInfo(' Skipping code generating because already generated in the previous function.',ReportFileName,'file','y'); + // #RNU_RES_E + SharedInfo.SkipNextEqual = SharedInfo.SkipNextEqual - 1; + return; +end + +// #BJ +// size should be managed as other functions +// otherwise size(4) will lead to a C variable __4Size reference +// wich will never exists + +// #RNU_RES_B +// Exit if the function is size. +// #RNU_RES_E +// if ((mtlb_strcmp(FunctionName,'size'))) +// // #RNU_RES_B +// PrintStringInfo(' Anticipated exit for the size function.',ReportFileName,'file','y'); +// // #RNU_RES_E +// CCall =''; +// if (NInArg == 1) +// if (NOutArg == 1) +// CCall = CCall+OutArg(1).Name+'[0] = __'+InArg(1).Name+'Size[0];'; +// // #RNU_RES_B +// PrintStringInfo(' '+CCall,ReportFileName,'file','y'); +// // #RNU_RES_E +// PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); + +// CCall =''; +// CCall = CCall+OutArg(1).Name+'[1] = __'+InArg(1).Name+'Size[1];'; +// // #RNU_RES_B +// PrintStringInfo(' '+CCall,ReportFileName,'file','y'); +// // #RNU_RES_E +// PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); +// elseif (NOutArg == 2) +// CCall = CCall+OutArg(1).Name+' = __'+InArg(1).Name+'Size[0];'; +// // #RNU_RES_B +// PrintStringInfo(' '+CCall,ReportFileName,'file','y'); +// // #RNU_RES_E +// PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); + +// CCall =''; +// CCall = CCall+OutArg(2).Name+' = __'+InArg(1).Name+'Size[1];'; +// // #RNU_RES_B +// PrintStringInfo(' '+CCall,ReportFileName,'file','y'); +// // #RNU_RES_E +// PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); +// else +// SCI2Cerror('Don''t know how to manage size function with number of output args different from 1 and 2.'); +// end +// elseif (NInArg == 2) +// if (NOutArg == 1) +// if (InArg(2).Value == 1) +// CCall = CCall+OutArg(1).Name+' = __'+InArg(1).Name+'Size[0];'; +// // #RNU_RES_B +// PrintStringInfo(' '+CCall,ReportFileName,'file','y'); +// // #RNU_RES_E +// PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); +// elseif (InArg(2).Value == 2) +// CCall = CCall+OutArg(1).Name+' = __'+InArg(1).Name+'Size[1];'; +// // #RNU_RES_B +// PrintStringInfo(' '+CCall,ReportFileName,'file','y'); +// // #RNU_RES_E +// PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); +// else +// SCI2Cerror('Not known the value of the second input arg for the size function.'); +// end +// else +// SCI2Cerror('Don''t know how to manage size function with number of output args different from 1.'); +// end +// else +// SCI2Cerror('Don''t know how to manage size function with number of input args different from 1 and 2.'); +// end +// return; +// end +// ------------------------------------------------------ +// --- End Manage anticipated exit from the function. --- +// ------------------------------------------------------ + +// #RNU_RES_B +// ------------------------------------------------------------ +// --- Allocate memory and size array for output arguments. --- +// ------------------------------------------------------------ +// #RNU_RES_E +if (FlagCall == 1) +// #RNU_RES_B +//RNU qui va tolto tutto una volta sicuri che la memallocout puo' essere fatta dentro la st_insoutarg +// C_MemAllocOutTempVars(OutArg,NOutArg,CPass1FileName,CPass1FreeFileName,IndentLevel,ReportFileName); +// #RNU_RES_E +end + +// ---------------------------- +// --- Generate the C call. --- +// ---------------------------- +CCall =''; +if (FunInfo.CFunctionName == SharedInfo.CMainFunName) + if (FlagCall == 1) + SCI2Cerror('main function called in a source code!'); + else + CCall =CCall+'SCI2Cint '; + end +else + if (PosFirstOutScalar >= 1) + if (FlagCall == 1) + CCall = CCall+OutArg(PosFirstOutScalar).Name+' = '; + else + CCall = CCall+C_Type(OutArg(PosFirstOutScalar).Type)+' '; + end + else + if (FlagCall == 0) + CCall = CCall+'void '; + end + end +end + + +CCall = CCall+CFunName+'('; +// #RNU_RES_B +PrintStringInfo(' C call after output scalar args check: '+CCall,ReportFileName,'file','y'); +// #RNU_RES_E +clear counterin +for counterin = 1:NInArg + + if (InArg(counterin).Type == 'g' & InArg(counterin).Scope == 'String') + TmpInArgName = '""'+InArg(counterin).Name+'""'; + elseif (InArg(counterin).Type == 'z' & (InArg(counterin).Scope == 'Number')) + TmpInArgName = 'DoubleComplex('+SCI2Cstring(real(InArg(counterin).Value))+','+SCI2Cstring(imag(InArg(counterin).Value))+')'; + elseif (InArg(counterin).Type == 'c' & (InArg(counterin).Scope == 'Number')) + TmpInArgName = 'FloatComplex('+SCI2Cstring(real(InArg(counterin).Value))+','+SCI2Cstring(imag(InArg(counterin).Value))+')'; + else + TmpInArgName = InArg(counterin).Name; + end + + TmpInArgType = C_Type(InArg(counterin).Type); + + //if (FunctionName == 'OpEqual') + // TmpInArgSizeVar = '__'+OutArg(counterin).Name+'Size'; + // else + TmpInArgSizeVar = '__'+InArg(counterin).Name+'Size'; + //end + + if (InArg(counterin).Dimension == 0) + if (FlagCall == 0) + CCall = CCall+TmpInArgType+' '; + end + CCall = CCall+TmpInArgName+','; + else + if (FlagCall == 0) + CCall = CCall+TmpInArgType+'* '+TmpInArgName+', SCI2Cint* __'+TmpInArgName+'Size,'; + else + CCall = CCall+TmpInArgName+', '+TmpInArgSizeVar+','; + end + end +end +// #RNU_RES_B +PrintStringInfo(' C call after input args analysis: '+CCall,ReportFileName,'file','y'); +// #RNU_RES_E +for counterout = 1:NOutArg + TmpOutArgName = OutArg(counterout).Name; + TmpOutArgType = C_Type(OutArg(counterout).Type); + if (counterout == PosFirstOutScalar) + if (FlagCall == 0) + // #RNU_RES_B + // --- Write in the declaration file the returned output scalar (if any). --- + // #RNU_RES_E + outscalardeclaration = TmpOutArgType+' '+TmpOutArgName+';'; + // #RNU_RES_B + PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); + // #RNU_RES_E + PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CDeclarationFileName,'file','y'); + PrintStringInfo(' ',CDeclarationFileName,'file','y'); + end + else + if (OutArg(counterout).Dimension == 0) + if (FlagCall == 0) + // --- Write in the declaration file the returned output scalar (if any). --- + outscalardeclaration = TmpOutArgType+' '+TmpOutArgName+';'; + PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CDeclarationFileName,'file','y'); + PrintStringInfo(' ',CDeclarationFileName,'file','y'); + CCall = CCall+TmpOutArgType+'* __ptr'+TmpOutArgName+', '; + else + CCall = CCall+'&'+TmpOutArgName+', ';//NUT: verifica se ci vuole l'& + end + else + if (FlagCall == 0) + CCall = CCall+TmpOutArgType+'* '+TmpOutArgName+','; + if (OutArg(counterout).FindLike == 1) + CCall = CCall+'SCI2Cint* __'+TmpOutArgName+'Size'+','; + end + // #RNU_RES_B + //NUT prova a sostituire le variabili strutture con variabili dichiarate all'inizio del codice. + // --- Declare the size of the output arguments. --- + // #RNU_RES_E + outscalardeclaration = 'SCI2Cint __'+TmpOutArgName+'Size[2];'; + PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CDeclarationFileName,'file','y'); + outscalardeclaration = '__'+TmpOutArgName+'Size[0] = '+(OutArg(counterout).Size(1))+';'; + PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CInitVarsFileName,'file','y'); + outscalardeclaration = '__'+TmpOutArgName+'Size[1] = '+(OutArg(counterout).Size(2))+';'; + PrintStringInfo(outscalardeclaration,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+outscalardeclaration,CInitVarsFileName,'file','y'); + PrintStringInfo(' ',CInitVarsFileName,'file','y'); + else + CCall = CCall+OutArg(counterout).Name+','; + if (OutArg(counterout).FindLike == 1) + CCall = CCall+'(SCI2Cint* ) __'+TmpOutArgName+'Size'+','; + end + end + end + end +end +PrintStringInfo(' C call after output args analysis: '+CCall,ReportFileName,'file','y'); +// Remove the last " " and "," +if (part(CCall,length(CCall):length(CCall)) == ' ') + CCall = part(CCall,1:length(CCall)-1); +end +if (part(CCall,length(CCall):length(CCall)) == ',') + CCall = part(CCall,1:length(CCall)-1); +end + +CCall = CCall+')'; +if (FlagCall == 1) + CCall = CCall+';'; +end +//NUT: la parte di generazione della C call va inserita in una funzione a parte. +//NUT: tale funzione deve avere anche uno switch che consenta di generare differenti versioni +//NUT: delle chiamate C in accordo con la libreria disponibile, fermo restando che +//NUT: e' sempre possibile fornire la lista delle macro. +if mtlb_strcmp(FunctionName,'return') + // Here I introduce the pointer assignment for output scalar arguments. + for cntout = 1:SharedInfo.CurrentFunInfo.NOutArg + if (cntout ~= SharedInfo.CurrentFunInfo.PosFirstOutScalar & ... + SharedInfo.CurrentFunInfo.OutArg(cntout).Dimension == 0) + CCall = ''; + CCall = CCall+'*__ptr'+SharedInfo.CurrentFunInfo.OutArg(cntout).Name+' = '+... + SharedInfo.CurrentFunInfo.OutArg(cntout).Name+';'; + PrintStringInfo(' '+CCall,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); + end + end + // --- Then I free the memory dinamically allocated. --- + // ---------------------------- + // --- Handle Free section. --- + // ---------------------------- + PrintStringInfo(C_IndentBlanks(1)+'/*',CPass1FreeFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+'** ------------------------- ',CPass1FreeFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+'** --- End Free Section. --- ',CPass1FreeFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+'** ------------------------- ',CPass1FreeFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+'*/',CPass1FreeFileName,'file','y'); + PrintStringInfo(' ',CPass1FreeFileName,'file','y'); + SCI2Ccopyfile(CPass1FreeFileName,... + CPass1FileName,'append'); + // -------------------------------- + // --- End Handle Free section. --- + // -------------------------------- + + // --- Then I introduce the return to the first scalar output arguments. --- + CCall = ''; + // #RNU_RES_B + //NUT: non capisco questo skip a questo punto. + //NUT: perche' la return finale la sto gestendo nella AST_HandleEndProgram. + PrintStringInfo(' return function of the AST is skipped.',ReportFileName,'file','y'); + //RN provo a non skippare e a mettere la return. + // #RNU_RES_E + if (SharedInfo.CurrentFunInfo.CFunctionName == SharedInfo.CMainFunName) + CCall = CCall+'return(0);'; + else + if (SharedInfo.CurrentFunInfo.PosFirstOutScalar > 0) + CCall = CCall+'return('+SharedInfo.CurrentFunInfo.OutArg(SharedInfo.CurrentFunInfo.PosFirstOutScalar).Name+');' + end + end + // #RNU_RES_B + PrintStringInfo(' '+CCall,ReportFileName,'file','y'); + // #RNU_RES_E + PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); +else + // #RNU_RES_B + PrintStringInfo(' '+CCall,ReportFileName,'file','y'); + // #RNU_RES_E + PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); + if (FlagCall == 0) + // Add prototype to the header file + + C_InitHeader(CCall+';',HeaderFileName,SharedInfo.Sci2CLibMainHeaderFName); + + // Add { at the beginning of the function. + PrintStringInfo(' {',ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(IndentLevel)+'{',CPass1FileName,'file','y'); + + end +end + +// #RNU_RES_B +// Add in the C code the new size of the output argument when SCI2Cresize function is called. +// #RNU_RES_E +if (FunctionName == 'SCI2Cresize') + // #RNU_RES_B + PrintStringInfo(' Found SCI2Cresize -> Changing the size of the output argument.',ReportFileName,'file','y'); + // #RNU_RES_E + OutArgName = OutArg(counterout).Name; + tmpcode = '__'+OutArgName+'Size[0]='+OutArg(counterout).Size(1)+';'; + PrintStringInfo(C_IndentBlanks(IndentLevel)+tmpcode,CPass1FileName,'file','y'); + // #RNU_RES_B + PrintStringInfo(' '+tmpcode,ReportFileName,'file','y'); + // #RNU_RES_E + tmpcode = '__'+OutArgName+'Size[1]='+OutArg(counterout).Size(2)+';'; + PrintStringInfo(C_IndentBlanks(IndentLevel)+tmpcode,CPass1FileName,'file','y'); + // #RNU_RES_B + PrintStringInfo(' '+tmpcode,ReportFileName,'file','y'); + // #RNU_RES_E +end +endfunction diff --git a/macros/CCodeGeneration/C_GenDeclarations.sci b/macros/CCodeGeneration/C_GenDeclarations.sci new file mode 100644 index 00000000..936280b8 --- /dev/null +++ b/macros/CCodeGeneration/C_GenDeclarations.sci @@ -0,0 +1,133 @@ +function Cdeclaration = C_GenDeclarations(ArgStruct,CDeclarationFileName,IndentLevel,ReportFileName,FlagExt,ResizeApproach) +// function Cdeclaration = C_GenDeclarations(ArgStruct,CDeclarationFileName,IndentLevel,ReportFileName,FlagExt,ResizeApproach) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// 10-Jun-2008 -- Raffaele Nutricato: adapted to work with realloc function. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),6,6); + +// #RNU_RES_B +//NUT: ilnome di questa funzione va cambiato perche' le dichiarazioni le fanno anche i for e i while. + +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Generating C declaration***',ReportFileName,'file','y'); +// #RNU_RES_E + +Cdeclaration = ''; +NDeclarations = 0; +if (ArgStruct.Dimension > 0) + if (FlagExt == 1) + Cdeclaration(1) = 'extern '; + Cdeclaration(2) = 'extern '; + else + Cdeclaration(1) = ''; + Cdeclaration(2) = ''; + end + // #RNU_RES_B + //NUT: vedi Mem_Alloc_Out per maggiori info sulla rimozione della temp nella if + // if ((ArgStruct.Scope=='Temp') | (ArgStruct.FindLike == -1) | (isnum(ArgStruct.Size(1))==%F) | (isnum(ArgStruct.Size(2))==%F)) + // #RNU_RES_E + if (ArgStruct.Type=='g') + // if (isnan(ArgStruct.Value) ) + if ((isnum(ArgStruct.Size(1))==%F) | (isnum(ArgStruct.Size(2))==%F) ) + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+... + ' * '+ArgStruct.Name+';'; + else + if ((FlagExt == 1) | (isnan(ArgStruct.Value))) + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+... + ' '+ArgStruct.Name+'['+ArgStruct.Size(1)+'*'+ArgStruct.Size(2)+'];'; + else + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+... + ' '+ArgStruct.Name+'['+ArgStruct.Size(1)+'*'+ArgStruct.Size(2)+'] = {'+ArgStruct.Value+'};'; + end + end + Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2] = {'+ArgStruct.Size(1)+','+ArgStruct.Size(2)+'};'; + NDeclarations = 2; + elseif ((ArgStruct.FindLike == -1) | ... + (isnum(ArgStruct.Size(1))==%F) | (isnum(ArgStruct.Size(2))==%F) | ... + (ResizeApproach=='REALLOC_ALL_RESIZE_ALL' & ArgStruct.Type~='g')) + // #RNU_RES_B + //RNU sulle stringhe non ho ancora deciso se applicare la realloc. + // Generate only the pointer that will be used by the malloc function. + // #RNU_RES_E + if (FlagExt == 1) + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+'* '+... + ArgStruct.Name+';'; + else + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+'* '+... + ArgStruct.Name+' = NULL;'; + end + // Declare the Size array + Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2];'; + NDeclarations = 2; + else + // Declare the array with its size. + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+... + ' '+ArgStruct.Name+'['+ArgStruct.Size(1)+'*'+ArgStruct.Size(2)+'];'; + if (FlagExt == 1) + Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2];'; + else + Cdeclaration(2) = Cdeclaration(2)+C_Type('i')+' __'+ArgStruct.Name+'Size[2] = {'+ArgStruct.Size(1)+','+ArgStruct.Size(2)+'};'; + end + NDeclarations = 2; + end +else + if (FlagExt == 1) + Cdeclaration(1) = 'extern '; + else + Cdeclaration(1) = ''; + end + Cdeclaration(1) = Cdeclaration(1)+C_Type(ArgStruct.Type)+' '+ArgStruct.Name; + if (~isnan(ArgStruct.Value) & (FlagExt == 0)) + if isreal(ArgStruct.Value) + Cdeclaration(1) = Cdeclaration(1)+' = '+SCI2Cstring(ArgStruct.Value); + else + if (ArgStruct.Type == 'z') + Cdeclaration(1) = Cdeclaration(1)+' = DoubleComplex('+SCI2Cstring(real(ArgStruct.Value))+','+SCI2Cstring(imag(ArgStruct.Value))+')'; + else + Cdeclaration(1) = Cdeclaration(1)+' = FloatComplex('+SCI2Cstring(real(ArgStruct.Value))+','+SCI2Cstring(imag(ArgStruct.Value))+')'; + end + end + end + Cdeclaration(1) = Cdeclaration(1)+';'; + NDeclarations = 1; +end + + +// -------------------------------------------- +// --- Write C declaration into the C file. --- +// -------------------------------------------- +for cntdecl = 1:NDeclarations + // #RNU_RES_B + PrintStringInfo(' '+Cdeclaration(cntdecl),ReportFileName,'file','y'); + // #RNU_RES_E +end +// #RNU_RES_B +PrintStringInfo(' Writing C declaration in: '+CDeclarationFileName,ReportFileName,'file','y'); +// #RNU_RES_E +for cntdecl = 1:NDeclarations + PrintStringInfo(C_IndentBlanks(IndentLevel)+Cdeclaration(cntdecl),CDeclarationFileName,'file','y'); +end +PrintStringInfo(' ',CDeclarationFileName,'file','y'); + +endfunction +// #RNU_RES_B +//NUT: dove sta il controllo che verifica se dopo aver dichiarato una local A[10] essa viene utilizzata +//NUT: per memorizzare un A = sin(B) dove B[11]?? +// #RNU_RES_E diff --git a/macros/CCodeGeneration/C_GenerateFunName.sci b/macros/CCodeGeneration/C_GenerateFunName.sci new file mode 100644 index 00000000..b5b8c12d --- /dev/null +++ b/macros/CCodeGeneration/C_GenerateFunName.sci @@ -0,0 +1,45 @@ +function CFunName = C_GenerateFunName(FunctionName,InArg,NInArg,OutArg,NOutArg) +// function CFunName = C_GenerateFunName(FunctionName,InArg,NInArg,OutArg,NOutArg) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 26-Oct-2007 -- Raffaele Nutricato: Author. +// 26-Oct-2007 -- Alberto Morea: Test Ok. +// 11-Nov-2007 -- Raffaele Nutricato: changed naming rule. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),5,5); +CFunName = ''; + +for tmpcnt = 1:NInArg + if (InArg(tmpcnt).Dimension == 1) + CFunName = CFunName+InArg(tmpcnt).Type+'2'; + else + CFunName = CFunName+InArg(tmpcnt).Type+SCI2Cstring(InArg(tmpcnt).Dimension); + end +end + +CFunName = CFunName+FunctionName; + +for tmpcnt = 1:NOutArg + if (OutArg(tmpcnt).Dimension == 1) + CFunName = CFunName+OutArg(tmpcnt).Type+'2'; + else + CFunName = CFunName+OutArg(tmpcnt).Type+SCI2Cstring(OutArg(tmpcnt).Dimension); + end +end + +endfunction diff --git a/macros/CCodeGeneration/C_GenerateLaunchScript.sci b/macros/CCodeGeneration/C_GenerateLaunchScript.sci new file mode 100644 index 00000000..027d4c70 --- /dev/null +++ b/macros/CCodeGeneration/C_GenerateLaunchScript.sci @@ -0,0 +1,86 @@ +function C_GenerateLaunchScript(OutDir,ListSCI2CInputPrmFiles) +// function C_GenerateLaunchScript(OutDir,ListSCI2CInputPrmFiles) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Generate the script that can be used to compile all the regression +// tests and to run them and finally to write results in the report +// file. +// #RNU_RES_E +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 26-Jan-2008 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +ScriptFileName = fullfile(OutDir,'LaunchRegressionTests.rc'); +NTranslations = size(ListSCI2CInputPrmFiles,1); +// --------------------------- +// --- End Initialization. --- +// --------------------------- +SCI2Cmdelete(ScriptFileName); +PrintStringInfo('#! /bin/bash ',ScriptFileName,'file','y'); +PrintStringInfo(' ',ScriptFileName,'file','y'); +PrintStringInfo('maindir=$PWD',ScriptFileName,'file','y'); +PrintStringInfo(' ',ScriptFileName,'file','y'); +PrintStringInfo('INTIALIZE()',ScriptFileName,'file','y'); +PrintStringInfo('{',ScriptFileName,'file','y'); +PrintStringInfo(' reportfile=$maindir/RegressionTestsReport.txt',ScriptFileName,'file','y'); +PrintStringInfo(' echo ""#############'+'#################"" > $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' echo ""REPORT OF THE REGRESSION TESTS"" > $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' echo ""#############'+'#################"" > $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' echo ""Author: Raffaele Nutricato"" > $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' echo ""Copyright 2008 Raffaele Nutricato"" > $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' echo "" "" > $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' cd $maindir ',ScriptFileName,'file','y'); +PrintStringInfo('}',ScriptFileName,'file','y'); +PrintStringInfo(' ',ScriptFileName,'file','y'); +PrintStringInfo('EXECUTE()',ScriptFileName,'file','y'); +PrintStringInfo('{',ScriptFileName,'file','y'); +PrintStringInfo(' echo ""xxxxxxxxxxxxxx'+'xxxxxxxxxxxxxxxxxx'+'xxxxxxxxxxxx""',ScriptFileName,'file','y'); +PrintStringInfo(' echo "" "" >> $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' echo "" "" >> $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' echo "" "" >> $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' echo ""xxxxxxxxxxxxxx'+'xxxxxxxxxxxxxxxxxxxxxxx'+'xxxxxxx"" >> $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' echo $testname ',ScriptFileName,'file','y'); +PrintStringInfo(' echo $testname >> $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' echo ""xxxxxxxxxxxxxxx'+'xxxxxxxxxxxxxxxxx'+'xxxxxxxxxxxx"" ',ScriptFileName,'file','y'); +PrintStringInfo(' echo ""xxxxxxxxxxxxxxxx'+'xxxxxxxxxxxxxxxxxxxx'+'xxxxxxxx"" >> $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' cd $testname/C_Code',ScriptFileName,'file','y'); +PrintStringInfo(' make >> $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' cd $maindir',ScriptFileName,'file','y'); +PrintStringInfo(' echo "" "" >> $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' echo "" "" >> $reportfile',ScriptFileName,'file','y'); +PrintStringInfo(' echo "" "" >> $reportfile',ScriptFileName,'file','y'); +PrintStringInfo('}',ScriptFileName,'file','y'); +PrintStringInfo(' ',ScriptFileName,'file','y'); +PrintStringInfo('#############'+'##############',ScriptFileName,'file','y'); +PrintStringInfo('### ADD YOUR TESTS HERE ###',ScriptFileName,'file','y'); +PrintStringInfo('##############'+'#############',ScriptFileName,'file','y'); +PrintStringInfo('INTIALIZE',ScriptFileName,'file','y'); +PrintStringInfo(' ',ScriptFileName,'file','y'); + +for cnttransl = 1:NTranslations + [testpath,tmpname,tmpext] = fileparts(ListSCI2CInputPrmFiles(cnttransl)); + testpath = ConvertPathMat2C(testpath,'cygwin'); + PrintStringInfo('testname=""'+testpath+'""',ScriptFileName,'file','y'); + PrintStringInfo('EXECUTE $testname',ScriptFileName,'file','y'); + PrintStringInfo(' ',ScriptFileName,'file','y'); +end + +endfunction diff --git a/macros/CCodeGeneration/C_GenerateMakefile.sci b/macros/CCodeGeneration/C_GenerateMakefile.sci new file mode 100644 index 00000000..3914d4dc --- /dev/null +++ b/macros/CCodeGeneration/C_GenerateMakefile.sci @@ -0,0 +1,133 @@ +function C_GenerateMakefile(FileInfo,SharedInfo) +// function C_GenerateMakefile(FileInfo,SharedInfo) +// ----------------------------------------------------------------- +// Generate the makefile. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 26-Jan-2008 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +PrintStepInfo('Generating Builder '+FileInfo.MakefileFilename,... + FileInfo.GeneralReport,'both'); +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +PrintStringInfo('# SCI2C Makefile',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('# hArtes EU Project.',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('# Authors: PoliBa & Inria',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('# -----------------------',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('# --- USER PARAMETERS ---',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('# -----------------------',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('# --- DIRECTORIES AND FILES ---',FileInfo.MakefileFilename,'file','y'); + +makecsrcdir = pathconvert('src/c', %f, %f, 'u'); +// makecsrcdir = FileInfo.CStyleSCI2CMainDir+'\CFiles\sci2ccode'; +makehsrcdir = pathconvert('includes', %f, %f, 'u'); +// makehsrcdir = FileInfo.CStyleSCI2CMainDir+'\CFiles\sci2cincludes'; +makeisrcdir = pathconvert('interfaces', %f, %f, 'u'); +// makeisrcdir = FileInfo.CStyleSCI2CMainDir+'\CFiles\sci2cinterfaces'; +makesci2cdir = FileInfo.CStyleOutCCCodeDir; +// makesci2cdir = FileInfo.CStyleOutCCCodeDir; + + +PrintStringInfo('CSRCDIR = '+makecsrcdir,FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('HSRCDIR = '+makehsrcdir,FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('ISRCDIR = '+makeisrcdir,FileInfo.MakefileFilename,'file','y','y'); +//PrintStringInfo('SCI2CDIR = '+makesci2cdir,FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('SCI2CDIR = .',FileInfo.MakefileFilename,'file','y','y'); + +// Compiler definition +PrintStringInfo('CC = gcc',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('CFLAGS = -Wall -pedantic -I $(HSRCDIR) -I $(ISRCDIR) -lm',FileInfo.MakefileFilename,'file','y','y'); + +// Binary definition +PrintStringInfo('EXEFILENAME = mytest.exe',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('EXEFILE = $(SCI2CDIR)/$(EXEFILENAME)', FileInfo.MakefileFilename,'file','y','y'); + +// Sources +PrintStringInfo('SRC = \\', FileInfo.MakefileFilename,'file','y','y'); +allSources = getAllSources(); +nbSources = size(allSources); +for i = 1:(nbSources(1) - 1) + [tmppath,tmpfile,tmpext] = fileparts(allSources(i)); + PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext+' \\', FileInfo.MakefileFilename,'file','y','y'); +end +[tmppath,tmpfile,tmpext] = fileparts(allSources(nbSources(1))); +PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext, FileInfo.MakefileFilename,'file','y','y'); + +// Objects +PrintStringInfo('OBJ = $(SRC:.c=.o)', FileInfo.MakefileFilename,'file','y','y'); + +// Rules +PrintStringInfo('# ---------------',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('# --- TARGETS ---',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('# ---------------',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('compileexecute: $(OBJ)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""============================""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""Generation of the executable""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""============================""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t$(CC) $(CFLAGS) $(OBJ) *.c -llapack -lblas -o $(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""==============""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""Executing code""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""==============""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t$(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); + +PrintStringInfo('clean:',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""=============================""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""Removing only exe + obj files""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""=============================""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\trm -rf $(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\trm -rf $(OBJ)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); + +PrintStringInfo('distclean: clean',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""==========================""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""Removing only the exe file""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""==========================""',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\trm -rf $(EXEFILE)',FileInfo.MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y','y'); + +if getos() == 'Windows' then + C_GenerateMakefile_msvc(FileInfo,SharedInfo); +end + + +// ------------------------------- +// --- Open template makefile. --- +// ------------------------------- +//fidfile = SCI2COpenFileRead(FileInfo.MakefileTemplate); + +// ------------------- +// --- Read lines. --- +// ------------------- +//tmpline = mgetl(fidfile,1); +//while (meof(fidfile) == 0) +// PrintStringInfo(tmpline,FileInfo.MakefileFilename,'file','y'); +// tmpline = mgetl(fidfile,1); +//end + +//mclose(fidfile); + +endfunction
\ No newline at end of file diff --git a/macros/CCodeGeneration/C_GenerateMakefile_msvc.sci b/macros/CCodeGeneration/C_GenerateMakefile_msvc.sci new file mode 100644 index 00000000..b49a2c31 --- /dev/null +++ b/macros/CCodeGeneration/C_GenerateMakefile_msvc.sci @@ -0,0 +1,110 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010-2010 - DIGITEO - Allan CORNET +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// +// + +function C_GenerateMakefile_msvc(FileInfo, SharedInfo) +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +MakefileFilename = FileInfo.MakefileFilename + '.mak'; + +// ----------------------- +// --- Initialization. --- +// ----------------------- +PrintStepInfo('Generating Builder '+MakefileFilename,... + FileInfo.GeneralReport,'both'); + +PrintStringInfo('# SCI2C Makefile (Visual Studio 2008)',MakefileFilename,'file','y','y'); +PrintStringInfo('# hArtes EU Project.',MakefileFilename,'file','y','y'); +PrintStringInfo('# Authors: PoliBa & Inria & DIGITEO',MakefileFilename,'file','y','y'); +PrintStringInfo('# -----------------------',MakefileFilename,'file','y','y'); +PrintStringInfo('# --- USER PARAMETERS ---',MakefileFilename,'file','y','y'); +PrintStringInfo('# -----------------------',MakefileFilename,'file','y','y'); +PrintStringInfo('# --- DIRECTORIES AND FILES ---',MakefileFilename,'file','y','y'); + +makecsrcdir = pathconvert('src/c', %f, %f, 'u'); +makehsrcdir = pathconvert('includes', %f, %f, 'u'); +makeisrcdir = pathconvert('interfaces', %f, %f, 'u'); +makesci2cdir = FileInfo.CStyleOutCCCodeDir; +PrintStringInfo('CSRCDIR = '+makecsrcdir,MakefileFilename,'file','y','y'); +PrintStringInfo('HSRCDIR = '+makehsrcdir,MakefileFilename,'file','y','y'); +PrintStringInfo('ISRCDIR = '+makeisrcdir,MakefileFilename,'file','y','y'); +PrintStringInfo('SCI2CDIR = .',MakefileFilename,'file','y','y'); + +PrintStringInfo('DIR_OBJ=Release',MakefileFilename,'file','y','y'); +PrintStringInfo('LAPACK_LIB =$(SCI2CDIR)/external-libs/lapack.lib',MakefileFilename,'file','y','y'); +PrintStringInfo('BLAS_LIB = $(SCI2CDIR)/external-libs/blasplus.lib',MakefileFilename,'file','y','y'); +PrintStringInfo('CC = cl',MakefileFilename,'file','y','y'); +PrintStringInfo('LINKER = link',MakefileFilename,'file','y','y'); +PrintStringInfo('LINKER_OPTIMISATION_MODE=/RELEASE ',MakefileFilename,'file','y','y'); +PrintStringInfo('CC__OPTIMISATION_MODE=-Z7 -O2 -MD',MakefileFilename,'file','y','y'); +PrintStringInfo('CC_OPTIONS = $(CC_COMMON) -W3 -Gd $(CC__OPTIMISATION_MODE) /Fo""$(DIR_OBJ)/"" /Fd""$(DIR_OBJ)/"" ',MakefileFilename,'file','y','y'); +PrintStringInfo('CFLAGS = $(CC_OPTIONS) -I""$(HSRCDIR)"" -I""$(ISRCDIR)"" /EHsc /TP ',MakefileFilename,'file','y','y'); +PrintStringInfo('EXEFILENAME = mytest',MakefileFilename,'file','y','y'); +PrintStringInfo('EXEFILE = $(SCI2CDIR)\\$(EXEFILENAME)',MakefileFilename,'file','y','y'); +PrintStringInfo('MAIN_SRC = $(SCI2CDIR)/main.c',MakefileFilename,'file','y','y'); + +// Sources +PrintStringInfo('SRC = \\', MakefileFilename,'file','y','y'); +allSources = getAllSources(); +nbSources = size(allSources); +for i = 1:(nbSources(1) - 1) + [tmppath,tmpfile,tmpext] = fileparts(allSources(i)); + PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext+' \\', MakefileFilename,'file','y','y'); +end +[tmppath,tmpfile,tmpext] = fileparts(allSources(nbSources(1))); +PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext, MakefileFilename,'file','y','y'); + +PrintStringInfo('OBJ = $(SRC:.c=.obj) $(MAIN_SRC:.c=.obj)',MakefileFilename,'file','y','y'); +PrintStringInfo('# ---------------',MakefileFilename,'file','y','y'); +PrintStringInfo('# --- TARGETS ---',MakefileFilename,'file','y','y'); +PrintStringInfo('# ---------------',MakefileFilename,'file','y','y'); +PrintStringInfo('compileexecute: ',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""============================""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""Generation of the executable""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""============================""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-IF NOT EXIST $(DIR_OBJ) mkdir $(DIR_OBJ)',MakefileFilename,'file','y','y'); +PrintStringInfo('\t$(CC) $(CFLAGS) $(SRC) $(MAIN_SRC) /link $(LAPACK_LIB) $(BLAS_LIB) /out:$(EXEFILE).exe',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""==============""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""Executing code""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""==============""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t$(EXEFILE).exe',MakefileFilename,'file','y','y'); +PrintStringInfo('clean:',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""=============================""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""Removing only exe + obj files""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""=============================""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-del ""$(DIR_OBJ)\*.obj""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-rmdir ""$(DIR_OBJ)""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-del $(EXEFILE).exe',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-del $(EXEFILE).exp',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-del $(EXEFILE).lib',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-del $(EXEFILE).pdb',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-del $(EXEFILE).ilk',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',MakefileFilename,'file','y','y'); +PrintStringInfo('distclean: clean',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""==========================""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""Removing only the exe file""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo ""==========================""',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-del $(EXEFILE).exe',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-del $(EXEFILE).exp',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-del $(EXEFILE).lib',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-del $(EXEFILE).pdb',MakefileFilename,'file','y','y'); +PrintStringInfo('\t-del $(EXEFILE).ilk',MakefileFilename,'file','y','y'); +PrintStringInfo('\t@echo "" ""',MakefileFilename,'file','y','y'); + + +endfunction
\ No newline at end of file diff --git a/macros/CCodeGeneration/C_IfElseBlocks.sci b/macros/CCodeGeneration/C_IfElseBlocks.sci new file mode 100644 index 00000000..71b45966 --- /dev/null +++ b/macros/CCodeGeneration/C_IfElseBlocks.sci @@ -0,0 +1,68 @@ +function SharedInfo = C_IfElseBlocks(FileInfo,SharedInfo,InOutStatements) +// function SharedInfo = C_IfElseBlocks(FileInfo,SharedInfo,InOutStatements) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),3,3); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; + +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName; + +IndentLevel = SharedInfo.NIndent; + +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo(' Generate ""{"" or ""}"" code for if/else statement',ReportFileName,'file','y'); +// #RNU_RES_E +CCall = ''; +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// #RNU_RES_B +// ----------------------------------------------------- +// --- Generate the C call/Update indentation level. --- +// ----------------------------------------------------- +// #RNU_RES_E +if (InOutStatements=='in') + CCall = CCall+'{'; + PrintStringInfo(' '+CCall,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); + IndentLevel = IndentLevel + 1; +elseif (InOutStatements=='out') + CCall = CCall+'}'; + IndentLevel = IndentLevel - 1; + PrintStringInfo(' '+CCall,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(IndentLevel)+CCall,CPass1FileName,'file','y'); +else + SCI2CerrorFile('Unknown setting for InOutStatements: '+InOutStatements'.',ReportFileName); +end + +// #RNU_RES_B +PrintStringInfo(' Updating indentation level to:'+string(IndentLevel),ReportFileName,'file','y'); +// #RNU_RES_E +SharedInfo.NIndent = IndentLevel; + +endfunction diff --git a/macros/CCodeGeneration/C_IfExpression.sci b/macros/CCodeGeneration/C_IfExpression.sci new file mode 100644 index 00000000..772f24ff --- /dev/null +++ b/macros/CCodeGeneration/C_IfExpression.sci @@ -0,0 +1,91 @@ +function SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo,SharedInfo) +// function SharedInfo = C_IfExpression(IfCondArg,NIfCondArg,ASTIfExpType,FileInfo,SharedInfo) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),5,5); + +// --- Check NIfCondArg value. --- +if ((NIfCondArg ~= 1) & (ASTIfExpType~='else')) + SCI2CerrorFile('Cannot manage ""if/elseif"" with a number of condition variables not equal to 1.',ReportFileName); +end + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; + +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName; + +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Generating C code***',ReportFileName,'file','y'); +// #RNU_RES_E +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// -------------------------------------------- +// --- Generate the C name of the function. --- +// -------------------------------------------- +if (ASTIfExpType=='if') + CFunName = 'if'; +elseif (ASTIfExpType=='elseif') + CFunName = 'if'; +elseif (ASTIfExpType=='else') + CFunName = 'else'; +else + SCI2CerrorFile('Unknown ASTIfExpType ""'+ASTIfExpType+'"".',ReportFileName); +end + +// ---------------------------- +// --- Generate the C call. --- +// ---------------------------- +if SCI2Cstrncmps1size(ASTIfExpType,'else') + // #RNU_RES_B + // before opening a new C block, closes the previous one. + // #RNU_RES_E + SharedInfo = C_IfElseBlocks(FileInfo,SharedInfo,'out'); +end + +CCall =''; +CCall = CCall+CFunName; +if (ASTIfExpType~='else') + CCall = CCall+'('+IfCondArg(1)+')'; +end +PrintStringInfo(' '+CCall,ReportFileName,'file','y'); +PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + +SharedInfo = C_IfElseBlocks(FileInfo,SharedInfo,'in'); + +// #RNU_RES_B +// --------------------------------- +// --- Update counter nested if. --- +// --------------------------------- +// #RNU_RES_E +if (ASTIfExpType=='elseif') + // #RNU_RES_B + // every elseif statement a new } is required. + // #RNU_RES_E + SharedInfo.CountNestedIf = SharedInfo.CountNestedIf + 1; +end + +endfunction diff --git a/macros/CCodeGeneration/C_IndentBlanks.sci b/macros/CCodeGeneration/C_IndentBlanks.sci new file mode 100644 index 00000000..9304aefb --- /dev/null +++ b/macros/CCodeGeneration/C_IndentBlanks.sci @@ -0,0 +1,31 @@ +function OutBlanksString = C_IndentBlanks(IndentLevel) +// function OutBlanksString = C_IndentBlanks(IndentLevel) +// ----------------------------------------------------------------- +// Delete function for a generic SCI2C table. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 26-Oct-2007 -- Raffaele Nutricato: Author. +// 26-Oct-2007 -- Alberto Morea: Test Ok. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +OutBlanksString = ''; +BlanksPerLevel = ' '; +for cntind = 1:IndentLevel + OutBlanksString = OutBlanksString + BlanksPerLevel; +end + +endfunction diff --git a/macros/CCodeGeneration/C_InitHeader.sci b/macros/CCodeGeneration/C_InitHeader.sci new file mode 100644 index 00000000..7d794127 --- /dev/null +++ b/macros/CCodeGeneration/C_InitHeader.sci @@ -0,0 +1,68 @@ +function C_InitHeader(C_Prototype,HeaderFileName,Sci2CLibMainHeaderFName) +// function C_InitHeader(C_Prototype,HeaderFileName,Sci2CLibMainHeaderFName) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),3,3); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +// --------------------------- +// --- End Initialization. --- +// --------------------------- + + +C_SCI2CHeader(HeaderFileName); +[tmppath,tmpfname,tmpextension]=fileparts(HeaderFileName); +PrintStringInfo('#ifndef '+tmpfname+'_h',HeaderFileName,'file','y'); +PrintStringInfo('#define '+tmpfname+'_h',HeaderFileName,'file','y'); +PrintStringInfo('/*',HeaderFileName,'file','y'); +PrintStringInfo('** ----------------------- ',HeaderFileName,'file','y'); +PrintStringInfo('** --- SCI2C Includes. --- ',HeaderFileName,'file','y'); +PrintStringInfo('** ----------------------- ',HeaderFileName,'file','y'); +PrintStringInfo('*/',HeaderFileName,'file','y'); +PrintStringInfo('#include ""'+Sci2CLibMainHeaderFName+'""',HeaderFileName,'file','y'); +PrintStringInfo('/*',HeaderFileName,'file','y'); +PrintStringInfo('** --------------------------- ',HeaderFileName,'file','y'); +PrintStringInfo('** --- End SCI2C Includes. --- ',HeaderFileName,'file','y'); +PrintStringInfo('** --------------------------- ',HeaderFileName,'file','y'); +PrintStringInfo('*/',HeaderFileName,'file','y'); +PrintStringInfo(' ',HeaderFileName,'file','y'); +PrintStringInfo(' ',HeaderFileName,'file','y'); +PrintStringInfo('/*',HeaderFileName,'file','y'); +PrintStringInfo('** ------------------- ',HeaderFileName,'file','y'); +PrintStringInfo('** --- Prototypes. --- ',HeaderFileName,'file','y'); +PrintStringInfo('** ------------------- ',HeaderFileName,'file','y'); +PrintStringInfo('*/',HeaderFileName,'file','y'); +PrintStringInfo(C_IndentBlanks(0)+C_Prototype,HeaderFileName,'file','y'); +PrintStringInfo('/*',HeaderFileName,'file','y'); +PrintStringInfo('** ----------------------- ',HeaderFileName,'file','y'); +PrintStringInfo('** --- End Prototypes. --- ',HeaderFileName,'file','y'); +PrintStringInfo('** ----------------------- ',HeaderFileName,'file','y'); +PrintStringInfo('*/',HeaderFileName,'file','y'); +PrintStringInfo(' ',HeaderFileName,'file','y'); +PrintStringInfo(' ',HeaderFileName,'file','y'); +PrintStringInfo('/*',HeaderFileName,'file','y'); +PrintStringInfo('** ------------------------ ',HeaderFileName,'file','y'); +PrintStringInfo('** --- USER2C Includes. --- ',HeaderFileName,'file','y'); +PrintStringInfo('** ------------------------ ',HeaderFileName,'file','y'); +PrintStringInfo('*/',HeaderFileName,'file','y'); + +endfunction diff --git a/macros/CCodeGeneration/C_MemAllocOutTempVars.sci b/macros/CCodeGeneration/C_MemAllocOutTempVars.sci new file mode 100644 index 00000000..dedcfd33 --- /dev/null +++ b/macros/CCodeGeneration/C_MemAllocOutTempVars.sci @@ -0,0 +1,64 @@ +function C_MemAllocOutTempVars(OutArg,NOutArg,CPass1FileName,CPass1FreeFileName,IndentLevel,ReportFileName,ResizeApproach) +// function C_MemAllocOutTempVars(OutArg,NOutArg,CPass1FileName,CPass1FreeFileName,IndentLevel,ReportFileName,ResizeApproach) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// 10-Jun-2008 -- Raffaele Nutricato: replaced malloc with realloc. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),7,7); + +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Allocating memory for temp variables***',ReportFileName,'file','y'); +// #RNU_RES_E + +// #RNU_RES_B +// --- Allocate memory and size array for output arguments. --- +// #RNU_RES_E +for counterout = 1:NOutArg + if (OutArg(counterout).Dimension > 0) + // #RNU_RES_B + // if ((OutArg(counterout).Scope == 'Temp') | (OutArg(counterout).FindLike == -1) | ... + // (isnum(OutArg(counterout).Size(1))==%F) | (isnum(OutArg(counterout).Size(2))==%F)) + //NUT: qui forse ci vuole un check per verificare se per caso la variabile e' globale e non se ne conosce la size numerica. + //NUT infatti. Per ora se la size numerica assumo che la variabile globale e' da reallocare. Secondo me occorre aggiungere + //NUT un campo negli argomenti che specifichi la presenza di realloc da fare. + //NUT: ho tolto il check sulle temp perche' se una temp ha size numerica non voglio fare malloc. + //RNU sulle stringhe ancora non applico realloc + // #RNU_RES_E + if ((OutArg(counterout).FindLike == -1) | ... + (isnum(OutArg(counterout).Size(1))==%F) | (isnum(OutArg(counterout).Size(2))==%F)| ... + (ResizeApproach=='REALLOC_ALL_RESIZE_ALL' & OutArg(counterout).Type ~= 'g')) + OutArgName = OutArg(counterout).Name; + tmpcode = '__'+OutArgName+'Size[0]='+OutArg(counterout).Size(1)+';'; + PrintStringInfo(C_IndentBlanks(IndentLevel)+tmpcode,CPass1FileName,'file','y'); + PrintStringInfo(' '+tmpcode,ReportFileName,'file','y'); + tmpcode = '__'+OutArgName+'Size[1]='+OutArg(counterout).Size(2)+';'; + PrintStringInfo(C_IndentBlanks(IndentLevel)+tmpcode,CPass1FileName,'file','y'); + PrintStringInfo(' '+tmpcode,ReportFileName,'file','y'); + //a->val = (double *) malloc(nnz * sizeof(double)); + // numbers = (int*) realloc (numbers, count * sizeof(int)); + tmpcode = OutArgName+' = ('+C_Type(OutArg(counterout).Type)+'*) realloc('+OutArgName+',('+OutArg(counterout).Size(1)+')*('+OutArg(counterout).Size(2)+')*sizeof('+C_Type(OutArg(counterout).Type)+'));'; + PrintStringInfo(C_IndentBlanks(IndentLevel)+tmpcode,CPass1FileName,'file','y'); + PrintStringInfo(' '+tmpcode,ReportFileName,'file','y'); + PrintStringInfo(C_IndentBlanks(1)+'free('+OutArgName+');',CPass1FreeFileName,'file','y'); + end + end +end + +endfunction diff --git a/macros/CCodeGeneration/C_SCI2CHeader.sci b/macros/CCodeGeneration/C_SCI2CHeader.sci new file mode 100644 index 00000000..5e8acd5d --- /dev/null +++ b/macros/CCodeGeneration/C_SCI2CHeader.sci @@ -0,0 +1,41 @@ +function C_SCI2CHeader(FileName) +// function C_SCI2CHeader(FileName) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 21-Dec-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +// --------------------------- +// --- End Initialization. --- +// --------------------------- + + +PrintStringInfo('/*',FileName,'file','y'); +PrintStringInfo('** ************************************************',FileName,'file','y'); +PrintStringInfo('** hArtes/POLIBA SCILAB2C',FileName,'file','y'); +PrintStringInfo('** Contact: raffaele.nutricato@tiscali.it',FileName,'file','y'); +PrintStringInfo('** ************************************************',FileName,'file','y'); +PrintStringInfo('*/',FileName,'file','y'); +PrintStringInfo(' ',FileName,'file','y'); +PrintStringInfo(' ',FileName,'file','y'); + +endfunction diff --git a/macros/CCodeGeneration/C_Type.sci b/macros/CCodeGeneration/C_Type.sci new file mode 100644 index 00000000..f49dd9b1 --- /dev/null +++ b/macros/CCodeGeneration/C_Type.sci @@ -0,0 +1,41 @@ +function OutC_Type = C_Type(ArgType) +// function OutC_Type = C_Type(ArgType) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +if (ArgType == 's') + OutC_Type = 'float'; +elseif (ArgType == 'd') + OutC_Type = 'double'; +elseif (ArgType == 'c') + OutC_Type = 'floatComplex'; +elseif (ArgType == 'z') + OutC_Type = 'doubleComplex'; +elseif (ArgType == 'i') + OutC_Type = 'SCI2Cint'; +elseif (ArgType == 'g') + OutC_Type = 'char'; +elseif (ArgType == 'f') + OutC_Type = 'SCI2CFILEID'; +else + SCI2Cerror('Unknown Argument Type: ""'+ArgType+'"".'); +end +endfunction diff --git a/macros/CCodeGeneration/C_WhileExpression.sci b/macros/CCodeGeneration/C_WhileExpression.sci new file mode 100644 index 00000000..edd2830e --- /dev/null +++ b/macros/CCodeGeneration/C_WhileExpression.sci @@ -0,0 +1,93 @@ +function SharedInfo = C_WhileExpression(FileInfo,SharedInfo) +// function SharedInfo = C_WhileExpression(FileInfo,SharedInfo) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 15-Nov-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; + +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; +CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName; + +CPass1WhileProlFileName = FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level); +CPass1WhileEpilFileName = FileInfo.Funct(nxtscifunnumber).CPass1WhileEpilFileName(SharedInfo.While.Level); +CDeclarationFileName = FileInfo.Funct(nxtscifunnumber).CDeclarationFileName; + +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Generating C code***',ReportFileName,'file','y'); +// #RNU_RES_E +CCall =''; +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// ---------------------------- +// --- Generate the C call. --- +// ---------------------------- + +// ------------------------- +// --- Manage all cases. --- +// ------------------------- +PrintStringInfo(' Handling While Expression with OpColon.',ReportFileName,'file','y'); //NUT: sistema il commento. + +// ------------------------------------------------------------------------------------- +// --- Generate Prologue and Epilogue -> Copy the first N-1 lines of the for.c code. --- +// ------------------------------------------------------------------------------------- +[C_Strings,NumCStrings] = File2StringArray(CPass1WhileProlFileName); +C_Strings = stripblanks(C_Strings); +for cntstr = 1:NumCStrings + // Prologue + PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+C_Strings(cntstr),CPass1FileName,'file','y','n'); + // Epilogue + if (length(C_Strings(cntstr)) == 0) + C_Strings(cntstr) = ' '; // RNU for Bruno: If I don't do that I get a PrintStringInfo error related to mputstr. + // Function not defined for given argument type(s),
+ // check arguments or define function %0_mputstr for overloading. + end + PrintStringInfo(C_Strings(cntstr),CPass1WhileEpilFileName ,'file','y','n'); +end +// ---------------------------------------- +// --- Insert "}" in the epilogue file. --- +// ---------------------------------------- +PrintStringInfo('}',CPass1WhileEpilFileName ,'file','y'); + +// ------------------------------ +// --- Insert for expression. --- +// ------------------------------ +CCall = 'while('+SharedInfo.WhileExpr.CondVar+')'; +PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + +// ------------------- +// --- Insert "{". --- +// ------------------- +CCall = '{'; +PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y'); + +// --------------------------------- +// --- Update Indentation Level. --- +// --------------------------------- +SharedInfo.NIndent = SharedInfo.NIndent + 1; + +endfunction diff --git a/macros/CCodeGeneration/GenCFunDatFiles.sci b/macros/CCodeGeneration/GenCFunDatFiles.sci new file mode 100644 index 00000000..62c8f4bc --- /dev/null +++ b/macros/CCodeGeneration/GenCFunDatFiles.sci @@ -0,0 +1,73 @@ +function GenCFunDatFiles(FunctionName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInArg,OutArg,NOutArg,CFunName,LibTypeInfo,FunInfoDatDir) +// function GenCFunDatFiles(FunctionName,FunPrecSpecifier,FunTypeAnnot,FunSizeAnnot,InArg,NInArg,OutArg,NOutArg,CFunName,LibTypeInfo,FunInfoDatDir) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 30-Oct-2007 -- Raffaele Nutricato: Author. +// 30-Oct-2007 -- Alberto Morea: Test Ok. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// #RNU_RES_B +//NUT Nella fun info posso mettere le size simboliche per out arg e non quelle numeriche +//NUT che non usero' mai, anche perche' se un giorno decidero' di cambiare approccio e usero' funzioni +//NUT differenti per size differenti allora dovro' cambiare anche il loro nome per distinguerle +//NUT e di conseguenza avro' funinfo differenti. +// #RNU_RES_E +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),11,11); + + +// ----------------------- +// --- Initialization. --- +// ----------------------- +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// #RNU_RES_B +// ---------------------------------------------------------- +// --- Find Position of the first output scalar argument. --- +// ---------------------------------------------------------- +// #RNU_RES_E +PosFirstOutScalar = 0; +FoundOutScalar = 0; +for counterout = 1:NOutArg + if (OutArg(counterout).Dimension == 0) + if (FoundOutScalar==0) + PosFirstOutScalar = counterout; + FoundOutScalar = 1; + end + end +end + +// ------------------------------------ +// --- Update C function dat files. --- +// ------------------------------------ +clear FunInfo +FunInfo.SCIFunctionName = FunctionName; +FunInfo.CFunctionName = CFunName; +FunInfo.FunPrecSpecifier = FunPrecSpecifier; +FunInfo.FunTypeAnnot = FunTypeAnnot; +FunInfo.FunSizeAnnot = FunSizeAnnot; +FunInfo.InArg = InArg; +FunInfo.NInArg = NInArg; +FunInfo.OutArg = OutArg; +FunInfo.NOutArg = NOutArg; +FunInfo.PosFirstOutScalar = PosFirstOutScalar; +FunInfo.LibTypeInfo = LibTypeInfo; +save(fullfile(FunInfoDatDir,CFunName+'.dat'),FunInfo); +clear FunInfo + +endfunction diff --git a/macros/CCodeGeneration/GetClsFileName.sci b/macros/CCodeGeneration/GetClsFileName.sci new file mode 100644 index 00000000..ec9ce5b9 --- /dev/null +++ b/macros/CCodeGeneration/GetClsFileName.sci @@ -0,0 +1,95 @@ +function SCI2CClassFileName = GetClsFileName(FunName,FileInfo,SharedInfo) +// function SCI2CClassFileName = GetClsFileName(FunName,FileInfo,SharedInfo) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 11-Jul-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),3,3); + +// //NUT: verifica che il nome sia accettabile e che non +// //NUT: occorra spezzettarla in piu funzioni. + +// --- Extraction of the function name and number. --- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; + +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; + +// --- Initialization. --- +tmpannfilename = FunName+'.ann'; +tmpscifilename = FunName+'.sci'; +AnnFileName = ''; +ClsFileName = '' + +SCI2CClassSpecifier = SharedInfo.Annotations.FUNCLASS; +FlagFoundAnnFile = 0; +// #RNU_RES_B +//NUT: qui e' presente la lista delle priorita' di accesso alle annotazioni. +// #RNU_RES_E +if SCI2Cfileexist(FileInfo.USER2CLibCAnnFun,tmpannfilename) + // #RNU_RES_B + // It is a C function of the USER2C library. + // #RNU_RES_E + FlagFoundAnnFile = 1; + AnnFileName = fullfile(FileInfo.USER2CLibCAnnFun,tmpannfilename); + SCI2CClassName = FL_GetFunctionClass(AnnFileName,SCI2CClassSpecifier,ReportFileName); + SCI2CClassFileName = fullfile(FileInfo.USER2CLibCAnnCls,SCI2CClassName+'.acls'); +elseif SCI2Cfileexist(FileInfo.USER2CLibSCIAnnFun,tmpannfilename) + // #RNU_RES_B + // It is a scilab function of the USER2C library. + // #RNU_RES_E + FlagFoundAnnFile = 1; + AnnFileName = fullfile(FileInfo.USER2CLibSCIAnnFun,tmpannfilename); + SCI2CClassName = FL_GetFunctionClass(AnnFileName,SCI2CClassSpecifier,ReportFileName); + SCI2CClassFileName = fullfile(FileInfo.USER2CLibSCIAnnCls,SCI2CClassName+'.acls'); +elseif (SCI2Cfileexist(FileInfo.SCI2CLibCAnnFun,tmpannfilename)) + // #RNU_RES_B + // It is a C function of the SCI2C library. + // #RNU_RES_E + FlagFoundAnnFile = 1; + AnnFileName = fullfile(FileInfo.SCI2CLibCAnnFun,tmpannfilename); + SCI2CClassName = FL_GetFunctionClass(AnnFileName,SCI2CClassSpecifier,ReportFileName); + SCI2CClassFileName = fullfile(FileInfo.SCI2CLibCAnnCls,SCI2CClassName+'.acls'); +elseif (SCI2Cfileexist(FileInfo.SCI2CLibSCIAnnFun,tmpannfilename)) + // #RNU_RES_B + // It is a scilab function of the SCI2C library. + // #RNU_RES_E + FlagFoundAnnFile = 1; + AnnFileName = fullfile(FileInfo.SCI2CLibSCIAnnFun,tmpannfilename); + SCI2CClassName = FL_GetFunctionClass(AnnFileName,SCI2CClassSpecifier,ReportFileName); + SCI2CClassFileName = fullfile(FileInfo.SCI2CLibSCIAnnCls,SCI2CClassName+'.acls'); +end + +if (FlagFoundAnnFile == 0) + [FlagFoundAnnFile,fullpathscifilename] = SCI2CFindFile(FileInfo.UserSciFilesPaths,FunName+'.sci'); + if (FlagFoundAnnFile == 0) + // #RNU_RES_B + PrintStringInfo(' ',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: Missing function annotation. Could not find',ReportFileName,'both','y'); + PrintStringInfo('SCI2CERROR: an associated .sci or .ann file for function: '+FunName,ReportFileName,'both','y'); + PrintStringInfo(' ',ReportFileName,'both','y'); + // #RNU_RES_E + SCI2Cerror(' '); + end + AnnFileName = fullfile(FileInfo.USER2CLibSCIAnnFun,tmpannfilename); + SCI2CClassName = FunName; + SCI2CClassFileName = fullfile(FileInfo.USER2CLibSCIAnnCls,SCI2CClassName+'.acls'); + Sci2AnnotationFile(fullpathscifilename,SCI2CClassFileName,AnnFileName,... + SharedInfo.Annotations.USERFUN,ReportFileName); +end +endfunction diff --git a/macros/CCodeGeneration/GetSymbolDimension.sci b/macros/CCodeGeneration/GetSymbolDimension.sci new file mode 100644 index 00000000..4fe3cc8d --- /dev/null +++ b/macros/CCodeGeneration/GetSymbolDimension.sci @@ -0,0 +1,70 @@ +function symboldimension = GetSymbolDimension(Field_Size) +// function symboldimension = GetSymbolDimension(Field_Size) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Get the dimesion (0D,1D,2D) of a symbol given its size. +// +// Input data: +// Field_Size: it is the Size field of the InArg or OutArg structures. +// It is a 2-element array. N-dim array are not supported +// in this release. +// +// Output data: +// symboldimension: number specifying the dimension of the symbol. +// 0 = scalar; 1 = column or row; 2 = matrix. +// +// #RNU_RES_E +// Status: +// 26-Oct-2007 -- Raffaele Nutricato: Author. +// 26-Oct-2007 -- Alberto Morea: Test Ok. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +// Size is expressed as an array of two strings. +Nelem = max(size(Field_Size)); +if (Nelem < 2) + SCI2Cerror('The size of a symbol cannot be expressed with one or zero numbers.'); +end +for countersize = 1:Nelem + // #RNU_RES_B + // Field_Type = 1; if Size is Symbol or a number > 1 + // Field_Type = 0; if Size is a number == 1 + // error if Size is 0. + // A symbol is scalar if the sum of the Field_Type elements is zero. + // A symbol is column or row if the sum of the Field_Type elements is one. + // A symbol is a matrix if the sum of the Field_Type elements is > 1. + // #RNU_RES_E + if (isnum(Field_Size(countersize))) + tmpnum = eval(Field_Size(countersize)); + if (tmpnum == 0) + SCI2Cerror('Found a symbol that has zeros elements. 0xN or Nx0 matrices are not allowed.'); + elseif (tmpnum == 1) + Field_Type(countersize) = 0; + else + Field_Type(countersize) = 1; + end + else + Field_Type(countersize) = 1; + end +end + +Sum_Field_Type = sum(Field_Type); +if (Sum_Field_Type == 0) + symboldimension = 0; +elseif (Sum_Field_Type == 1) + // #RNU_RES_B + // symboldimension = 1; //NUT for this release there will not be difference between vectors and matrices. + // #RNU_RES_E + symboldimension = 2; +else + symboldimension = 2; +end + +endfunction diff --git a/macros/CCodeGeneration/GetWhileCondVariable.sci b/macros/CCodeGeneration/GetWhileCondVariable.sci new file mode 100644 index 00000000..ba4c7e92 --- /dev/null +++ b/macros/CCodeGeneration/GetWhileCondVariable.sci @@ -0,0 +1,72 @@ +function SharedInfo = GetWhileCondVariable(OutArg,NOutArg,FunctionName,FileInfo,SharedInfo) +// function SharedInfo = GetWhileCondVariable(OutArg,NOutArg,FunctionName,FileInfo,SharedInfo) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 26-Oct-2007 -- Raffaele Nutricato: Author. +// 26-Oct-2007 -- Alberto Morea: Test Ok. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +//NUT: secondo me questa funzione non serve a nulla + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),5,5); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +nxtscifunnumber = SharedInfo.NextSCIFunNumber; +ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName; + +// #RNU_RES_B +PrintStringInfo(' ',ReportFileName,'file','y'); +PrintStringInfo('***Checking if the current function is handling while counter variables.***',ReportFileName,'file','y'); +// #RNU_RES_E + +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// #RNU_RES_B +// ----------------------------------------------- +// --- Initial Check on While counter variables. --- +// ----------------------------------------------- +// #RNU_RES_E +if ((SharedInfo.WhileExpr.OnExec > 0) & (NOutArg==1)) + // #RNU_RES_B + //NUT: se sono in una while expression devo memorizzarmi l'ultima variabile di output + //NUT: perche' e' quella che contiene la condizione da testare, + //NUT: allora io me le salvo tutte e l'ultima salvata sara' quella che andra' a finire + //NUT: nella while. + // #RNU_RES_E + SharedInfo.WhileExpr.CondVar = OutArg(1).Name; + // #RNU_RES_B + //if (SharedInfo.WhileExpr.AssignmentFun == 0) + //NUT: Test also that SharedInfo.WhileExpr.AssignmentFun because sometimes Equal are dummy! + //NUT: verifica se e' giusta questa mia affermazione. + //RNU il seguente test e' stato spostato nella AST_HandleWhileStatem.c perche' + //RNU: secondo me la matrice finale non e' supportata dalla while, ma while(det(M)>0) + //RNU: puo' essere benissimo supportato. + // if (OutArg.Dimension > 0) + // SCI2CerrorFile('Cannot manage while with matrix conditions',ReportFileName); + // SharedInfo.SkipNextFun = 0; //NUT verifica se serve + // end + // #RNU_RES_E + SharedInfo.WhileExpr.DimCondVar = OutArg(1).Dimension; + ///end +end + +endfunction diff --git a/macros/CCodeGeneration/JoinDeclarAndCcode.sci b/macros/CCodeGeneration/JoinDeclarAndCcode.sci new file mode 100644 index 00000000..ebbf0023 --- /dev/null +++ b/macros/CCodeGeneration/JoinDeclarAndCcode.sci @@ -0,0 +1,168 @@ +function JoinDeclarAndCcode(FileInfoDatFile) +// function JoinDeclarAndCcode(FileInfoDatFile) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 07-Nov-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +// --------------------- +// --- Load section. --- +// --------------------- +// --- Load File Info Structure. --- +load(FileInfoDatFile,'FileInfo'); + +// --- Load Shared Info Structure. --- +load(FileInfo.SharedInfoDatFile,'SharedInfo'); +// ------------------------- +// --- End load section. --- +// ------------------------- + +// ----------------------- +// --- Initialization. --- +// ----------------------- +nxtscifunname = SharedInfo.NextSCIFunName; +funnumber = SharedInfo.NextSCIFunNumber; + +CPass1FileName = FileInfo.Funct(funnumber).CPass1FileName; +CPass2FileName = FileInfo.Funct(funnumber).CPass2FileName; +CDeclarationFileName = FileInfo.Funct(funnumber).CDeclarationFileName; +CGblDeclarFileName = FileInfo.Funct(funnumber).CGblDeclarFileName; +CInitVarsFileName = FileInfo.Funct(funnumber).CInitVarsFileName; +ReportFileName = FileInfo.Funct(funnumber).ReportFileName; + +CPass1V1FileFid = SCI2COpenFileRead(CPass1FileName); +CDeclarationFileFid = SCI2COpenFileRead(CDeclarationFileName); +CGblDeclarFileFid = SCI2COpenFileRead(CGblDeclarFileName); +CInitVarsFileFid = SCI2COpenFileRead(CInitVarsFileName); +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +PrintStepInfo('Joining declaration and C-call files',ReportFileName,'file'); + +PrintStringInfo('/*',CPass2FileName,'file','y'); +PrintStringInfo('** -------------------------------------',CPass2FileName,'file','y'); +PrintStringInfo('** --- Global Variables Declaration. ---',CPass2FileName,'file','y'); +PrintStringInfo('** -------------------------------------',CPass2FileName,'file','y'); +PrintStringInfo('*/',CPass2FileName,'file','y'); +// #RNU_RES_B +// --- Copy in V2 the global declaration file. --- +// #RNU_RES_E +while (~meof(CGblDeclarFileFid)) + // Read a line from C Global Declaration file. + tmpcline = mgetl(CGblDeclarFileFid,1); + if (length(tmpcline) == 0) + tmpcline = ' '; + end + + noblkstmpcline = stripblanks(tmpcline); + PrintStringInfo(tmpcline,CPass2FileName,'file','y'); +end +PrintStringInfo('/*',CPass2FileName,'file','y'); +PrintStringInfo('** -----------------------------------------',CPass2FileName,'file','y'); +PrintStringInfo('** --- End Global Variables Declaration. ---',CPass2FileName,'file','y'); +PrintStringInfo('** -----------------------------------------',CPass2FileName,'file','y'); +PrintStringInfo('*/',CPass2FileName,'file','y'); +PrintStringInfo(' ',CPass2FileName,'file','y'); + +// #RNU_RES_B +// --- Copy in V2 the first part of V1 up to "{". --- +// #RNU_RES_E +FoundCurlyBracket = 0; +while ((~meof(CPass1V1FileFid)) & (FoundCurlyBracket == 0)) + // Read a line from C Pass1 file. + tmpcline = mgetl(CPass1V1FileFid,1); + noblkstmpcline = stripblanks(tmpcline); + if (length(noblkstmpcline) > 0) + if (SCI2Cstrncmps1size('{',noblkstmpcline)) + FoundCurlyBracket = 1; + end + else + tmpcline = ' '; + end + PrintStringInfo(tmpcline,CPass2FileName,'file','y'); +end + +if (FoundCurlyBracket == 0) + SCI2CerrorFile('""{"" char not found in:'+CPass1FileName,ReportFileName); +end + +PrintStringInfo('/*',CPass2FileName,'file','y'); +PrintStringInfo('** -----------------------------',CPass2FileName,'file','y'); +PrintStringInfo('** --- Variable Declaration. ---',CPass2FileName,'file','y'); +PrintStringInfo('** -----------------------------',CPass2FileName,'file','y'); +PrintStringInfo('*/',CPass2FileName,'file','y'); +// --- Copy in V2 the declaration file. --- +while (~meof(CDeclarationFileFid)) + // Read a line from C Declaration file. + tmpcline = mgetl(CDeclarationFileFid,1); + if (length(tmpcline) == 0) + tmpcline = ' '; + end + + noblkstmpcline = stripblanks(tmpcline); + PrintStringInfo(tmpcline,CPass2FileName,'file','y'); +end + +// #RNU_RES_B +// --- Copy in V2 the variable initialization file. --- +// #RNU_RES_E +while (~meof(CInitVarsFileFid)) + // Read a line from C Declaration file. + tmpcline = mgetl(CInitVarsFileFid,1); + if (length(tmpcline) == 0) + tmpcline = ' '; + end + + noblkstmpcline = stripblanks(tmpcline); + PrintStringInfo(tmpcline,CPass2FileName,'file','y'); +end +PrintStringInfo('/*',CPass2FileName,'file','y'); +PrintStringInfo('** ---------------------------------',CPass2FileName,'file','y'); +PrintStringInfo('** --- End Variable Declaration. ---',CPass2FileName,'file','y'); +PrintStringInfo('** ---------------------------------',CPass2FileName,'file','y'); +PrintStringInfo('*/',CPass2FileName,'file','y'); + + +PrintStringInfo('/*',CPass2FileName,'file','y'); +PrintStringInfo('** ---------------',CPass2FileName,'file','y'); +PrintStringInfo('** --- C code. ---',CPass2FileName,'file','y'); +PrintStringInfo('** ---------------',CPass2FileName,'file','y'); +PrintStringInfo('*/',CPass2FileName,'file','y'); +// --- Copy the remaining part of V1 in V2. --- +while (~meof(CPass1V1FileFid)) + // #RNU_RES_B + // Read a line from C Pass1 file. + // #RNU_RES_E + tmpcline = mgetl(CPass1V1FileFid,1); + if (length(tmpcline) == 0) + tmpcline = ' '; + end + PrintStringInfo(tmpcline,CPass2FileName,'file','y'); +end + +// -------------------- +// --- Close Files. --- +// -------------------- +mclose(CPass1V1FileFid); +mclose(CDeclarationFileFid); +mclose(CGblDeclarFileFid); +mclose(CInitVarsFileFid); + +endfunction diff --git a/macros/CCodeGeneration/SCI2CMakefileTemplate.bkp b/macros/CCodeGeneration/SCI2CMakefileTemplate.bkp new file mode 100644 index 00000000..65184df1 --- /dev/null +++ b/macros/CCodeGeneration/SCI2CMakefileTemplate.bkp @@ -0,0 +1,230 @@ +
+# --- C COMPILER ---
+CC = gcc
+CFLAGS = -Wall -pedantic -O3 -I $(HSRCDIR)
+# ---------------------------
+# --- END USER PARAMETERS ---
+# ---------------------------
+
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# DON'T TOUCH ANYTHING BELOW THIS LINE
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+
+ELEMENTARY_FUNCTIONS_DIR = $(CSRCDIR)/src/elementaryFunctions
+CFLAGS_ELEMENTARY_FUNCTIONS = -I $(ELEMENTARY_FUNCTIONS_DIR)/includes -I $(ELEMENTARY_FUNCTIONS_DIR)/interfaces
+
+
+EXEFILE = $(SCI2CDIR)/$(EXEFILENAME)
+
+objects = \
+ $(OBJDIR)/doubleComplex.o \
+ $(OBJDIR)/floatComplex.o \
+ $(OBJDIR)/RealToComplex.o \
+ $(OBJDIR)/conj.o \
+ $(OBJDIR)/disp.o \
+ $(OBJDIR)/ones.o \
+ $(OBJDIR)/zeros.o \
+ $(OBJDIR)/OpApex.o \
+ $(OBJDIR)/OpColon.o \
+ $(OBJDIR)/OpDotStar.o \
+ $(OBJDIR)/OpDotHat.o \
+ $(OBJDIR)/OpDotSlash.o \
+ $(OBJDIR)/OpEqual.o \
+ $(OBJDIR)/OpPlus.o \
+ $(OBJDIR)/OpMinus.o \
+ $(OBJDIR)/OpStar.o \
+ $(OBJDIR)/OpIns.o \
+ $(OBJDIR)/OpExt.o \
+ $(OBJDIR)/OpRc.o \
+ $(OBJDIR)/OpCc.o \
+ $(OBJDIR)/cos.o \
+ $(OBJDIR)/cosh.o \
+ $(OBJDIR)/sin.o \
+ $(OBJDIR)/sinh.o \
+ $(OBJDIR)/FileManagement.o \
+ $(OBJDIR)/OpLogLt.o \
+ $(OBJDIR)/OpLogGt.o \
+ $(OBJDIR)/OpLogGe.o \
+ $(OBJDIR)/OpLogLe.o \
+ $(OBJDIR)/OpLogEq.o \
+ $(OBJDIR)/Find.o \
+ $(OBJDIR)/ConvertPrecision.o \
+ $(OBJDIR)/SCI2Cfft.o \
+ $(OBJDIR)/SCI2Cconvol.o \
+ $(OBJDIR)/ssqrts.o \
+ $(OBJDIR)/dsqrts.o \
+ $(OBJDIR)/csqrts.o \
+ $(OBJDIR)/zsqrts.o \
+ $(OBJDIR)/ssqrta.o \
+ $(OBJDIR)/dsqrta.o \
+ $(OBJDIR)/csqrta.o \
+ $(OBJDIR)/zsqrta.o
+
+# ---------------
+# --- TARGETS ---
+# ---------------
+compileexecute: $(objects)
+ @echo " "
+ @echo "============================"
+ @echo "Generation of the executable"
+ @echo "============================"
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) $(objects) $(SCI2CDIR)/*.c -o $(EXEFILE)
+ @echo " "
+ @echo "=============="
+ @echo "Executing code"
+ @echo "=============="
+ $(EXEFILE)
+
+clean:
+ @echo " "
+ @echo "============================="
+ @echo "Removing only exe + obj files"
+ @echo "============================="
+ rm -rf $(EXEFILE)
+ rm -rf $(objects)
+ @echo " "
+
+cleanexe:
+ @echo " "
+ @echo "=========================="
+ @echo "Removing only the exe file"
+ @echo "=========================="
+ rm -rf $(EXEFILE)
+ @echo " "
+
+$(OBJDIR)/doubleComplex.o: $(CSRCDIR)/doubleComplex.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/doubleComplex.c -o $(OBJDIR)/doubleComplex.o
+
+$(OBJDIR)/floatComplex.o: $(CSRCDIR)/floatComplex.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/floatComplex.c -o $(OBJDIR)/floatComplex.o
+
+$(OBJDIR)/RealToComplex.o: $(CSRCDIR)/RealToComplex.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/RealToComplex.c -o $(OBJDIR)/RealToComplex.o
+
+$(OBJDIR)/conj.o: $(CSRCDIR)/conj.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/conj.c -o $(OBJDIR)/conj.o
+
+$(OBJDIR)/disp.o: $(CSRCDIR)/disp.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/disp.c -o $(OBJDIR)/disp.o
+
+$(OBJDIR)/zeros.o: $(CSRCDIR)/zeros.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/zeros.c -o $(OBJDIR)/zeros.o
+
+$(OBJDIR)/ones.o: $(CSRCDIR)/ones.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/ones.c -o $(OBJDIR)/ones.o
+
+$(OBJDIR)/OpApex.o: $(CSRCDIR)/OpApex.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpApex.c -o $(OBJDIR)/OpApex.o
+
+$(OBJDIR)/OpColon.o: $(CSRCDIR)/OpColon.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpColon.c -o $(OBJDIR)/OpColon.o
+
+$(OBJDIR)/OpDotStar.o: $(CSRCDIR)/OpDotStar.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpDotStar.c -o $(OBJDIR)/OpDotStar.o
+
+$(OBJDIR)/OpDotHat.o: $(CSRCDIR)/OpDotHat.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpDotHat.c -o $(OBJDIR)/OpDotHat.o
+
+$(OBJDIR)/OpDotSlash.o: $(CSRCDIR)/OpDotSlash.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpDotSlash.c -o $(OBJDIR)/OpDotSlash.o
+
+$(OBJDIR)/OpEqual.o: $(CSRCDIR)/OpEqual.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpEqual.c -o $(OBJDIR)/OpEqual.o
+
+$(OBJDIR)/OpPlus.o: $(CSRCDIR)/OpPlus.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpPlus.c -o $(OBJDIR)/OpPlus.o
+
+$(OBJDIR)/OpMinus.o: $(CSRCDIR)/OpMinus.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpMinus.c -o $(OBJDIR)/OpMinus.o
+
+$(OBJDIR)/OpStar.o: $(CSRCDIR)/OpStar.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpStar.c -o $(OBJDIR)/OpStar.o
+
+$(OBJDIR)/OpIns.o: $(CSRCDIR)/OpIns.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpIns.c -o $(OBJDIR)/OpIns.o
+
+$(OBJDIR)/OpExt.o: $(CSRCDIR)/OpExt.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpExt.c -o $(OBJDIR)/OpExt.o
+
+$(OBJDIR)/OpRc.o: $(CSRCDIR)/OpRc.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpRc.c -o $(OBJDIR)/OpRc.o
+
+$(OBJDIR)/OpCc.o: $(CSRCDIR)/OpCc.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpCc.c -o $(OBJDIR)/OpCc.o
+
+$(OBJDIR)/cos.o: $(CSRCDIR)/cos.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/cos.c -o $(OBJDIR)/cos.o
+
+$(OBJDIR)/cosh.o: $(CSRCDIR)/cosh.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/cosh.c -o $(OBJDIR)/cosh.o
+
+$(OBJDIR)/sin.o: $(CSRCDIR)/sin.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/sin.c -o $(OBJDIR)/sin.o
+
+$(OBJDIR)/sinh.o: $(CSRCDIR)/sinh.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/sinh.c -o $(OBJDIR)/sinh.o
+
+$(OBJDIR)/FileManagement.o: $(CSRCDIR)/FileManagement.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/FileManagement.c -o $(OBJDIR)/FileManagement.o
+
+$(OBJDIR)/OpLogLt.o: $(CSRCDIR)/OpLogLt.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpLogLt.c -o $(OBJDIR)/OpLogLt.o
+
+$(OBJDIR)/OpLogGt.o: $(CSRCDIR)/OpLogGt.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpLogGt.c -o $(OBJDIR)/OpLogGt.o
+
+$(OBJDIR)/OpLogLe.o: $(CSRCDIR)/OpLogLe.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpLogLe.c -o $(OBJDIR)/OpLogLe.o
+
+$(OBJDIR)/OpLogGe.o: $(CSRCDIR)/OpLogGe.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpLogGe.c -o $(OBJDIR)/OpLogGe.o
+
+$(OBJDIR)/OpLogEq.o: $(CSRCDIR)/OpLogEq.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpLogEq.c -o $(OBJDIR)/OpLogEq.o
+
+$(OBJDIR)/Find.o: $(CSRCDIR)/Find.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/Find.c -o $(OBJDIR)/Find.o
+
+$(OBJDIR)/ConvertPrecision.o: $(CSRCDIR)/ConvertPrecision.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/ConvertPrecision.c -o $(OBJDIR)/ConvertPrecision.o
+
+$(OBJDIR)/SCI2Cfft.o: $(CSRCDIR)/SCI2Cfft.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/SCI2Cfft.c -o $(OBJDIR)/SCI2Cfft.o
+
+$(OBJDIR)/SCI2Cconvol.o: $(CSRCDIR)/SCI2Cconvol.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/SCI2Cconvol.c -o $(OBJDIR)/SCI2Cconvol.o
+
+$(OBJDIR)/sqrt.o: $(CSRCELEMFUNDIR)/sqrt/*sqrt*.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCELEMFUNDIR)/sqrt/*sqrt*.c -o $(OBJDIR)/sqrt.o
+
+$(OBJDIR)/ssqrts.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/ssqrts.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/ssqrts.c -o $(OBJDIR)/ssqrts.o
+
+$(OBJDIR)/dsqrts.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/dsqrts.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/dsqrts.c -o $(OBJDIR)/dsqrts.o
+
+$(OBJDIR)/csqrts.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/csqrts.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/csqrts.c -o $(OBJDIR)/csqrts.o
+
+$(OBJDIR)/zsqrts.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/zsqrts.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/zsqrts.c -o $(OBJDIR)/zsqrts.o
+
+$(OBJDIR)/ssqrta.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/ssqrta.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/ssqrta.c -o $(OBJDIR)/ssqrta.o
+
+$(OBJDIR)/dsqrta.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/dsqrta.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/dsqrta.c -o $(OBJDIR)/dsqrta.o
+
+$(OBJDIR)/csqrta.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/csqrta.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/csqrta.c -o $(OBJDIR)/csqrta.o
+
+$(OBJDIR)/zsqrta.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/zsqrta.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/zsqrta.c -o $(OBJDIR)/zsqrta.o
diff --git a/macros/CCodeGeneration/SCI2CMakefileTemplate.bkp1 b/macros/CCodeGeneration/SCI2CMakefileTemplate.bkp1 new file mode 100644 index 00000000..65184df1 --- /dev/null +++ b/macros/CCodeGeneration/SCI2CMakefileTemplate.bkp1 @@ -0,0 +1,230 @@ +
+# --- C COMPILER ---
+CC = gcc
+CFLAGS = -Wall -pedantic -O3 -I $(HSRCDIR)
+# ---------------------------
+# --- END USER PARAMETERS ---
+# ---------------------------
+
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# DON'T TOUCH ANYTHING BELOW THIS LINE
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+
+ELEMENTARY_FUNCTIONS_DIR = $(CSRCDIR)/src/elementaryFunctions
+CFLAGS_ELEMENTARY_FUNCTIONS = -I $(ELEMENTARY_FUNCTIONS_DIR)/includes -I $(ELEMENTARY_FUNCTIONS_DIR)/interfaces
+
+
+EXEFILE = $(SCI2CDIR)/$(EXEFILENAME)
+
+objects = \
+ $(OBJDIR)/doubleComplex.o \
+ $(OBJDIR)/floatComplex.o \
+ $(OBJDIR)/RealToComplex.o \
+ $(OBJDIR)/conj.o \
+ $(OBJDIR)/disp.o \
+ $(OBJDIR)/ones.o \
+ $(OBJDIR)/zeros.o \
+ $(OBJDIR)/OpApex.o \
+ $(OBJDIR)/OpColon.o \
+ $(OBJDIR)/OpDotStar.o \
+ $(OBJDIR)/OpDotHat.o \
+ $(OBJDIR)/OpDotSlash.o \
+ $(OBJDIR)/OpEqual.o \
+ $(OBJDIR)/OpPlus.o \
+ $(OBJDIR)/OpMinus.o \
+ $(OBJDIR)/OpStar.o \
+ $(OBJDIR)/OpIns.o \
+ $(OBJDIR)/OpExt.o \
+ $(OBJDIR)/OpRc.o \
+ $(OBJDIR)/OpCc.o \
+ $(OBJDIR)/cos.o \
+ $(OBJDIR)/cosh.o \
+ $(OBJDIR)/sin.o \
+ $(OBJDIR)/sinh.o \
+ $(OBJDIR)/FileManagement.o \
+ $(OBJDIR)/OpLogLt.o \
+ $(OBJDIR)/OpLogGt.o \
+ $(OBJDIR)/OpLogGe.o \
+ $(OBJDIR)/OpLogLe.o \
+ $(OBJDIR)/OpLogEq.o \
+ $(OBJDIR)/Find.o \
+ $(OBJDIR)/ConvertPrecision.o \
+ $(OBJDIR)/SCI2Cfft.o \
+ $(OBJDIR)/SCI2Cconvol.o \
+ $(OBJDIR)/ssqrts.o \
+ $(OBJDIR)/dsqrts.o \
+ $(OBJDIR)/csqrts.o \
+ $(OBJDIR)/zsqrts.o \
+ $(OBJDIR)/ssqrta.o \
+ $(OBJDIR)/dsqrta.o \
+ $(OBJDIR)/csqrta.o \
+ $(OBJDIR)/zsqrta.o
+
+# ---------------
+# --- TARGETS ---
+# ---------------
+compileexecute: $(objects)
+ @echo " "
+ @echo "============================"
+ @echo "Generation of the executable"
+ @echo "============================"
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) $(objects) $(SCI2CDIR)/*.c -o $(EXEFILE)
+ @echo " "
+ @echo "=============="
+ @echo "Executing code"
+ @echo "=============="
+ $(EXEFILE)
+
+clean:
+ @echo " "
+ @echo "============================="
+ @echo "Removing only exe + obj files"
+ @echo "============================="
+ rm -rf $(EXEFILE)
+ rm -rf $(objects)
+ @echo " "
+
+cleanexe:
+ @echo " "
+ @echo "=========================="
+ @echo "Removing only the exe file"
+ @echo "=========================="
+ rm -rf $(EXEFILE)
+ @echo " "
+
+$(OBJDIR)/doubleComplex.o: $(CSRCDIR)/doubleComplex.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/doubleComplex.c -o $(OBJDIR)/doubleComplex.o
+
+$(OBJDIR)/floatComplex.o: $(CSRCDIR)/floatComplex.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/floatComplex.c -o $(OBJDIR)/floatComplex.o
+
+$(OBJDIR)/RealToComplex.o: $(CSRCDIR)/RealToComplex.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/RealToComplex.c -o $(OBJDIR)/RealToComplex.o
+
+$(OBJDIR)/conj.o: $(CSRCDIR)/conj.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/conj.c -o $(OBJDIR)/conj.o
+
+$(OBJDIR)/disp.o: $(CSRCDIR)/disp.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/disp.c -o $(OBJDIR)/disp.o
+
+$(OBJDIR)/zeros.o: $(CSRCDIR)/zeros.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/zeros.c -o $(OBJDIR)/zeros.o
+
+$(OBJDIR)/ones.o: $(CSRCDIR)/ones.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/ones.c -o $(OBJDIR)/ones.o
+
+$(OBJDIR)/OpApex.o: $(CSRCDIR)/OpApex.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpApex.c -o $(OBJDIR)/OpApex.o
+
+$(OBJDIR)/OpColon.o: $(CSRCDIR)/OpColon.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpColon.c -o $(OBJDIR)/OpColon.o
+
+$(OBJDIR)/OpDotStar.o: $(CSRCDIR)/OpDotStar.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpDotStar.c -o $(OBJDIR)/OpDotStar.o
+
+$(OBJDIR)/OpDotHat.o: $(CSRCDIR)/OpDotHat.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpDotHat.c -o $(OBJDIR)/OpDotHat.o
+
+$(OBJDIR)/OpDotSlash.o: $(CSRCDIR)/OpDotSlash.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpDotSlash.c -o $(OBJDIR)/OpDotSlash.o
+
+$(OBJDIR)/OpEqual.o: $(CSRCDIR)/OpEqual.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpEqual.c -o $(OBJDIR)/OpEqual.o
+
+$(OBJDIR)/OpPlus.o: $(CSRCDIR)/OpPlus.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpPlus.c -o $(OBJDIR)/OpPlus.o
+
+$(OBJDIR)/OpMinus.o: $(CSRCDIR)/OpMinus.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpMinus.c -o $(OBJDIR)/OpMinus.o
+
+$(OBJDIR)/OpStar.o: $(CSRCDIR)/OpStar.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpStar.c -o $(OBJDIR)/OpStar.o
+
+$(OBJDIR)/OpIns.o: $(CSRCDIR)/OpIns.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpIns.c -o $(OBJDIR)/OpIns.o
+
+$(OBJDIR)/OpExt.o: $(CSRCDIR)/OpExt.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpExt.c -o $(OBJDIR)/OpExt.o
+
+$(OBJDIR)/OpRc.o: $(CSRCDIR)/OpRc.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpRc.c -o $(OBJDIR)/OpRc.o
+
+$(OBJDIR)/OpCc.o: $(CSRCDIR)/OpCc.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpCc.c -o $(OBJDIR)/OpCc.o
+
+$(OBJDIR)/cos.o: $(CSRCDIR)/cos.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/cos.c -o $(OBJDIR)/cos.o
+
+$(OBJDIR)/cosh.o: $(CSRCDIR)/cosh.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/cosh.c -o $(OBJDIR)/cosh.o
+
+$(OBJDIR)/sin.o: $(CSRCDIR)/sin.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/sin.c -o $(OBJDIR)/sin.o
+
+$(OBJDIR)/sinh.o: $(CSRCDIR)/sinh.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/sinh.c -o $(OBJDIR)/sinh.o
+
+$(OBJDIR)/FileManagement.o: $(CSRCDIR)/FileManagement.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/FileManagement.c -o $(OBJDIR)/FileManagement.o
+
+$(OBJDIR)/OpLogLt.o: $(CSRCDIR)/OpLogLt.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpLogLt.c -o $(OBJDIR)/OpLogLt.o
+
+$(OBJDIR)/OpLogGt.o: $(CSRCDIR)/OpLogGt.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpLogGt.c -o $(OBJDIR)/OpLogGt.o
+
+$(OBJDIR)/OpLogLe.o: $(CSRCDIR)/OpLogLe.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpLogLe.c -o $(OBJDIR)/OpLogLe.o
+
+$(OBJDIR)/OpLogGe.o: $(CSRCDIR)/OpLogGe.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpLogGe.c -o $(OBJDIR)/OpLogGe.o
+
+$(OBJDIR)/OpLogEq.o: $(CSRCDIR)/OpLogEq.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/OpLogEq.c -o $(OBJDIR)/OpLogEq.o
+
+$(OBJDIR)/Find.o: $(CSRCDIR)/Find.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/Find.c -o $(OBJDIR)/Find.o
+
+$(OBJDIR)/ConvertPrecision.o: $(CSRCDIR)/ConvertPrecision.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/ConvertPrecision.c -o $(OBJDIR)/ConvertPrecision.o
+
+$(OBJDIR)/SCI2Cfft.o: $(CSRCDIR)/SCI2Cfft.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/SCI2Cfft.c -o $(OBJDIR)/SCI2Cfft.o
+
+$(OBJDIR)/SCI2Cconvol.o: $(CSRCDIR)/SCI2Cconvol.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCDIR)/SCI2Cconvol.c -o $(OBJDIR)/SCI2Cconvol.o
+
+$(OBJDIR)/sqrt.o: $(CSRCELEMFUNDIR)/sqrt/*sqrt*.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) -c $(CSRCELEMFUNDIR)/sqrt/*sqrt*.c -o $(OBJDIR)/sqrt.o
+
+$(OBJDIR)/ssqrts.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/ssqrts.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/ssqrts.c -o $(OBJDIR)/ssqrts.o
+
+$(OBJDIR)/dsqrts.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/dsqrts.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/dsqrts.c -o $(OBJDIR)/dsqrts.o
+
+$(OBJDIR)/csqrts.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/csqrts.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/csqrts.c -o $(OBJDIR)/csqrts.o
+
+$(OBJDIR)/zsqrts.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/zsqrts.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/zsqrts.c -o $(OBJDIR)/zsqrts.o
+
+$(OBJDIR)/ssqrta.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/ssqrta.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/ssqrta.c -o $(OBJDIR)/ssqrta.o
+
+$(OBJDIR)/dsqrta.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/dsqrta.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/dsqrta.c -o $(OBJDIR)/dsqrta.o
+
+$(OBJDIR)/csqrta.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/csqrta.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/csqrta.c -o $(OBJDIR)/csqrta.o
+
+$(OBJDIR)/zsqrta.o: $(CSRCDIR)/src/elementaryFunctions/sqrt/zsqrta.c $(HSRCDIR)/*.h
+ $(CC) $(CFLAGS) $(CFLAGS_ELEMENTARY_FUNCTIONS) -c $(ELEMENTARY_FUNCTIONS_DIR)/sqrt/zsqrta.c -o $(OBJDIR)/zsqrta.o
diff --git a/macros/CCodeGeneration/SCI2CMakefileTemplate.bkp2 b/macros/CCodeGeneration/SCI2CMakefileTemplate.bkp2 new file mode 100644 index 00000000..c6ba2a9c --- /dev/null +++ b/macros/CCodeGeneration/SCI2CMakefileTemplate.bkp2 @@ -0,0 +1,126 @@ +
+# --- C COMPILER ---
+CC = gcc
+CFLAGS = -Wall -pedantic -O3 -I $(HSRCDIR) -I $(ISRCDIR)
+# ---------------------------
+# --- END USER PARAMETERS ---
+# ---------------------------
+
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# DON'T TOUCH ANYTHING BELOW THIS LINE
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+# ------------------------------------
+
+EXEFILE = $(SCI2CDIR)/$(EXEFILENAME)
+
+SWSRCS = \
+ $(CSRCDIR)/doubleComplex.c \
+ $(CSRCDIR)/floatComplex.c \
+ $(CSRCDIR)/RealToComplex.c \
+ $(CSRCDIR)/conj.c \
+ $(CSRCDIR)/disp.c \
+ $(CSRCDIR)/ones.c \
+ $(CSRCDIR)/zeros.c \
+ $(CSRCDIR)/OpApex.c \
+ $(CSRCDIR)/OpColon.c \
+ $(CSRCDIR)/OpDotStar.c \
+ $(CSRCDIR)/OpDotHat.c \
+ $(CSRCDIR)/OpDotSlash.c \
+ $(CSRCDIR)/OpEqual.c \
+ $(CSRCDIR)/OpPlus.c \
+ $(CSRCDIR)/OpMinus.c \
+ $(CSRCDIR)/OpStar.c \
+ $(CSRCDIR)/OpIns.c \
+ $(CSRCDIR)/OpExt.c \
+ $(CSRCDIR)/OpRc.c \
+ $(CSRCDIR)/OpCc.c \
+ $(CSRCDIR)/cos.c \
+ $(CSRCDIR)/cosh.c \
+ $(CSRCDIR)/sin.c \
+ $(CSRCDIR)/sinh.c \
+ $(CSRCDIR)/FileManagement.c \
+ $(CSRCDIR)/OpLogLt.c \
+ $(CSRCDIR)/OpLogGt.c \
+ $(CSRCDIR)/OpLogGe.c \
+ $(CSRCDIR)/OpLogLe.c \
+ $(CSRCDIR)/OpLogEq.c \
+ $(CSRCDIR)/OpLogOr.c \
+ $(CSRCDIR)/OpLogAnd.c \
+ $(CSRCDIR)/Find.c \
+ $(CSRCDIR)/ConvertPrecision.c \
+ $(CSRCDIR)/SCI2Cfft.c \
+ $(CSRCDIR)/SCI2Cconvol.c \
+ $(CSRCDIR)/ssqrts.c \
+ $(CSRCDIR)/dsqrts.c \
+ $(CSRCDIR)/csqrts.c \
+ $(CSRCDIR)/zsqrts.c \
+ $(CSRCDIR)/ssqrta.c \
+ $(CSRCDIR)/dsqrta.c \
+ $(CSRCDIR)/csqrta.c \
+ $(CSRCDIR)/zsqrta.c \
+ $(CSRCDIR)/sabss.c \ + $(CSRCDIR)/dabss.c \ + $(CSRCDIR)/cabss.c \ + $(CSRCDIR)/zabss.c \ + $(CSRCDIR)/sabsa.c \ + $(CSRCDIR)/dabsa.c \ + $(CSRCDIR)/cabsa.c \ + $(CSRCDIR)/zabsa.c \ + $(CSRCDIR)/sexps.c \ + $(CSRCDIR)/dexps.c \ + $(CSRCDIR)/cexps.c \ + $(CSRCDIR)/zexps.c \ + $(CSRCDIR)/sexpa.c \ + $(CSRCDIR)/dexpa.c \ + $(CSRCDIR)/cexpa.c \ + $(CSRCDIR)/zexpa.c +
+SWOBJS = $(SWSRCS:.c=.o) +
+# ---------------
+# --- TARGETS ---
+# ---------------
+compileexecute: $(SWOBJS)
+ @echo " "
+ @echo "============================"
+ @echo "Generation of the executable"
+ @echo "============================"
+ $(CC) $(CFLAGS) $(SWOBJS) $(SCI2CDIR)/*.c -o $(EXEFILE)
+ @echo " "
+ @echo "=============="
+ @echo "Executing code"
+ @echo "=============="
+ $(EXEFILE)
+
+clean:
+ @echo " "
+ @echo "============================="
+ @echo "Removing only exe + obj files"
+ @echo "============================="
+ rm -rf $(EXEFILE)
+ rm -rf $(SWOBJS)
+ @echo " "
+
+cleanexe:
+ @echo " "
+ @echo "=========================="
+ @echo "Removing only the exe file"
+ @echo "=========================="
+ rm -rf $(EXEFILE)
+ @echo " "
+
+# how to compile object code .o from C source files .c (general rule) +# space between -o and filename for SUN make +.c.o: + $(CC) $(CFLAGS) -c -o $(@) $<
+
+# Make object code from source +swobjs: $(SWOBJS) +
diff --git a/macros/CCodeGeneration/SCI2CMakefileTemplate.rc b/macros/CCodeGeneration/SCI2CMakefileTemplate.rc new file mode 100644 index 00000000..6d459829 --- /dev/null +++ b/macros/CCodeGeneration/SCI2CMakefileTemplate.rc @@ -0,0 +1,548 @@ + +# --- C COMPILER --- +CC = gcc +CFLAGS = -Wall -pedantic -O3 -I $(HSRCDIR) -I $(ISRCDIR) -lm +# --------------------------- +# --- END USER PARAMETERS --- +# --------------------------- + +# ------------------------------------ +# ------------------------------------ +# ------------------------------------ +# ------------------------------------ +# ------------------------------------ +# DON'T TOUCH ANYTHING BELOW THIS LINE +# ------------------------------------ +# ------------------------------------ +# ------------------------------------ +# ------------------------------------ +# ------------------------------------ + +EXEFILE = $(SCI2CDIR)/$(EXEFILENAME) + +SWSRCS = \ + $(CSRCDIR)/doubleComplex.c \ + $(CSRCDIR)/floatComplex.c \ + $(CSRCDIR)/ssqrts.c \ + $(CSRCDIR)/dsqrts.c \ + $(CSRCDIR)/csqrts.c \ + $(CSRCDIR)/zsqrts.c \ + $(CSRCDIR)/ssqrta.c \ + $(CSRCDIR)/dsqrta.c \ + $(CSRCDIR)/csqrta.c \ + $(CSRCDIR)/zsqrta.c \ + $(CSRCDIR)/sabss.c \ + $(CSRCDIR)/dabss.c \ + $(CSRCDIR)/cabss.c \ + $(CSRCDIR)/zabss.c \ + $(CSRCDIR)/sabsa.c \ + $(CSRCDIR)/dabsa.c \ + $(CSRCDIR)/cabsa.c \ + $(CSRCDIR)/zabsa.c \ + $(CSRCDIR)/smeana.c \ + $(CSRCDIR)/dmeana.c \ + $(CSRCDIR)/cmeana.c \ + $(CSRCDIR)/zmeana.c \ + $(CSRCDIR)/slog1ps.c \ + $(CSRCDIR)/dlog1ps.c \ + $(CSRCDIR)/slog1pa.c \ + $(CSRCDIR)/dlog1pa.c \ + $(CSRCDIR)/dfinda.c \ + $(CSRCDIR)/sfinda.c \ + $(CSRCDIR)/cfinda.c \ + $(CSRCDIR)/zfinda.c\ + $(CSRCDIR)/dfind2da.c \ + $(CSRCDIR)/sfind2da.c \ + $(CSRCDIR)/cfind2da.c \ + $(CSRCDIR)/zfind2da.c\ + $(CSRCDIR)/scats.c \ + $(CSRCDIR)/scata.c \ + $(CSRCDIR)/dcats.c \ + $(CSRCDIR)/dcata.c \ + $(CSRCDIR)/ccats.c \ + $(CSRCDIR)/ccata.c \ + $(CSRCDIR)/zcats.c \ + $(CSRCDIR)/zcata.c \ + $(CSRCDIR)/sdisps.c \ + $(CSRCDIR)/sdispa.c \ + $(CSRCDIR)/ddisps.c \ + $(CSRCDIR)/ddispa.c\ + $(CSRCDIR)/cdisps.c \ + $(CSRCDIR)/cdispa.c\ + $(CSRCDIR)/zdisps.c \ + $(CSRCDIR)/zdispa.c\ + $(CSRCDIR)/cmuls.c\ + $(CSRCDIR)/cmula.c \ + $(CSRCDIR)/dmuls.c\ + $(CSRCDIR)/dmula.c \ + $(CSRCDIR)/smuls.c\ + $(CSRCDIR)/smula.c \ + $(CSRCDIR)/zmuls.c\ + $(CSRCDIR)/zmula.c \ + $(CSRCDIR)/cadds.c\ + $(CSRCDIR)/cadda.c \ + $(CSRCDIR)/dadds.c\ + $(CSRCDIR)/dadda.c \ + $(CSRCDIR)/sadds.c\ + $(CSRCDIR)/sadda.c \ + $(CSRCDIR)/zadds.c\ + $(CSRCDIR)/zadda.c\ + $(CSRCDIR)/cdiffs.c\ + $(CSRCDIR)/cdiffa.c \ + $(CSRCDIR)/ddiffs.c\ + $(CSRCDIR)/ddiffa.c \ + $(CSRCDIR)/sdiffs.c\ + $(CSRCDIR)/sdiffa.c \ + $(CSRCDIR)/zdiffs.c\ + $(CSRCDIR)/zdiffa.c \ + $(CSRCDIR)/cfilla.c\ + $(CSRCDIR)/dfilla.c\ + $(CSRCDIR)/sfilla.c\ + $(CSRCDIR)/zfilla.c \ + $(CSRCDIR)/conesa.c\ + $(CSRCDIR)/donesa.c\ + $(CSRCDIR)/sonesa.c\ + $(CSRCDIR)/zonesa.c\ + $(CSRCDIR)/crdivs.c\ + $(CSRCDIR)/crdiva.c \ + $(CSRCDIR)/drdivs.c\ + $(CSRCDIR)/drdiva.c \ + $(CSRCDIR)/srdivs.c\ + $(CSRCDIR)/srdiva.c \ + $(CSRCDIR)/zrdivs.c\ + $(CSRCDIR)/zrdiva.c\ + $(CSRCDIR)/cldivs.c\ + $(CSRCDIR)/cldiva.c \ + $(CSRCDIR)/dldivs.c\ + $(CSRCDIR)/dldiva.c \ + $(CSRCDIR)/sldivs.c\ + $(CSRCDIR)/sldiva.c \ + $(CSRCDIR)/zldivs.c\ + $(CSRCDIR)/zldiva.c\ + $(CSRCDIR)/cconjs.c\ + $(CSRCDIR)/cconja.c\ + $(CSRCDIR)/zconjs.c\ + $(CSRCDIR)/zconja.c\ + $(CSRCDIR)/ceyea.c\ + $(CSRCDIR)/deyea.c\ + $(CSRCDIR)/seyea.c\ + $(CSRCDIR)/zeyea.c\ + $(CSRCDIR)/ctracea.c\ + $(CSRCDIR)/dtracea.c\ + $(CSRCDIR)/stracea.c\ + $(CSRCDIR)/ztracea.c\ + $(CSRCDIR)/srowmeana.c \ + $(CSRCDIR)/drowmeana.c \ + $(CSRCDIR)/crowmeana.c \ + $(CSRCDIR)/zrowmeana.c \ + $(CSRCDIR)/scolumnmeana.c \ + $(CSRCDIR)/dcolumnmeana.c \ + $(CSRCDIR)/ccolumnmeana.c \ + $(CSRCDIR)/zcolumnmeana.c \ + $(CSRCDIR)/ssuma.c \ + $(CSRCDIR)/dsuma.c \ + $(CSRCDIR)/csuma.c \ + $(CSRCDIR)/zsuma.c \ + $(CSRCDIR)/srowsuma.c \ + $(CSRCDIR)/drowsuma.c \ + $(CSRCDIR)/crowsuma.c \ + $(CSRCDIR)/zrowsuma.c \ + $(CSRCDIR)/scolumnsuma.c \ + $(CSRCDIR)/dcolumnsuma.c \ + $(CSRCDIR)/ccolumnsuma.c \ + $(CSRCDIR)/zcolumnsuma.c\ + $(CSRCDIR)/cmulma.c\ + $(CSRCDIR)/dmulma.c\ + $(CSRCDIR)/smulma.c\ + $(CSRCDIR)/zmulma.c\ + $(CSRCDIR)/svariancea.c \ + $(CSRCDIR)/dvariancea.c \ + $(CSRCDIR)/cvariancea.c \ + $(CSRCDIR)/zvariancea.c \ + $(CSRCDIR)/srowvariancea.c \ + $(CSRCDIR)/drowvariancea.c \ + $(CSRCDIR)/crowvariancea.c \ + $(CSRCDIR)/zrowvariancea.c \ + $(CSRCDIR)/scolumnvariancea.c \ + $(CSRCDIR)/dcolumnvariancea.c \ + $(CSRCDIR)/ccolumnvariancea.c \ + $(CSRCDIR)/zcolumnvariancea.c \ + $(CSRCDIR)/cpows.c \ + $(CSRCDIR)/cpowa.c \ + $(CSRCDIR)/dpows.c \ + $(CSRCDIR)/dpowa.c \ + $(CSRCDIR)/spows.c \ + $(CSRCDIR)/spowa.c \ + $(CSRCDIR)/zpows.c \ + $(CSRCDIR)/zpowa.c \ + $(CSRCDIR)/ctransposea.c \ + $(CSRCDIR)/dtransposea.c \ + $(CSRCDIR)/stransposea.c \ + $(CSRCDIR)/ztransposea.c \ + $(CSRCDIR)/clogs.c \ + $(CSRCDIR)/cloga.c \ + $(CSRCDIR)/dlogs.c \ + $(CSRCDIR)/dloga.c \ + $(CSRCDIR)/slogs.c \ + $(CSRCDIR)/sloga.c \ + $(CSRCDIR)/zlogs.c \ + $(CSRCDIR)/zloga.c \ + $(CSRCDIR)/cpythags.c\ + $(CSRCDIR)/dpythags.c \ + $(CSRCDIR)/spythags.c\ + $(CSRCDIR)/zpythags.c \ + $(CSRCDIR)/cacoss.c \ + $(CSRCDIR)/cacosa.c \ + $(CSRCDIR)/dacoss.c \ + $(CSRCDIR)/dacosa.c \ + $(CSRCDIR)/sacoss.c \ + $(CSRCDIR)/sacosa.c \ + $(CSRCDIR)/zacoss.c \ + $(CSRCDIR)/zacosa.c \ + $(CSRCDIR)/catans.c \ + $(CSRCDIR)/catana.c \ + $(CSRCDIR)/datans.c \ + $(CSRCDIR)/datana.c \ + $(CSRCDIR)/satans.c \ + $(CSRCDIR)/satana.c \ + $(CSRCDIR)/zatans.c \ + $(CSRCDIR)/zatana.c \ + $(CSRCDIR)/dlnp1m1s.c \ + $(CSRCDIR)/slnp1m1s.c\ + $(CSRCDIR)/cacoshs.c \ + $(CSRCDIR)/cacosha.c \ + $(CSRCDIR)/dacoshs.c \ + $(CSRCDIR)/dacosha.c \ + $(CSRCDIR)/sacoshs.c \ + $(CSRCDIR)/sacosha.c \ + $(CSRCDIR)/zacoshs.c \ + $(CSRCDIR)/zacosha.c\ + $(CSRCDIR)/crdivma.c \ + $(CSRCDIR)/drdivma.c \ + $(CSRCDIR)/srdivma.c \ + $(CSRCDIR)/zrdivma.c\ + $(CSRCDIR)/cldivma.c \ + $(CSRCDIR)/dldivma.c \ + $(CSRCDIR)/sldivma.c \ + $(CSRCDIR)/zldivma.c \ + $(CSRCDIR)/cinverma.c \ + $(CSRCDIR)/dinverma.c \ + $(CSRCDIR)/sinverma.c \ + $(CSRCDIR)/zinverma.c \ + $(CSRCDIR)/cexps.c \ + $(CSRCDIR)/dexps.c \ + $(CSRCDIR)/sexps.c \ + $(CSRCDIR)/zexps.c \ + $(CSRCDIR)/cexpa.c \ + $(CSRCDIR)/dexpa.c \ + $(CSRCDIR)/sexpa.c \ + $(CSRCDIR)/zexpa.c \ + $(CSRCDIR)/cexpma.c \ + $(CSRCDIR)/dexpma.c \ + $(CSRCDIR)/sexpma.c \ + $(CSRCDIR)/zexpma.c \ + $(CSRCDIR)/dfrexps.c \ + $(CSRCDIR)/sfrexps.c \ + $(CSRCDIR)/cinfnorma.c \ + $(CSRCDIR)/dinfnorma.c \ + $(CSRCDIR)/sinfnorma.c \ + $(CSRCDIR)/zinfnorma.c \ + $(CSRCDIR)/csigns.c \ + $(CSRCDIR)/csigna.c \ + $(CSRCDIR)/dsigns.c \ + $(CSRCDIR)/dsigna.c \ + $(CSRCDIR)/ssigns.c \ + $(CSRCDIR)/ssigna.c \ + $(CSRCDIR)/zsigns.c \ + $(CSRCDIR)/zsigna.c \ + $(CSRCDIR)/cdeterma.c \ + $(CSRCDIR)/ddeterma.c \ + $(CSRCDIR)/sdeterma.c \ + $(CSRCDIR)/zdeterma.c \ + $(CSRCDIR)/csins.c \ + $(CSRCDIR)/csina.c \ + $(CSRCDIR)/dsins.c \ + $(CSRCDIR)/dsina.c \ + $(CSRCDIR)/ssins.c \ + $(CSRCDIR)/ssina.c \ + $(CSRCDIR)/zsins.c \ + $(CSRCDIR)/zsina.c \ + $(CSRCDIR)/csinhs.c \ + $(CSRCDIR)/csinha.c \ + $(CSRCDIR)/dsinhs.c \ + $(CSRCDIR)/dsinha.c \ + $(CSRCDIR)/ssinhs.c \ + $(CSRCDIR)/ssinha.c \ + $(CSRCDIR)/zsinhs.c \ + $(CSRCDIR)/zsinha.c \ + $(CSRCDIR)/ccoshs.c \ + $(CSRCDIR)/ccosha.c \ + $(CSRCDIR)/dcoshs.c \ + $(CSRCDIR)/dcosha.c \ + $(CSRCDIR)/scoshs.c \ + $(CSRCDIR)/scosha.c \ + $(CSRCDIR)/zcoshs.c \ + $(CSRCDIR)/zcosha.c\ + $(CSRCDIR)/ccoss.c \ + $(CSRCDIR)/ccosa.c \ + $(CSRCDIR)/dcoss.c \ + $(CSRCDIR)/dcosa.c \ + $(CSRCDIR)/scoss.c \ + $(CSRCDIR)/scosa.c \ + $(CSRCDIR)/zcoss.c \ + $(CSRCDIR)/zcosa.c \ + $(CSRCDIR)/casins.c \ + $(CSRCDIR)/casina.c \ + $(CSRCDIR)/dasins.c \ + $(CSRCDIR)/dasina.c \ + $(CSRCDIR)/sasins.c \ + $(CSRCDIR)/sasina.c \ + $(CSRCDIR)/zasins.c \ + $(CSRCDIR)/zasina.c \ + $(CSRCDIR)/casinhs.c \ + $(CSRCDIR)/casinha.c \ + $(CSRCDIR)/dasinhs.c \ + $(CSRCDIR)/dasinha.c \ + $(CSRCDIR)/sasinhs.c \ + $(CSRCDIR)/sasinha.c \ + $(CSRCDIR)/zasinhs.c \ + $(CSRCDIR)/zasinha.c \ + $(CSRCDIR)/datan2s.c \ + $(CSRCDIR)/datan2a.c \ + $(CSRCDIR)/satan2s.c \ + $(CSRCDIR)/satan2a.c \ + $(CSRCDIR)/catanhs.c \ + $(CSRCDIR)/catanha.c \ + $(CSRCDIR)/datanhs.c \ + $(CSRCDIR)/datanha.c \ + $(CSRCDIR)/satanhs.c \ + $(CSRCDIR)/satanha.c \ + $(CSRCDIR)/zatanhs.c \ + $(CSRCDIR)/zatanha.c \ + $(CSRCDIR)/clog10s.c \ + $(CSRCDIR)/clog10a.c \ + $(CSRCDIR)/dlog10s.c \ + $(CSRCDIR)/dlog10a.c \ + $(CSRCDIR)/slog10s.c \ + $(CSRCDIR)/slog10a.c \ + $(CSRCDIR)/zlog10s.c \ + $(CSRCDIR)/zlog10a.c \ + $(CSRCDIR)/ctans.c \ + $(CSRCDIR)/ctana.c \ + $(CSRCDIR)/dtans.c \ + $(CSRCDIR)/dtana.c \ + $(CSRCDIR)/stans.c \ + $(CSRCDIR)/stana.c \ + $(CSRCDIR)/ztans.c \ + $(CSRCDIR)/ztana.c \ + $(CSRCDIR)/ctanhs.c \ + $(CSRCDIR)/ctanha.c \ + $(CSRCDIR)/dtanhs.c \ + $(CSRCDIR)/dtanha.c \ + $(CSRCDIR)/stanhs.c \ + $(CSRCDIR)/stanha.c \ + $(CSRCDIR)/ztanhs.c \ + $(CSRCDIR)/ztanha.c \ + $(CSRCDIR)/cisnans.c \ + $(CSRCDIR)/cisnana.c \ + $(CSRCDIR)/disnans.c \ + $(CSRCDIR)/disnana.c \ + $(CSRCDIR)/sisnans.c \ + $(CSRCDIR)/sisnana.c \ + $(CSRCDIR)/zisnans.c \ + $(CSRCDIR)/zisnana.c \ + $(CSRCDIR)/cconva.c \ + $(CSRCDIR)/dconva.c \ + $(CSRCDIR)/sconva.c \ + $(CSRCDIR)/zconva.c \ + $(CSRCDIR)/cconv2da.c \ + $(CSRCDIR)/dconv2da.c \ + $(CSRCDIR)/sconv2da.c \ + $(CSRCDIR)/zconv2da.c \ + $(CSRCDIR)/sfftma.c \ + $(CSRCDIR)/dfftma.c \ + $(CSRCDIR)/cfftma.c \ + $(CSRCDIR)/zfftma.c \ + $(CSRCDIR)/dfft2.c \ + $(CSRCDIR)/dfftbi.c \ + $(CSRCDIR)/dfftmx.c \ + $(CSRCDIR)/fft842.c \ + $(CSRCDIR)/r2tx.c \ + $(CSRCDIR)/r4tx.c \ + $(CSRCDIR)/r8tx.c \ + $(CSRCDIR)/sifftma.c \ + $(CSRCDIR)/difftma.c \ + $(CSRCDIR)/cifftma.c \ + $(CSRCDIR)/zifftma.c \ + $(CSRCDIR)/difft2.c \ + $(CSRCDIR)/difftbi.c \ + $(CSRCDIR)/difftmx.c \ + $(CSRCDIR)/ifft842.c \ + $(CSRCDIR)/ir2tx.c \ + $(CSRCDIR)/ir4tx.c \ + $(CSRCDIR)/ir8tx.c \ + $(CSRCDIR)/cchola.c \ + $(CSRCDIR)/dchols.c \ + $(CSRCDIR)/dchola.c \ + $(CSRCDIR)/schols.c \ + $(CSRCDIR)/schola.c \ + $(CSRCDIR)/zchola.c \ + $(CSRCDIR)/cleva.c \ + $(CSRCDIR)/dleva.c \ + $(CSRCDIR)/sleva.c \ + $(CSRCDIR)/zleva.c \ + $(CSRCDIR)/cleva2.c \ + $(CSRCDIR)/dleva2.c \ + $(CSRCDIR)/sleva2.c \ + $(CSRCDIR)/zleva2.c \ + $(CSRCDIR)/cimplicitLists.c \ + $(CSRCDIR)/dimplicitLists.c \ + $(CSRCDIR)/simplicitLists.c \ + $(CSRCDIR)/zimplicitLists.c \ + $(CSRCDIR)/czerosa.c \ + $(CSRCDIR)/dzerosa.c \ + $(CSRCDIR)/szerosa.c \ + $(CSRCDIR)/zzerosa.c \ + $(CSRCDIR)/cspeca.c \ + $(CSRCDIR)/dspeca.c \ + $(CSRCDIR)/sspeca.c \ + $(CSRCDIR)/zspeca.c \ + $(CSRCDIR)/cspec2a.c \ + $(CSRCDIR)/dspec2a.c \ + $(CSRCDIR)/sspec2a.c \ + $(CSRCDIR)/zspec2a.c \ + $(CSRCDIR)/smina.c \ + $(CSRCDIR)/smaxa.c \ + $(CSRCDIR)/srowmina.c \ + $(CSRCDIR)/srowmaxa.c \ + $(CSRCDIR)/scolumnmina.c \ + $(CSRCDIR)/scolumnmaxa.c \ + $(CSRCDIR)/dmina.c \ + $(CSRCDIR)/dmaxa.c \ + $(CSRCDIR)/drowmina.c \ + $(CSRCDIR)/drowmaxa.c \ + $(CSRCDIR)/dcolumnmina.c \ + $(CSRCDIR)/dcolumnmaxa.c \ + $(CSRCDIR)/cpowma.c \ + $(CSRCDIR)/dpowma.c \ + $(CSRCDIR)/spowma.c \ + $(CSRCDIR)/zpowma.c \ + $(CSRCDIR)/cfftshifta.c \ + $(CSRCDIR)/dfftshifta.c \ + $(CSRCDIR)/sfftshifta.c \ + $(CSRCDIR)/zfftshifta.c \ + $(CSRCDIR)/crowfftshifta.c \ + $(CSRCDIR)/drowfftshifta.c \ + $(CSRCDIR)/srowfftshifta.c \ + $(CSRCDIR)/zrowfftshifta.c \ + $(CSRCDIR)/ccolumnfftshifta.c \ + $(CSRCDIR)/dcolumnfftshifta.c \ + $(CSRCDIR)/scolumnfftshifta.c \ + $(CSRCDIR)/zcolumnfftshifta.c \ + $(CSRCDIR)/cceils.c \ + $(CSRCDIR)/cceila.c \ + $(CSRCDIR)/dceils.c \ + $(CSRCDIR)/dceila.c \ + $(CSRCDIR)/sceils.c \ + $(CSRCDIR)/sceila.c \ + $(CSRCDIR)/zceils.c \ + $(CSRCDIR)/zceila.c \ + $(CSRCDIR)/cfixs.c \ + $(CSRCDIR)/cfixa.c \ + $(CSRCDIR)/dfixs.c \ + $(CSRCDIR)/dfixa.c \ + $(CSRCDIR)/sfixs.c \ + $(CSRCDIR)/sfixa.c \ + $(CSRCDIR)/zfixs.c \ + $(CSRCDIR)/zfixa.c \ + $(CSRCDIR)/cfloors.c \ + $(CSRCDIR)/cfloora.c \ + $(CSRCDIR)/dfloors.c \ + $(CSRCDIR)/dfloora.c \ + $(CSRCDIR)/sfloors.c \ + $(CSRCDIR)/sfloora.c \ + $(CSRCDIR)/zfloors.c \ + $(CSRCDIR)/zfloora.c \ + $(CSRCDIR)/cints.c \ + $(CSRCDIR)/cinta.c \ + $(CSRCDIR)/dints.c \ + $(CSRCDIR)/dinta.c \ + $(CSRCDIR)/sints.c \ + $(CSRCDIR)/sinta.c \ + $(CSRCDIR)/zints.c \ + $(CSRCDIR)/zinta.c \ + $(CSRCDIR)/crounds.c \ + $(CSRCDIR)/crounda.c \ + $(CSRCDIR)/drounds.c \ + $(CSRCDIR)/drounda.c \ + $(CSRCDIR)/srounds.c \ + $(CSRCDIR)/srounda.c \ + $(CSRCDIR)/zrounds.c \ + $(CSRCDIR)/zrounda.c + + + + +# $(CSRCDIR)/RealToComplex.c \ +# $(CSRCDIR)/OpIns.c \ +# $(CSRCDIR)/OpExt.c \ +# $(CSRCDIR)/FileManagement.c \ +# $(CSRCDIR)/OpLogLt.c \ +# $(CSRCDIR)/OpLogGt.c \ +# $(CSRCDIR)/OpLogGe.c \ +# $(CSRCDIR)/OpLogLe.c \ +# $(CSRCDIR)/OpLogOr.c \ +# $(CSRCDIR)/OpLogAnd.c \ +# $(CSRCDIR)/ConvertPrecision.c \ + + + + + +# $(CSRCDIR)/clog1ps.c \ +# $(CSRCDIR)/zlog1ps.c \ +# $(CSRCDIR)/clog1pa.c \ +# $(CSRCDIR)/zlog1pa.c + +SWOBJS = $(SWSRCS:.c=.o) + +# --------------- +# --- TARGETS --- +# --------------- +compileexecute: $(SWOBJS) + @echo " " + @echo "============================" + @echo "Generation of the executable" + @echo "============================" + $(CC) $(CFLAGS) $(SWOBJS) *.c -llapack -lblas -o $(EXEFILE) + @echo " " + @echo "==============" + @echo "Executing code" + @echo "==============" + $(EXEFILE) + +clean: + @echo " " + @echo "=============================" + @echo "Removing only exe + obj files" + @echo "=============================" + rm -rf $(EXEFILE) + rm -rf $(SWOBJS) + @echo " " + +cleanexe: + @echo " " + @echo "==========================" + @echo "Removing only the exe file" + @echo "==========================" + rm -rf $(EXEFILE) + @echo " " + +# how to compile object code .o from C source files .c (general rule) +# space between -o and filename for SUN make +.c.o: + $(CC) $(CFLAGS) -c -o $(@) $< + +# Make object code from source +swobjs: $(SWOBJS) + diff --git a/macros/CCodeGeneration/Sci2AnnotationFile.sci b/macros/CCodeGeneration/Sci2AnnotationFile.sci new file mode 100644 index 00000000..001ed250 --- /dev/null +++ b/macros/CCodeGeneration/Sci2AnnotationFile.sci @@ -0,0 +1,55 @@ +function Sci2AnnotationFile(SciFileName,ClsFileName,AnnFileName,AnnSpecifier,ReportFileName) +// function Sci2AnnotationFile(SciFileName,ClsFileName,AnnFileName,AnnSpecifier,ReportFileName) +// -------------------------------------------------------------------------------- +// #RNU_RES_B +// This function reads the .sci input file and generates the correspondig .ann +// and .acls files. +// #RNU_RES_E +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 25-Jun-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),5,5); + +[tmppath,tmpfunname,tmpext] = fileparts(SciFileName); + +// --------------------------------------- +// --- Open the .sci file (read only). --- +// --------------------------------------- +inscifid = SCI2COpenFileRead(SciFileName); + +// ---------------------------------------------- +// --- Loop over the lines of the input file. --- +// ---------------------------------------------- +line_position = 0; +L_AnnSpecifierP1 = length(AnnSpecifier)+1; +while (meof(inscifid) == 0) + check_string = stripblanks(mgetl(inscifid,1)); + line_position = line_position + 1; + L_string = length(check_string); + if (L_string >= 1) + if (SCI2Cstrncmps1size(AnnSpecifier,check_string)) + tmpannotation = stripblanks(part(check_string,L_AnnSpecifierP1:L_string)); + PrintStringInfo(tmpannotation,ClsFileName,'file','y'); + end + end +end +mclose(inscifid); +// -------------------------------------------------- +// --- End loop over the lines of the input file. --- +// -------------------------------------------------- +PrintStringInfo('CLASS: '+tmpfunname,AnnFileName,'file','y'); +endfunction diff --git a/macros/CCodeGeneration/buildmacros.sce b/macros/CCodeGeneration/buildmacros.sce new file mode 100644 index 00000000..60fd2843 --- /dev/null +++ b/macros/CCodeGeneration/buildmacros.sce @@ -0,0 +1,15 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// +// + +tbx_build_macros(TOOLBOX_NAME, get_absolute_file_path('buildmacros.sce')); + +clear tbx_build_macros; |