Main Page Class Hierarchy Compound List File List Compound Members File Members

# MakefileGenerator Class Reference

Collaboration diagram for MakefileGenerator:

[legend]
List of all members.

## Public Methods
void | analyze_file (const Constituent& constituent, const cmt_string& file)
void | analyze_document_file (const cmt_string& file, const cmt_string& constituent_name, const cmt_string& output_suffix)
void | reset ()
void | prepare_proto_file (const cmt_string& file)
void | proto_file_action (const cmt_string& file, const Constituent& constituent)
void | module_file_action (SourceFile& file, const Constituent& constituent)
void | java_file_action (SourceFile& file, const Constituent& constituent)
void | fill_outputs ()
void | build_application_makefile (const cmt_string& package, const Constituent& constituent)
void | build_library_makefile (const cmt_string& package, const Constituent& constituent)
void | build_document_makefile (const cmt_string& package, const Constituent& constituent)
void | prepare_use_context ()
void | set_full_name (cmt_string& full_name, cmt_string& file)
## Public Attributes
cmt_string | PACKINCLUDES
bool | PACKOS9
cmt_string | GENERATOR
bool | is_library
bool | is_application
bool | is_document
cmt_string | srcdir
cmt_string | docdir
cmt_string | cmtdir
cmt_string | incdir
cmt_string | msdevdir
cmt_string | src
cmt_string | doc
cmt_string | inc
cmt_string | mgr
cmt_string | cmt
cmt_string | protos
cmt_string | protonames
cmt_string | os9sources
cmt_vector<SourceFile> | source_files
FILE* | output_file
DepsBuilder | deps_builder

## Member Function Documentation

void MakefileGenerator::analyze_document_file ( | const cmt_string & file,
| const cmt_string & constituent_name,
| const cmt_string & output_suffix )

| Definition at line 382 of file cmt_generator.cxx. Referenced by build_document_makefile().
    00385 {
    00386   static cmt_string output_dir;
    00387   static cmt_string suffix;
    00388   static cmt_string name;
    00389   static cmt_string obj;
    00390
    00391   CmtSystem::dirname (file, output_dir);
    00392   output_dir += CmtSystem::file_separator ();
    00393
    00394   filter_paths (output_dir);
    00395
    00396   CmtSystem::get_suffix (file, suffix);
    00397   CmtSystem::basename (file, suffix, name);
    00398
    00399   //obj = output_dir;
    00400   obj = "$(";
    00401   obj += constituent_name;
    00402   obj += "_output)";
    00403   obj += name;
    00404   obj += output_suffix;
    00405
    00406   SourceFile& source = source_files.add ();
    00407   source.set (file, Language::null (), obj);
    00408 }

void MakefileGenerator::analyze_file ( | const Constituent & constituent,
| const cmt_string & file )

| Definition at line 299 of file cmt_generator.cxx. Referenced by build_library_makefile().
    00301 {
    00302   static cmt_string suffix;
    00303   static cmt_string name;
    00304   static cmt_string obj;
    00305
    00306   obj = file;
    00307
    00308   if (Cmt::get_debug ())
    00309     {
    00310       cout << "MakefileGenerator::analyze_file> constituent=" <<
    00311           constituent.name <<
    00312           " file=" << file << endl;
    00313     }
    00314
    00315   CmtSystem::get_suffix (file, suffix);
    00316   CmtSystem::basename (file, suffix, name);
    00317
    00318   Language& language = Language::find_with_suffix (suffix);
    00319
    00320   if (LINKMACRO == "")
    00321     {
    00322       LINKMACRO = language.linker;
    00323     }
    00324
    00325   if (language == "java")
    00326     {
    00327       static Packager packager;
    00328
    00329       obj  = "$(javabin)";
    00330
    00331       packager.run (file);
    00332       if (packager.package_name () != "")
    00333         {
    00334           obj += packager.package_name ();
    00335           obj += CmtSystem::file_separator ();
    00336         }
    00337
    00338       obj += name;
    00339       obj += ".class";
    00340     }
    00341   else if (language != Language::null ())
    00342     {
    00343       obj  = "$(bin)";
    00344       if (Cmt::build_nmake ()) obj +=  CONSTITUENT;
    00345       if (Cmt::build_nmake ()) obj +=  CmtSystem::file_separator ();
    00346       obj += name;
    00347       obj += language.output_suffix;
    00348       obj += constituent.suffix;
    00349       if (Cmt::build_nmake ()) obj += ".obj";
    00350       else obj += ".o";
    00351
    00352       for (int i = 0; i < language.extra_output_suffixes.size (); i++)
    00353         {
    00354           cmt_string& extra_suffix = language.extra_output_suffixes[i];
    00355
    00356           obj += " $(bin)";
    00357           obj += name;
    00358           obj += extra_suffix;
    00359           obj += language.output_suffix;
    00360           obj += constituent.suffix;
    00361           if (Cmt::build_nmake ()) obj += ".obj";
    00362           else obj += ".o";
    00363         }
    00364     }
    00365   else
    00366     {
    00367       cout << "#CMT> analyze_file file=" << file << " no language" << endl;
    00368     }
    00369
    00370   if (Cmt::get_debug ())
    00371     {
    00372       cout << "MakefileGenerator::analyze_file> constituent=" <<
    00373           constituent.name <<
    00374           " obj=" << obj << endl;
    00375     }
    00376
    00377   SourceFile& source = source_files.add ();
    00378   source.set (file, language, obj);
    00379 }

void MakefileGenerator::build_application_makefile ( | const cmt_string & package,
| const Constituent & constituent )

| Definition at line 619 of file cmt_generator.cxx. Referenced by Generator::build_constituent_makefile().
    00621 {
    00622   build_library_makefile (package, constituent);
    00623 }

void MakefileGenerator::build_document_makefile ( | const cmt_string & package,
| const Constituent & constituent )

