#include <cmt_generators.h>
Inheritance diagram for DefaultMakefileGenerator:
Public Member Functions | |
void | build () |
|
Definition at line 1435 of file cmt_generators.cxx. References cmt_string::c_str(), cmt_string::find(), Cmt::get_debug(), CmtSystem::pwd(), cmt_string::read(), CmtSystem::test_file(), and cmt_string::write(). Referenced by Generator::build_default_makefile().
01436 { 01437 cmt_string makefile; 01438 01439 //reset (); 01440 01441 //--- Build a simple Makefile if none is installed 01442 01443 #ifndef WIN32 01444 01445 bool need_makefile = false; 01446 01447 makefile = cmtdir + "Makefile"; 01448 01449 if (!CmtSystem::test_file (makefile)) 01450 { 01451 need_makefile = true; 01452 } 01453 else 01454 { 01455 static cmt_string s; 01456 01457 s.read (makefile); 01458 if ((s.find ("METHODSROOT") != cmt_string::npos) || 01459 (s.find ("$(CMTROOT)/src/constituents.make") == cmt_string::npos)) 01460 { 01461 static cmt_string backup = makefile; 01462 backup += "_backup"; 01463 01464 makefile += ".cmt"; 01465 01466 if (!CmtSystem::test_file (makefile)) 01467 { 01468 FILE* file = fopen (backup.c_str (), "wb"); 01469 if (file != NULL) 01470 { 01471 cerr << "# " << endl; 01472 cerr << "#CMT> Warning: " << endl; 01473 cerr << "# A Makefile already exists " 01474 "but it does not provides " << endl; 01475 cerr << "# the recommended features " 01476 "for a full benefit of CMT" << endl; 01477 cerr << "# " << endl; 01478 cerr << "# CMT is now building " 01479 "a new 'Makefile.cmt' which you can use" << endl; 01480 cerr << "# to upgrade your current one." << endl; 01481 cerr << "# " << endl; 01482 01483 s.write (file); 01484 fclose (file); 01485 01486 need_makefile = true; 01487 } 01488 } 01489 } 01490 } 01491 01492 if (need_makefile) 01493 { 01494 FILE* file = fopen (makefile.c_str (), "wb"); 01495 if (file != NULL) 01496 { 01497 fprintf (file, "include $(CMTROOT)/src/Makefile.header\n"); 01498 fprintf (file, "\n"); 01499 fprintf (file, "include $(CMTROOT)/src/constituents.make\n"); 01500 fprintf (file, "\n"); 01501 fclose (file); 01502 } 01503 } 01504 01505 #endif 01506 01507 #ifdef WIN32 01508 01509 makefile = cmtdir + "NMake"; 01510 01511 if (Cmt::get_debug ()) 01512 { 01513 cout << "DefaultMakefileGenerator::build> pwd=" << CmtSystem::pwd () << " cmtdir=" << cmtdir << endl; 01514 } 01515 01516 if (!CmtSystem::test_file (makefile)) 01517 { 01518 FILE* file = fopen (makefile.c_str (), "wb"); 01519 if (file != NULL) 01520 { 01521 fprintf (file, "!include $(CMTROOT)\\src\\NMakefile.header\n"); 01522 fprintf (file, "\n"); 01523 fprintf (file, "!include $(CMTROOT)\\src\\constituents.nmake\n"); 01524 fprintf (file, "\n"); 01525 fclose (file); 01526 } 01527 } 01528 01529 #endif 01530 01531 } |