annotate helpers/makeline.c @ 26:db9c43a9e218

components: condat2 paths changed to just condat
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 23:12:02 +0000
parents e825175be40d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
12
e825175be40d helpers: s/Magnetite/Selenite/
Mychaela Falconia <falcon@freecalypso.org>
parents: 11
diff changeset
2 * This helper utility for the FreeCalypso Selenite build system
11
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * emits potentially long generated Makefile lines, breaking them into
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * multiple lines with backslashes.
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 int is_cmd, equ_or_colon, extra_indent;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 int linelen;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 main(argc, argv)
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char **argv;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 char **ap;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 if (argc < 4) {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 fprintf(stderr, "error: too few arguments\n", argv[0]);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 exit(1);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 }
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 if (!strcmp(argv[1], "def")) {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 is_cmd = 0;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 equ_or_colon = '=';
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 extra_indent = 0;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 } else if (!strcmp(argv[1], "dep")) {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 is_cmd = 0;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 equ_or_colon = ':';
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 extra_indent = 1;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 } else if (!strcmp(argv[1], "cmd")) {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 is_cmd = 1;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 extra_indent = 1;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 } else {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 fprintf(stderr, "error: line type \"%s\" not known\n", argv[1]);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 exit(1);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 if (is_cmd) {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 putchar('\t');
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 linelen = 8;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 } else
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 linelen = 0;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 fputs(argv[2], stdout);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 linelen += strlen(argv[2]);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 if (is_cmd) {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 putchar(' ');
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 linelen++;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 } else {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 putchar(equ_or_colon);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 linelen++;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 putchar('\t');
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 do
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 linelen++;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 while (linelen & 7);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 fputs(argv[3], stdout);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 linelen += strlen(argv[3]);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 for (ap = argv + 4; *ap; ap++) {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 if (linelen + 1 + strlen(*ap) <= 78) {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 putchar(' ');
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 linelen++;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 } else {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 fputs(" \\\n\t", stdout);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 linelen = 8;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 if (extra_indent) {
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 fputs(" ", stdout);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 linelen += 4;
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 }
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 }
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 fputs(*ap, stdout);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 linelen += strlen(*ap);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 }
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 putchar('\n');
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 exit(0);
b493d3857f4e helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 }