commit - 8a3a48941f0ec06b9254f344bed42d71d9f59fbe
commit + 35118df7689138726f0ed92f5a17e6d1ef227092
blob - aa200b3b57f84a9e0016a851779258676baf01a5
blob + 173e3c310bc0b7078fd8fa940b99e7fd6716f771
--- make/MyMakefile
+++ make/MyMakefile
-CC = cc
CFLAGS = -g -O0 -ansi -Wall -Wno-deprecated-non-prototype -Wno-comment -Wno-implicit-int
all: make
blob - 7ded115b6ab788205cd8f96db53d22881aa5f243
blob + 89b09c5fd7ac1dbdc372e6a857552470bbfc3d36
--- make/make.c
+++ make/make.c
struct path *dir;
char *path;
{
- struct macro *m;
+ struct macro *m, *m2;
struct rule *r = NULL;
size_t len, cap;
char *s, *t;
t[-1] = '\0';
m->lazy = 0;
m->value = evalcom (sc, dir, trim (t + 1));
+ } else if (t[-1] == '?') {
+ t[-1] = '\0';
+ m2 = find_macro (sc, trim (s));
+ if (m2 != NULL) {
+ m->value = m2->value;
+ } else {
+ m->value = strdup (trim (t + 1));
+ }
+ m->lazy = 1;
} else {
m->lazy = 1;
m->value = strdup (trim (t + 1));
{
struct scope *sc;
struct path *path;
- int i, option, pr = 0;
+ struct macro *m;
+ char *s;
+ int i, option, pr = 0, n = 0;
m_make.value = argv[0];
argv += optind;
argc -= optind;
+
+ for (i = 0; i < argc; ++i) {
+ s = strchr (argv[i], '=');
+ if (s == NULL)
+ continue;
+
+ *s = '\0';
+ m = new (struct macro);
+ m->next = globals;
+ m->name = trim (argv[i]);
+ m->value = trim (s + 1);
+ globals = m;
+ argv[i] = NULL;
+ }
+
sc = parse_recursive (".");
if (pr) {
print_sc (sc);
return 0;
}
-
- if (argc == 0) {
- build (sc, &path_null);
- } else {
- for (i = 0; i < argc; ++i) {
- path = parse_path (argv[i]);
- build (sc, path);
- }
+
+ for (i = 0; i < argc; ++i) {
+ if (argv[i] == NULL)
+ continue;
+
+ path = parse_path (argv[i]);
+ build (sc, path);
+ ++n;
}
+ if (n == 0)
+ build (sc, &path_null);
return 0;
}