annotate helpers/makeline.c @ 26:680f6fdb5e62

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