| Definition at line 1220 of file cmt_generator.cxx. Referenced by Generator::build_constituent_makefile().
    01222 {
    01223   static cmt_string names;
    01224   static cmt_string output_dir;
    01225   static cmt_string name;
    01226   static cmt_string full_name;
    01227   static cmt_string suffix;
    01228   static cmt_string output_suffix;
    01229   static cmt_string fragment_suffix;
    01230   int i;
    01231
    01232   cout << TITLE << " " << CONSTITUENT << endl;
    01233
    01234   //
    01235   // Prepare the include paths.
    01236   //
    01237
    01238   const CmtSystem::cmt_string_vector& includes = constituent.includes;
    01239
    01240   for (i = 0; i < includes.size (); i++)
    01241     {
    01242       const cmt_string& subdir = includes[i];
    01243
    01244       PACKINCLUDES += " -I";
    01245       PACKINCLUDES += subdir;
    01246     }
    01247
    01248   //
    01249   // Get the fragment associated with the document style
    01250   //
    01251
    01252   FragmentHandle fragment (GENERATOR);
    01253
    01254   fragment_suffix = fragment.suffix ();
    01255
    01256   output_suffix = ".";
    01257
    01258   if (fragment_suffix == "")
    01259     {
    01260       output_suffix += fragment.name ();
    01261     }
    01262   else
    01263     {
    01264       output_suffix += fragment_suffix;
    01265     }
    01266
    01267   //
    01268   // Scan the sources.
    01269   //
    01270
    01271   const CmtSystem::cmt_string_vector& sources = constituent.modules;
    01272
    01273   for (i = 0; i < sources.size (); i++)
    01274     {
    01275       cmt_string& file = sources[i];
    01276
    01277       set_full_name (full_name, file);
    01278       if (full_name == "") continue;
    01279
    01280       static CmtSystem::cmt_string_vector files;
    01281
    01282       get_all_files (full_name, files);
    01283
    01284       for (int j = 0; j < files.size (); j++)
    01285         {
    01286           const cmt_string& name = files[j];
    01287
    01288           if (name != "")
    01289             {
    01290               analyze_document_file (name, constituent.name, output_suffix);
    01291             }
    01292         }
    01293     }
    01294
    01295   fill_outputs ();
    01296
    01297   prepare_use_context ();
    01298
    01299   DATE = CmtSystem::now ();
    01300   USER = CmtSystem::user ();
    01301   PACKAGE = package;
    01302
    01303   make_header_fragment.copy (output_file, constituent.variables, 6,
    01304                              &TITLE, &CONSTITUENT, &CONSTITUENTSUFFIX,
    01305                              &USER, &DATE, &PACKAGE);
    01306
    01307   const cmt_string& header = fragment.header ();
    01308
    01309   //
    01310   // If the document type specifies a header, use it .
    01311   // otherwise, use the default document header fragment.
    01312   //
    01313   if (header != "")
    01314     {
    01315       FragmentHandle header_fragment (header);
    01316       header_fragment.copy (output_file, constituent.variables, 3,
    01317                             &CONSTITUENT, &CONSTITUENTSUFFIX, &OBJS);
    01318     }
    01319   else
    01320     {
    01321       document_header_fragment.copy (output_file, constituent.variables, 3,
    01322                                      &CONSTITUENT, &CONSTITUENTSUFFIX, &OBJS);
    01323     }
    01324
    01325   if (fragment.need_dependencies ())
    01326     {
    01327       LINE = "";
    01328       for (i = 0; i < sources.size (); i++)
    01329         {
    01330           cmt_string& file = sources[i];
    01331
    01332           set_full_name (full_name, file);
    01333           if (full_name == "") continue;
    01334
    01335           static CmtSystem::cmt_string_vector files;
    01336           get_all_files (full_name, files);
    01337
    01338           int count = 0;
    01339
    01340           for (int j = 0; j < files.size (); j++)
    01341             {
    01342               cmt_string& n = files[j];
    01343               if (n != "") count++;
    01344             }
    01345
    01346           if (count > 0)
    01347             {
    01348               LINE += full_name;
    01349               LINE += " ";
    01350             }
    01351         }
    01352
    01353       filter_paths (LINE.value);
    01354
    01355       dependencies_fragment.copy (output_file, constituent.variables, 3,
    01356                                   &CONSTITUENT, &CONSTITUENTSUFFIX, &LINE);
    01357     }
    01358   else
    01359     {
    01360       for (i = 0; i < sources.size (); i++)
    01361         {
    01362           cmt_string& file = sources[i];
    01363
    01364           set_full_name (full_name, file);
    01365           if (full_name == "") continue;
    01366
    01367           static CmtSystem::cmt_string_vector files;
    01368
    01369           get_all_files (full_name, files);
    01370
    01371           for (int j = 0; j < files.size (); j++)
    01372             {
    01373               const cmt_string& name = files[j];
    01374
    01375               if (name != "")
    01376                 {
    01377                   static cmt_string s;
    01378                   static cmt_string n;
    01379
    01380                   CmtSystem::get_dot_suffix (name, s);
    01381                   CmtSystem::basename (name, s, n);
    01382                   CmtSystem::get_suffix (name, s);
    01383
    01384                   fprintf (output_file, "%s_%s_dependencies = %s\n",
    01385                            n.c_str (),
    01386                            s.c_str (),
    01387                            name.c_str ());
    01388                 }
    01389             }
    01390         }
    01391     }
    01392
    01393   SUFFIX = fragment_suffix;
    01394   for (i = 0; i < source_files.size (); i++)
    01395     {
    01396       SourceFile& file = source_files[i];
    01397       const cmt_string& file_name = file.name ();
    01398       FULLNAME = file_name;
    01399       CmtSystem::get_dot_suffix (file_name, suffix);
    01400       CmtSystem::basename (file_name, suffix, NAME.value);
    01401       CmtSystem::dirname (file_name, FILEPATH.value);
    01402       if (FILEPATH.value != "") FILEPATH.value += CmtSystem::file_separator ();
    01403       filter_paths (FILEPATH.value);
    01404       CmtSystem::basename (file_name, FILENAME.value);
    01405       CmtSystem::get_dot_suffix (FILENAME.value, FILESUFFIX.value);
    01406
    01407       if (!CmtSystem::test_file (file_name))
    01408         {
    01409           cout << "#CMT> Warning : Source file " << file_name << " not found" << endl;
    01410         }
    01411
    01412       filter_paths (FULLNAME.value);
    01413
    01414       fragment.copy (output_file, constituent.variables, 8,
    01415                      &FILEPATH, &SUFFIX,
    01416                      &CONSTITUENT, &CONSTITUENTSUFFIX, &FILENAME,
    01417                      &NAME, &FULLNAME, &FILESUFFIX);
    01418     }
    01419
    01420   const cmt_string& trailer = fragment.trailer ();
    01421   if (trailer != "")
    01422     {
    01423       FragmentHandle trailer_fragment (trailer);
    01424       trailer_fragment.copy (output_file, constituent.variables, 3,
    01425                              &CONSTITUENT, &CONSTITUENTSUFFIX, &OBJS);
    01426     }
    01427
    01428   //
    01429   //  Generate package cleanup operations.
    01430   //
    01431
    01432   cleanup_header_fragment.copy (output_file, constituent.variables, 2,
    01433                                 &CONSTITUENT, &CONSTITUENTSUFFIX);
    01434 }

