#include <cmt_generators.h>
Inheritance diagram for DefaultMakefileGenerator:
Public Methods |
|
| void? | build () |
|
| ? |
Definition at line 1400 of file cmt_generators.cxx. References cmt_string::c_str(), CmtGenerator::cmtdir, cmt_string::find(), Cmt::get_debug(), cmt_string::npos, CmtSystem::pwd(), cmt_string::read(), CmtSystem::test_file(), and cmt_string::write(). Referenced by Generator::build_default_makefile(). 01401 {
01402 cmt_string makefile;
01403
01404 //reset ();
01405
01406 //--- Build a simple Makefile if none is installed
01407
01408 #ifndef WIN32
01409
01410 bool need_makefile = false;
01411
01412 makefile = cmtdir + "Makefile";
01413
01414 if (!CmtSystem::test_file (makefile))
01415 {
01416 need_makefile = true;
01417 }
01418 else
01419 {
01420 static cmt_string s;
01421
01422 s.read (makefile);
01423 if ((s.find ("METHODSROOT") != cmt_string::npos) ||
01424 (s.find ("$(CMTROOT)/src/constituents.make") == cmt_string::npos))
01425 {
01426 static cmt_string backup = makefile;
01427 backup += "_backup";
01428
01429 makefile += ".cmt";
01430
01431 if (!CmtSystem::test_file (makefile))
01432 {
01433 FILE* file = fopen (backup.c_str (), "wb");
01434 if (file != NULL)
01435 {
01436 cout << "# " << endl;
01437 cout << "#CMT> Warning : " << endl;
01438 cout << "# A Makefile already exists "
01439 "but it does not provides " << endl;
01440 cout << "# the recommended features "
01441 "for a full benefit of CMT" << endl;
01442 cout << "# " << endl;
01443 cout << "# CMT is now building "
01444 "a new 'Makefile.cmt' which you can use" << endl;
01445 cout << "# to upgrade your current one." << endl;
01446 cout << "# " << endl;
01447
01448 s.write (file);
01449 fclose (file);
01450
01451 need_makefile = true;
01452 }
01453 }
01454 }
01455 }
01456
01457 if (need_makefile)
01458 {
01459 FILE* file = fopen (makefile.c_str (), "wb");
01460 if (file != NULL)
01461 {
01462 fprintf (file, "include $(CMTROOT)/src/Makefile.header\n");
01463 fprintf (file, "\n");
01464 fprintf (file, "include $(CMTROOT)/src/constituents.make\n");
01465 fprintf (file, "\n");
01466 fclose (file);
01467 }
01468 }
01469
01470 #endif
01471
01472 #ifdef WIN32
01473
01474 makefile = cmtdir + "NMake";
01475
01476 if (Cmt::get_debug ())
01477 {
01478 cout << "DefaultMakefileGenerator::build> pwd=" << CmtSystem::pwd () << " cmtdir=" << cmtdir << endl;
01479 }
01480
01481 if (!CmtSystem::test_file (makefile))
01482 {
01483 FILE* file = fopen (makefile.c_str (), "wb");
01484 if (file != NULL)
01485 {
01486 fprintf (file, "!include $(CMTROOT)\\src\\NMakefile.header\n");
01487 fprintf (file, "\n");
01488 fprintf (file, "!include $(CMTROOT)\\src\\constituents.nmake\n");
01489 fprintf (file, "\n");
01490 fclose (file);
01491 }
01492 }
01493
01494 #endif
01495
01496 }
|