Subversion Repositories Programming Utils

Compare Revisions

Ignore whitespace Rev 48 → Rev 49

/trunk/C-CPP-utils/supermakemake/MakefileObject.cpp
11,7 → 11,6
#include <sstream>
#include <iterator>
#include <algorithm>
#include <map>
 
#include "MakefileObject.h"
#include "dirlist.h"
23,6 → 22,7
using std::string;
using std::set;
using std::cout;
using std::pair;
 
static string parseList( char* buffer ){
string finalString;
87,11 → 87,26
string* lastUsedVariable = NULL;
set<string>* lastUsedList = NULL;
bool append = false;
char* equalsLocation;
while( theFile.good() ){
theFile.getline( buffer, 300 );
 
if( equalsLocation = strstr( buffer, "=" ) ){
string beginning( buffer, equalsLocation );
string end( equalsLocation + 1 );
if( end[ end.size() ] == '\\' ){
append = true;
end.resize( end.size() - 1 );
}
// if( regex[ 0 ] == "CPP_FLAGS" || regex[ 0 ] == "H_FLAGS" //...etc, don't put in standard variables
// }else{
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 ) );
110,12 → 125,15
lastUsedList = NULL;
append = false;
}
*/
 
if( theFile.gcount() >= 300 ){
//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() ] == '\\' ){
append = true;
}
 
if( memcmp( buffer, "CPP_FILES", 9 ) == 0 ){
/* if( memcmp( buffer, "CPP_FILES", 9 ) == 0 ){
parseFileList( buffer, &cpp_files );
lastUsedList = &cpp_files;
}
177,6 → 195,7
if( memcmp( buffer, "CXX =", 5 ) == 0 ){
config["cpp_compiler"] = parseList( buffer );
}
*/
 
printf("BUFFER IS |%s|\n", buffer );
197,7 → 216,11
}
 
void Makefile::writeMakefile(){
findMainPrograms();
findLibraries();
 
write_header();
write_variables();
write_lists();
write_main_targets();
write_dependencies();
223,25 → 246,9
*/
 
void Makefile::write_header() {
ifstream in;
time_t now( time( 0 ) );
 
//
// Open the header file
//
if( (*configuration)["header_file"] == "//" ){
//
// They specifically said not to use one.
//
in.clear( ios::badbit | ios::failbit );
} else {
//
// Open the one they said to use.
//
in.open( ((*configuration)["header_file"]).c_str() );
}
 
//
// Write the header
//
cout << "#\n";
295,6 → 302,27
cout << "CC =\t\tcc\n";
cout << "CXX =\t\tCC\n";
}*/
}
 
 
void Makefile::write_variables(){
ifstream in;
 
//
// Open the header file
//
if( (*configuration)["header_file"] == "//" ){
//
// They specifically said not to use one.
//
in.clear( ios::badbit | ios::failbit );
} else {
//
// Open the one they said to use.
//
in.open( ((*configuration)["header_file"]).c_str() );
}
 
cout << "CC = \t\t" << (*configuration)["c_compiler"] << endl;
cout << "CXX = \t\t" << (*configuration)["cpp_compiler"] << endl;
cout << "\n";
306,6 → 334,15
cout << "COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c\n";
cout << '\n';
 
if( makefileVariables.size() > 0 ){
cout << "########## Custom Variables\n\n";
for( map<string,string>::iterator iter = makefileVariables.begin();
iter != makefileVariables.end();
iter++ ){
cout << (*iter).first << " = " << (*iter).second << "\n";
}
}
 
if( in ){
cout << "########## Flags from " << (*configuration)["header_file"] << "\n\n";
copy(istreambuf_iterator<char>(in),
338,7 → 375,8
}
cout << "LIBFLAGS =\t-lm\n";
cout << "########## End of default flags\n";
//if( !lib_files.empty() ){
// CFLAGS += -fPIC
cout << '\n';
}
cout << '\n';
348,7 → 386,7
cout << "CPP_FILES =\t" << FileListInserter( cpp_files ) << '\n';
cout << "C_FILES =\t" << FileListInserter( c_files ) << '\n';
//cout << "PS_FILES = \t \n";
cout << "S_FILES =\t" << FileListInserter( s_files ) << '\n';
//cout << "S_FILES =\t" << FileListInserter( s_files ) << '\n';
cout << "H_FILES =\t" << FileListInserter( h_files ) << '\n';
if( (*configuration)["m4"] == "true" ){
//cout << "M4_FILES = \t" << FileListInserter(dirlist.h_m4) << FileListInserter(dirlist.cpp_m4);
520,6 → 558,26
"$(CC) $(CFLAGS)" ,
local_libs + " $(CLIBFLAGS)");
}
 
//
//Write out shared libraries
//
if( !lib_files.empty() ){
cout << "#\n"
<< "# SO targets\n"
<< "#\n\n";
 
for( set<string>::const_iterator it = lib_files.begin();
it != lib_files.end();
++it ) {
string basename( DirList::basename( *it) );
 
cout << basename << ":\t";
cout << basename << ".o $(OBJFILES)\n";
cout << "$(CC) -shared -Wl,-soname," << basename << ".so -o $(OBJFILES)\n";
}
}
 
}
 
 
802,6 → 860,24
 
}
 
