00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef MORE_LANG_COMPILATION_H
00032 #define MORE_LANG_COMPILATION_H
00033
00034 #include <string>
00035 #include <list>
00036 #include <map>
00037 #include <more/io/fwd.h>
00038
00039 namespace more {
00040 namespace lang {
00041
00042
00043 enum lang_t
00044 {
00045
00046
00047 lang_undefined,
00048
00049
00050 lang_c,
00051 lang_cxx,
00052
00053
00054 lang_scheme,
00055 lang_java,
00056 lang_shell,
00057 lang_perl,
00058 lang_f77,
00059 lang_f90,
00060
00061
00062 lang_end
00063 };
00064
00065 std::string language_name(lang_t lang);
00066
00067 std::string header_file_name(std::string const& bname, lang_t lang,
00068 std::string const& dir = ".");
00069 std::string source_file_name(std::string const& bname, lang_t lang,
00070 std::string const& dir = ".");
00071 std::string c_header_file_name(std::string const& bname,
00072 std::string const& dir = ".");
00073 std::string cxx_header_file_name(std::string const& bname,
00074 std::string const& dir = ".");
00075 std::string c_source_file_name(std::string const& bname,
00076 std::string const& dir = ".");
00077 std::string cxx_source_file_name(std::string const& bname,
00078 std::string const& dir = ".");
00079 std::string ltobject_file_name(std::string const& bname,
00080 std::string const& dir = ".");
00081 std::string program_file_name(std::string const& bname,
00082 std::string const& dir = ".");
00083 std::string library_file_name(std::string const& bname,
00084 std::string const& dir = ".");
00085 std::string dlopen_file_name(std::string const& bname,
00086 std::string const& dir = ".");
00087
00088
00089 struct compilation
00090 {
00091 enum target_type
00092 {
00093 target_none, target_program,
00094 target_library, target_library_dlopen
00095 };
00096 typedef unsigned long version_type;
00097
00098 private:
00099 struct source_entry
00100 {
00101 source_entry() {}
00102 source_entry(lang_t lang, double t, bool rebuild_p)
00103 : m_lang(lang), m_version(t), m_rebuild_p(rebuild_p) {}
00104 void sync(io::syncstream&);
00105
00106 lang_t m_lang;
00107 double m_version;
00108 bool m_rebuild_p;
00109 };
00110 typedef std::map<std::string, source_entry> source_entry_container;
00111 typedef source_entry_container::iterator source_entry_iterator;
00112 typedef source_entry_container::const_iterator source_entry_const_iterator;
00113
00114 public:
00115 compilation(std::string const& srcdir,
00116 std::string const& builddir);
00117
00118 compilation(std::string const& srcdir,
00119 std::string const& builddir,
00120 std::string const& includedir,
00121 std::string const& libdir);
00122
00123
00124 std::string const& src_dir() const { return m_srcdir; }
00125 std::string const& build_dir() const { return m_builddir; }
00126 std::string const& include_dir() const { return m_includedir; }
00127 std::string const& lib_dir() const { return m_libdir; }
00128
00129
00130
00131
00132
00133 std::string insert_header(std::string const& bname, lang_t lang);
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 std::string insert_source(std::string const& bname, lang_t lang,
00146 version_type version);
00147
00148
00149
00150 std::string insert_source(std::string const& bname, lang_t lang);
00151
00152 std::string insert_libadd(std::string const& bname);
00153
00154
00155 void append_cppflags(std::string const& cppflags);
00156 void append_cflags(std::string const& cxxflags);
00157 void append_cxxflags(std::string const& cflags);
00158 void append_ldflags(std::string const& ldflags);
00159
00160
00161 void set_target_program(std::string const& bname);
00162 void set_target_library(std::string const& bname, bool module_p);
00163
00164
00165 std::string program_file_name() const { return m_target; }
00166 std::string library_file_name() const { return m_target; }
00167
00168
00169 bool make_all();
00170 bool make_install();
00171
00172
00173 void set_interface_added() { m_interface_added = 1; }
00174 void set_interface_changed() { m_interface_changed = 1; }
00175
00176 private:
00177 bool check_cache();
00178
00179 bool libtool(std::string const& cmd, char const* mode);
00180 bool libtool_compile(std::string const& cmd)
00181 {
00182 return libtool(cmd, "compile");
00183 }
00184 bool libtool_link(std::string const& cmd)
00185 {
00186 return libtool(cmd, "link");
00187 }
00188
00189 void sync_state(io::syncstream&);
00190
00191 typedef std::list<std::string> string_list;
00192
00193 std::string m_srcdir;
00194 std::string m_builddir;
00195 std::string m_includedir;
00196 std::string m_libdir;
00197
00198
00199
00200
00201 string_list m_headers;
00202 source_entry_container m_sources;
00203
00204
00205
00206 std::string m_cppflags;
00207 std::string m_cflags;
00208 std::string m_cxxflags;
00209 std::string m_ldflags;
00210
00211 target_type m_target_type;
00212 std::string m_target;
00213 std::string m_target_bname;
00214
00215 int m_so_version_scheme;
00216 static int const s_so_version_scheme_none = 0;
00217 static int const s_so_version_scheme_libtool = 1;
00218 static int const s_so_version_scheme_max = 1;
00219 int m_so_version_current;
00220 int m_so_version_revision;
00221 int m_so_version_age;
00222 unsigned int m_interface_added : 1;
00223 unsigned int m_interface_changed : 1;
00224 };
00225
00226 }}
00227
00228 #endif