diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 4c3215e024ae..9cb4eb6955b9 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.154 2008/10/22 15:04:49 apb Exp $ */ +/* $NetBSD: main.c,v 1.155 2008/12/07 04:50:15 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.154 2008/10/22 15:04:49 apb Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.155 2008/12/07 04:50:15 christos Exp $"; #else #include #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.154 2008/10/22 15:04:49 apb Exp $"); +__RCSID("$NetBSD: main.c,v 1.155 2008/12/07 04:50:15 christos Exp $"); #endif #endif /* not lint */ #endif @@ -204,6 +204,9 @@ parse_debug_options(const char *argvalue) case 'a': debug |= DEBUG_ARCH; break; + case 'C': + debug |= DEBUG_CWD; + break; case 'c': debug |= DEBUG_COND; break; @@ -1262,12 +1265,17 @@ Check_Cwd_av(int ac, char **av, int copy) int i; int n; - if (Check_Cwd_Off) + if (Check_Cwd_Off) { + if (DEBUG(CWD)) + fprintf(debug_file, "check_cwd: check is off.\n"); return NULL; + } if (make[0] == NULL) { if (Var_Exists("NOCHECKMAKECHDIR", VAR_GLOBAL)) { Check_Cwd_Off = 1; + if (DEBUG(CWD)) + fprintf(debug_file, "check_cwd: turning check off.\n"); return NULL; } @@ -1280,12 +1288,18 @@ Check_Cwd_av(int ac, char **av, int copy) make[2] = NULL; cur_dir = Var_Value(".CURDIR", VAR_GLOBAL, &cp); } - if (ac == 0 || av == NULL) + if (ac == 0 || av == NULL) { + if (DEBUG(CWD)) + fprintf(debug_file, "check_cwd: empty command.\n"); return NULL; /* initialization only */ + } if (getenv("MAKEOBJDIR") == NULL && - getenv("MAKEOBJDIRPREFIX") == NULL) + getenv("MAKEOBJDIRPREFIX") == NULL) { + if (DEBUG(CWD)) + fprintf(debug_file, "check_cwd: no obj dirs.\n"); return NULL; + } next_cmd = 1; @@ -1308,8 +1322,8 @@ Check_Cwd_av(int ac, char **av, int copy) /* * XXX this should not happen. */ - fprintf(stderr, "WARNING: raw arg ends in shell meta '%s'\n", - av[i]); + fprintf(stderr, "%s: WARNING: raw arg ends in shell meta '%s'\n", + progname, av[i]); } } else next_cmd = 0; @@ -1318,10 +1332,9 @@ Check_Cwd_av(int ac, char **av, int copy) if (*cp == ';' || *cp == '&' || *cp == '|') is_cmd = 1; -#ifdef check_cwd_debug - fprintf(stderr, "av[%d] == %s '%s'", + if (DEBUG(CWD)) + fprintf(debug_file, "av[%d] == %s '%s'", i, (is_cmd) ? "cmd" : "arg", av[i]); -#endif if (is_cmd != 0) { if (*cp == '(' || *cp == '{' || *cp == ';' || *cp == '&' || *cp == '|') { @@ -1335,25 +1348,22 @@ Check_Cwd_av(int ac, char **av, int copy) } } if (strcmp(cp, "cd") == 0 || strcmp(cp, "chdir") == 0) { -#ifdef check_cwd_debug - fprintf(stderr, " == cd, done.\n"); -#endif + if (DEBUG(CWD)) + fprintf(debug_file, " == cd, done.\n"); return NULL; } for (mp = make; *mp != NULL; ++mp) { n = strlen(*mp); if (strcmp(cp, *mp) == 0) { -#ifdef check_cwd_debug - fprintf(stderr, " %s == '%s', chdir(%s)\n", + if (DEBUG(CWD)) + fprintf(debug_file, " %s == '%s', chdir(%s)\n", cp, *mp, cur_dir); -#endif return cur_dir; } } } -#ifdef check_cwd_debug - fprintf(stderr, "\n"); -#endif + if (DEBUG(CWD)) + fprintf(debug_file, "\n"); } return NULL; } @@ -1370,10 +1380,9 @@ Check_Cwd_Cmd(const char *cmd) if (cmd) { av = brk_string(cmd, &ac, TRUE, &bp); -#ifdef check_cwd_debug - fprintf(stderr, "splitting: '%s' -> %d words\n", + if (DEBUG(CWD)) + fprintf(debug_file, "splitting: '%s' -> %d words\n", cmd, ac); -#endif } else { ac = 0; av = NULL; diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1 index 974a15f7e101..8dffc98b624a 100644 --- a/usr.bin/make/make.1 +++ b/usr.bin/make/make.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.146 2008/11/26 19:08:05 wiz Exp $ +.\" $NetBSD: make.1,v 1.147 2008/12/07 04:50:15 christos Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd November 25, 2008 +.Dd December 6, 2008 .Dt MAKE 1 .Os .Sh NAME @@ -132,6 +132,8 @@ Print all possible debugging information; equivalent to specifying all of the debugging flags. .It Ar a Print debugging information about archive searching and caching. +.It Ar C +Print debugging information about current working directory. .It Ar c Print debugging information about conditional evaluation. .It Ar d diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h index bcd0fdccfec1..cc33fcd4f8c2 100644 --- a/usr.bin/make/make.h +++ b/usr.bin/make/make.h @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.74 2008/02/15 21:29:50 christos Exp $ */ +/* $NetBSD: make.h,v 1.75 2008/12/07 04:50:15 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -410,23 +410,24 @@ extern char *progname; /* The program name */ */ FILE *debug_file; /* Output written here - default stdout */ extern int debug; -#define DEBUG_ARCH 0x0001 -#define DEBUG_COND 0x0002 -#define DEBUG_DIR 0x0004 -#define DEBUG_GRAPH1 0x0008 -#define DEBUG_GRAPH2 0x0010 -#define DEBUG_JOB 0x0020 -#define DEBUG_MAKE 0x0040 -#define DEBUG_SUFF 0x0080 -#define DEBUG_TARG 0x0100 -#define DEBUG_VAR 0x0200 -#define DEBUG_FOR 0x0400 -#define DEBUG_SHELL 0x0800 -#define DEBUG_ERROR 0x1000 -#define DEBUG_LOUD 0x2000 +#define DEBUG_ARCH 0x00001 +#define DEBUG_COND 0x00002 +#define DEBUG_DIR 0x00004 +#define DEBUG_GRAPH1 0x00008 +#define DEBUG_GRAPH2 0x00010 +#define DEBUG_JOB 0x00020 +#define DEBUG_MAKE 0x00040 +#define DEBUG_SUFF 0x00080 +#define DEBUG_TARG 0x00100 +#define DEBUG_VAR 0x00200 +#define DEBUG_FOR 0x00400 +#define DEBUG_SHELL 0x00800 +#define DEBUG_ERROR 0x01000 +#define DEBUG_LOUD 0x02000 #define DEBUG_GRAPH3 0x10000 #define DEBUG_SCRIPT 0x20000 #define DEBUG_PARSE 0x40000 +#define DEBUG_CWD 0x80000 #define CONCAT(a,b) a##b