void MakefileGenerator::build_library_makefile ( | const cmt_string & package,
| const Constituent & constituent )

| Definition at line 821 of file cmt_generator.cxx. Referenced by build_application_makefile(), and Generator::build_constituent_makefile().
    00823 {
    00824   static cmt_string lib;
    00825   static cmt_string allsources;
    00826   static cmt_string file;
    00827   static cmt_string full_name;
    00828   static cmt_string compressed_name;
    00829   static cmt_string suffix;
    00830   int i;
    00831   bool need_prototypes;
    00832
    00833   source_files.clear ();
    00834
    00835   need_prototypes = constituent.need_prototypes;
    00836
    00837   cout << TITLE << " " << CONSTITUENT << endl;
    00838
    00839   lib  = "$(";
    00840   lib += CONSTITUENT;
    00841   lib += "lib)";
    00842
    00843   //
    00844   // Prepare the include paths
    00845   //
    00846
    00847   const CmtSystem::cmt_string_vector& includes = constituent.includes;
    00848
    00849   for (i = 0; i < includes.size (); i++)
    00850     {
    00851       const cmt_string& subdir = includes[i];
    00852
    00853       PACKINCLUDES += " -I";
    00854       PACKINCLUDES += subdir;
    00855     }
    00856
    00857   //
    00858   // Scan the sources.
    00859   //
    00860
    00861   const CmtSystem::cmt_string_vector& sources = constituent.modules;
    00862
    00863   for (i = 0; i < sources.size (); i++)
    00864     {
    00865       file = sources[i];
    00866
    00867       set_full_name (full_name, file);
    00868       if (full_name == "") continue;
    00869
    00870       CmtSystem::compress_path (full_name, compressed_name);
    00871       full_name = compressed_name;
    00872
    00873       static CmtSystem::cmt_string_vector files;
    00874
    00875       get_all_files (full_name, files);
    00876
    00877       for (int j = 0; j < files.size (); j++)
    00878         {
    00879           const cmt_string& name = files[j];
    00880
    00881           if (name != "")
    00882             {
    00883               analyze_file (constituent, name);
    00884             }
    00885         }
    00886     }
    00887
    00888   fill_outputs ();
    00889
    00890   prepare_use_context ();
    00891
    00892   DATE = CmtSystem::now ();
    00893   USER = CmtSystem::user ();
    00894   PACKAGE = package;
    00895
    00896   make_header_fragment.copy (output_file, constituent.variables, 6,
    00897                              &TITLE, &CONSTITUENT, &CONSTITUENTSUFFIX,
    00898                              &USER, &DATE, &PACKAGE);
    00899
    00900   if (need_prototypes)
    00901     {
    00902       need_prototypes = false;
    00903
    00904       for (i = 0; i < source_files.size (); i++)
    00905         {
    00906           const SourceFile& file = source_files[i];
    00907           Language& language = file.language ();
    00908           if (language.prototypes)
    00909             {
    00910               need_prototypes = true;
    00911               break;
    00912             }
    00913         }
    00914     }
    00915
    00916   //-------------------------------------------
    00917   //
    00918   // Specific targets (application, library or java)
    00919   // Prepare in case prototype files are needed
    00920   //
    00921   //-------------------------------------------
    00922
    00923   PROTOTARGET = "";
    00924
    00925   //if ((Cmt::current_build_strategy & PrototypesMask) == Prototypes)
    00926   if (need_prototypes)
    00927     {
    00928       PROTOTARGET = CONSTITUENT;
    00929       PROTOTARGET += "PROTOS";
    00930     }
    00931
    00932   if (LINKMACRO == "java")
    00933     {
    00934       if (is_library)
    00935         {
    00936           jar_header_fragment.copy (output_file, constituent.variables, 3,
    00937                                     &CONSTITUENT, &CONSTITUENTSUFFIX, &OBJS);
    00938         }
    00939       else
    00940         {
    00941           java_header_fragment.copy (output_file, constituent.variables, 3,
    00942                                      &CONSTITUENT, &CONSTITUENTSUFFIX, &OBJS);
    00943         }
    00944     }
    00945   else
    00946     {
    00947       if (is_library)
    00948         {
    00949           library_header_fragment.copy (output_file, constituent.variables, 3,
    00950                                         &CONSTITUENT,
    00951                                         &CONSTITUENTSUFFIX,
    00952                                         &PROTOTARGET);
    00953         }
    00954       else
    00955         {
    00956           application_header_fragment.copy (output_file, constituent.variables, 3,
    00957                                             &CONSTITUENT, &CONSTITUENTSUFFIX,
    00958                                             &PROTOTARGET);
    00959         }
    00960     }
    00961
    00962
    00963   //----------------------------------------------------
    00964   //
    00965   // Preparing prototype files.
    00966   //
    00967   //----------------------------------------------------
    00968
    00969   //if ((Cmt::current_build_strategy & PrototypesMask) == Prototypes)
    00970   if (need_prototypes)
    00971     {
    00972       for (i = 0; i < source_files.size (); i++)
    00973         {
    00974           const SourceFile& file = source_files[i];
    00975           Language& language = file.language ();
    00976           if (language.prototypes)
    00977             {
    00978               prepare_proto_file (file.name ());
    00979             }
    00980         }
    00981
    00982       if (PROTOSTAMPS != "")
    00983         {
    00984           protos_header_fragment.copy (output_file, constituent.variables, 3,
    00985                                        &CONSTITUENT, &CONSTITUENTSUFFIX, &PROTOSTAMPS);
    00986         }
    00987
    00988       if (protonames != "")
    00989         {
    00990           for (i = 0; i < source_files.size (); i++)
    00991             {
    00992               const SourceFile& file = source_files[i];
    00993               Language& language = file.language ();
    00994               if (language.prototypes)
    00995                 {
    00996                   proto_file_action (file.name (), constituent);
    00997                 }
    00998             }
    00999         }
    01000     }
    01001
    01002   //----------------------------------------------------
    01003   //
    01004   // Preparing the library.
    01005   //
    01006   //----------------------------------------------------
    01007
    01008   if (OBJS != "")
    01009     {
    01010       if (LINKMACRO == "java")
    01011         {
    01012           if (is_library)
    01013             {
    01014               cmt_string classes = OBJS.value;
    01015
    01016               classes.replace_all ("$(javabin)", "");
    01017               classes.replace_all (srcdir.c_str (), "");
    01018
    01019               CLASSES = classes;
    01020
    01021               jar_fragment.copy (output_file, constituent.variables, 4,
    01022                                  &CONSTITUENT, &CONSTITUENTSUFFIX, &OBJS, &CLASSES);
    01023             }
    01024         }
    01025       else
    01026         {
    01027           if (is_library)
    01028             {
    01029               if (constituent.no_share)
    01030                 {
    01031                   library_no_share_fragment.copy (output_file, constituent.variables, 3,
    01032                                                   &CONSTITUENT, &CONSTITUENTSUFFIX, &OBJS);
    01033                 }
    01034               else
    01035                 {
    01036                   library_fragment.copy (output_file, constituent.variables, 3,
    01037                                          &CONSTITUENT, &CONSTITUENTSUFFIX, &OBJS);
    01038                 }
    01039             }
    01040           else
    01041             {
    01042               application_fragment.copy (output_file, constituent.variables, 4,
    01043                                          &CONSTITUENT, &CONSTITUENTSUFFIX,
    01044                                          &OBJS, &LINKMACRO);
    01045             }
    01046         }
    01047     }
    01048
    01049   LINE = "";
    01050   for (i = 0; i < sources.size (); i++)
    01051     {
    01052       file = sources[i];
    01053
    01054       set_full_name (full_name, file);
    01055       if (full_name == "") continue;
    01056
    01057       static CmtSystem::cmt_string_vector files;
    01058       get_all_files (full_name, files);
    01059
    01060       int count = 0;
    01061
    01062       for (int j = 0; j < files.size (); j++)
    01063         {
    01064           cmt_string& n = files[j];
    01065           if (n != "") count++;
    01066         }
    01067
    01068       if (count > 0)
    01069         {
    01070           LINE += full_name;
    01071           LINE += " ";
    01072         }
    01073     }
    01074
    01075   filter_paths (LINE.value);
    01076
    01077   if (constituent.build_triggers)
    01078     {
    01079       dependencies_and_triggers_fragment.copy (output_file,
    01080                                                constituent.variables, 3,
    01081                                                &CONSTITUENT,
    01082                                                &CONSTITUENTSUFFIX,
    01083                                                &LINE);
    01084     }
    01085   else
    01086     {
    01087       dependencies_fragment.copy (output_file,
    01088                                   constituent.variables, 3,
    01089                                   &CONSTITUENT,
    01090                                   &CONSTITUENTSUFFIX,
    01091                                   &LINE);
    01092     }
    01093
    01094   //----------------------------------------------------
    01095   //
    01096   // Building actual individual targets.
    01097   //
    01098   //----------------------------------------------------
    01099
    01100   for (i = 0; i < source_files.size (); i++)
    01101     {
    01102       SourceFile& file = source_files[i];
    01103       Language& language = file.language ();
    01104
    01105       if (language == "java")
    01106         {
    01107           java_file_action (file, constituent);
    01108         }
    01109       else
    01110         {
    01111           module_file_action (file, constituent);
    01112         }
    01113     }
    01114
    01115   if (PACKOS9)
    01116     {
    01117       if (os9sources != "")
    01118         {
    01119           //
    01120           // Generate transfers to the OS9 area.
    01121           //
    01122
    01123           ALLOS9SOURCES = "";
    01124           allsources = "";
    01125         }
    01126     }
    01127
    01128   /*
    01129     for file in `cmt_sort_line.csh ${os9sources}` ; do
    01130     if test `echo ${file} | grep '$(src)'` ; then
    01131     name=`echo ${file} | sed 's#$(src)##'`
    01132     ALLOS9SOURCES="${ALLOS9SOURCES} ../OS9/${name}"
    01133     allsources="${allsources} ${file}"
    01134     elif test `echo ${file} | grep '$(inc)'` ; then
    01135     name=`echo ${file} | sed 's#$(inc)##'`
    01136     ALLOS9SOURCES="${ALLOS9SOURCES} ../OS9/${name}"
    01137     allsources="${allsources} ${file}"
    01138     fi
    01139     done
    01140
    01141     if test ! "${ALLOS9SOURCES}" = "" ; then
    01142
    01143     sed -e "`subs_vars ALLOS9SOURCES`" \
    01144     ${os9_header_fragment} \
    01145     >>${output}
    01146
    01147     for FULLNAME in ${allsources} ; do
    01148
    01149     NAME=`echo ${FULLNAME} | sed -e 's#$(src)##' -e 's#$(inc)##'`
    01150
    01151     sed -e "`subs_vars NAME FULLNAME`" \
    01152     ${os9_fragment} \
    01153     >>${output}
    01154
    01155     done
    01156     fi
    01157     fi
    01158     fi
    01159   */
    01160
    01161   //
    01162   //  Generate package cleanup operations.
    01163   //
    01164
    01165   cleanup_header_fragment.copy (output_file, constituent.variables, 2,
    01166                                 &CONSTITUENT, &CONSTITUENTSUFFIX);
    01167
    01168   //if ((Cmt::current_build_strategy & PrototypesMask) == Prototypes)
    01169   if (need_prototypes)
    01170     {
    01171       if (protos != "")
    01172         {
    01173           FULLNAME = protos;
    01174           cleanup_fragment.copy (output_file, constituent.variables, 1, &FULLNAME);
    01175           FULLNAME = PROTOSTAMPS;
    01176           cleanup_fragment.copy (output_file, constituent.variables, 1, &FULLNAME);
    01177         }
    01178     }
    01179
    01180   if (LINKMACRO == "java")
    01181     {
    01182       cleanup_java_fragment.copy (output_file, constituent.variables, 1, &OBJS);
    01183
    01184       if (!is_library)
    01185         {
    01186           if (constituent.need_check)
    01187             {
    01188               check_java_fragment.copy (output_file, constituent.variables, 2,
    01189                                         &CONSTITUENT, &CONSTITUENTSUFFIX);
    01190             }
    01191         }
    01192     }
    01193   else
    01194     {
    01195       if (is_library)
    01196         {
    01197           cleanup_library_fragment.copy (output_file, constituent.variables, 2,
    01198                                          &CONSTITUENT, &CONSTITUENTSUFFIX);
    01199         }
    01200       else
    01201         {
    01202           cleanup_application_fragment.copy (output_file, constituent.variables, 2,
    01203                                              &CONSTITUENT, &CONSTITUENTSUFFIX);
    01204           if (OBJS != "")
    01205             {
    01206               cleanup_objects_fragment.copy (output_file, constituent.variables, 3,
    01207                                              &OBJS, &CONSTITUENT, &CONSTITUENTSUFFIX);
    01208             }
    01209
    01210           if (constituent.need_check)
    01211             {
    01212               check_application_fragment.copy (output_file, constituent.variables, 2,
    01213                                                &CONSTITUENT, &CONSTITUENTSUFFIX);
    01214             }
    01215         }
    01216     }
    01217 }

