From 036ccd8efa9ca16734b8baf4cc022eacb5d78576 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Tue, 24 Mar 2015 21:29:00 +0300 Subject: Support SunOS make target-specific variables --- read.c | 7 ++++++- tests/scripts/features/sun-targetvars | 23 +++++++++++++++++++++++ variable.c | 3 +++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/scripts/features/sun-targetvars diff --git a/read.c b/read.c index e67d386..38cdbdd 100644 --- a/read.c +++ b/read.c @@ -1157,6 +1157,10 @@ eval (struct ebuffer *ebuf, int set_default) if (two_colon) p2++; + /* In sunmake mode ":=" means target-specific variable, not ":" */ + if (sun_flag && (*p2 == '=')) + p2++; + /* Test to see if it's a target-specific variable. Copy the rest of the buffer over, possibly temporarily (we'll expand it later if it's not a target-specific variable). PLEN saves the length @@ -2668,7 +2672,8 @@ get_next_mword (char *buffer, char *delim, char **startp, unsigned int *length) case '=': ++p; - wtype = w_varassign; + /* In sunmake mode ":=" acts as ":" in normal mode. */ + wtype = sun_flag ? w_colon : w_varassign; break; } break; diff --git a/tests/scripts/features/sun-targetvars b/tests/scripts/features/sun-targetvars new file mode 100644 index 0000000..157973b --- /dev/null +++ b/tests/scripts/features/sun-targetvars @@ -0,0 +1,23 @@ +# -*-perl-*- +$description = "Check SunOS make target-specific assignment."; + +$details = "In SunOS make mode ':=' is used for target-specific variable, instead of ':' +Thus, ':=' cannot be used as variable assignment at all."; + +# SunOS make mode, $(other) is undefined: +run_make_test(' +FOO = true +all: other + @echo $(FOO) +other := FOO = false +other: + @echo $(FOO) $(other) +', +'--sun', +"false\ntrue\n"); + +# Same file, but in normal mode, $(other) is "FOO = false": +run_make_test(undef, '', "true FOO = false\ntrue\n"); + +# This tells the test driver that the perl test script executed properly. +1; diff --git a/variable.c b/variable.c index 0b89d37..207b6d8 100644 --- a/variable.c +++ b/variable.c @@ -1492,6 +1492,9 @@ parse_variable_definition (const char *p, struct variable *var) switch (c) { case ':': + /* In sunmake mode ":=" is not a variable assignment. */ + if (sun_flag) + return NULL; var->flavor = f_simple; break; case '+': -- cgit v1.2.3