:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / tools / depends.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 int main(int argc, char* argv[])
6 {
7   char buf[512];
8   char ch;
9   unsigned int i;
10   char* dot;
11   char* prefix;
12   FILE* out;
13
14   if (argc != 3)
15     {
16       printf("Too few arguments\n");
17       return(1);
18     }
19
20   prefix = strdup(argv[1]);
21   
22   out = fopen(argv[2], "wb");
23   if (out == NULL)
24     {
25       printf("Unable to open output file\n");
26       return(1);
27     }
28
29   i = 0;
30   while ((ch = fgetc(stdin)) != ':' && ch != EOF)
31     {
32       buf[i] = ch;
33       i++;
34     }
35   buf[i] = 0;
36   
37   if (i == 0)
38     {
39       return(0);
40     }
41
42   dot = strrchr(buf, '.');
43   if (dot != NULL)
44     {
45       *dot = 0;
46     }
47   fprintf(out, "%s/.%s.TAG %s/.%s.d %s/%s.o:", prefix, buf, prefix, buf, 
48           prefix,buf);
49
50   while ((ch = fgetc(stdin)) != EOF)
51     {
52       fputc(ch, out);
53     }
54
55   return(0);
56 }