#include <stdio.h>
#include <math.h>
#include <string.h>

int main(int argc, char **argv)
{
  int major, minor, day, month, year;
  char tmp[1024];
  char *format;
  
  if (argc != 3)
  {
    fprintf(stderr, "Usage: parse_version <major> <minor>\n");
    exit(2);
  }
  major = atoi(argv[1]);
  minor = atoi(argv[2]);
  year = 0;
  month = 0;
  day = 0;
  format = "/*
 * version.h file. Automatically generated by parse_version.
 */

#ifndef __VERSION_H__
#define __VERSION_H__

/* Commodities.h defines MesaGL@TARGET@_VERSION too, so wait for our defines
   to come last, and undef the sucker now! */
#undef MesaGL@TARGET@_VERSION

#define MesaGL@TARGET@_NAME		\"MesaGL@TARGET@.library\"
#define MesaGL@TARGET@_IDSTRING	\"MesaGL@TARGET@ %d.%d [%s] (%d.%d.%d)\"
#define MesaGL@TARGET@_VERSION	%d
#define MesaGL@TARGET@_REVISION	%d
#define MesaGL@TARGET@_PRIORITY	0

#endif
";

  tmp[0] = '\0';

#ifdef PROFILE
  if (tmp[0])
    strcat(tmp, ", ");
  strcat(tmp, "profile");
#endif

  if (tmp[0])
    strcat(tmp, ", ");

#if defined(__mc68060__)
  strcat(tmp, "68060");
#elif defined(__mc68040__)
  strcat(tmp, "68040");
#elif defined(__mc68020__) || defined(__mc68030__)
  strcat(tmp, "68020");
#else
  strcat(tmp, "68000");
#endif

#if defined(__HAVE_68881__) || defined(__mc68881__) || defined(__mc68882__)
  strcat(tmp, ", fpu");
#else
  strcat(tmp, ", soft-float");
#endif

  strcat(tmp, ", amigaos");

  printf(format, major, minor, tmp, day, month, year,
	         major, minor, tmp, day, month, year, major, minor);
  return 0;
}
