}
+static int set_ignore_errors (const char *arg) {
+
+ (void) arg;
+
+ state->ignore_errors = 1;
+ return 0;
+
+}
+
+static int set_dry_run (const char *arg) {
+
+ (void) arg;
+
+ state->dry_run = 1;
+ return 0;
+
+}
+
static int set_no_print (const char *arg) {
(void) arg;
{ "--file=", &add_makefile },
{ "-f:", &add_makefile },
+ { "--ignore-errors", &set_ignore_errors },
+ { "-i", &set_ignore_errors },
+
+ { "--dry_run", &set_dry_run },
+ { "-n", &set_dry_run },
+
+
+
{ 0, &non_option }
};
static int rule_run_command (const char *filename, unsigned long line_no, const char *name, char *p, char *q) {
- int is_quiet = state->quiet, is_ignoring_errors = 0;
char *new_cmds, *s;
+ int is_ignoring_errors = state->ignore_errors;
+ int is_quiet = state->quiet;
+ int should_execute = !state->dry_run;
+
*q = '\0';
new_cmds = xstrdup (p);
new_cmds = variable_expand_line ("<command-line>", 1, new_cmds);
s = new_cmds;
- while (isspace ((int) *s) || *s == '-' || *s == '@') {
+ while (isspace ((int) *s) || *s == '-' || *s == '@' || *s == '+') {
if (*s == '@') {
is_quiet = 1;
is_ignoring_errors = 1;
}
+ if (*s == '+') {
+ should_execute = 1;
+ }
+
s++;
}
printf ("%s\n", new_cmds);
}
- /*if (!dry_run) */{
+ if (should_execute) {
int error = system (s);
variable_add (xstrdup ("OS"), xstrdup (os_name), VAR_ORIGIN_FILE);
variable_add (xstrdup ("MAKE"), xstrdup (argv[0]), VAR_ORIGIN_FILE);
+#if defined (_WIN32) || defined (__WIN32__)
+ variable_add (xstrdup ("SHELL"), xstrdup ("cmd.exe"), VAR_ORIGIN_FILE);
+#else
+ variable_add (xstrdup ("SHELL"), xstrdup ("sh.exe"), VAR_ORIGIN_FILE);
+#endif
+
state = xmalloc (sizeof (*state));
parse_args (argv, argc);
{
- char *cwd, *path;
- size_t len;
+ char *path, *cwd = get_current_directory ();
- cwd = get_current_directory ();
- len = strlen ("CURDIR") + 4 + strlen (cwd);
-
- path = xmalloc (len + 1);
+ path = xmalloc (strlen ("CURDIR") + 4 + strlen (cwd) + 1);
sprintf (path, "CURDIR ?= %s", cwd);
parse_var_line ("<command-line>", 1, path, VAR_ORIGIN_FILE);
free (path);
- len = strlen (".CURDIR") + 4 + strlen (cwd);
-
- path = xmalloc (len + 1);
+ path = xmalloc (strlen (".CURDIR") + 4 + strlen (cwd) + 1);
sprintf (path, ".CURDIR ?= %s", cwd);
parse_var_line ("<command-line>", 1, path, VAR_ORIGIN_FILE);