diff options
author | jofret | 2009-06-02 11:34:48 +0000 |
---|---|---|
committer | jofret | 2009-06-02 11:34:48 +0000 |
commit | 7e9e5b32b06d7774cbb948d57c9d0bae2dfdc554 (patch) | |
tree | a2033a8373e964613fdd47543bdee37d67bdcfcb /macros/CCodeGeneration | |
parent | abdca53e9896cfda1db0621ccc8766597f913c1c (diff) | |
download | scilab2c-7e9e5b32b06d7774cbb948d57c9d0bae2dfdc554.tar.gz scilab2c-7e9e5b32b06d7774cbb948d57c9d0bae2dfdc554.tar.bz2 scilab2c-7e9e5b32b06d7774cbb948d57c9d0bae2dfdc554.zip |
Generate Makefile to avoid path trouble
Diffstat (limited to 'macros/CCodeGeneration')
-rw-r--r-- | macros/CCodeGeneration/C_GenerateMakefile.sci | 69 |
1 files changed, 62 insertions, 7 deletions
diff --git a/macros/CCodeGeneration/C_GenerateMakefile.sci b/macros/CCodeGeneration/C_GenerateMakefile.sci index 4ea53426..6f4f8e75 100644 --- a/macros/CCodeGeneration/C_GenerateMakefile.sci +++ b/macros/CCodeGeneration/C_GenerateMakefile.sci @@ -53,22 +53,77 @@ PrintStringInfo('HSRCDIR = '+makehsrcdir,FileInfo.MakefileFilename,'file','y PrintStringInfo('ISRCDIR = '+makeisrcdir,FileInfo.MakefileFilename,'file','y'); //PrintStringInfo('SCI2CDIR = '+makesci2cdir,FileInfo.MakefileFilename,'file','y'); PrintStringInfo('SCI2CDIR = .',FileInfo.MakefileFilename,'file','y'); + +// Compiler definition +PrintStringInfo('CC = gcc',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('CFLAGS = -Wall -pedantic -O3 -I $(HSRCDIR) -I $(ISRCDIR) -lm',FileInfo.MakefileFilename,'file','y'); + +// Binary definition PrintStringInfo('EXEFILENAME = mytest.exe',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('EXEFILE = $(SCI2CDIR)/$(EXEFILENAME)', FileInfo.MakefileFilename,'file','y'); + +// Sources +PrintStringInfo('SRC = \\', FileInfo.MakefileFilename,'file','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'); +end +[tmppath,tmpfile,tmpext] = fileparts(allSources(nbSources(1))); +PrintStringInfo(' $(CSRCDIR)/'+tmpfile+tmpext, FileInfo.MakefileFilename,'file','y'); + +// Objects +PrintStringInfo('OBJ = $(SRC:.c=.o)', FileInfo.MakefileFilename,'file','y'); + +// Rules +PrintStringInfo('# ---------------',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('# --- TARGETS ---',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('# ---------------',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('compileexecute: $(OBJ)',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo ""============================""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo ""Generation of the executable""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo ""============================""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t$(CC) $(CFLAGS) $(OBJ) *.c -llapack -lblas -o $(EXEFILE)',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo ""==============""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo ""Executing code""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo ""==============""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t$(EXEFILE)',FileInfo.MakefileFilename,'file','y'); + +PrintStringInfo('clean:',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo ""=============================""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo ""Removing only exe + obj files""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo ""=============================""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\trm -rf $(EXEFILE)',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\trm -rf $(OBJ)',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y'); + +PrintStringInfo('distclean: clean',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo ""==========================""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo ""Removing only the exe file""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo ""==========================""',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\trm -rf $(EXEFILE)',FileInfo.MakefileFilename,'file','y'); +PrintStringInfo('\t@echo "" ""',FileInfo.MakefileFilename,'file','y'); + // ------------------------------- // --- Open template makefile. --- // ------------------------------- -fidfile = SCI2COpenFileRead(FileInfo.MakefileTemplate); +//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 +//tmpline = mgetl(fidfile,1); +//while (meof(fidfile) == 0) +// PrintStringInfo(tmpline,FileInfo.MakefileFilename,'file','y'); +// tmpline = mgetl(fidfile,1); +//end -mclose(fidfile); +//mclose(fidfile); endfunction |