aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2013-08-02 05:23:57 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2013-08-02 05:23:57 +0000
commite0f69e1d23f496f590728b9bb0cf0778e4df1210 (patch)
tree9f9944063b4983031d8155b70d2f48d1bc3f290e
parent45f33ab2b2f3f9436d40a229bf4ac6dca9411c05 (diff)
downloadsrc-vendor/NetBSD/bmake/20130730.tar.gz
src-vendor/NetBSD/bmake/20130730.zip
Import bmake-20130730 - allows folk to supress job tokens.vendor/NetBSD/bmake/20130730
-rw-r--r--ChangeLog33
-rw-r--r--Makefile4
-rw-r--r--bmake.129
-rw-r--r--bmake.cat122
-rw-r--r--compat.c23
-rwxr-xr-xconfigure25
-rw-r--r--configure.in13
-rw-r--r--job.c29
-rw-r--r--job.h3
-rw-r--r--main.c111
-rw-r--r--make.124
-rw-r--r--make.h7
-rw-r--r--meta.c41
-rw-r--r--mk/ChangeLog15
-rw-r--r--mk/init.mk8
-rw-r--r--mk/install-mk4
-rw-r--r--mk/lib.mk21
-rwxr-xr-xmk/meta2deps.py36
-rw-r--r--mk/own.mk3
-rw-r--r--mk/prog.mk11
-rw-r--r--parse.c12
-rw-r--r--unit-tests/Makefile.in6
-rw-r--r--var.c50
23 files changed, 365 insertions, 165 deletions
diff --git a/ChangeLog b/ChangeLog
index 587c7f90ad71..21ab78e57216 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2013-07-30 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile (MAKE_VERSION): 20130730
+ Merge with NetBSD make, pick up
+ o Allow suppression of --- job -- tokens by setting
+ .MAKE.JOB.PREFIX empty.
+
+2013-07-16 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile (MAKE_VERSION): 20130716
+ Merge with NetBSD make, pick up
+ o number of gmake compatability tweaks
+ -w for gmake style entering/leaving messages
+ if .MAKE.LEVEL > 0 indicate it in progname "make[1]" etc.
+ handle MAKEFLAGS containing only letters.
+ o when overriding a GLOBAL variable on the command line,
+ delete it from GLOBAL context so -V doesn't show the wrong
+ value.
+
+2013-07-06 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * configure.in: We don't need MAKE_LEVEL_SAFE anymore.
+
+ * Makefile (MAKE_VERSION): 20130706
+ Merge with NetBSD make, pick up
+ o Shell_Init(): export shellErrFlag if commandShell hasErrCtl is
+ true so that CompatRunCommand() can use it, to ensure
+ consistent behavior with jobs mode.
+ o use MAKE_LEVEL_ENV to define the variable to propagate
+ .MAKE.LEVEL - currently set to MAKELEVEL (same as gmake).
+ o meta.c: use .MAKE.META.IGNORE_PATHS to allow customization of
+ paths to ignore.
+
2013-06-04 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20130604
diff --git a/Makefile b/Makefile
index c4bcfa428a4e..1b1cd5944d4b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
-# $Id: Makefile,v 1.14 2013/06/05 04:03:22 sjg Exp $
+# $Id: Makefile,v 1.17 2013/07/30 19:13:53 sjg Exp $
# Base version on src date
-MAKE_VERSION= 20130604
+MAKE_VERSION= 20130730
PROG= bmake
diff --git a/bmake.1 b/bmake.1
index 2403eae7078f..021a94ad24ac 100644
--- a/bmake.1
+++ b/bmake.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.213 2013/03/31 05:49:51 sjg Exp $
+.\" $NetBSD: make.1,v 1.220 2013/07/30 19:09:57 sjg 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 March 30, 2013
+.Dd July 30, 2013
.Dt MAKE 1
.Os
.Sh NAME
@@ -37,7 +37,7 @@
.Nd maintain program dependencies
.Sh SYNOPSIS
.Nm
-.Op Fl BeikNnqrstWX
+.Op Fl BeikNnqrstWwX
.Op Fl C Ar directory
.Op Fl D Ar variable
.Op Fl d Ar flags
@@ -209,6 +209,8 @@ Force the
option to print raw values of variables.
.It Ar v
Print debugging information about variable assignment.
+.It Ar w
+Print entering and leaving directory messages, pre and post processing.
.It Ar x
Run shell commands with
.Fl x
@@ -743,6 +745,9 @@ then output for each target is prefixed with a token
.Ql --- target ---
the first part of which can be controlled via
.Va .MAKE.JOB.PREFIX .
+If
+.Va .MAKE.JOB.PREFIX
+is empty, no token is printed.
.br
For example:
.Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
@@ -856,6 +861,11 @@ In "meta" mode, this variable contains a list of all the meta files
used (updated or not).
This list can be used to process the meta files to extract dependency
information.
+.It Va .MAKE.META.IGNORE_PATHS
+Provides a list of path prefixes that should be ignored;
+because the contents are expected to change over time.
+The default list includes:
+.Ql Pa /dev /etc /proc /tmp /var/run /var/tmp
.It Va .MAKE.META.PREFIX
Defines the message printed for each meta file updated in "meta verbose" mode.
The default value is:
@@ -877,7 +887,7 @@ is modified.
.It Va .MAKE.PATH_FILEMON
If
.Nm
-was built with
+was built with
.Xr filemon 4
support, this is set to the path of the device node.
This allows makefiles to test for this support.
@@ -1298,7 +1308,7 @@ should start and end with a period.
For example.
.Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
.Pp
-However a single character varaiable is often more readable:
+However a single character variable is often more readable:
.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
.It Cm \&:U Ns Ar newval
If the variable is undefined
@@ -1321,7 +1331,7 @@ The path of the node which has the same name as the variable
is the value.
If no such node exists or its path is null, then the
name of the variable is used.
-In order for this modifier to work, the name (node) must at least have
+In order for this modifier to work, the name (node) must at least have
appeared on the rhs of a dependency.
.Sm off
.It Cm \&:\&! Ar cmd Cm \&!
@@ -2115,6 +2125,13 @@ for Sprite at Berkeley.
It was designed to be a parallel distributed make running jobs on different
machines using a daemon called
.Dq customs .
+.Pp
+Historically the target/dependency
+.Dq FRC
+has been used to FoRCe rebuilding (since the target/dependency
+does not exist... unless someone creates an
+.Dq FRC
+file).
.Sh BUGS
The
make
diff --git a/bmake.cat1 b/bmake.cat1
index e446e891450c..e18c26729145 100644
--- a/bmake.cat1
+++ b/bmake.cat1
@@ -4,7 +4,7 @@ NNAAMMEE
bbmmaakkee -- maintain program dependencies
SSYYNNOOPPSSIISS
- bbmmaakkee [--BBeeiikkNNnnqqrrssttWWXX] [--CC _d_i_r_e_c_t_o_r_y] [--DD _v_a_r_i_a_b_l_e] [--dd _f_l_a_g_s]
+ bbmmaakkee [--BBeeiikkNNnnqqrrssttWWwwXX] [--CC _d_i_r_e_c_t_o_r_y] [--DD _v_a_r_i_a_b_l_e] [--dd _f_l_a_g_s]
[--ff _m_a_k_e_f_i_l_e] [--II _d_i_r_e_c_t_o_r_y] [--JJ _p_r_i_v_a_t_e] [--jj _m_a_x___j_o_b_s]
[--mm _d_i_r_e_c_t_o_r_y] [--TT _f_i_l_e] [--VV _v_a_r_i_a_b_l_e] [_v_a_r_i_a_b_l_e_=_v_a_l_u_e]
[_t_a_r_g_e_t _._._.]
@@ -122,6 +122,9 @@ DDEESSCCRRIIPPTTIIOONN
_v Print debugging information about variable assignment.
+ _w Print entering and leaving directory messages, pre and
+ post processing.
+
_x Run shell commands with --xx so the actual commands are
printed as they are executed.
@@ -469,7 +472,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
_._M_A_K_E_._J_O_B_._P_R_E_F_I_X
If bbmmaakkee is run with _j then output for each target is
prefixed with a token `--- target ---' the first part of
- which can be controlled via _._M_A_K_E_._J_O_B_._P_R_E_F_I_X.
+ which can be controlled via _._M_A_K_E_._J_O_B_._P_R_E_F_I_X. If
+ _._M_A_K_E_._J_O_B_._P_R_E_F_I_X is empty, no token is printed.
For example:
.MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
would produce tokens like `---make[1234] target ---' mak-
@@ -551,6 +555,12 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
to process the meta files to extract dependency informa-
tion.
+ _._M_A_K_E_._M_E_T_A_._I_G_N_O_R_E___P_A_T_H_S
+ Provides a list of path prefixes that should be ignored;
+ because the contents are expected to change over time.
+ The default list includes: `_/_d_e_v _/_e_t_c _/_p_r_o_c _/_t_m_p _/_v_a_r_/_r_u_n
+ _/_v_a_r_/_t_m_p'
+
_._M_A_K_E_._M_E_T_A_._P_R_E_F_I_X
Defines the message printed for each meta file updated in
"meta verbose" mode. The default value is:
@@ -818,7 +828,7 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
period. For example.
${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
- However a single character varaiable is often more readable:
+ However a single character variable is often more readable:
${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
::UU_n_e_w_v_a_l
@@ -1351,6 +1361,10 @@ HHIISSTTOORRYY
Berkeley. It was designed to be a parallel distributed make running jobs
on different machines using a daemon called ``customs''.
+ Historically the target/dependency ``FRC'' has been used to FoRCe
+ rebuilding (since the target/dependency does not exist... unless someone
+ creates an ``FRC'' file).
+
BBUUGGSS
The make syntax is difficult to parse without actually acting of the
data. For instance finding the end of a variable use should involve
@@ -1360,4 +1374,4 @@ BBUUGGSS
There is no way of escaping a space character in a filename.
-NetBSD 5.1 March 30, 2013 NetBSD 5.1
+NetBSD 5.1 July 30, 2013 NetBSD 5.1
diff --git a/compat.c b/compat.c
index 8f931cbdc48d..35860485581c 100644
--- a/compat.c
+++ b/compat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.91 2013/01/25 02:01:10 sjg Exp $ */
+/* $NetBSD: compat.c,v 1.92 2013/07/05 22:14:56 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.91 2013/01/25 02:01:10 sjg Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.92 2013/07/05 22:14:56 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: compat.c,v 1.91 2013/01/25 02:01:10 sjg Exp $");
+__RCSID("$NetBSD: compat.c,v 1.92 2013/07/05 22:14:56 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -332,18 +332,23 @@ again:
* We need to pass the command off to the shell, typically
* because the command contains a "meta" character.
*/
- static const char *shargv[4];
+ static const char *shargv[5];
+ int shargc;
- shargv[0] = shellPath;
+ shargc = 0;
+ shargv[shargc++] = shellPath;
/*
* The following work for any of the builtin shell specs.
*/
+ if (shellErrFlag) {
+ shargv[shargc++] = shellErrFlag;
+ }
if (DEBUG(SHELL))
- shargv[1] = "-xc";
+ shargv[shargc++] = "-xc";
else
- shargv[1] = "-c";
- shargv[2] = cmd;
- shargv[3] = NULL;
+ shargv[shargc++] = "-c";
+ shargv[shargc++] = cmd;
+ shargv[shargc++] = NULL;
av = shargv;
argc = 0;
bp = NULL;
diff --git a/configure b/configure
index a515b278c276..7accf1a1f0f3 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.64 for bmake 20130303.
+# Generated by GNU Autoconf 2.64 for bmake 20130706.
#
# Report bugs to <sjg@NetBSD.org>.
#
@@ -549,8 +549,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bmake'
PACKAGE_TARNAME='bmake'
-PACKAGE_VERSION='20130303'
-PACKAGE_STRING='bmake 20130303'
+PACKAGE_VERSION='20130706'
+PACKAGE_STRING='bmake 20130706'
PACKAGE_BUGREPORT='sjg@NetBSD.org'
PACKAGE_URL=''
@@ -1220,7 +1220,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures bmake 20130303 to adapt to many kinds of systems.
+\`configure' configures bmake 20130706 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1281,7 +1281,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of bmake 20130303:";;
+ short | recursive ) echo "Configuration of bmake 20130706:";;
esac
cat <<\_ACEOF
@@ -1386,7 +1386,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-bmake configure 20130303
+bmake configure 20130706
generated by GNU Autoconf 2.64
Copyright (C) 2009 Free Software Foundation, Inc.
@@ -1907,7 +1907,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by bmake $as_me 20130303, which was
+It was created by bmake $as_me 20130706, which was
generated by GNU Autoconf 2.64. Invocation command line was
$ $0 $@
@@ -4245,13 +4245,6 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-echo $ECHO_N "checking if sh will pass .MAKE. variables... $ECHO_C" >&6
-ok=`env .MAKE.LEVEL=1 /bin/sh -c env | grep LEVEL=`
-case "$ok" in
-"") echo no >&6; CPPFLAGS="${CPPFLAGS} -DNEED_MAKE_LEVEL_SAFE";;
-*) echo yes >&6;;
-esac
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
@@ -6374,7 +6367,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by bmake $as_me 20130303, which was
+This file was extended by bmake $as_me 20130706, which was
generated by GNU Autoconf 2.64. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -6434,7 +6427,7 @@ Report bugs to <sjg@NetBSD.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
-bmake config.status 20130303
+bmake config.status 20130706
configured by $0, generated by GNU Autoconf 2.64,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/configure.in b/configure.in
index ba82a75e598d..ac2cc2e64b9b 100644
--- a/configure.in
+++ b/configure.in
@@ -1,10 +1,10 @@
dnl
dnl RCSid:
-dnl $Id: configure.in,v 1.48 2013/03/04 21:25:57 sjg Exp $
+dnl $Id: configure.in,v 1.49 2013/07/06 18:25:19 sjg Exp $
dnl
dnl Process this file with autoconf to produce a configure script
dnl
-AC_INIT([bmake], [20130303], [sjg@NetBSD.org])
+AC_INIT([bmake], [20130706], [sjg@NetBSD.org])
AC_CONFIG_HEADER(config.h)
dnl make srcdir absolute
@@ -79,15 +79,6 @@ dnl Executable suffix - normally empty; .exe on os2.
AC_SUBST(ac_exe_suffix)dnl
dnl
-dnl Check if /bin/sh will pass .MAKE.LEVEL
-echo $ECHO_N "checking if sh will pass .MAKE. variables... $ECHO_C" >&6
-ok=`env .MAKE.LEVEL=1 /bin/sh -c env | grep LEVEL=`
-case "$ok" in
-"") echo no >&6; CPPFLAGS="${CPPFLAGS} -DNEED_MAKE_LEVEL_SAFE";;
-*) echo yes >&6;;
-esac
-
-dnl
dnl AC_C_CROSS
dnl
diff --git a/job.c b/job.c
index a0e407cdfcf5..902050d22374 100644
--- a/job.c
+++ b/job.c
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.173 2013/06/05 03:59:43 sjg Exp $ */
+/* $NetBSD: job.c,v 1.175 2013/07/30 19:09:57 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.173 2013/06/05 03:59:43 sjg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.175 2013/07/30 19:09:57 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: job.c,v 1.173 2013/06/05 03:59:43 sjg Exp $");
+__RCSID("$NetBSD: job.c,v 1.175 2013/07/30 19:09:57 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -313,6 +313,7 @@ static Shell *commandShell = &shells[DEFSHELL_INDEX]; /* this is the shell to
const char *shellPath = NULL, /* full pathname of
* executable image */
*shellName = NULL; /* last component of shell */
+char *shellErrFlag = NULL;
static const char *shellArgv = NULL; /* Custom shell args */
@@ -344,7 +345,7 @@ static Job childExitJob; /* child exit pseudo-job */
#define TARG_FMT "%s %s ---\n" /* Default format */
#define MESSAGE(fp, gn) \
- if (maxJobs != 1) \
+ if (maxJobs != 1 && targPrefix && *targPrefix) \
(void)fprintf(fp, TARG_FMT, targPrefix, gn->name)
static sigset_t caught_signals; /* Set of signals we handle */
@@ -2152,6 +2153,24 @@ Shell_Init(void)
if (commandShell->echo == NULL) {
commandShell->echo = "";
}
+ if (commandShell->hasErrCtl && *commandShell->exit) {
+ if (shellErrFlag &&
+ strcmp(commandShell->exit, &shellErrFlag[1]) != 0) {
+ free(shellErrFlag);
+ shellErrFlag = NULL;
+ }
+ if (!shellErrFlag) {
+ int n = strlen(commandShell->exit) + 2;
+
+ shellErrFlag = bmake_malloc(n);
+ if (shellErrFlag) {
+ snprintf(shellErrFlag, n, "-%s", commandShell->exit);
+ }
+ }
+ } else if (shellErrFlag) {
+ free(shellErrFlag);
+ shellErrFlag = NULL;
+ }
}
/*-
@@ -2496,6 +2515,8 @@ Job_ParseShell(char *line)
commandShell = bmake_malloc(sizeof(Shell));
*commandShell = newShell;
}
+ /* this will take care of shellErrFlag */
+ Shell_Init();
}
if (commandShell->echoOn && commandShell->echoOff) {
diff --git a/job.h b/job.h
index 5323b100412b..91e2c8782723 100644
--- a/job.h
+++ b/job.h
@@ -1,4 +1,4 @@
-/* $NetBSD: job.h,v 1.41 2013/03/05 22:01:44 christos Exp $ */
+/* $NetBSD: job.h,v 1.42 2013/07/05 22:14:56 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -243,6 +243,7 @@ typedef struct Shell {
extern const char *shellPath;
extern const char *shellName;
+extern char *shellErrFlag;
extern int jobTokensRunning; /* tokens currently "out" */
extern int maxJobs; /* Max jobs we can run */
diff --git a/main.c b/main.c
index 84c6935f81e4..3a164ce33f5d 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $ */
+/* $NetBSD: main.c,v 1.222 2013/07/18 15:31:49 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.222 2013/07/18 15:31:49 sjg Exp $";
#else
#include <sys/cdefs.h>
#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.210 2013/03/23 05:31:29 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.222 2013/07/18 15:31:49 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -117,17 +117,18 @@ __RCSID("$NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $");
#include <sys/time.h>
#include <sys/param.h>
#include <sys/resource.h>
-#include <signal.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include "wait.h"
#include <errno.h>
#include <fcntl.h>
+#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
+#include <ctype.h>
#include "make.h"
#include "hash.h"
@@ -163,6 +164,7 @@ Boolean noRecursiveExecute; /* -N flag */
Boolean keepgoing; /* -k flag */
Boolean queryFlag; /* -q flag */
Boolean touchFlag; /* -t flag */
+Boolean enterFlag; /* -w flag */
Boolean ignoreErrors; /* -i flag */
Boolean beSilent; /* -s flag */
Boolean oldVars; /* variable substitution style */
@@ -184,6 +186,7 @@ char curdir[MAXPATHLEN + 1]; /* Startup directory */
char *progname; /* the program name */
char *makeDependfile;
pid_t myPid;
+int makelevel;
Boolean forceJobs = FALSE;
@@ -198,6 +201,38 @@ Boolean forceJobs = FALSE;
extern Lst parseIncPath;
+/*
+ * For compatibility with the POSIX version of MAKEFLAGS that includes
+ * all the options with out -, convert flags to -f -l -a -g -s.
+ */
+static char *
+explode(const char *flags)
+{
+ size_t len;
+ char *nf, *st;
+ const char *f;
+
+ if (flags == NULL)
+ return NULL;
+
+ for (f = flags; *f; f++)
+ if (!isalpha((unsigned char)*f))
+ break;
+
+ if (*f)
+ return bmake_strdup(flags);
+
+ len = strlen(flags);
+ st = nf = bmake_malloc(len * 3 + 1);
+ while (*flags) {
+ *nf++ = '-';
+ *nf++ = *flags++;
+ *nf++ = ' ';
+ }
+ *nf = '\0';
+ return st;
+}
+
static void
parse_debug_options(const char *argvalue)
{
@@ -350,7 +385,7 @@ MainParseArgs(int argc, char **argv)
Boolean inOption, dashDash = FALSE;
char found_path[MAXPATHLEN + 1]; /* for searching for sys.mk */
-#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrst"
+#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrstw"
/* Can't actually use getopt(3) because rescanning is not portable */
getopt_def = OPTFLAGS;
@@ -558,6 +593,10 @@ rearg:
touchFlag = TRUE;
Var_Append(MAKEFLAGS, "-t", VAR_GLOBAL);
break;
+ case 'w':
+ enterFlag = TRUE;
+ Var_Append(MAKEFLAGS, "-w", VAR_GLOBAL);
+ break;
case '-':
dashDash = TRUE;
break;
@@ -796,7 +835,7 @@ main(int argc, char **argv)
Lst targs; /* target nodes to create -- passed to Make_Init */
Boolean outOfDate = FALSE; /* FALSE if all targets up to date */
struct stat sb, sa;
- char *p1, *path, *pwd;
+ char *p1, *path;
char mdpath[MAXPATHLEN];
#ifdef FORCE_MACHINE
const char *machine = FORCE_MACHINE;
@@ -963,26 +1002,30 @@ main(int argc, char **argv)
Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL, 0);
Var_Set("MFLAGS", "", VAR_GLOBAL, 0);
Var_Set(".ALLTARGETS", "", VAR_GLOBAL, 0);
+ /* some makefiles need to know this */
+ Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, VAR_CMD, 0);
/*
* Set some other useful macros
*/
{
- char tmp[64];
- const char *ep;
+ char tmp[64], *ep;
- if (!(ep = getenv(MAKE_LEVEL))) {
-#ifdef MAKE_LEVEL_SAFE
- if (!(ep = getenv(MAKE_LEVEL_SAFE)))
-#endif
- ep = "0";
- }
- Var_Set(MAKE_LEVEL, ep, VAR_GLOBAL, 0);
+ makelevel = ((ep = getenv(MAKE_LEVEL_ENV)) && *ep) ? atoi(ep) : 0;
+ if (makelevel < 0)
+ makelevel = 0;
+ snprintf(tmp, sizeof(tmp), "%d", makelevel);
+ Var_Set(MAKE_LEVEL, tmp, VAR_GLOBAL, 0);
snprintf(tmp, sizeof(tmp), "%u", myPid);
Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0);
snprintf(tmp, sizeof(tmp), "%u", getppid());
Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0);
}
+ if (makelevel > 0) {
+ char pn[1024];
+ snprintf(pn, sizeof(pn), "%s[%d]", progname, makelevel);
+ progname = bmake_strdup(pn);
+ }
Job_SetPrefix();
#ifdef USE_META
@@ -994,7 +1037,9 @@ main(int argc, char **argv)
* in a different format).
*/
#ifdef POSIX
- Main_ParseArgLine(getenv("MAKEFLAGS"));
+ p1 = explode(getenv("MAKEFLAGS"));
+ Main_ParseArgLine(p1);
+ free(p1);
#else
Main_ParseArgLine(getenv("MAKE"));
#endif
@@ -1011,6 +1056,9 @@ main(int argc, char **argv)
MainParseArgs(argc, argv);
+ if (enterFlag)
+ printf("%s: Entering directory `%s'\n", progname, curdir);
+
/*
* Verify that cwd is sane.
*/
@@ -1032,15 +1080,19 @@ main(int argc, char **argv)
* MAKEOBJDIRPREFIX is set or MAKEOBJDIR contains a transform.
*/
#ifndef NO_PWD_OVERRIDE
- if (!ignorePWD &&
- (pwd = getenv("PWD")) != NULL &&
- getenv("MAKEOBJDIRPREFIX") == NULL) {
- const char *makeobjdir = getenv("MAKEOBJDIR");
-
- if (makeobjdir == NULL || !strchr(makeobjdir, '$')) {
- if (stat(pwd, &sb) == 0 && sa.st_ino == sb.st_ino &&
- sa.st_dev == sb.st_dev)
- (void)strncpy(curdir, pwd, MAXPATHLEN);
+ if (!ignorePWD) {
+ char *pwd;
+
+ if ((pwd = getenv("PWD")) != NULL &&
+ getenv("MAKEOBJDIRPREFIX") == NULL) {
+ const char *makeobjdir = getenv("MAKEOBJDIR");
+
+ if (makeobjdir == NULL || !strchr(makeobjdir, '$')) {
+ if (stat(pwd, &sb) == 0 &&
+ sa.st_ino == sb.st_ino &&
+ sa.st_dev == sb.st_dev)
+ (void)strncpy(curdir, pwd, MAXPATHLEN);
+ }
}
}
#endif
@@ -1328,6 +1380,9 @@ main(int argc, char **argv)
Trace_Log(MAKEEND, 0);
+ if (enterFlag)
+ printf("%s: Leaving directory `%s'\n", progname, curdir);
+
Suff_End();
Targ_End();
Arch_End();
@@ -1756,8 +1811,12 @@ execError(const char *af, const char *av)
static void
usage(void)
{
+ char *p;
+ if ((p = strchr(progname, '[')) != NULL)
+ *p = '\0';
+
(void)fprintf(stderr,
-"usage: %s [-BeikNnqrstWX] \n\
+"usage: %s [-BeikNnqrstWwX] \n\
[-C directory] [-D variable] [-d flags] [-f makefile]\n\
[-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]\n\
[-V variable] [variable=value] [target ...]\n", progname);
diff --git a/make.1 b/make.1
index a2cc16a2bfdf..4e3c11170051 100644
--- a/make.1
+++ b/make.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.215 2013/05/22 19:35:11 christos Exp $
+.\" $NetBSD: make.1,v 1.220 2013/07/30 19:09:57 sjg 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 May 22, 2013
+.Dd July 30, 2013
.Dt MAKE 1
.Os
.Sh NAME
@@ -37,7 +37,7 @@
.Nd maintain program dependencies
.Sh SYNOPSIS
.Nm
-.Op Fl BeikNnqrstWX
+.Op Fl BeikNnqrstWwX
.Op Fl C Ar directory
.Op Fl D Ar variable
.Op Fl d Ar flags
@@ -209,6 +209,8 @@ Force the
option to print raw values of variables.
.It Ar v
Print debugging information about variable assignment.
+.It Ar w
+Print entering and leaving directory messages, pre and post processing.
.It Ar x
Run shell commands with
.Fl x
@@ -743,6 +745,9 @@ then output for each target is prefixed with a token
.Ql --- target ---
the first part of which can be controlled via
.Va .MAKE.JOB.PREFIX .
+If
+.Va .MAKE.JOB.PREFIX
+is empty, no token is printed.
.br
For example:
.Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
@@ -856,6 +861,11 @@ In "meta" mode, this variable contains a list of all the meta files
used (updated or not).
This list can be used to process the meta files to extract dependency
information.
+.It Va .MAKE.META.IGNORE_PATHS
+Provides a list of path prefixes that should be ignored;
+because the contents are expected to change over time.
+The default list includes:
+.Ql Pa /dev /etc /proc /tmp /var/run /var/tmp
.It Va .MAKE.META.PREFIX
Defines the message printed for each meta file updated in "meta verbose" mode.
The default value is:
@@ -877,7 +887,7 @@ is modified.
.It Va .MAKE.PATH_FILEMON
If
.Nm
-was built with
+was built with
.Xr filemon 4
support, this is set to the path of the device node.
This allows makefiles to test for this support.
@@ -1298,7 +1308,7 @@ should start and end with a period.
For example.
.Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
.Pp
-However a single character varaiable is often more readable:
+However a single character variable is often more readable:
.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
.It Cm \&:U Ns Ar newval
If the variable is undefined
@@ -1321,7 +1331,7 @@ The path of the node which has the same name as the variable
is the value.
If no such node exists or its path is null, then the
name of the variable is used.
-In order for this modifier to work, the name (node) must at least have
+In order for this modifier to work, the name (node) must at least have
appeared on the rhs of a dependency.
.Sm off
.It Cm \&:\&! Ar cmd Cm \&!
@@ -2114,7 +2124,7 @@ machines using a daemon called
Historically the target/dependency
.Dq FRC
has been used to FoRCe rebuilding (since the target/dependency
-does not exist... unless someone creates an
+does not exist... unless someone creates an
.Dq FRC
file).
.Sh BUGS
diff --git a/make.h b/make.h
index c9c72bcb0d51..c51fbe5ef629 100644
--- a/make.h
+++ b/make.h
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.90 2013/02/25 01:57:14 dholland Exp $ */
+/* $NetBSD: make.h,v 1.91 2013/06/18 20:06:09 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -442,9 +442,8 @@ extern pid_t myPid;
#define MAKEFILE_PREFERENCE ".MAKE.MAKEFILE_PREFERENCE"
#define MAKE_DEPENDFILE ".MAKE.DEPENDFILE" /* .depend */
#define MAKE_MODE ".MAKE.MODE"
-
-#ifdef NEED_MAKE_LEVEL_SAFE
-# define MAKE_LEVEL_SAFE "_MAKE_LEVEL" /* some shells will not pass .MAKE. */
+#ifndef MAKE_LEVEL_ENV
+# define MAKE_LEVEL_ENV "MAKELEVEL"
#endif
/*
diff --git a/meta.c b/meta.c
index 3aec19a78907..e7c7597a3af3 100644
--- a/meta.c
+++ b/meta.c
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.30 2013/05/16 21:56:56 sjg Exp $ */
+/* $NetBSD: meta.c,v 1.32 2013/06/25 00:20:54 sjg Exp $ */
/*
* Implement 'meta' mode.
@@ -55,7 +55,12 @@
#endif
static BuildMon Mybm; /* for compat */
-static Lst metaBailiwick; /* our scope of control */
+static Lst metaBailiwick; /* our scope of control */
+static Lst metaIgnorePaths; /* paths we deliberately ignore */
+
+#ifndef MAKE_META_IGNORE_PATHS
+#define MAKE_META_IGNORE_PATHS ".MAKE.META.IGNORE_PATHS"
+#endif
Boolean useMeta = FALSE;
static Boolean useFilemon = FALSE;
@@ -607,6 +612,17 @@ meta_mode_init(const char *make_mode)
if (cp) {
str2Lst_Append(metaBailiwick, cp, NULL);
}
+ /*
+ * We ignore any paths that start with ${.MAKE.META.IGNORE_PATHS}
+ */
+ metaIgnorePaths = Lst_Init(FALSE);
+ Var_Append(MAKE_META_IGNORE_PATHS,
+ "/dev /etc /proc /tmp /var/run /var/tmp ${TMPDIR}", VAR_GLOBAL);
+ cp = Var_Subst(NULL,
+ "${" MAKE_META_IGNORE_PATHS ":O:u:tA}", VAR_GLOBAL, 0);
+ if (cp) {
+ str2Lst_Append(metaIgnorePaths, cp, NULL);
+ }
}
/*
@@ -1110,20 +1126,15 @@ meta_oodate(GNode *gn, Boolean oodate)
* be part of the dependencies because
* they are _expected_ to change.
*/
- if (strncmp(p, "/tmp/", 5) == 0 ||
- (tmplen > 0 && strncmp(p, tmpdir, tmplen) == 0))
- break;
-
- if (strncmp(p, "/var/", 5) == 0)
- break;
-
- /* Ignore device files. */
- if (strncmp(p, "/dev/", 5) == 0)
- break;
-
- /* Ignore /etc/ files. */
- if (strncmp(p, "/etc/", 5) == 0)
+ if (*p == '/' &&
+ Lst_ForEach(metaIgnorePaths, prefix_match, p)) {
+#ifdef DEBUG_META_MODE
+ if (DEBUG(META))
+ fprintf(debug_file, "meta_oodate: ignoring: %s\n",
+ p);
+#endif
break;
+ }
if ((cp = strrchr(p, '/'))) {
cp++;
diff --git a/mk/ChangeLog b/mk/ChangeLog
index 32e064ba44d5..db1e289f92b1 100644
--- a/mk/ChangeLog
+++ b/mk/ChangeLog
@@ -1,3 +1,18 @@
+2013-07-26 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): 20130726
+ some updates from Juniper and FreeBSD
+ o meta2deps.py: indicate file and line number when we hit parse
+ errors
+ also allow @file to provide huge list of .meta files.
+ * meta2deps.py: add try_parse() to cleanup the above.
+
+2013-07-16 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): 20130716
+ * own.mk: add GPROG as an option
+ * prog.mk: honor MK_GPROF==yes
+
2013-05-10 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20130505
diff --git a/mk/init.mk b/mk/init.mk
index ed63fe6f1a5f..e70037080896 100644
--- a/mk/init.mk
+++ b/mk/init.mk
@@ -1,4 +1,4 @@
-# $Id: init.mk,v 1.8 2012/11/11 22:37:02 sjg Exp $
+# $Id: init.mk,v 1.9 2013/07/18 05:46:24 sjg Exp $
#
# @(#) Copyright (c) 2002, Simon J. Gerraty
#
@@ -36,6 +36,12 @@ COPTS += ${COPTS.${.IMPSRC:T}}
CPPFLAGS += ${CPPFLAGS.${.IMPSRC:T}}
CPUFLAGS += ${CPUFLAGS.${.IMPSRC:T}}
+CC_PG?= -pg
+CXX_PG?= ${CC_PG}
+CC_PIC?= -DPIC
+CXX_PIC?= ${CC_PIC}
+PROFFLAGS?= -DGPROF -DPROF
+
.if ${.MAKE.LEVEL:U1} == 0 && ${BUILD_AT_LEVEL0:Uyes:tl} == "no"
# this tells lib.mk and prog.mk to not actually build anything
_SKIP_BUILD = not building at level 0
diff --git a/mk/install-mk b/mk/install-mk
index da15d8041d14..59b1b0151fee 100644
--- a/mk/install-mk
+++ b/mk/install-mk
@@ -55,7 +55,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: install-mk,v 1.90 2013/05/11 05:16:26 sjg Exp $
+# $Id: install-mk,v 1.92 2013/07/27 05:37:37 sjg Exp $
#
# @(#) Copyright (c) 1994 Simon J. Gerraty
#
@@ -70,7 +70,7 @@
# sjg@crufty.net
#
-MK_VERSION=20130505
+MK_VERSION=20130726
OWNER=
GROUP=
MODE=444
diff --git a/mk/lib.mk b/mk/lib.mk
index 24f9527f003f..f219115433ec 100644
--- a/mk/lib.mk
+++ b/mk/lib.mk
@@ -1,4 +1,4 @@
-# $Id: lib.mk,v 1.48 2012/11/12 04:08:18 sjg Exp $
+# $Id: lib.mk,v 1.49 2013/07/18 05:46:24 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -146,9 +146,6 @@ LD_shared=${SHLIB_SHFLAGS}
MKPICLIB?= yes
# sys.mk can override these
-CC_PG?=-pg
-CC_PIC?=-DPIC
-
LD_X?=-X
LD_x?=-x
LD_r?=-r
@@ -284,7 +281,7 @@ SHLIB_AGE != . ${.CURDIR}/shlib_version ; echo $$age
.if (${LD_X} == "")
.c.po:
- ${COMPILE.c} ${CC_PG} ${.IMPSRC} -o ${.TARGET}
+ ${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
.cc.po .C.po:
${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}
@@ -293,14 +290,14 @@ SHLIB_AGE != . ${.CURDIR}/shlib_version ; echo $$age
${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
.else
.c.po:
- @echo ${COMPILE.c} ${CC_PG} ${.IMPSRC} -o ${.TARGET}
- @${COMPILE.c} ${CC_PG} ${.IMPSRC} -o ${.TARGET}.o
+ @echo ${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
+ @${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}.o
@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
@rm -f ${.TARGET}.o
.cc.po .C.po:
- @echo ${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}
- @${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}.o
+ @echo ${COMPILE.cc} ${CXX_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
+ @${COMPILE.cc} ${CXX_PG} ${.IMPSRC} -o ${.TARGET}.o
@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
@rm -f ${.TARGET}.o
@@ -319,7 +316,7 @@ SHLIB_AGE != . ${.CURDIR}/shlib_version ; echo $$age
${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
.S.po .s.po:
- ${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
+ ${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
.else
.c.so:
@@ -335,8 +332,8 @@ SHLIB_AGE != . ${.CURDIR}/shlib_version ; echo $$age
@rm -f ${.TARGET}.o
.S.po .s.po:
- @echo ${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
- @${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
+ @echo ${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
+ @${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
@rm -f ${.TARGET}.o
diff --git a/mk/meta2deps.py b/mk/meta2deps.py
index 8c42303373f0..254f230688a7 100755
--- a/mk/meta2deps.py
+++ b/mk/meta2deps.py
@@ -35,7 +35,7 @@ We only pay attention to a subset of the information in the
"""
RCSid:
- $Id: meta2deps.py,v 1.13 2013/05/11 05:16:26 sjg Exp $
+ $Id: meta2deps.py,v 1.15 2013/07/29 20:41:23 sjg Exp $
Copyright (c) 2011-2013, Juniper Networks, Inc.
All rights reserved.
@@ -77,7 +77,7 @@ def resolve(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
"""
if path.endswith('/.'):
path = path[0:-2]
- if path[0] == '/':
+ if len(path) > 0 and path[0] == '/':
return path
if path == '.':
return cwd
@@ -107,10 +107,12 @@ def abspath(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
this gets called a lot, so we try to avoid calling realpath
until we know we have something.
"""
- path = resolve(path, cwd, last_dir, debug, debug_out)
- if path and (path.find('./') > 0 or
- path.endswith('/..') or
- os.path.islink(path)):
+ rpath = resolve(path, cwd, last_dir, debug, debug_out)
+ if rpath:
+ path = rpath
+ if (path.find('./') > 0 or
+ path.endswith('/..') or
+ os.path.islink(path)):
return os.path.realpath(path)
return path
@@ -191,6 +193,7 @@ class MetaFile:
self.curdir = getv(conf, 'CURDIR')
self.reldir = getv(conf, 'RELDIR')
self.dpdeps = getv(conf, 'DPDEPS')
+ self.line = 0
if not self.conf:
# some of the steps below we want to do only once
@@ -254,7 +257,7 @@ class MetaFile:
self.cwd = os.getcwd() # make sure this is initialized
if name:
- self.parse()
+ self.try_parse()
def reset(self):
"""reset state if we are being passed meta files from multiple directories."""
@@ -333,6 +336,15 @@ class MetaFile:
return ddep
+ def try_parse(self, name=None, file=None):
+ """give file and line number causing exception"""
+ try:
+ self.parse(name, file)
+ except:
+ # give a useful clue
+ print >> sys.stderr, '{}:{}: '.format(self.name, self.line),
+ raise
+
def parse(self, name=None, file=None):
"""A meta file looks like:
@@ -373,11 +385,13 @@ class MetaFile:
pid_last_dir = {}
last_pid = 0
+ self.line = 0
if self.curdir:
self.seenit(self.curdir) # we ignore this
interesting = 'CEFLRV'
for line in f:
+ self.line += 1
# ignore anything we don't care about
if not line[0] in interesting:
continue
@@ -634,7 +648,13 @@ def main(argv, klass=MetaFile, xopts='', xoptf=None):
print >> debug_out, "%s=%s" % (k,v)
for a in args:
- m = klass(a, conf)
+ if a.endswith('.meta'):
+ m = klass(a, conf)
+ elif a.startswith('@'):
+ # there can actually multiple files per line
+ for line in open(a[1:]):
+ for f in line.strip().split():
+ m = klass(f, conf)
if output:
print m.dirdeps()
diff --git a/mk/own.mk b/mk/own.mk
index 85ea66b80094..e29ff9e6d6c7 100644
--- a/mk/own.mk
+++ b/mk/own.mk
@@ -1,4 +1,4 @@
-# $Id: own.mk,v 1.26 2012/12/11 23:40:19 sjg Exp $
+# $Id: own.mk,v 1.27 2013/07/18 05:46:24 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -90,6 +90,7 @@ OPTIONS_DEFAULT_NO+= DPADD_MK
# process options
OPTIONS_DEFAULT_NO+= \
INSTALL_AS_USER \
+ GPROF \
LIBTOOL \
LINT \
META_MODE \
diff --git a/mk/prog.mk b/mk/prog.mk
index 99fd7e81f50e..3a7a07ea78ed 100644
--- a/mk/prog.mk
+++ b/mk/prog.mk
@@ -1,4 +1,4 @@
-# $Id: prog.mk,v 1.24 2012/12/13 23:04:14 sjg Exp $
+# $Id: prog.mk,v 1.25 2013/07/18 05:46:24 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -50,6 +50,15 @@ LIBCRT0= ${DESTDIR}/usr/lib/crt0.o
.include <dpadd.mk>
.endif
+.if ${MK_GPROF} == "yes"
+CFLAGS+= ${CC_PG} ${PROFFLAGS}
+LDADD+= ${CC_PG}
+.if ${MK_DPADD_MK} == "no"
+LDADD_LIBC_P?= -lc_p
+LDADD_LAST+= ${LDADD_LIBC_P}
+.endif
+.endif
+
.if defined(SHAREDSTRINGS)
CLEANFILES+=strings
.c.o:
diff --git a/parse.c b/parse.c
index 14c868b1f9d3..928ff4aa2930 100644
--- a/parse.c
+++ b/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.188 2013/03/22 16:07:59 sjg Exp $ */
+/* $NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.188 2013/03/22 16:07:59 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: parse.c,v 1.188 2013/03/22 16:07:59 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -157,7 +157,7 @@ __RCSID("$NetBSD: parse.c,v 1.188 2013/03/22 16:07:59 sjg Exp $");
* Structure for a file being read ("included file")
*/
typedef struct IFile {
- const char *fname; /* name of file */
+ char *fname; /* name of file */
int lineno; /* current line number in file */
int first_lineno; /* line number of start of text */
int cond_depth; /* 'if' nesting when file opened */
@@ -2344,7 +2344,7 @@ Parse_SetInput(const char *name, int line, int fd,
* name of the include file so error messages refer to the right
* place.
*/
- curFile->fname = name;
+ curFile->fname = bmake_strdup(name);
curFile->lineno = line;
curFile->first_lineno = line;
curFile->nextbuf = nextbuf;
@@ -2357,6 +2357,8 @@ Parse_SetInput(const char *name, int line, int fd,
buf = curFile->nextbuf(curFile->nextbuf_arg, &len);
if (buf == NULL) {
/* Was all a waste of time ... */
+ if (curFile->fname)
+ free(curFile->fname);
free(curFile);
return;
}
diff --git a/unit-tests/Makefile.in b/unit-tests/Makefile.in
index bfd29b261397..78ca92faa1d9 100644
--- a/unit-tests/Makefile.in
+++ b/unit-tests/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.42 2013/03/23 02:31:13 sjg Exp $
+# $Id: Makefile.in,v 1.43 2013/07/16 21:14:30 sjg Exp $
#
-# $NetBSD: Makefile,v 1.36 2013/03/22 16:36:46 sjg Exp $
+# $NetBSD: Makefile,v 1.37 2013/07/16 19:59:28 sjg Exp $
#
# Unit tests for make(1)
# The main targets are:
@@ -89,7 +89,7 @@ test:
@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
${TOOL_TR} -d '\015' | \
- ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \
+ ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[^:]*:,make:,' \
-e '/stopped/s, /.*, unit-tests,' \
-e 's,${.CURDIR:C/\./\\\./g}/,,g' \
-e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
diff --git a/var.c b/var.c
index d0d5266db497..c5c16b8803b6 100644
--- a/var.c
+++ b/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $ */
+/* $NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -139,6 +139,7 @@ __RCSID("$NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $");
#include "dir.h"
#include "job.h"
+extern int makelevel;
/*
* This lets us tell if we have replaced the original environ
* (which we cannot free).
@@ -657,6 +658,15 @@ Var_ExportVars(void)
char *val;
int n;
+ /*
+ * Several make's support this sort of mechanism for tracking
+ * recursion - but each uses a different name.
+ * We allow the makefiles to update MAKELEVEL and ensure
+ * children see a correctly incremented value.
+ */
+ snprintf(tmp, sizeof(tmp), "%d", makelevel + 1);
+ setenv(MAKE_LEVEL_ENV, tmp, 1);
+
if (VAR_EXPORTED_NONE == var_exportedVars)
return;
@@ -778,7 +788,7 @@ Var_UnExport(char *str)
if (unexport_env) {
char **newenv;
- cp = getenv(MAKE_LEVEL); /* we should preserve this */
+ cp = getenv(MAKE_LEVEL_ENV); /* we should preserve this */
if (environ == savedEnv) {
/* we have been here before! */
newenv = bmake_realloc(environ, 2 * sizeof(char *));
@@ -795,10 +805,7 @@ Var_UnExport(char *str)
environ = savedEnv = newenv;
newenv[0] = NULL;
newenv[1] = NULL;
- setenv(MAKE_LEVEL, cp, 1);
-#ifdef MAKE_LEVEL_SAFE
- setenv(MAKE_LEVEL_SAFE, cp, 1);
-#endif
+ setenv(MAKE_LEVEL_ENV, cp, 1);
} else {
for (; *str != '\n' && isspace((unsigned char) *str); str++)
continue;
@@ -922,6 +929,14 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags)
}
v = VarFind(name, ctxt, 0);
if (v == NULL) {
+ if (ctxt == VAR_CMD && (flags & VAR_NO_EXPORT) == 0) {
+ /*
+ * This var would normally prevent the same name being added
+ * to VAR_GLOBAL, so delete it from there if needed.
+ * Otherwise -V name may show the wrong value.
+ */
+ Var_Delete(name, VAR_GLOBAL);
+ }
VarAdd(name, val, ctxt);
} else {
Buf_Empty(&v->val);
@@ -956,25 +971,6 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags)
Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
}
- /*
- * Another special case.
- * Several make's support this sort of mechanism for tracking
- * recursion - but each uses a different name.
- * We allow the makefiles to update .MAKE.LEVEL and ensure
- * children see a correctly incremented value.
- */
- if (ctxt == VAR_GLOBAL && strcmp(MAKE_LEVEL, name) == 0) {
- char tmp[64];
- int level;
-
- level = atoi(val);
- snprintf(tmp, sizeof(tmp), "%u", level + 1);
- setenv(MAKE_LEVEL, tmp, 1);
-#ifdef MAKE_LEVEL_SAFE
- setenv(MAKE_LEVEL_SAFE, tmp, 1);
-#endif
- }
-
out:
if (expanded_name != NULL)