version.cxx

Go to the documentation of this file.
00001 int main(int argc, char *argv[])
00002 {
00003    // Reads from the file build/version_number the new version
00004    // number and generates the header base/inc/RVersion.h.
00005    // To be executed as CINT script by build/unix/makeversion.sh.
00006    //
00007    // Author: Fons Rademakers   11/10/99
00008 
00009    const char *in  = "build/version_number";
00010    const char *inr = "etc/svninfo.txt";
00011 
00012    FILE *fp = fopen(in, "r");
00013    if (!fp) {
00014       printf("%s: can not open input file %s\n", argv[0], in);
00015       exit(1);
00016    }
00017    char vers[32];
00018    fgets(vers, sizeof(vers), fp);
00019    if (vers[strlen(vers)-1] == '\n') vers[strlen(vers)-1] = 0;
00020    fclose(fp);
00021 
00022    fp = fopen(inr, "r");
00023    if (!fp) {
00024       printf("%s: can not open input file %s\n", argv[0], in);
00025       exit(1);
00026    }
00027    char branch[2048];
00028    fgets(branch, sizeof(branch), fp);
00029    if (branch[strlen(branch)-1] == '\n') branch[strlen(branch)-1] = 0;
00030    char revs[32];
00031    fgets(revs, sizeof(revs), fp);
00032    if (revs[strlen(revs)-1] == '\n') revs[strlen(revs)-1] = 0;
00033    fclose(fp);
00034    
00035    const char *out = "core/base/inc/RVersion.h";
00036    fp = fopen(out, "w");
00037    if (!fp) {
00038       printf("%s: can not open output file %s\n", argv[0], out);
00039       exit(1);
00040    }
00041 
00042    fprintf(fp, "#ifndef ROOT_RVersion\n");
00043    fprintf(fp, "#define ROOT_RVersion\n\n");
00044    fprintf(fp, "/* Version information automatically generated by installer. */\n\n");
00045    fprintf(fp, "/*\n");
00046    fprintf(fp, " * These macros can be used in the following way:\n");
00047    fprintf(fp, " *\n");
00048    fprintf(fp, " *    #if ROOT_VERSION_CODE >= ROOT_VERSION(2,23,4)\n");
00049    fprintf(fp, " *       #include <newheader.h>\n");
00050    fprintf(fp, " *    #else\n");
00051    fprintf(fp, " *       #include <oldheader.h>\n");
00052    fprintf(fp, " *    #endif\n");
00053    fprintf(fp, " *\n");
00054    fprintf(fp, "*/\n\n");
00055 
00056    int xx, yy, zz, rev;
00057    char patch = '\0';
00058    sscanf(vers, "%d.%d/%d%c", &xx, &yy, &zz, &patch);
00059    int vers_code = (xx << 16) + (yy << 8) + zz;
00060    int full_vers_code = (xx << 24) + (yy << 16) + (zz << 8) + patch;
00061    sscanf(revs, "%d", &rev);
00062 
00063    fprintf(fp, "#define ROOT_RELEASE \"%s\"\n", vers);
00064    fprintf(fp, "#define ROOT_RELEASE_DATE \"%s\"\n", __DATE__);
00065    fprintf(fp, "#define ROOT_RELEASE_TIME \"%s\"\n", __TIME__);
00066    fprintf(fp, "#define ROOT_SVN_REVISION %d\n", rev);
00067    fprintf(fp, "#define ROOT_SVN_BRANCH \"%s\"\n", branch);
00068    fprintf(fp, "#define ROOT_VERSION_CODE %d\n", vers_code);
00069    fprintf(fp, "#define ROOT_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))\n");
00070    fprintf(fp, "#define ROOT_FULL_VERSION_CODE %d\n", full_vers_code);
00071    fprintf(fp, "#define ROOT_FULL_VERSION(a,b,c,p) (((a) << 24) + ((b) << 16) + ((c) << 8) + (p))\n");
00072    fprintf(fp, "\n#endif\n");
00073 
00074    fclose(fp);
00075 
00076    exit(0);
00077 }

Generated on Tue Jul 5 14:10:18 2011 for ROOT_528-00b_version by  doxygen 1.5.1