summaryrefslogtreecommitdiff
path: root/2.3-1/macros/CCodeGeneration/C_GenerateMakefile.sci
diff options
context:
space:
mode:
authorSiddhesh Wani2015-05-25 14:46:31 +0530
committerSiddhesh Wani2015-05-25 14:46:31 +0530
commit6a320264c2de3d6dd8cc1d1327b3c30df4c8cb26 (patch)
tree1b7bd89fdcfd01715713d8a15db471dc75a96bbf /2.3-1/macros/CCodeGeneration/C_GenerateMakefile.sci
downloadScilab2C-6a320264c2de3d6dd8cc1d1327b3c30df4c8cb26.tar.gz
Scilab2C-6a320264c2de3d6dd8cc1d1327b3c30df4c8cb26.tar.bz2
Scilab2C-6a320264c2de3d6dd8cc1d1327b3c30df4c8cb26.zip
Original Version
Diffstat (limited to '2.3-1/macros/CCodeGeneration/C_GenerateMakefile.sci')
-rw-r--r--2.3-1/macros/CCodeGeneration/C_GenerateMakefile.sci112
1 files changed, 112 insertions, 0 deletions
diff --git a/2.3-1/macros/CCodeGeneration/C_GenerateMakefile.sci b/2.3-1/macros/CCodeGeneration/C_GenerateMakefile.sci
new file mode 100644
index 00000000..8956d51d
--- /dev/null
+++ b/2.3-1/macros/CCodeGeneration/C_GenerateMakefile.sci
@@ -0,0 +1,112 @@
+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');
+makehsrcdir = pathconvert('includes', %f, %f, 'u');
+makeisrcdir = pathconvert('interfaces', %f, %f, 'u');
+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 = .',FileInfo.MakefileFilename,'file','y','y');
+
+// Compiler definition
+PrintStringInfo('CC = gcc',FileInfo.MakefileFilename,'file','y','y');
+PrintStringInfo('CFLAGS = -Wall -pedantic -I $(HSRCDIR) -I $(ISRCDIR)',FileInfo.MakefileFilename,'file','y','y');
+PrintStringInfo('LDFLAGS = -lblas -llapack -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 $(LDFLAGS) -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
+
+endfunction \ No newline at end of file