home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / gcc / ixemulsrc.lha / ixemul / library / parse_version.c < prev    next >
C/C++ Source or Header  |  1996-12-11  |  2KB  |  87 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(int argc, char **argv)
  5. {
  6.   FILE *f;
  7.   int major, minor, day, month, year;
  8.   char tmp[1024];
  9.   char *format;
  10.   
  11.   if (argc != 2)
  12.   {
  13.     fprintf(stderr, "Usage: parse_version <srcdir>\n");
  14.     exit(2);
  15.   }
  16.   strcpy(tmp, argv[1]);
  17.   strcat(tmp, "/../version.in");
  18.   f = fopen(tmp, "r");
  19.   if (f == NULL)
  20.   {
  21.     fprintf(stderr, "Cannot open %s\n", tmp);
  22.     exit(2);
  23.   }
  24.   fscanf(f, "%d.%d,%d.%d.%d", &major, &minor, &day, &month, &year);
  25.   fclose(f);
  26.   format = "/*
  27.  * version.h file. Automatically generated by parse_version.
  28.  */
  29.  
  30. #ifndef __VERSION_H__
  31. #define __VERSION_H__
  32.  
  33. /* Commodities.h defines IX_VERSION too, so wait for our defines
  34.    to come last, and undef the sucker now! */
  35. #undef IX_VERSION
  36.  
  37. #define IX_NAME        \"ixemul.library\"
  38. #ifdef TRACE_LIBRARY
  39. #define IX_IDSTRING    \"ixemul %d.%d [trace, %s] (%d.%d.%d)\"
  40. #else
  41. #define IX_IDSTRING    \"ixemul %d.%d [%s] (%d.%d.%d)\"
  42. #endif
  43. #define IX_VERSION    %d
  44. #define IX_REVISION    %d
  45. #define IX_PRIORITY    0
  46.  
  47. #endif
  48. ";
  49.  
  50.   tmp[0] = '\0';
  51.  
  52. #ifdef NOTRAP
  53.   if (tmp[0])
  54.     strcat(tmp, ", ");
  55.   strcat(tmp, "notrap");
  56. #endif
  57.  
  58. #ifdef DEBUG_VERSION
  59.   if (tmp[0])
  60.     strcat(tmp, ", ");
  61.   strcat(tmp, "debug");
  62. #endif
  63.  
  64.   if (tmp[0])
  65.     strcat(tmp, ", ");
  66.  
  67. #if defined(mc68060)
  68.   strcat(tmp, "68060");
  69. #elif defined(mc68040)
  70.   strcat(tmp, "68040");
  71. #elif defined(mc68020)
  72.   strcat(tmp, "68020");
  73. #else
  74.   strcat(tmp, "68000");
  75. #endif
  76.  
  77. #ifdef __HAVE_68881__
  78.   strcat(tmp, ", fpu");
  79. #else
  80.   strcat(tmp, ", soft-float");
  81. #endif
  82.  
  83.   printf(format, major, minor, tmp, day, month, year,
  84.              major, minor, tmp, day, month, year, major, minor);
  85.   return 0;
  86. }
  87.