Subversion Repositories Programming Utils

Compare Revisions

Ignore whitespace Rev 78 → Rev 79

/trunk/C-CPP-utils/supermakemake/MakefileObject.cpp
39,6 → 39,7
char* file = strtok( buffer + ( equalsLocation - buffer ) + 1, " \t" );
while( file != NULL ){
finalString.append( file );
finalString.append( " " );
file = strtok( NULL, " " );
}
 
85,27 → 86,11
 
buffer = (char*)malloc( 300 );
 
//Initialize our default configuration
/* configuration = new map<string, string>();
map<string, string>& config = (*configuration);
config["c_compiler"] = "cc";
config["cpp_compiler"] = "CC";
config["no_debug"] = "false";
config["header_file"] = "header.mak";
config["program_file"] = "programs.mak";
config["update"] = "false";
config["depends"] = "false";
config["ar"] = "false";
config["so"] = "false";
config["install"] = "false";
config["prefix"] = "/usr/bin";
config["dirs"] = ".";
*/
 
initializeMakefileVariables();
 
if( theFile.fail() ){
cerr << "ERROR: Couldn't open file " << makefile << endl;
return;
}
 
string* lastUsedVariable = NULL;
122,18 → 107,16
append = true;
end.resize( end.size() - 1 );
}
// if( regex[ 0 ] == "CPP_FLAGS" || regex[ 0 ] == "H_FLAGS" //...etc, don't put in standard variables
// }else{
beginning = trim( beginning );
end = trim( end );
cout << "inserting |" << beginning << "| => |" << end << "|\n";
if( standardVariables.find( beginning ) == standardVariables.end() ){
//cout << "inserting |" << beginning << "| => |" << end << "|\n";
makefileVariables.insert( pair<string,string>( beginning, end ) );
// }
}else if( append ){
}
}
 
//if the append variable is set, we have not reached the end of our line
/* if( append ){
if( append ){
if( lastUsedVariable != NULL ){
//append to our string variable
lastUsedVariable->append( parseList( buffer ) );
152,8 → 135,8
lastUsedList = NULL;
append = false;
}
*/
 
 
//if we have more than 300 characters, OR the last character on the line is a \,
//we go onto the next line
if( theFile.gcount() >= 300 || buffer[ theFile.gcount() ] == '\\' ){
160,7 → 143,7
append = true;
}
 
/* if( memcmp( buffer, "CPP_FILES", 9 ) == 0 ){
if( memcmp( buffer, "CPP_FILES", 9 ) == 0 ){
parseFileList( buffer, &cpp_files );
lastUsedList = &cpp_files;
}
216,23 → 199,30
}
if( memcmp( buffer, "CC =", 4 ) == 0 ){
config["c_compiler"] = parseList( buffer );
(*configuration)["c_compiler"] = parseList( buffer );
}
 
if( memcmp( buffer, "CXX =", 5 ) == 0 ){
config["cpp_compiler"] = parseList( buffer );
(*configuration)["cpp_compiler"] = parseList( buffer );
}
*/
 
printf("BUFFER IS |%s|\n", buffer );
fflush(stdout);
/*
printf("BUFFER IS |%s|\n", buffer );
fflush(stdout);
*/
}
 
free( buffer );
 
remove_old_files();
//add in the variables that we parsed
makefileVariables[ "CPPFLAGS" ] = cpp_flags;
makefileVariables[ "CFLAGS" ] = c_flags;
makefileVariables[ "CXXFLAGS" ] = cxx_flags;
makefileVariables[ "CLIBFLAGS" ] = clib_flags;
makefileVariables[ "CCLIBFLAGS" ] = cxxlib_flags;
 
remove_old_files();
}
 
Makefile::Makefile( std::map<string, string>* conf, DirList* dirList ){
241,6 → 231,21
 
//Copy everything from the DirList to our object
cpp_files = dirList->cpp;
cpp_main = dirList->cpp_main;
cpp_other = dirList->cpp_other;
h_files = dirList->h;
c_files = dirList->c;
c_main = dirList->c_main;
c_other = dirList->c_other;
ps_files = dirList->preass;
ps_main = dirList->preass_main;
ps_other = dirList->preass_other;
s_files = dirList->ass;
s_main = dirList->ass_main;
s_other = dirList->ass_other;
// set<string> archive; // All .a files
// set<string> h_m4; // All .h.m4 .H.m4 files
// set<string> cpp_m4; // All .cpp.m4 .cc.m4 .C.m4 files
}
 