void MakefileGenerator::fill_outputs ( | )

| Definition at line 781 of file cmt_generator.cxx. Referenced by build_document_makefile(), and build_library_makefile().
    00782 {
    00783   bool first = true;
    00784
    00785   OBJS = "";
    00786
    00787   for (int i = 0; i < source_files.size (); i++)
    00788     {
    00789       const SourceFile& file = source_files[i];
    00790       const cmt_string output = file.output ();
    00791
    00792       if (output != "")
    00793         {
    00794           if (first)
    00795             {
    00796               first = false;
    00797             }
    00798           else
    00799             {
    00800               OBJS += " ";
    00801             }
    00802
    00803           OBJS += output;
    00804         }
    00805
    00806       if (Cmt::get_debug ())
    00807         {
    00808           cout << "MakefileGenerator::fill_outputs> output=" << output << " OBJS=" << OBJS << endl;
    00809         }
    00810
    00811     }
    00812
    00813   if (Cmt::get_debug ())
    00814     {
    00815       cout << "MakefileGenerator::fill_outputs> OBJS=" << OBJS << endl;
    00816     }
    00817
    00818 }

void MakefileGenerator::java_file_action ( | SourceFile & file,
| const Constituent & constituent )

| Definition at line 756 of file cmt_generator.cxx. Referenced by build_library_makefile().
    00757 {
    00758   static cmt_string suffix;
    00759
    00760   FULLNAME = file.name ();
    00761   OUTPUTNAME = file.output ();
    00762
    00763   CmtSystem::get_dot_suffix (FULLNAME, suffix);
    00764
    00765   CmtSystem::basename (FULLNAME, suffix, NAME.value);
    00766   CmtSystem::basename (FULLNAME, FILENAME.value);
    00767
    00768   if (CmtSystem::test_file (FULLNAME))
    00769     {
    00770       java_fragment.copy (output_file, constituent.variables, 5, &NAME,
    00771                           &FULLNAME, &OUTPUTNAME,
    00772                           &CONSTITUENT, &CONSTITUENTSUFFIX);
    00773     }
    00774   else
    00775     {
    00776       cout << "#CMT> Warning : file " << FULLNAME << " not found" << endl;
    00777     }
    00778 }

