Previous 199869 Revisions Next

r23808 Thursday 20th June, 2013 at 08:07:38 UTC by Miodrag Milanović
Updated makemak to support splitting per libraries (nw)
[src/build]makelist.c makemak.c

trunk/src/build/makemak.c
r23807r23808
8181   astring         name;
8282};
8383
84struct librarylist_entry
85{
86   librarylist_entry *    next;
87   list_entry *    sourcefiles;
88   astring         name;
89};
8490
8591struct file_entry;
8692
r23807r23808
108114static include_path *incpaths;
109115static exclude_path *excpaths;
110116static tagmap_t<file_entry *> file_map;
111static const char *sourcelst[MAX_SOURCES];
112static int sourcecount;
117static librarylist_entry *librarylist;
118
119static librarylist_entry *last_libraryitem;
120static list_entry *last_sourceitem;
121
113122static tagmap_t<char *> include_map;
114123
115124
r23807r23808
186195}
187196
188197//-------------------------------------------------
189//  isonlist - return info if item is in source
190//  list or not
191//-------------------------------------------------
192
193bool isonlist(const char *drivname)
194{
195   if (sourcecount>0) {
196      for(int i=0;i<sourcecount;i++) {
197         if (strcmp(sourcelst[i],drivname)==0) return true;
198      }
199   }
200   return false;
201}
202
203//-------------------------------------------------
204198//  parse_file - parse a single file, may be
205199//  called recursively
206200//-------------------------------------------------
r23807r23808
292286            drivname[pos+1] = 0;
293287         }
294288         fprintf(stderr, "Creating make dependancy for '%s'\n", drivname);
295         char *name = (char *)malloc(strlen(drivname) + 1);
296         strcpy(name, drivname);
297         sourcelst[sourcecount++] = name;
289
290         list_entry *lentry = new list_entry;
291         lentry->name.cpy(drivname);
292         lentry->next = NULL;
293         if (last_sourceitem!=NULL)
294         {
295            last_sourceitem->next = lentry;         
296         }         
297         last_sourceitem = lentry;         
298         if (last_libraryitem->sourcefiles==NULL)
299         {
300            last_libraryitem->sourcefiles = lentry;
301         }
298302         continue;
299303      }
304      if (c == '+')
305      {
306         // Used for makemak tool
307         char drivname[256];
308         drivname[0] = 0;
309         for (int pos = 0; srcptr < endptr && pos < ARRAY_LENGTH(drivname) - 1 && !isspace(*srcptr); pos++)
310         {
311            drivname[pos] = *srcptr++;
312            drivname[pos+1] = 0;
313         }
314         fprintf(stderr, "Creating library for '%s'\n", drivname);
315         
316         librarylist_entry *lentry = new librarylist_entry;
317         lentry->name.cpy(drivname);
318         lentry->next = NULL;
319         lentry->sourcefiles = NULL;
320         if (last_libraryitem!=NULL)
321         {
322            last_libraryitem->next = lentry;         
323         }         
324         last_libraryitem = lentry;         
325         last_sourceitem = NULL;
300326
327         if (librarylist==NULL)
328         {
329            librarylist = lentry;
330         }
331         
332         continue;
333      }
334
335
301336      srcptr--;
302337      for (int pos = 0; srcptr < endptr && !isspace(*srcptr); pos++)
303338      {
r23807r23808
330365   exclude_path **excpathhead = &excpaths;
331366   astring srcdir;
332367   int unadorned = 0;
333   sourcecount = 0;
334368   
369   librarylist = NULL;
370   last_libraryitem = NULL;
371   last_sourceitem = NULL;
372   
373   
335374   // extract arguments
336375   const char *srcfile = argv[1];   
337376   if (parse_file(srcfile))
r23807r23808
387426      usage(argv[0]);
388427
389428
390   if (sourcecount>0)
429   if (librarylist!=NULL)
391430   {   
392431      printf("OBJDIRS += \\\n");
393432      printf("\t$(OBJ)/mame/audio \\\n");
r23807r23808
398437      printf("\n\n");
399438      printf("DRVLIBS += \\\n");
400439     
401      for(int i=0;i<sourcecount;i++) {     
402         printf("\t$(OBJ)/mame/%s.a \\\n",sourcelst[i]);
440      for (librarylist_entry *lib = librarylist; lib != NULL; lib = lib->next)   
441      {
442         printf("\t$(OBJ)/mame/%s.a \\\n",lib->name.cstr());
403443      }
404444      printf("\n");
405445   }   
r23807r23808
447487{
448488   int result = 0;
449489
450   // iterate through each file
451   for(int i=0;i<sourcecount;i++)
490   // iterate through each file   
491   for (librarylist_entry *lib = librarylist; lib != NULL; lib = lib->next)   
452492   {
453      astring srcfile;
454
455      // build the source filename
456      srcfile.printf("%s%c%s.c", srcdir.cstr(), PATH_SEPARATOR[0], sourcelst[i]);
493      for (list_entry *src = lib->sourcefiles; src != NULL; src = src->next)   
494      {
457495   
458      dependency_map depend_map;
496         astring srcfile;
459497
460      // find dependencies
461      file_entry &file = compute_dependencies(srcfile);
462      recurse_dependencies(file, depend_map);
498         // build the source filename
499         srcfile.printf("%s%c%s.c", srcdir.cstr(), PATH_SEPARATOR[0], src->name.cstr());
463500     
501         dependency_map depend_map;
502
503         // find dependencies
504         file_entry &file = compute_dependencies(srcfile);
505         recurse_dependencies(file, depend_map);
506         
464507         for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
465508         {
466509            astring t(entry->tag());
r23807r23808
474517               }
475518            }
476519         }
477     
520      }     
478521   }
479522
480523     
481524   // iterate through each file
482   for(int i=0;i<sourcecount;i++)
525   for (librarylist_entry *lib = librarylist; lib != NULL; lib = lib->next)   
483526   {
484      astring srcfile;
527      // convert the target from source to object (makes assumptions about rules)
528      astring target("$(OBJ)/mame/",lib->name.cstr());
529      target.cat(".a");
530      printf("\n%s : \\\n", target.cstr());
531   
532      for (list_entry *src = lib->sourcefiles; src != NULL; src = src->next)   
533      {
534         astring srcfile;
485535
486      // build the source filename
487      srcfile.printf("%s%c%s.c", srcdir.cstr(), PATH_SEPARATOR[0], sourcelst[i]);
488     
489      dependency_map depend_map;
536         // build the source filename
537         srcfile.printf("%s%c%s.c", srcdir.cstr(), PATH_SEPARATOR[0], src->name.cstr());
538         dependency_map depend_map;
490539
491      // find dependencies
492      file_entry &file = compute_dependencies(srcfile);
493      recurse_dependencies(file, depend_map);
540         // find dependencies
541         file_entry &file = compute_dependencies(srcfile);
542         recurse_dependencies(file, depend_map);
494543
495      // convert the target from source to object (makes assumptions about rules)
496      astring target(file.name);
497      target.replace(0, "src/", "$(OBJ)/");
498      target.replace(0, "drivers/", "");
499      target.replace(0, ".c", ".a");
500      printf("\n%s : \\\n", target.cstr());
501
502      // iterate over the hashed dependencies and output them as well
503      for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
504      {
505         astring t(entry->tag());
506         t.replace(0, "src/", "$(OBJ)/");
507         t.replace(0, ".c", ".o");
508         if (core_filename_ends_with(t, ".o"))
544         // iterate over the hashed dependencies and output them as well
545         for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
509546         {
510            printf("\t%s \\\n", t.cstr());
547            astring t(entry->tag());
548            t.replace(0, "src/", "$(OBJ)/");
549            t.replace(0, ".c", ".o");
550            if (core_filename_ends_with(t, ".o"))
551            {
552               printf("\t%s \\\n", t.cstr());
553            }
511554         }
512555      }
513     
514      printf("\n");
515      printf("\n");
516      for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
556      printf("\n");   
557      for (list_entry *src = lib->sourcefiles; src != NULL; src = src->next)   
517558      {
518         astring t(entry->tag());
519         if (core_filename_ends_with(t, ".lay"))
520         {
521            astring target2(file.name);
522            target2.replace(0, "src/", "$(OBJ)/");
523            target2.replace(0, ".c", ".o");
559         astring srcfile;
524560
525            t.replace(0, "src/", "$(OBJ)/");
526            t.replace(0, ".lay", ".lh");
527           
528            printf("%s:   %s\n", target2.cstr(), t.cstr());
529         }
530         if (core_filename_ends_with(t, ".inc"))
561         // build the source filename
562         srcfile.printf("%s%c%s.c", srcdir.cstr(), PATH_SEPARATOR[0], src->name.cstr());
563         dependency_map depend_map;
564
565         // find dependencies
566         file_entry &file = compute_dependencies(srcfile);
567         recurse_dependencies(file, depend_map);     
568         for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
531569         {
532            astring target2(file.name);
533            target2.replace(0, "src/", "$(OBJ)/");
534            target2.replace(0, ".c", ".o");
570            astring t(entry->tag());
571            if (core_filename_ends_with(t, ".lay"))
572            {
573               astring target2(file.name);
574               target2.replace(0, "src/", "$(OBJ)/");
575               target2.replace(0, ".c", ".o");
535576
536            printf("%s:   %s\n", target2.cstr(), t.cstr());
577               t.replace(0, "src/", "$(OBJ)/");
578               t.replace(0, ".lay", ".lh");
579               
580               printf("%s:   %s\n", target2.cstr(), t.cstr());
581            }
582            if (core_filename_ends_with(t, ".inc"))
583            {
584               astring target2(file.name);
585               target2.replace(0, "src/", "$(OBJ)/");
586               target2.replace(0, ".c", ".o");
587
588               printf("%s:   %s\n", target2.cstr(), t.cstr());
589            }
537590         }
538591      }
539     
540592   }
541593   return result;
542594}
trunk/src/build/makelist.c
r23807r23808
187187         }
188188         continue;
189189      }
190      if (c == '+')
191      {
192         // Used for makemak tool
193         char drivname[256];
194         drivname[0] = 0;
195         for (int pos = 0; srcptr < endptr && pos < ARRAY_LENGTH(drivname) - 1 && !isspace(*srcptr); pos++)
196         {
197            drivname[pos] = *srcptr++;
198            drivname[pos+1] = 0;
199         }
200         continue;
201      }
190202
191203      // otherwise treat as a driver name
192204      char drivname[32];

Previous 199869 Revisions Next


© 1997-2024 The MAME Team