void Makefile::findLibraries(){
//First, let's check all of our C files
for( set<string>::iterator it = c_files.begin(); it != c_files.end(); it++ ){
if( (*it).find( "lib" ) == string::npos ){
lib_files.insert( *it );
}
}
 
//Now, all of our CPP files
for( set<string>::iterator it = cpp_files.begin(); it != cpp_files.end(); it++ ){
}
 
//Finally, all of our assembly files
for( set<string>::iterator it = s_files.begin(); it != s_files.end(); it++ ){
}
 
}
 
void Makefile::remove_old_files(){
FILE* theFile;
 
832,3 → 908,9
}
}
}
 
void Makefile::addFiles( DirList* dirlist ){
cpp_files.insert( dirlist->cpp.begin(), dirlist->cpp.end() );
c_files.insert( dirlist->c.begin(), dirlist->c.end() );
h_files.insert( dirlist->h.begin(), dirlist->h.end() );
}
/trunk/C-CPP-utils/supermakemake/MakefileObject.h
3,7 → 3,10
 
#include <set>
#include <string>
#include <map>
 
#include "dirlist.h"
 
/**
* Represents a makefile
*/
27,9 → 30,16
*/
void writeMakefile();
 
/**
* Add files to the makefile
*/
void addFiles( DirList* dirlist );
 
private:
void write_header();
 
void write_variables();
 
void write_lists();
 
void write_main_targets();
42,6 → 52,8
 
void findMainPrograms();
 
void findLibraries();
 
void write_install_targets();
 
void remove_old_files();
64,6 → 76,7
std::set<std::string> s_files; //assembly
std::set<std::string> s_main; //assembly files with main
std::set<std::string> s_other; //assembly files with no main
std::set<std::string> lib_files; //library files(those that start with 'lib')
 
std::set<std::string> archive; //all archive files
75,6 → 88,11
std::string clib_flags; //c library flags
std::string cxxlib_flags; //c++ library flags
 
std::map<std::string, std::string> makefileVariables; //Variables that were defined
//in the makefile. These may be
//standard variables, or they
//may be custom
 
std::map<std::string, std::string>* configuration;
 
};
/trunk/C-CPP-utils/supermakemake/makemake.1
3,11 → 3,12
makemake, gmakemake \- automatically create and update makefiles
.SH SYNOPSIS
 
 
.SH DESCRIPTION
.B makemake
will automatically create makefiles for use with the make command.
 
.SH BUGS
Please report bugs @ rm5248.com
Please report bugs @ programming.rm5248.com
.SH AUTHOR
rm5248
/trunk/C-CPP-utils/supermakemake/makemake.cpp
19,6 → 19,7
 
#include "dirlist.h"
#include "write.h"
#include "MakefileObject.h"
 
bool debug( false );
 
56,18 → 57,18
" files The files to create the makefile from. If no files are\n"
" specified, makemake will look through the current\n"
" directory\n"
"\n"
"SuperMakemake v1.0\n"
"Based off of code by Prof. Sidney Marshall,\n"
"\n"
"SuperMakemake v1.0\n"
"Based off of code by Prof. Sidney Marshall,\n"
"Rochester Institute of Technology Department of Computer Science\n"
"Original source code may be found at http://cs.rit.edu/~swm/makemake\n"
"Currently maintained by rm5248 @ www.programming.rm5248.com\n";
"Original source code may be found at http://cs.rit.edu/~swm/makemake\n"
"Currently maintained by rm5248 @ www.programming.rm5248.com\n";
 
cout << "Usage: " << progName << " [-update] [-depends] [-header headerfile | -no-header] [-programs programsfile | -no-programs] ";
cout << "[-no-debug] [-ar name] [-so name] [-install] [--prefix=PREFIX] [--dirs=DIRS | -r] [files] " << endl;
cout << endl;
cout << "Note that " << progName << " outputs the makefile to STDOUT; it is typically invoked as " << progName << " > Makefile" << endl;
cout << "Usage: " << progName << " [-update] [-depends] [-header headerfile | -no-header] [-programs programsfile | -no-programs] ";
cout << "[-no-debug] [-ar name] [-so name] [-install] [--prefix=PREFIX] [--dirs=DIRS | -r] [files] " << endl;
cout << endl;
 
cout << "Note that " << progName << " outputs the makefile to STDOUT; it is typically invoked as " << progName << " > Makefile" << endl;
cout << endl;
 
75,7 → 76,6
}
 
#include "MakefileObject.h"
int main( int argc, char **argv ){
bool search_dirs = false;
bool recursive_search = false;
188,5 → 188,10
//
//Write write( *dirlist, &config );
 
makefile = new Makefile( "Makefile.wevp" );
// makefile = new Makefile( &config );
// makefile->addFiles( dirlist );
makefile->writeMakefile();
 
return 0;
}