DSMCC  17.9.0
 All Data Structures Files Functions Typedefs
amsdeps.c
1 /* Output the two static dependancy files: .E and .Q */
2 /* These are later included in *.P files by sunrise
3  * make script immediately after compilation */
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <fcntl.h>
8 
9 int main(int argc, char *argv[])
10 {
11  FILE *out;
12  int flen;
13  char *tag, *fnm;
14  if (argc != 3)
15  {
16  fprintf(stderr, "Usage:\n\t%s <source name tag> <E output file>\n", argv[0]);
17  return -1;
18  }
19  else
20  {
21  tag = argv[1];
22  fnm = argv[2];
23  flen = strlen(fnm);
24  out = fopen(fnm, "w+");
25  if (out == NULL)
26  {
27  fprintf(stderr, "failed to open file %s\n", fnm);
28  return -2;
29  }
30  else
31  {
32  fprintf(out, "DIFS_%s := $(filter-out $(DEFINES),$(ODEFS_%s)) $(filter-out $(ODEFS_%s),$(DEFINES))\n", tag, tag, tag);
33  fprintf(out, "ifneq ($(strip $(DIFS_%s)),)\n", tag);
34  fprintf(out, "ifneq ($(strip $(filter $(subst =, ,$(DIFS_%s)),$(FDEPS_%s))),)\n", tag, tag);
35  fprintf(out, "FORCE_%s = force\nendif\nendif\n", tag);
36  fclose(out);
37  }
38  fnm[flen - 1] = 'Q';
39  out = fopen(fnm, "w+");
40  if (out == NULL)
41  {
42  fprintf(stderr, "failed to open file %s\n", fnm);
43  return -3;
44  }
45  else
46  {
47  fprintf(out, " $(FORCE_%s)\n", tag);
48  fclose(out);
49  }
50  return 0;
51  }
52 }
53