void MakefileGenerator::module_file_action ( | SourceFile & file,
| const Constituent & constituent )

| Definition at line 679 of file cmt_generator.cxx. Referenced by build_library_makefile().
    00680 {
    00681   cmt_string name = file.name ();
    00682   Language& language = file.language ();
    00683
    00684   static cmt_string suffix;
    00685   static cmt_string prefix;
    00686   static cmt_string preproc;
    00687
    00688   FULLNAME = name;
    00689
    00690   CmtSystem::get_dot_suffix (name, suffix);
    00691
    00692   CmtSystem::basename (name, suffix, NAME.value);
    00693
    00694   CmtSystem::dirname (name, prefix);
    00695   CmtSystem::basename (name, FILENAME.value);
    00696
    00697   FragmentHandle* fragment;
    00698
    00699   if (language != Language::null ())
    00700     {
    00701       preproc = language.preprocessor_command;
    00702       fragment = (is_library) ? &(language.library) : &(language.application);
    00703     }
    00704   else
    00705     {
    00706       //
    00707       // What happens when the language is not known???
    00708       //
    00709       //
    00710       preproc = "-I";
    00711       fragment = 0;
    00712     }
    00713
    00714   if ((prefix == "../src") || (prefix == "..\\src"))
    00715     {
    00716       ADDINCLUDE = "";
    00717     }
    00718   else if (prefix != "")
    00719     {
    00720       ADDINCLUDE  = preproc;
    00721       ADDINCLUDE += prefix;
    00722     }
    00723
    00724   if (!CmtSystem::test_file (name))
    00725     {
    00726       cout << "#CMT> Warning : Source file " << name << " not found" << endl;
    00727     }
    00728
    00729   FILEPATH = prefix;
    00730   if (FILEPATH.value != "") FILEPATH.value += CmtSystem::file_separator ();
    00731   filter_paths (FILEPATH.value);
    00732
    00733   LINE = FULLNAME.value;
    00734   LINE += " ";
    00735
    00736   filter_paths (FULLNAME.value);
    00737   filter_paths (LINE.value);
    00738
    00739   CmtSystem::get_suffix (name, FILESUFFIX.value);
    00740
    00741   if (fragment != 0)
    00742     {
    00743       fragment->copy (output_file, constituent.variables, 10,
    00744                       &CONSTITUENT, &CONSTITUENTSUFFIX, &FILENAME, &NAME, &LINE,
    00745                       &ADDINCLUDE, &FULLNAME, &FILEPATH, &FILESUFFIX, &PACKAGE);
    00746     }
    00747
    00748   if (PACKOS9)
    00749     {
    00750       os9sources += LINE;
    00751       os9sources += " ";
    00752     }
    00753 }