Makefile::~Makefile(){
357,7 → 362,6
 
//Write out our compiler variables
//C compiler
/*
iter = makefileVariables.find( "CC" );
cout << "CC = \t\t" << makefileVariables[ "CC" ] << "\n";
makefileVariables.erase( iter );
394,11 → 398,10
iter = makefileVariables.find( "COMPILE.cc" );
cout << "COMPILE.cc = " << makefileVariables[ "COMPILE.cc" ] << "\n";
makefileVariables.erase( iter );
*/
 
cout << '\n';
 
if( makefileVariables.size() > 0 ){
if( makefileVariables.size() > 5 ){
cout << "########## Custom Variables\n";
for( iter = makefileVariables.begin();
iter != makefileVariables.end();
408,7 → 411,7
(*iter).first.compare( "CXXFLAGS" ) == 0 ||
(*iter).first.compare( "CLIBFLAGS" ) == 0 ||
(*iter).first.compare( "CCLIBFLAGS" ) == 0 ){
// continue;
continue;
}
cout << (*iter).first << " =\t" << (*iter).second << "\n";
}
831,7 → 834,7
cout << '\n';
 
cout << "clean:\n"
<< "\t-/bin/rm $(OBJFILES)";
<< "\t$(RM) $(OBJFILES)";
if( !cpp_main.empty() ){
cout << " " << FileListInserter( cpp_main, ".o" );
}
848,7 → 851,7
}
cout << '\n';
cout << "realclean: clean\n";
cout << "\t-/bin/rm -rf ";
cout << "\t$(RM) -rf ";
if(products.empty()) {
#ifdef WINDOWS
cout << FileListInserter( cpp_main, ".exe" );
996,6 → 999,16
makefileVariables[ "CXXFLAGS" ] = "-xildoff -xsb";
}
}
makefileVariables[ "CC" ] = (*configuration)[ "c_compiler" ];
makefileVariables[ "CXX" ] = (*configuration)[ "cpp_compiler" ];
makefileVariables[ "CLIBFLAGS" ] = "-lm";
makefileVariables[ "CCLIBFLAGS" ] = "";
 
standardVariables.insert( "CPP_FILES" );
standardVariables.insert( "C_FILES" );
standardVariables.insert( "H_FILES" );
standardVariables.insert( "OBJFILES" );
standardVariables.insert( "PS_FILES" );
standardVariables.insert( "SOURCEFILES" );
standardVariables.insert( "S_FILES" );
}
/trunk/C-CPP-utils/supermakemake/MakefileObject.h
100,6 → 100,8
 
std::map<std::string, std::string>* configuration;
 
std::set<std::string> standardVariables; //standard variables in the makefile
 
};
 
#endif
/trunk/C-CPP-utils/supermakemake/makemake.cpp
187,9 → 187,6
}
}
 
std::cout << open_makefile << std::endl;
return 1;
 
if( poptVal != -1 ){
std::cerr << "Unable to parse options: " << poptStrerror( poptVal ) << std::endl;
return 1;
220,6 → 217,9
//useGCC = true;
config["c_compiler"] = "gcc";
config["cpp_compiler"] = "g++";
}else{
config["c_compiler"] = "cc";
config["cpp_compiler"] = "CC";
}
progName = argv[0];
config["executable"] = string( progName );
227,6 → 227,7
//
// Process command line options
//
/*
while( argc--, *++argv != NULL && **argv == '-' ){
if( strcmp( *argv, "-header" ) == 0 && argv[ 1 ] != NULL ){
config["header_file"] = *++argv;
280,6 → 281,7
}
}
}
*/
 
//
// Read the current directory (and cmd line arguments) to find
299,8 → 301,15
//
//Write write( *dirlist, &config );
 
//makefile = new Makefile( "Makefile", &config );
makefile = new Makefile( &config, dirlist );
if( update || depends ){
if( open_makefile != NULL ){
makefile = new Makefile( open_makefile, &config );
}else{
makefile = new Makefile( "Makefile", &config );
}
}else{
makefile = new Makefile( &config, dirlist );
}
// makefile->addFiles( dirlist );
makefile->writeMakefile();