Sat Mar 23 05:31:29 2013 UTC ()
If built with filemon support, set .MAKE.PATH_FILEMON to _PATH_FILEMON
so that makefiles can test for it.


(sjg)
diff -r1.209 -r1.210 src/usr.bin/make/main.c
diff -r1.211 -r1.212 src/usr.bin/make/make.1
diff -r1.26 -r1.27 src/usr.bin/make/meta.c
diff -r1.2 -r1.3 src/usr.bin/make/meta.h

cvs diff -r1.209 -r1.210 src/usr.bin/make/main.c (expand / switch to unified diff)

--- src/usr.bin/make/main.c 2013/02/26 00:45:27 1.209
+++ src/usr.bin/make/main.c 2013/03/23 05:31:29 1.210
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: main.c,v 1.209 2013/02/26 00:45:27 christos Exp $ */ 1/* $NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990, 1993 4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -59,39 +59,39 @@ @@ -59,39 +59,39 @@
59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE. 68 * SUCH DAMAGE.
69 */ 69 */
70 70
71#ifndef MAKE_NATIVE 71#ifndef MAKE_NATIVE
72static char rcsid[] = "$NetBSD: main.c,v 1.209 2013/02/26 00:45:27 christos Exp $"; 72static char rcsid[] = "$NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $";
73#else 73#else
74#include <sys/cdefs.h> 74#include <sys/cdefs.h>
75#ifndef lint 75#ifndef lint
76__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ 76__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
77 The Regents of the University of California. All rights reserved."); 77 The Regents of the University of California. All rights reserved.");
78#endif /* not lint */ 78#endif /* not lint */
79 79
80#ifndef lint 80#ifndef lint
81#if 0 81#if 0
82static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; 82static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
83#else 83#else
84__RCSID("$NetBSD: main.c,v 1.209 2013/02/26 00:45:27 christos Exp $"); 84__RCSID("$NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $");
85#endif 85#endif
86#endif /* not lint */ 86#endif /* not lint */
87#endif 87#endif
88 88
89/*- 89/*-
90 * main.c -- 90 * main.c --
91 * The main file for this entire program. Exit routines etc 91 * The main file for this entire program. Exit routines etc
92 * reside here. 92 * reside here.
93 * 93 *
94 * Utility functions defined in this file: 94 * Utility functions defined in this file:
95 * Main_ParseArgLine Takes a line of arguments, breaks them and 95 * Main_ParseArgLine Takes a line of arguments, breaks them and
96 * treats them as if they were given when first 96 * treats them as if they were given when first
97 * invoked. Used by the parse module to implement 97 * invoked. Used by the parse module to implement
@@ -729,27 +729,27 @@ MakeMode(const char *mode) @@ -729,27 +729,27 @@ MakeMode(const char *mode)
729{ 729{
730 char *mp = NULL; 730 char *mp = NULL;
731 731
732 if (!mode) 732 if (!mode)
733 mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}", VAR_GLOBAL, 0); 733 mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}", VAR_GLOBAL, 0);
734 734
735 if (mode && *mode) { 735 if (mode && *mode) {
736 if (strstr(mode, "compat")) { 736 if (strstr(mode, "compat")) {
737 compatMake = TRUE; 737 compatMake = TRUE;
738 forceJobs = FALSE; 738 forceJobs = FALSE;
739 } 739 }
740#if USE_META 740#if USE_META
741 if (strstr(mode, "meta")) 741 if (strstr(mode, "meta"))
742 meta_init(mode); 742 meta_mode_init(mode);
743#endif 743#endif
744 } 744 }
745 if (mp) 745 if (mp)
746 free(mp); 746 free(mp);
747} 747}
748 748
749/*- 749/*-
750 * main -- 750 * main --
751 * The main function, for obvious reasons. Initializes variables 751 * The main function, for obvious reasons. Initializes variables
752 * and a few modules, then parses the arguments give it in the 752 * and a few modules, then parses the arguments give it in the
753 * environment and on the command line. Reads the system makefile 753 * environment and on the command line. Reads the system makefile
754 * followed by either Makefile, makefile or the file given by the 754 * followed by either Makefile, makefile or the file given by the
755 * -f argument. Sets the .MAKEFLAGS PMake variable based on all the 755 * -f argument. Sets the .MAKEFLAGS PMake variable based on all the
@@ -941,26 +941,29 @@ main(int argc, char **argv) @@ -941,26 +941,29 @@ main(int argc, char **argv)
941 const char *ep; 941 const char *ep;
942 942
943 if (!(ep = getenv(MAKE_LEVEL))) { 943 if (!(ep = getenv(MAKE_LEVEL))) {
944 ep = "0"; 944 ep = "0";
945 } 945 }
946 Var_Set(MAKE_LEVEL, ep, VAR_GLOBAL, 0); 946 Var_Set(MAKE_LEVEL, ep, VAR_GLOBAL, 0);
947 snprintf(tmp, sizeof(tmp), "%u", myPid); 947 snprintf(tmp, sizeof(tmp), "%u", myPid);
948 Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0); 948 Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0);
949 snprintf(tmp, sizeof(tmp), "%u", getppid()); 949 snprintf(tmp, sizeof(tmp), "%u", getppid());
950 Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0); 950 Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0);
951 } 951 }
952 Job_SetPrefix(); 952 Job_SetPrefix();
953 953
 954#ifdef USE_META
 955 meta_init();
 956#endif
954 /* 957 /*
955 * First snag any flags out of the MAKE environment variable. 958 * First snag any flags out of the MAKE environment variable.
956 * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's 959 * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's
957 * in a different format). 960 * in a different format).
958 */ 961 */
959#ifdef POSIX 962#ifdef POSIX
960 Main_ParseArgLine(getenv("MAKEFLAGS")); 963 Main_ParseArgLine(getenv("MAKEFLAGS"));
961#else 964#else
962 Main_ParseArgLine(getenv("MAKE")); 965 Main_ParseArgLine(getenv("MAKE"));
963#endif 966#endif
964 967
965 /* 968 /*
966 * Find where we are (now). 969 * Find where we are (now).

cvs diff -r1.211 -r1.212 src/usr.bin/make/make.1 (expand / switch to unified diff)

--- src/usr.bin/make/make.1 2013/03/05 22:01:44 1.211
+++ src/usr.bin/make/make.1 2013/03/23 05:31:29 1.212
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: make.1,v 1.211 2013/03/05 22:01:44 christos Exp $ 1.\" $NetBSD: make.1,v 1.212 2013/03/23 05:31:29 sjg Exp $
2.\" 2.\"
3.\" Copyright (c) 1990, 1993 3.\" Copyright (c) 1990, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors 14.\" 3. Neither the name of the University nor the names of its contributors
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE. 28.\" SUCH DAMAGE.
29.\" 29.\"
30.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 30.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
31.\" 31.\"
32.Dd March 5, 2013 32.Dd March 22, 2013
33.Dt MAKE 1 33.Dt MAKE 1
34.Os 34.Os
35.Sh NAME 35.Sh NAME
36.Nm make 36.Nm make
37.Nd maintain program dependencies 37.Nd maintain program dependencies
38.Sh SYNOPSIS 38.Sh SYNOPSIS
39.Nm 39.Nm
40.Op Fl BeikNnqrstWX 40.Op Fl BeikNnqrstWX
41.Op Fl C Ar directory 41.Op Fl C Ar directory
42.Op Fl D Ar variable 42.Op Fl D Ar variable
43.Op Fl d Ar flags 43.Op Fl d Ar flags
44.Op Fl f Ar makefile 44.Op Fl f Ar makefile
45.Op Fl I Ar directory 45.Op Fl I Ar directory
@@ -864,26 +864,33 @@ The default value is: @@ -864,26 +864,33 @@ The default value is:
864This variable is used to record the names of variables assigned to 864This variable is used to record the names of variables assigned to
865on the command line, so that they may be exported as part of 865on the command line, so that they may be exported as part of
866.Ql Ev MAKEFLAGS . 866.Ql Ev MAKEFLAGS .
867This behaviour can be disabled by assigning an empty value to 867This behaviour can be disabled by assigning an empty value to
868.Ql Va .MAKEOVERRIDES 868.Ql Va .MAKEOVERRIDES
869within a makefile. 869within a makefile.
870Extra variables can be exported from a makefile 870Extra variables can be exported from a makefile
871by appending their names to 871by appending their names to
872.Ql Va .MAKEOVERRIDES . 872.Ql Va .MAKEOVERRIDES .
873.Ql Ev MAKEFLAGS 873.Ql Ev MAKEFLAGS
874is re-exported whenever 874is re-exported whenever
875.Ql Va .MAKEOVERRIDES 875.Ql Va .MAKEOVERRIDES
876is modified. 876is modified.
 877.It Va .MAKE.PATH_FILEMON
 878If
 879.Nm
 880was built with
 881.Xr filemon 4
 882support, this is set to the path of the device node.
 883This allows makefiles to test for this support.
877.It Va .MAKE.PID 884.It Va .MAKE.PID
878The process-id of 885The process-id of
879.Nm . 886.Nm .
880.It Va .MAKE.PPID 887.It Va .MAKE.PPID
881The parent process-id of 888The parent process-id of
882.Nm . 889.Nm .
883.It Va MAKE_PRINT_VAR_ON_ERROR 890.It Va MAKE_PRINT_VAR_ON_ERROR
884When 891When
885.Nm 892.Nm
886stops due to an error, it prints its name and the value of 893stops due to an error, it prints its name and the value of
887.Ql Va .CURDIR 894.Ql Va .CURDIR
888as well as the value of any variables named in 895as well as the value of any variables named in
889.Ql Va MAKE_PRINT_VAR_ON_ERROR . 896.Ql Va MAKE_PRINT_VAR_ON_ERROR .

cvs diff -r1.26 -r1.27 src/usr.bin/make/meta.c (expand / switch to unified diff)

--- src/usr.bin/make/meta.c 2013/01/19 04:23:37 1.26
+++ src/usr.bin/make/meta.c 2013/03/23 05:31:29 1.27
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: meta.c,v 1.26 2013/01/19 04:23:37 sjg Exp $ */ 1/* $NetBSD: meta.c,v 1.27 2013/03/23 05:31:29 sjg Exp $ */
2 2
3/* 3/*
4 * Implement 'meta' mode. 4 * Implement 'meta' mode.
5 * Adapted from John Birrell's patches to FreeBSD make. 5 * Adapted from John Birrell's patches to FreeBSD make.
6 * --sjg 6 * --sjg
7 */ 7 */
8/* 8/*
9 * Copyright (c) 2009-2010, Juniper Networks, Inc. 9 * Copyright (c) 2009-2010, Juniper Networks, Inc.
10 * Portions Copyright (c) 2009, John Birrell. 10 * Portions Copyright (c) 2009, John Birrell.
11 *  11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions  13 * modification, are permitted provided that the following conditions
14 * are met:  14 * are met:
@@ -529,28 +529,44 @@ static Boolean @@ -529,28 +529,44 @@ static Boolean
529boolValue(char *s) 529boolValue(char *s)
530{ 530{
531 switch(*s) { 531 switch(*s) {
532 case '0': 532 case '0':
533 case 'N': 533 case 'N':
534 case 'n': 534 case 'n':
535 case 'F': 535 case 'F':
536 case 'f': 536 case 'f':
537 return FALSE; 537 return FALSE;
538 } 538 }
539 return TRUE; 539 return TRUE;
540} 540}
541 541
 542/*
 543 * Initialization we need before reading makefiles.
 544 */
 545void
 546meta_init()
 547{
 548#ifdef USE_FILEMON
 549 /* this allows makefiles to test if we have filemon support */
 550 Var_Set(".MAKE.PATH_FILEMON", _PATH_FILEMON, VAR_GLOBAL, 0);
 551#endif
 552}
 553
 554
 555/*
 556 * Initialization we need after reading makefiles.
 557 */