void MakefileGenerator::prepare_proto_file ( | const cmt_string & file )

| Definition at line 626 of file cmt_generator.cxx. Referenced by build_library_makefile().
    00627 {
    00628   static cmt_string name;
    00629   static cmt_string pp;
    00630
    00631   CmtSystem::name (file, name);
    00632
    00633   if (CmtSystem::test_file (file))
    00634     {
    00635       pp  = incdir;
    00636       pp += name;
    00637       pp += ".pp";
    00638
    00639       if (!CmtSystem::test_file (pp))
    00640         {
    00641           //Generator::build_prototype (file);
    00642         }
    00643     }
    00644
    00645   protos += " ";
    00646   protos += inc;
    00647   protos += name;
    00648   protos += ".ph";
    00649
    00650   protonames += " ";
    00651   protonames += name;
    00652   protonames += ".ph";
    00653
    00654   PROTOSTAMPS += " ";
    00655   PROTOSTAMPS += inc;
    00656   PROTOSTAMPS += name;
    00657   PROTOSTAMPS += ".pp";
    00658 }

void MakefileGenerator::prepare_use_context ( | )

| Definition at line 1437 of file cmt_generator.cxx. Referenced by Generator::build_dependencies(), build_document_makefile(), and build_library_makefile().
    01438 {
    01439   cmt_string path;
    01440   cmt_string substitution;
    01441
    01442   Use* use = &Use::current ();
    01443
    01444   deps_builder.clear ();
    01445
    01446   if (use->include_path != "none")
    01447     {
    01448       if (use->include_path == "")
    01449         {
    01450           deps_builder.add (incdir, "$(src)");
    01451         }
    01452       else
    01453         {
    01454           substitution = use->include_path;
    01455
    01456           path = substitution;
    01457           Symbol::expand (path);
    01458
    01459           if (CmtSystem::file_separator () == '/')
    01460             {
    01461               path.replace_all ("\\", "/");
    01462               path.replace_all ("//", "/");
    01463             }
    01464           else
    01465             {
    01466               path.replace_all ("/", "\\");
    01467               path.replace_all ("\\\\", "\\");
    01468             }
    01469         }
    01470
    01471       deps_builder.add (path, substitution);
    01472     }
    01473
    01474   deps_builder.add_includes (*use);
    01475
    01476   Use::UsePtrVector& uses = Use::uses ();
    01477
    01478   if (uses.size () > 0)
    01479     {
    01480       int number;
    01481
    01482       for (number = 0; number < uses.size (); number++)
    01483         {
    01484           use = uses[number];
    01485           if (use->discarded) continue;
    01486
    01487           if (use->real_path != "")
    01488             {
    01489               if (use->include_path != "none")
    01490                 {
    01491                   if (use->include_path == "")
    01492                     {
    01493                       path = use->real_path;
    01494                       path += CmtSystem::file_separator ();
    01495                       path += use->package;
    01496                       path += CmtSystem::file_separator ();
    01497                       path += use->version;
    01498                       path += CmtSystem::file_separator ();
    01499                       path += "src";
    01500
    01501                       substitution = "$(";
    01502                       substitution += use->prefix;
    01503                       substitution += "ROOT)";
    01504                       substitution += CmtSystem::file_separator ();
    01505                       substitution += "src";
    01506                       substitution += CmtSystem::file_separator ();
    01507                     }
    01508                   else
    01509                     {
    01510                       substitution = use->include_path;
    01511
    01512                       path = substitution;
    01513                       Symbol::expand (path);
    01514
    01515                       if (CmtSystem::file_separator () == '/')
    01516                         {
    01517                           path.replace_all ("\\", "/");
    01518                           path.replace_all ("//", "/");
    01519                         }
    01520                       else
    01521                         {
    01522                           path.replace_all ("/", "\\");
    01523                           path.replace_all ("\\\\", "\\");
    01524                         }
    01525                     }
    01526
    01527                   deps_builder.add (path, substitution);
    01528                 }
    01529
    01530               deps_builder.add_includes (*use);
    01531             }
    01532         }
    01533     }
    01534 }

void MakefileGenerator::proto_file_action ( | const cmt_string & file,
| const Constituent & constituent )

