added source code
[unres.git] / source / unres / src_MD / src / compinfo.c
1 #include <stdio.h>
2 #include <sys/utsname.h>
3 #include <sys/types.h>
4 #include <time.h>
5 #include <string.h>
6
7 main()
8 {
9 FILE *in, *in1, *out;
10 int i,j,k,iv1,iv2,iv3;
11 char *p1,buf[500],buf1[500],buf2[100],buf3[100];
12 struct utsname Name;
13 time_t Tp;
14
15 in=fopen("cinfo.f","r");
16 out=fopen("cinfo.f.new","w");
17 fgets(buf,498,in);
18 fprintf(out,"C DO NOT EDIT THIS FILE - IT HAS BEEN GENERATED BY COMPINFO.C\n");
19 fgets(buf,498,in);
20 sscanf(&buf[1],"%d %d %d",&iv1,&iv2,&iv3);
21 iv3++;
22 fprintf(out,"C %d %d %d\n",iv1,iv2,iv3);
23 fprintf(out,"      subroutine cinfo\n");
24 fprintf(out,"      include 'COMMON.IOUNITS'\n");
25 fprintf(out,"      write(iout,*)'++++ Compile info ++++'\n");
26 fprintf(out,"      write(iout,*)'Version %d.%-d build %d'\n",iv1,iv2,iv3);
27 uname(&Name);
28 time(&Tp);
29 system("rm tmptmp; whoami > tmptmp");
30 in1=fopen("tmptmp","r");
31 fscanf(in1,"%s",buf1);
32 fclose(in1);
33 p1=ctime(&Tp);
34 p1[strlen(p1)-1]='\0';
35 fprintf(out,"      write(iout,*)'compiled %s'\n",p1);
36 fprintf(out,"      write(iout,*)'compiled by %s@%s'\n",buf1,Name.nodename);
37 fprintf(out,"      write(iout,*)'OS name:    %s '\n",Name.sysname);
38 fprintf(out,"      write(iout,*)'OS release: %s '\n",Name.release);
39 fprintf(out,"      write(iout,*)'OS version:',\n");
40 fprintf(out,"     & ' %s '\n",Name.version);
41 fprintf(out,"      write(iout,*)'flags:'\n");
42 in1=fopen("Makefile","r");
43 while(fgets(buf,498,in1) != NULL)
44  {
45  if((p1=strchr(buf,'=')) != NULL && buf[0] != '#')
46   {
47   buf[strlen(buf)-1]='\0';
48   if(strlen(buf) > 49)
49    {
50    buf[47]='\0';
51    strcat(buf,"...");
52    }
53   else
54    {
55    while(buf[strlen(buf)-1]=='\\')
56     {
57     strcat(buf,"\\");
58     fprintf(out,"      write(iout,*)'%s'\n",buf);
59     fgets(buf,498,in1);
60     buf[strlen(buf)-1]='\0';
61     if(strlen(buf) > 49)
62      {
63      buf[47]='\0';
64      strcat(buf,"...");
65      }
66     }
67    }
68   
69   fprintf(out,"      write(iout,*)'%s'\n",buf);
70   }
71  }
72 fprintf(out,"      write(iout,*)'++++ End of compile info ++++'\n");
73 fprintf(out,"      return\n");
74 fprintf(out,"      end\n");
75 fclose(out);
76 fclose(in1);
77 fclose(in);
78 system("mv cinfo.f.new cinfo.f");
79 }