00001 /* maker options. 00002 MAKER_ADD_DEPENDENCY="file.h" 00003 MAKER_ADD_DEPENDENCY="makeutilities.h" 00004 MAKER_ADD_DEPENDENCY="optionreader.h" 00005 */ 00006 00007 /************ file.h ************** 00008 $Revision: 1.2 $ 00009 $Author: pbergen $ 00010 $Date: 2001/05/13 21:56:03 $ 00011 ***********************************/ 00012 00013 #include <stdio.h> 00014 #include <stdlib.h> 00015 #include <string.h> 00016 00017 #include "optionreader.h" 00018 #include "file.h" 00019 00026 class Maker 00027 { 00028 public: 00029 00035 Maker(OptionReader *opt) 00036 { 00037 options=opt; 00038 00039 mainFile=new File(options->getMainfile()); 00040 File::addFile(mainFile); 00041 addHeaderFiles(); 00042 } 00043 00047 ~Maker() 00048 { 00049 } 00050 00054 void resolveDependencies(void) 00055 { 00056 mainFile->resolveDependencies(); 00057 mainFile->tagRebuild(); 00058 } 00059 00064 bool generateMakescript(void) 00065 { 00066 FILE *fout=fopen(options->getMakescript(),"w+"); 00067 if (fout) 00068 { 00069 mainFile->writeCompilation(fout,options->getCompiler()); 00070 if (options->performLink()) 00071 { 00072 mainFile->writeLink(fout,options->getExecutable(), 00073 options->getLinker(), 00074 options->getLinkerTail()); 00075 } 00076 fclose(fout); 00077 } 00078 else 00079 { 00080 return false; 00081 } 00082 return true; 00083 } 00084 00089 bool generateDotOutput(void) 00090 { 00091 File *tmpFile=fileRoot; 00092 while(tmpFile) 00093 { 00094 tmpFile->setGraphExcluded(1, 00095 options->isGraphExcluded(1,tmpFile->getFileName())); 00096 tmpFile=tmpFile->getNext(); 00097 } 00098 if (options->getDotoutput()) 00099 { 00100 return mainFile->writeDot(options->getDotoutput()); 00101 } 00102 return true; 00103 } 00104 00105 private: 00111 void addHeaderFiles(void) 00112 { 00113 File *tmpFile; 00114 char **argv; 00115 int argc=options->getArguments(argv); 00116 for (int i=1;i<argc;i++) 00117 { 00118 if (argv[i][0]!='-' && i!=options->getOptionFileIndex()) 00119 { 00120 tmpFile=new File(argv[i]); 00121 if (tmpFile->getFileName() && tmpFile->getExtension()==EXTH) 00122 { 00123 File::addFile(tmpFile); 00124 } 00125 else 00126 { 00127 delete tmpFile; 00128 } 00129 } 00130 } 00131 } 00132 00133 OptionReader *options; 00134 File *mainFile; 00135 }; 00136 00137 /*************** LOG ***************** 00138 $Log: maker.h,v $ 00139 Revision 1.2 2001/05/13 21:56:03 pbergen 00140 Improved dot output. 00141 00142 Revision 1.2 2001/05/09 14:52:14 pb 00143 Added NOLINK option. 00144 00145 Revision 1.1 2001/05/09 12:10:56 pb 00146 Cleaned up the source. Added new directive MAKER_ADD_DEPENDENCY. 00147 Added documentation. 00148 00149 *************************************/