Revision a58249bfd6fbb405de2aba3c2d9b59387e43e439 authored by Fons Rademakers on 05 March 2004, 11:29:02 UTC, committed by Fons Rademakers on 05 March 2004, 11:29:02 UTC

git-svn-id: http://root.cern.ch/svn/root/trunk@8330 27541ba8-7e3a-0410-8455-c3a389f83636
1 parent 41740f4
Raw File
version.cxx
int main(int argc, char *argv[])
{
   // Reads from the file build/version_number the new version
   // number and generates the header base/inc/RVersion.h.
   // To be executed as CINT script by build/unix/makeversion.sh.
   //
   // Author: Fons Rademakers   11/10/99

   const char *in  = "build/version_number";
   FILE *fp = fopen(in, "r");
   if (!fp) {
      printf("%s: can not open input file %s\n", argv[0], in);
      exit(1);
   }
   char vers[32];
   fgets(vers, sizeof(vers), fp);
   if (vers[strlen(vers)-1] == '\n') vers[strlen(vers)-1] = 0;
   fclose(fp);
   
   const char *out = "base/inc/RVersion.h";
   FILE *fp = fopen(out, "w");
   if (!fp) {
      printf("%s: can not open output file %s\n", argv[0], out);
      exit(1);
   }

   fprintf(fp, "#ifndef ROOT_RVersion\n");
   fprintf(fp, "#define ROOT_RVersion\n\n");
   fprintf(fp, "/* Version information automatically generated by installer. */\n\n");
   fprintf(fp, "/*\n");
   fprintf(fp, " * These macros can be used in the following way:\n");
   fprintf(fp, " *\n");
   fprintf(fp, " *    #if ROOT_VERSION_CODE >= ROOT_VERSION(2,23,4)\n");
   fprintf(fp, " *       #include <newheader.h>\n");
   fprintf(fp, " *    #else\n");
   fprintf(fp, " *       #include <oldheader.h>\n");
   fprintf(fp, " *    #endif\n");
   fprintf(fp, " *\n");
   fprintf(fp, "*/\n\n");

   int xx, yy, zz;
   sscanf(vers, "%d.%d/%d", &xx, &yy, &zz);
   int vers_code = (xx << 16) + (yy << 8) + zz;

   fprintf(fp, "#define ROOT_RELEASE \"%s\"\n", vers);
   fprintf(fp, "#define ROOT_VERSION_CODE %d\n", vers_code);
   fprintf(fp, "#define ROOT_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))\n");
   fprintf(fp, "\n#endif\n");

   fclose(fp);

   exit(0);
}
back to top