summaryrefslogtreecommitdiff
path: root/default.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-05-13 04:29:35 -0400
committerPaul Smith <psmith@gnu.org>2013-05-13 04:30:20 -0400
commit58dae243526bd322ae6bec0c4394a117a5fe0171 (patch)
tree921c2f73d7ef59e149880a44472ccd54106aca1c /default.c
parentc7732bd5add31b38fea113c9ab4ad4d97a0870c7 (diff)
downloadgunmake-58dae243526bd322ae6bec0c4394a117a5fe0171.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.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/default.c b/default.c
index 4b24e2e..18b4d4a 100644
--- a/default.c
+++ b/default.c
@@ -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);
+}