annotate helpers/makeline.c @ 271:d478d9ed1c3e

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