-
Notifications
You must be signed in to change notification settings - Fork 7
/
make-4.4.1-warn-env.patch
195 lines (177 loc) · 6.32 KB
/
make-4.4.1-warn-env.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
--- make-4.4.1-orig/src/expand.c 2023-01-28 18:18:16.000000000 +0300
+++ make-4.4.1/src/expand.c 2024-09-18 10:01:56.794868100 +0300
@@ -175,6 +175,8 @@
return value;
}
+#define CMPSTR(n,l,c) ( sizeof(c "") - 1 == (l) && memcmp(n, c, sizeof(c "") - 1) == 0 )
+
/* Expand a simple reference to variable NAME, which is LENGTH chars long. */
#ifdef __GNUC__
@@ -189,7 +191,22 @@
v = lookup_variable (name, length);
if (v == 0)
- warn_undefined (name, length);
+ {
+ if (
+ !CMPSTR(name, length, "GNUMAKEFLAGS") &&
+ !CMPSTR(name, length, "MAKEFLAGS"))
+ {
+ warn_undefined (name, length);
+ }
+ }
+ else if (v->origin == o_env &&
+ strcmp("GNUMAKEFLAGS", v->name) &&
+ strcmp("MAKEOVERRIDES", v->name) &&
+ strcmp("MAKEFLAGS", v->name) &&
+ strcmp("MAKELEVEL", v->name))
+ {
+ warn_env (v->name, v->length);
+ }
/* If there's no variable by that name or it has no value, stop now. */
if (v == 0 || (*v->value == '\0' && !v->append))
@@ -364,6 +381,8 @@
v = lookup_variable (beg, colon - beg);
if (v == 0)
warn_undefined (beg, colon - beg);
+ else if (v->origin == o_env)
+ warn_env (v->name, v->length);
/* If the variable is not empty, perform the
substitution. */
--- make-4.4.1-orig/src/function.c 2023-01-12 03:51:34.000000000 +0300
+++ make-4.4.1/src/function.c 2024-09-18 10:05:40.172670900 +0300
@@ -501,12 +501,20 @@
struct variable *v = lookup_variable (argv[0], strlen (argv[0]));
if (v == 0)
- o = variable_buffer_output (o, "undefined", 9);
+ {
+ warn_undefined (argv[0], strlen (argv[0]));
+ o = variable_buffer_output (o, "undefined", 9);
+ }
else
- if (v->recursive)
- o = variable_buffer_output (o, "recursive", 9);
- else
- o = variable_buffer_output (o, "simple", 6);
+ {
+ if (v->origin == o_env)
+ warn_env (v->name, v->length);
+
+ if (v->recursive)
+ o = variable_buffer_output (o, "recursive", 9);
+ else
+ o = variable_buffer_output (o, "simple", 6);
+ }
return o;
}
@@ -1575,7 +1583,14 @@
/* Copy its value into the output buffer without expanding it. */
if (v)
- o = variable_buffer_output (o, v->value, strlen (v->value));
+ {
+ if (v->origin == o_env)
+ warn_env (v->name, v->length);
+
+ o = variable_buffer_output (o, v->value, strlen (v->value));
+ }
+ else
+ warn_undefined (argv[0], strlen (argv[0]));
return o;
}
@@ -2750,6 +2765,8 @@
if (v == 0)
warn_undefined (fname, flen);
+ else if (v->origin == o_env)
+ warn_env (v->name, v->length);
if (v == 0 || *v->value == '\0')
return o;
--- make-4.4.1-orig/src/read.c 2023-01-01 18:06:01.000000000 +0300
+++ make-4.4.1/src/read.c 2024-09-18 10:08:21.629993900 +0300
@@ -824,7 +824,13 @@
{
struct variable *v = lookup_variable (p, l);
if (v == 0)
- v = define_variable_global (p, l, "", o_file, 0, fstart);
+ {
+ warn_undefined (p, l);
+ v = define_variable_global (p, l, "", o_file, 0, fstart);
+ }
+ else if (v->origin == o_env && exporting)
+ warn_env (v->name, v->length);
+
v->export = exporting ? v_export : v_noexport;
}
@@ -1674,6 +1680,10 @@
var[l] = '\0';
v = lookup_variable (var, l);
+ if (v == 0)
+ warn_undefined (var, l);
+ else if (v->origin == o_env)
+ warn_env (v->name, v->length);
conditionals->ignoring[o] =
((v != 0 && *v->value != '\0') == (cmdtype == c_ifndef));
--- make-4.4.1-orig/src/variable.c 2023-01-28 21:04:47.000000000 +0300
+++ make-4.4.1/src/variable.c 2024-09-18 10:11:55.857482600 +0300
@@ -1386,7 +1386,11 @@
The value is set IFF the variable is not defined yet. */
v = lookup_variable (varname, strlen (varname));
if (v)
- goto done;
+ {
+ if (v->origin == o_env)
+ warn_env (v->name, v->length);
+ goto done;
+ }
conditional = 1;
flavor = f_recursive;
@@ -1419,6 +1423,9 @@
{
/* There was no old value.
This becomes a normal recursive definition. */
+ if (strcmp(".INCLUDE_DIRS", varname))
+ warn_undefined (varname, strlen (varname));
+
newval = value;
flavor = f_recursive;
}
@@ -1431,6 +1438,9 @@
char *cp;
char *tp = NULL;
+ if (v->origin == o_env)
+ warn_env (v->name, v->length);
+
val = value;
if (v->recursive)
/* The previous definition of the variable was recursive.
@@ -1726,9 +1736,17 @@
var->flavor = f_append;
break;
case '?':
+ error (reading_file,
+ (int)((end ? end : p - 1) - var->name),
+ _("warning: conditionally-defined variable '%.*s'"),
+ (int)((end ? end : p - 1) - var->name), var->name);
var->flavor = f_conditional;
break;
case '!':
+ error (reading_file,
+ (int)((end ? end : p - 1) - var->name),
+ _("warning: shell-defined variable '%.*s'"),
+ (int)((end ? end : p - 1) - var->name), var->name);
var->flavor = f_shell;
break;
default:
--- make-4.4.1-orig/src/variable.h 2023-01-28 21:04:47.000000000 +0300
+++ make-4.4.1/src/variable.h 2024-09-18 10:13:54.390414600 +0300
@@ -247,6 +247,14 @@
#define undefine_variable_global(n,l,o) \
undefine_variable_in_set((n),(l),(o),NULL)
+/* Warn that NAME is an environment-defined variable . */
+
+#define warn_env(n,l) do{\
+ error (reading_file, (l), \
+ _("warning: using environment variable '%.*s'"), \
+ (int)(l), (n)); \
+ }while(0)
+
char **target_environment (struct file *file, int recursive);
struct pattern_var *create_pattern_var (const char *target,