Previous 199869 Revisions Next

r23819 Thursday 20th June, 2013 at 13:45:52 UTC by Miodrag Milanović
made makemak create lst as well, and some fixes for cpu.mak (nw)
[src/build]makemak.c
[src/emu/cpu]cpu.mak

trunk/src/build/makemak.c
r23818r23819
133133// path helpers
134134static bool find_include_file(astring &srcincpath, const astring &srcfile, const astring &filename);
135135
136
136static bool check_file(astring &srcincpath)
137{
138   // see if we can open it
139   core_file *testfile;
140   if (core_fopen(srcincpath, OPEN_FLAG_READ, &testfile) == FILERR_NONE)
141   {
142      // close the file
143      core_fclose(testfile);
144      return true;
145   }
146   return false;
147}
137148int include_mapping(const char *srcfile)
138149{
139150   // read source file
r23818r23819
285296            drivname[pos] = *srcptr++;
286297            drivname[pos+1] = 0;
287298         }
288         fprintf(stderr, "Creating make dependancy for '%s'\n", drivname);
289299
290300         list_entry *lentry = new list_entry;
291301         lentry->name.cpy(drivname);
r23818r23819
311321            drivname[pos] = *srcptr++;
312322            drivname[pos+1] = 0;
313323         }
314         fprintf(stderr, "Creating library for '%s'\n", drivname);
315324         
316325         librarylist_entry *lentry = new librarylist_entry;
317326         lentry->name.cpy(drivname);
r23818r23819
345354   return 0;
346355}
347356
357int parse_for_drivers(const char *srcfile)
358{
359   // read source file
360   core_file *file = NULL;
361
362   file_error filerr = core_fopen(srcfile, OPEN_FLAG_READ, &file);
363   if (filerr != FILERR_NONE)
364   {
365      fprintf(stderr, "Unable to read source file '%s'\n", srcfile);
366      return 1;
367   }
368   // loop over lines in the file
369   char buffer[4096];
370   while (core_fgets(buffer, ARRAY_LENGTH(buffer), file) != NULL)
371   {
372      astring line;
373     
374      // rip through it to find all drivers
375      char *srcptr = (char *)buffer;
376      char *endptr = srcptr + strlen(buffer);
377      bool in_comment = false;
378      while (srcptr < endptr)
379      {
380         char c = *srcptr++;
381
382         // skip any spaces
383         if (isspace(c))
384            continue;
385
386         // look for end of C comment
387         if (in_comment && c == '*' && *srcptr == '/')
388         {
389            srcptr++;
390            in_comment = false;
391            continue;
392         }
393
394         // skip anything else inside a C comment
395         if (in_comment)
396            continue;
397
398         // look for start of C comment
399         if (c == '/' && *srcptr == '*')
400         {
401            srcptr++;
402            in_comment = true;
403            continue;
404         }
405
406         // if we hit a C++ comment, scan to the end of line
407         if (c == '/' && *srcptr == '/')
408         {
409            while (srcptr < endptr && *srcptr != 13 && *srcptr != 10)
410               srcptr++;
411            continue;
412         }
413
414         srcptr--;
415         for (int pos = 0; srcptr < endptr && !isspace(*srcptr); pos++)
416         {
417            line.cat(*srcptr++);
418         }
419      }
420     
421      if ((line.find(0,"GAME(")==0) || (line.find(0,"GAMEL(")==0) ||
422         (line.find(0,"COMP(")==0) || (line.find(0,"CONS(")==0) ||
423         (line.find(0,"SYST(")==0))
424      {
425         int p1 = line.find(0,",");
426         if (p1<0) continue;
427         int p2 = line.find(p1+1,",");
428         if (p2<0) continue;
429         
430         printf("%s\n",line.substr(p1+1,p2-p1-1).cstr());
431      }
432   }
433   core_fclose(file);
434   return 0;
435}
436
348437/***************************************************************************
349438    MAIN
350439***************************************************************************/
r23818r23819
376465   if (parse_file(srcfile))
377466      return 1;
378467
379   include_mapping("src/emu/cpu/cpu.mak");
380   include_mapping("src/emu/video/video.mak");
381   include_mapping("src/emu/sound/sound.mak");
382   include_mapping("src/emu/machine/machine.mak");
383468   // loop over arguments
384469   for (int argnum = 2; argnum < argc; argnum++)
385470   {
r23818r23819
421506         usage(argv[0]);
422507   }
423508
424   // make sure we got 1 parameter
509   // generate list of drivers
425510   if (srcdir.len() == 0)
426      usage(argv[0]);
427
428
429   if (librarylist!=NULL)
430   {   
431      printf("OBJDIRS += \\\n");
432      printf("\t$(OBJ)/mame/audio \\\n");
433      printf("\t$(OBJ)/mame/drivers \\\n");
434      printf("\t$(OBJ)/mame/layout \\\n");
435      printf("\t$(OBJ)/mame/machine \\\n");
436      printf("\t$(OBJ)/mame/video \\\n");
437      printf("\n\n");
438      printf("DRVLIBS += \\\n");
439     
511   {
440512      for (librarylist_entry *lib = librarylist; lib != NULL; lib = lib->next)   
441513      {
442         printf("\t$(OBJ)/mame/%s.a \\\n",lib->name.cstr());
514         for (list_entry *src = lib->sourcefiles; src != NULL; src = src->next)   
515         {
516            printf("// Drivers from %s.c\n",src->name.cstr());
517            astring srcfile;
518            // build the source filename
519            srcfile.printf("%s%c%s.c", "src/mame/drivers", PATH_SEPARATOR[0], src->name.cstr());
520            parse_for_drivers(srcfile);
521           
522            astring srcfile_inc;
523            // build the source filename
524            srcfile_inc.printf("%s%c%s.inc", "src/mame/drivers", PATH_SEPARATOR[0], src->name.cstr());
525            if(check_file(srcfile_inc))
526               parse_for_drivers(srcfile_inc);
527         }
443528      }
444      printf("\n");
445   }   
529      return 0;
530   }
531   else
532   {
533      include_mapping("src/emu/cpu/cpu.mak");
534      include_mapping("src/emu/video/video.mak");
535      include_mapping("src/emu/sound/sound.mak");
536      include_mapping("src/emu/machine/machine.mak");
537      if (librarylist!=NULL)
538      {   
539         printf("OBJDIRS += \\\n");
540         printf("\t$(OBJ)/mame/audio \\\n");
541         printf("\t$(OBJ)/mame/drivers \\\n");
542         printf("\t$(OBJ)/mame/layout \\\n");
543         printf("\t$(OBJ)/mame/machine \\\n");
544         printf("\t$(OBJ)/mame/video \\\n");
545         printf("\n\n");
546         printf("DRVLIBS += \\\n");
547         
548         for (librarylist_entry *lib = librarylist; lib != NULL; lib = lib->next)   
549         {
550            printf("\t$(OBJ)/mame/mame/%s.a \\\n",lib->name.cstr());
551         }
552         printf("\n");
553      }   
446554
447   // recurse over subdirectories
448   return recurse_dir(srcdir);
555      // recurse over subdirectories
556      return recurse_dir(srcdir);
557   }
449558}
450559
451560
r23818r23819
525634   for (librarylist_entry *lib = librarylist; lib != NULL; lib = lib->next)   
526635   {
527636      // convert the target from source to object (makes assumptions about rules)
528      astring target("$(OBJ)/mame/",lib->name.cstr());
637      astring target("$(OBJ)/mame/mame/",lib->name.cstr());
529638      target.cat(".a");
530639      printf("\n%s : \\\n", target.cstr());
531640   
r23818r23819
593702   return result;
594703}
595704
596static bool check_file(astring &srcincpath)
597{
598   // see if we can open it
599   core_file *testfile;
600   if (core_fopen(srcincpath, OPEN_FLAG_READ, &testfile) == FILERR_NONE)
601   {
602      // close the file
603      core_fclose(testfile);
604      return true;
605   }
606   return false;
607}
608
609705/*-------------------------------------------------
610706    output_file - output a file, converting to
611707    HTML
trunk/src/emu/cpu/cpu.mak
r23818r23819
18681868#-------------------------------------------------
18691869# Texas Instruments TMS99xx series
18701870#@src/emu/cpu/tms9900/tms9900.h,CPUS += TMS9900
1871#@src/emu/cpu/tms9900/tms9900l.h,CPUS += TMS9900
1872#@src/emu/cpu/tms9900/tms9980a.h,CPUS += TMS9900
1873#@src/emu/cpu/tms9900/tms9995.h,CPUS += TMS9900
1874
18711875#-------------------------------------------------
18721876
18731877ifneq ($(filter TMS9900,$(CPUS)),)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team