summaryrefslogtreecommitdiffstatshomepage
path: root/src/build
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2013-06-19 14:05:35 +0000
committer Miodrag Milanovic <mmicko@gmail.com>2013-06-19 14:05:35 +0000
commit766a73b0418d770a0ce4ea3994ef0451e219c653 (patch)
tree6eeb2afb75da7d5d067d82dfc4b0021a33a5d0bb /src/build
parent1953d6cf08eaeb2dd1e829694c8d1a8fba9c3064 (diff)
simplified mamemak (nw)
Diffstat (limited to 'src/build')
-rw-r--r--src/build/makemak.c240
1 files changed, 73 insertions, 167 deletions
diff --git a/src/build/makemak.c b/src/build/makemak.c
index 9d7fc2f6b99..bb7bc530b42 100644
--- a/src/build/makemak.c
+++ b/src/build/makemak.c
@@ -118,7 +118,7 @@ static tagmap_t<char *> include_map;
***************************************************************************/
// core output functions
-static int recurse_dir(int srcrootlen, astring &srcdir);
+static int recurse_dir(astring &srcdir);
static file_entry &compute_dependencies(astring &srcfile);
// path helpers
@@ -405,7 +405,7 @@ int main(int argc, char *argv[])
}
// recurse over subdirectories
- return recurse_dir(srcdir.len(), srcdir);
+ return recurse_dir(srcdir);
}
@@ -414,14 +414,6 @@ int main(int argc, char *argv[])
CORE OUTPUT FUNCTIONS
***************************************************************************/
-static int compare_list_entries(const void *p1, const void *p2)
-{
- const list_entry *entry1 = *(const list_entry **)p1;
- const list_entry *entry2 = *(const list_entry **)p2;
- return entry1->name.cmp(entry2->name);
-}
-
-
/*-------------------------------------------------
recurse_dependencies - recurse through the
dependencies found, adding the mto the tagmap
@@ -451,187 +443,101 @@ static void recurse_dependencies(file_entry &file, dependency_map &map)
recurse_dir - recurse through a directory
-------------------------------------------------*/
-static int recurse_dir(int srcrootlen, astring &srcdir)
+static int recurse_dir(astring &srcdir)
{
- static const osd_dir_entry_type typelist[] = { ENTTYPE_DIR, ENTTYPE_FILE };
int result = 0;
- // iterate first over directories, then over files
- for (int entindex = 0; entindex < ARRAY_LENGTH(typelist) && result == 0; entindex++)
+ // iterate through each file
+ for(int i=0;i<sourcecount;i++)
{
- osd_dir_entry_type entry_type = typelist[entindex];
+ astring srcfile;
- // open the directory and iterate through it
- osd_directory *dir = osd_opendir(srcdir);
- if (dir == NULL)
- {
- result = 1;
- goto error;
- }
+ // build the source filename
+ srcfile.printf("%s%c%s.c", srcdir.cstr(), PATH_SEPARATOR[0], sourcelst[i]);
+
+ dependency_map depend_map;
- // build up the list of files
- const osd_directory_entry *entry;
- list_entry *list = NULL;
- int found = 0;
- while ((entry = osd_readdir(dir)) != NULL)
- if (entry->type == entry_type && entry->name[0] != '.')
+ // find dependencies
+ file_entry &file = compute_dependencies(srcfile);
+ recurse_dependencies(file, depend_map);
+
+ for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
{
- list_entry *lentry = new list_entry;
- lentry->name.cpy(entry->name);
- lentry->next = list;
- list = lentry;
- found++;
+ astring t(entry->tag());
+ if (core_filename_ends_with(t, ".h"))
+ {
+ char *foundfile = include_map.find(t);
+ if (foundfile != NULL) {
+ printf("%s\n", foundfile);
+ // we add things just once when needed
+ include_map.remove(t);
+ }
+ }
}
+
+ }
- // close the directory
- osd_closedir(dir);
-
- // skip if nothing found
- if (found == 0)
- continue;
+
+ // iterate through each file
+ for(int i=0;i<sourcecount;i++)
+ {
+ astring srcfile;
- // allocate memory for sorting
- list_entry **listarray = new list_entry *[found];
- found = 0;
- for (list_entry *curlist = list; curlist != NULL; curlist = curlist->next)
- listarray[found++] = curlist;
+ // build the source filename
+ srcfile.printf("%s%c%s.c", srcdir.cstr(), PATH_SEPARATOR[0], sourcelst[i]);
+
+ dependency_map depend_map;
- // sort the list
- qsort(listarray, found, sizeof(listarray[0]), compare_list_entries);
+ // find dependencies
+ file_entry &file = compute_dependencies(srcfile);
+ recurse_dependencies(file, depend_map);
- // rebuild the list
- list = NULL;
- while (--found >= 0)
- {
- listarray[found]->next = list;
- list = listarray[found];
- }
- delete[] listarray;
+ // convert the target from source to object (makes assumptions about rules)
+ astring target(file.name);
+ target.replace(0, "src/", "$(OBJ)/");
+ target.replace(0, "drivers/", "");
+ target.replace(0, ".c", ".a");
+ printf("\n%s : \\\n", target.cstr());
- // iterate through each file
- for (list_entry *curlist = list; curlist != NULL && result == 0; curlist = curlist->next)
+ // iterate over the hashed dependencies and output them as well
+ for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
{
- astring srcfile;
-
- // build the source filename
- srcfile.printf("%s%c%s", srcdir.cstr(), PATH_SEPARATOR[0], curlist->name.cstr());
-
- // if we have a file, output it
- if (entry_type == ENTTYPE_FILE)
+ astring t(entry->tag());
+ t.replace(0, "src/", "$(OBJ)/");
+ t.replace(0, ".c", ".o");
+ if (core_filename_ends_with(t, ".o"))
{
- // make sure we care, first
- if (core_filename_ends_with(curlist->name, ".c"))
- {
- dependency_map depend_map;
-
- // find dependencies
- file_entry &file = compute_dependencies(srcfile);
- recurse_dependencies(file, depend_map);
- astring fn = astring(curlist->name);
- fn.replace(".c","");
- if (isonlist(fn))
- {
- for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
- {
- astring t(entry->tag());
- if (core_filename_ends_with(t, ".h"))
- {
- char *foundfile = include_map.find(t);
- if (foundfile != NULL) {
- printf("%s\n", foundfile);
- // we add things just once when needed
- include_map.remove(t);
- }
- }
- }
- }
- }
+ printf("\t%s \\\n", t.cstr());
}
}
-
- // iterate through each file
- for (list_entry *curlist = list; curlist != NULL && result == 0; curlist = curlist->next)
+ printf("\n");
+ printf("\n");
+ for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
{
- astring srcfile;
-
- // build the source filename
- srcfile.printf("%s%c%s", srcdir.cstr(), PATH_SEPARATOR[0], curlist->name.cstr());
-
- // if we have a file, output it
- if (entry_type == ENTTYPE_FILE)
+ astring t(entry->tag());
+ if (core_filename_ends_with(t, ".lay"))
{
- // make sure we care, first
- if (core_filename_ends_with(curlist->name, ".c"))
- {
- dependency_map depend_map;
-
- // find dependencies
- file_entry &file = compute_dependencies(srcfile);
- recurse_dependencies(file, depend_map);
- astring fn = astring(curlist->name);
- fn.replace(".c","");
- if (isonlist(fn))
- {
- // convert the target from source to object (makes assumptions about rules)
- astring target(file.name);
- target.replace(0, "src/", "$(OBJ)/");
- target.replace(0, "drivers/", "");
- target.replace(0, ".c", ".a");
- printf("\n%s : \\\n", target.cstr());
-
- // iterate over the hashed dependencies and output them as well
- for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
- {
- astring t(entry->tag());
- t.replace(0, "src/", "$(OBJ)/");
- t.replace(0, ".c", ".o");
- if (core_filename_ends_with(t, ".o"))
- {
- printf("\t%s \\\n", t.cstr());
- }
- }
-
- printf("\n");
- printf("\n");
- for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
- {
- astring t(entry->tag());
- if (core_filename_ends_with(t, ".lay"))
- {
- astring target2(file.name);
- target2.replace(0, "src/", "$(OBJ)/");
- target2.replace(0, ".c", ".o");
-
- t.replace(0, "src/", "$(OBJ)/");
- t.replace(0, ".lay", ".lh");
-
- printf("%s: %s\n", target2.cstr(), t.cstr());
- }
- if (core_filename_ends_with(t, ".inc"))
- {
- astring target2(file.name);
- target2.replace(0, "src/", "$(OBJ)/");
- target2.replace(0, ".c", ".o");
-
- printf("%s: %s\n", target2.cstr(), t.cstr());
- }
- }
- }
- }
+ astring target2(file.name);
+ target2.replace(0, "src/", "$(OBJ)/");
+ target2.replace(0, ".c", ".o");
+
+ t.replace(0, "src/", "$(OBJ)/");
+ t.replace(0, ".lay", ".lh");
+
+ printf("%s: %s\n", target2.cstr(), t.cstr());
}
- }
+ if (core_filename_ends_with(t, ".inc"))
+ {
+ astring target2(file.name);
+ target2.replace(0, "src/", "$(OBJ)/");
+ target2.replace(0, ".c", ".o");
- // free all the allocated entries
- while (list != NULL)
- {
- list_entry *next = list->next;
- delete list;
- list = next;
+ printf("%s: %s\n", target2.cstr(), t.cstr());
+ }
}
+
}
-
-error:
return result;
}