| Definition at line 661 of file cmt_generator.cxx. Referenced by build_library_makefile().
    00662 {
    00663   static cmt_string suffix;
    00664
    00665   CmtSystem::dirname (file, FILEPATH.value);
    00666   if (FILEPATH.value != "") FILEPATH.value += CmtSystem::file_separator ();
    00667
    00668   filter_paths (FILEPATH.value);
    00669
    00670   CmtSystem::basename (file, FILENAME.value);
    00671   CmtSystem::get_dot_suffix (FILENAME, suffix);
    00672
    00673   CmtSystem::basename (FILENAME, suffix, NAME.value);
    00674
    00675   buildproto_fragment.copy (output_file, constituent.variables, 3, &NAME, &FILEPATH, &FILENAME);
    00676 }

void MakefileGenerator::reset ( | )

| Definition at line 411 of file cmt_generator.cxx. Referenced by Generator::build_constituent_makefile(), Generator::build_constituents_makefile(), Generator::build_dependencies(), Generator::build_make_setup(), Generator::build_msdev(), Generator::build_msdev_workspace(), and Generator::build_readme().
    00412 {
    00413   DOCPATH = "";
    00414   PACKAGEPATH = "";
    00415   PACKAGEPREFIX = "";
    00416   PACKAGE = "";
    00417   VERSION = "";
    00418   MGRSTYLE = "";
    00419   TITLE = "";
    00420   GROUP = "";
    00421   CONSTITUENT = "";
    00422   CONSTITUENTSUFFIX = "";
    00423   LIBRARYSUFFIX = "";
    00424   USER = "";
    00425   DATE = "";
    00426   PROTOTARGET = "";
    00427   OBJS = "";
    00428   CLASSES = "";
    00429   PROTOSTAMPS = "";
    00430   NAME = "";
    00431   FILEPATH = "";
    00432   FILESUFFIX = "";
    00433   SUFFIX = "";
    00434   FILENAME = "";
    00435   LINKMACRO = "";
    00436   LINE = "";
    00437   ADDINCLUDE = "";
    00438   FULLNAME = "";
    00439   OUTPUTNAME = "";
    00440   ALLOS9SOURCES = "";
    00441   NODEBUGUSELINKOPTS = "";
    00442   DEBUGUSELINKOPTS = "";
    00443   USEINCLUDES = "";
    00444
    00445   PACKINCLUDES = "";
    00446   PACKOS9      = false;
    00447   GENERATOR    = "";
    00448
    00449   is_library     = false;
    00450   is_application = false;
    00451   is_document    = false;
    00452   srcdir       = "";
    00453   docdir       = "";
    00454   cmtdir       = "";
    00455   incdir       = "";
    00456   src          = "$(src)";
    00457   doc          = "$(doc)";
    00458   inc          = "$(inc)";
    00459   mgr          = "$(mgr)";
    00460   cmt          = "$(cmt)";
    00461   protos       = "";
    00462   protonames   = "";
    00463   os9sources   = "";
    00464
    00465   source_files.clear ();
    00466
    00467   buildproto_fragment.reset ();
    00468   dependencies_fragment.reset ();
    00469   dependencies_and_triggers_fragment.reset ();
    00470
    00471   make_header_fragment.reset ();
    00472   library_header_fragment.reset ();
    00473   application_header_fragment.reset ();
    00474   document_header_fragment.reset ();
    00475   java_header_fragment.reset ();
    00476   jar_header_fragment.reset ();
    00477   protos_header_fragment.reset ();
    00478   library_fragment.reset ();
    00479   library_no_share_fragment.reset ();
    00480   jar_fragment.reset ();
    00481   application_fragment.reset ();
    00482   java_fragment.reset ();
    00483   cleanup_header_fragment.reset ();
    00484   cleanup_fragment.reset ();
    00485   cleanup_library_fragment.reset ();
    00486   cleanup_application_fragment.reset ();
    00487   cleanup_java_fragment.reset ();
    00488   cleanup_objects_fragment.reset ();
    00489
    00490   dsw_header_fragment.reset ();
    00491   dsw_project_fragment.reset ();
    00492   dsw_all_project_header_fragment.reset ();
    00493   dsw_all_project_dependency_fragment.reset ();
    00494   dsw_all_project_trailer_fragment.reset ();
    00495   dsw_trailer_fragment.reset ();
    00496
    00497   dsp_all_fragment.reset ();
    00498   dsp_library_header_fragment.reset ();
    00499   //dsp_shared_library_header_fragment.reset ();
    00500   dsp_application_header_fragment.reset ();
    00501   dsp_windows_header_fragment.reset ();
    00502   dsp_contents_fragment.reset ();
    00503   dsp_trailer_fragment.reset ();
    00504
    00505   make_setup_header_fragment.reset ();
    00506   make_setup_fragment.reset ();
    00507
    00508   constituents_header_fragment.reset ();
    00509   group_fragment.reset ();
    00510   constituent_fragment.reset ();
    00511   constituents_trailer_fragment.reset ();
    00512
    00513   readme_header_fragment.reset ();
    00514   readme_fragment.reset ();
    00515   readme_doc_fragment.reset ();
    00516   readme_use_fragment.reset ();
    00517   readme_trailer_fragment.reset ();
    00518
    00519   check_application_fragment.reset ();
    00520   check_java_fragment.reset ();
    00521   check_application_header_fragment.reset ();
    00522
    00523   Language::setup_all_fragments ();
    00524
    00525   CmtSystem::cd (Cmt::get_current_dir ());
    00526
    00527   cmt_string branch = CmtSystem::current_branch ();
    00528
    00529   if ((branch == "mgr") || (branch == "cmt"))
    00530     {
    00531       if (CmtSystem::test_directory ("../src"))
    00532         {
    00533           srcdir = "..";
    00534           srcdir += CmtSystem::file_separator ();
    00535           srcdir += "src";
    00536           srcdir += CmtSystem::file_separator ();
    00537         }
    00538       else
    00539         {
    00540           srcdir = "";
    00541         }
    00542
    00543       if (CmtSystem::test_directory ("../doc"))
    00544         {
    00545           docdir = "..";
    00546           docdir += CmtSystem::file_separator ();
    00547           docdir += "doc";
    00548           docdir += CmtSystem::file_separator ();
    00549         }
    00550       else
    00551         {
    00552           docdir = "";
    00553         }
    00554
    00555       if (CmtSystem::test_directory ("../cmt"))
    00556         {
    00557           cmtdir = "..";
    00558           cmtdir += CmtSystem::file_separator ();
    00559           cmtdir += "cmt";
    00560           cmtdir += CmtSystem::file_separator ();
    00561         }
    00562       else if (CmtSystem::test_directory ("../mgr"))
    00563         {
    00564           cmtdir = "..";
    00565           cmtdir += CmtSystem::file_separator ();
    00566           cmtdir += "mgr";
    00567           cmtdir += CmtSystem::file_separator ();
    00568         }
    00569       else
    00570         {
    00571           cmtdir = CmtSystem::pwd ();
    00572           cmtdir += CmtSystem::file_separator ();
    00573         }
    00574
    00575       if (CmtSystem::test_directory ("../src"))
    00576         {
    00577           incdir = "..";
    00578           incdir += CmtSystem::file_separator ();
    00579           incdir += "src";
    00580           incdir += CmtSystem::file_separator ();
    00581         }
    00582       else
    00583         {
    00584           incdir = "";
    00585         }
    00586
    00587 #ifdef WIN32
    00588       msdevdir = "..";
    00589       msdevdir += CmtSystem::file_separator ();
    00590       msdevdir += "Visual";
    00591
    00592       if (!CmtSystem::test_directory (msdevdir))
    00593         {
    00594           CmtSystem::mkdir (msdevdir);
    00595         }
    00596
    00597       msdevdir += CmtSystem::file_separator ();
    00598 #endif
    00599
    00600     }
    00601   else
    00602     {
    00603       srcdir = ".";
    00604       srcdir += CmtSystem::file_separator ();
    00605       docdir = ".";
    00606       docdir += CmtSystem::file_separator ();
    00607       cmtdir = CmtSystem::pwd ();
    00608       cmtdir += CmtSystem::file_separator ();
    00609       incdir = ".";
    00610       incdir += CmtSystem::file_separator ();
    00611 #ifdef WIN32
    00612       msdevdir = ".";
    00613       msdevdir += CmtSystem::file_separator ();
    00614 #endif
    00615     }
    00616 }