542void 558void
543meta_init(const char *make_mode) 559meta_mode_init(const char *make_mode)
544{ 560{
545 static int once = 0; 561 static int once = 0;
546 char *cp; 562 char *cp;
547 563
548 useMeta = TRUE; 564 useMeta = TRUE;
549 useFilemon = TRUE; 565 useFilemon = TRUE;
550 writeMeta = TRUE; 566 writeMeta = TRUE;
551 567
552 if (make_mode) { 568 if (make_mode) {
553 if (strstr(make_mode, "env")) 569 if (strstr(make_mode, "env"))
554 metaEnv = TRUE; 570 metaEnv = TRUE;
555 if (strstr(make_mode, "verb")) 571 if (strstr(make_mode, "verb"))
556 metaVerbose = TRUE; 572 metaVerbose = TRUE;

cvs diff -r1.2 -r1.3 src/usr.bin/make/meta.h (expand / switch to unified diff)

--- src/usr.bin/make/meta.h 2011/03/30 22:03:49 1.2
+++ src/usr.bin/make/meta.h 2013/03/23 05:31:29 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: meta.h,v 1.2 2011/03/30 22:03:49 sjg Exp $ */ 1/* $NetBSD: meta.h,v 1.3 2013/03/23 05:31:29 sjg Exp $ */
2 2
3/* 3/*
4 * Things needed for 'meta' mode. 4 * Things needed for 'meta' mode.
5 */ 5 */
6/* 6/*
7 * Copyright (c) 2009-2010, Juniper Networks, Inc. 7 * Copyright (c) 2009-2010, Juniper Networks, Inc.
8 *  8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions  10 * modification, are permitted provided that the following conditions
11 * are met:  11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.  13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -31,24 +31,25 @@ @@ -31,24 +31,25 @@
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34typedef struct BuildMon { 34typedef struct BuildMon {
35 char meta_fname[MAXPATHLEN]; 35 char meta_fname[MAXPATHLEN];
36 int filemon_fd; 36 int filemon_fd;
37 int mon_fd; 37 int mon_fd;
38 FILE *mfp; 38 FILE *mfp;
39} BuildMon; 39} BuildMon;
40 40
41extern Boolean useMeta; 41extern Boolean useMeta;
42 42
43struct Job; /* not defined yet */ 43struct Job; /* not defined yet */
44void meta_init(const char *); 44void meta_init(void);
 45void meta_mode_init(const char *);
45void meta_job_start(struct Job *, GNode *); 46void meta_job_start(struct Job *, GNode *);
46void meta_job_child(struct Job *); 47void meta_job_child(struct Job *);
47void meta_job_error(struct Job *, GNode *, int, int); 48void meta_job_error(struct Job *, GNode *, int, int);
48void meta_job_output(struct Job *, char *, const char *); 49void meta_job_output(struct Job *, char *, const char *);
49void meta_cmd_finish(void *); 50void meta_cmd_finish(void *);
50void meta_job_finish(struct Job *); 51void meta_job_finish(struct Job *);
51Boolean meta_oodate(GNode *, Boolean); 52Boolean meta_oodate(GNode *, Boolean);
52void meta_compat_start(void); 53void meta_compat_start(void);
53void meta_compat_child(void); 54void meta_compat_child(void);
54void meta_compat_parent(void); 55void meta_compat_parent(void);