diff options
author | Paul Smith <psmith@gnu.org> | 2013-05-13 04:30:20 -0400 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2013-05-13 04:30:20 -0400 |
commit | 437d162d3f4a7f1aa0609c5a515f4bd3c40d2a2f (patch) | |
tree | 921c2f73d7ef59e149880a44472ccd54106aca1c /default.c | |
parent | 40846b49c8de41dea720ef1bebd3bbee512f3b3e (diff) | |
download | make-437d162d3f4a7f1aa0609c5a515f4bd3c40d2a2f.tar.gz |
[Savannah #20501] Handle adding -r/-R to MAKEFLAGS in the makefile.
If -R is set in the makefile and not the command line, then go through all the
default variables and undefine them. If -r is set in the makefile and not in
the command line, then remove all .SUFFIX prefixes (unless the user set it)
and SUFFIX variable setting. In -p mode don't print builtins.
Diffstat (limited to 'default.c')
-rw-r--r-- | default.c | 34 |
1 files changed, 25 insertions, 9 deletions
@@ -15,6 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "makeint.h" + +#include <assert.h> + #include "filedef.h" #include "variable.h" #include "rule.h" @@ -536,15 +539,20 @@ void set_default_suffixes (void) { suffix_file = enter_file (strcache_add (".SUFFIXES")); + suffix_file->builtin = 1; if (no_builtin_rules_flag) define_variable_cname ("SUFFIXES", "", o_default, 0); else { + struct dep *d; char *p = default_suffixes; suffix_file->deps = enter_prereqs(PARSE_FILE_SEQ (&p, struct dep, '\0', NULL, 0), NULL); + for (d = suffix_file->deps; d; d = d->next) + d->file->builtin = 1; + define_variable_cname ("SUFFIXES", default_suffixes, o_default, 0); } } @@ -565,15 +573,14 @@ install_default_suffix_rules (void) for (s = default_suffix_rules; *s != 0; s += 2) { struct file *f = enter_file (strcache_add (s[0])); - /* Don't clobber cmds given in a makefile if there were any. */ - if (f->cmds == 0) - { - f->cmds = xmalloc (sizeof (struct commands)); - f->cmds->fileinfo.filenm = 0; - f->cmds->commands = s[1]; - f->cmds->command_lines = 0; - f->cmds->recipe_prefix = RECIPEPREFIX_DEFAULT; - } + /* This function should run before any makefile is parsed. */ + assert (f->cmds == 0); + f->cmds = xmalloc (sizeof (struct commands)); + f->cmds->fileinfo.filenm = 0; + f->cmds->commands = s[1]; + f->cmds->command_lines = 0; + f->cmds->recipe_prefix = RECIPEPREFIX_DEFAULT; + f->builtin = 1; } } @@ -606,3 +613,12 @@ define_default_variables (void) for (s = default_variables; *s != 0; s += 2) define_variable (s[0], strlen (s[0]), s[1], o_default, 1); } + +void +undefine_default_variables (void) +{ + const char **s; + + for (s = default_variables; *s != 0; s += 2) + undefine_variable_global (s[0], strlen (s[0]), o_default); +} |