void MakefileGenerator::set_full_name ( | cmt_string & full_name,
| cmt_string & file )

| Definition at line 1537 of file cmt_generator.cxx. Referenced by Generator::build_dependencies(), build_document_makefile(), build_library_makefile(), and Generator::build_msdev().
    01538 {
    01539   full_name = "";
    01540
    01541   Symbol::expand (file);
    01542
    01543   if (file == "") return;
    01544
    01545   if (!CmtSystem::absolute_path (file))
    01546     {
    01547       full_name = srcdir;
    01548       if (full_name != "") full_name += CmtSystem::file_separator ();
    01549     }
    01550
    01551   full_name += file;
    01552
    01553   char sep = CmtSystem::file_separator ();
    01554   if (sep == '/')
    01555     {
    01556       full_name.replace_all ("\\", sep);
    01557       full_name.replace_all ("//", "/");
    01558     }
    01559   else
    01560     {
    01561       full_name.replace_all ("/", sep);
    01562       full_name.replace_all ("\\\\", "\\");
    01563     }
    01564 }

## Member Data Documentation

cmt_string MakefileGenerator::GENERATOR

| Definition at line 124 of file cmt_generator.cxx.

cmt_string MakefileGenerator::PACKINCLUDES

| Definition at line 121 of file cmt_generator.cxx.

bool MakefileGenerator::PACKOS9

| Definition at line 122 of file cmt_generator.cxx.

cmt_string MakefileGenerator::cmt

| Definition at line 137 of file cmt_generator.cxx.

cmt_string MakefileGenerator::cmtdir

| Definition at line 130 of file cmt_generator.cxx.

DepsBuilder MakefileGenerator::deps_builder

| Definition at line 146 of file cmt_generator.cxx.

cmt_string MakefileGenerator::doc

| Definition at line 134 of file cmt_generator.cxx.

cmt_string MakefileGenerator::docdir

| Definition at line 129 of file cmt_generator.cxx.

cmt_string MakefileGenerator::inc

| Definition at line 135 of file cmt_generator.cxx.

cmt_string MakefileGenerator::incdir

| Definition at line 131 of file cmt_generator.cxx.

bool MakefileGenerator::is_application

| Definition at line 126 of file cmt_generator.cxx.

bool MakefileGenerator::is_document

| Definition at line 127 of file cmt_generator.cxx.

bool MakefileGenerator::is_library

| Definition at line 125 of file cmt_generator.cxx.

cmt_string MakefileGenerator::mgr

| Definition at line 136 of file cmt_generator.cxx.

cmt_string MakefileGenerator::msdevdir

| Definition at line 132 of file cmt_generator.cxx.

cmt_string MakefileGenerator::os9sources

| Definition at line 140 of file cmt_generator.cxx.

FILE * MakefileGenerator::output_file

| Definition at line 144 of file cmt_generator.cxx.

cmt_string MakefileGenerator::protonames

| Definition at line 139 of file cmt_generator.cxx.

cmt_string MakefileGenerator::protos

| Definition at line 138 of file cmt_generator.cxx.

cmt_vector< SourceFile > MakefileGenerator::source_files

| Definition at line 142 of file cmt_generator.cxx.

cmt_string MakefileGenerator::src

| Definition at line 133 of file cmt_generator.cxx.

cmt_string MakefileGenerator::srcdir

| Definition at line 128 of file cmt_generator.cxx.

The documentation for this class was generated from the following file:

- cmt_generator.cxx