Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Mar 2008 15:30:16 -0800
From:      "David O'Brien" <obrien@freebsd.org>
To:        freebsd-arch@freebsd.org
Subject:   Tweaking the "Remaking Makefiles" feature
Message-ID:  <20080304233016.GA2334@dragon.NUXI.org>

next in thread | raw e-mail | index | archive | help
Last year Max Khon implemented something called the "Remaking Makefiles"
feature to make(1):
  After reading Makefile and all the files that are included using .include
  or .sinclude directives (source Makefiles) make considers each source
  Makefile as a target and tries to rebuild it.  Both explicit and implicit
  rules are checked and all source Makefiles are updated if necessary. If
  any of the source Makefiles were rebuilt, make restarts from clean state.
  ..
  When remaking a source Makefile options -t (touch target), -q (query
  mode), and -n (no exec) do not take effect, unless source Makefile is
  specified explicitly as a target in make command line.
  Additionally, system makefiles and .depend are not considered as a
  Makefiles that can be rebuilt.
 

While I find the feature neat, I find this feature (enabled by default)
way too dangerous.  It caused a major problem with the CVS 1.11.22 import
I did, and I feel it could easily catch others off guard.  So I think it
should be turned off by default.  (How many of you didn't realize 'make
-n' could write to files?)

I propose a new directive called ".MAKEFILEDEPS" which enables it.
(TODO: man page update)

Index: globals.h
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/globals.h,v
retrieving revision 1.11
diff -u -p -r1.11 globals.h
--- globals.h	8 Mar 2007 09:16:10 -0000	1.11
+++ globals.h	4 Mar 2008 22:14:27 -0000
@@ -78,6 +78,7 @@ extern Boolean	beVerbose;	/* True if sho
 extern Boolean	noExecute;	/* True if should execute nothing */
 extern Boolean	allPrecious;	/* True if every target is precious */
 extern Boolean	is_posix;	/* .POSIX target seen */
+extern Boolean	mfAutoDeps;	/* .MAKEFILEDEPS target seen */
 
 /* True if should continue on unaffected portions of the graph
  * when have an error in one portion */
Index: hash_tables.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/hash_tables.c,v
retrieving revision 1.3
diff -u -p -r1.3 hash_tables.c
--- hash_tables.c	26 Sep 2005 20:31:00 -0000	1.3
+++ hash_tables.c	4 Mar 2008 23:13:34 -0000
@@ -1,7 +1,7 @@
 /*
  * DO NOT EDIT
- * $FreeBSD: src/usr.bin/make/hash_tables.c,v 1.3 2005/09/26 20:31:00 phk Exp $
- * auto-generated from FreeBSD: src/usr.bin/make/parse.c,v 1.108 2005/05/24 15:30:03 harti Exp 
+ * $FreeBSD$
+ * auto-generated from FreeBSD: src/usr.bin/make/parse.c,v 1.113 2007/04/12 18:14:00 ru Exp 
  * DO NOT EDIT
  */
 #include <sys/types.h>
@@ -66,12 +66,12 @@ directive_hash(const u_char *key, size_t
 }
 /*
  * d=2
- * n=72
- * m=34
+ * n=74
+ * m=35
  * c=2.09
  * maxlen=1
  * minklen=4
- * maxklen=12
+ * maxklen=13
  * minchar=46
  * maxchar=95
  * loop=0
@@ -80,30 +80,30 @@ directive_hash(const u_char *key, size_t
  */
 
 static const signed char keyword_g[] = {
-	8, 15, -1, 25, 22, 20, -1, 33, 16, -1,
-	21, 31, 0, 0, 0, 29, 30, 8, -1, 0,
-	-1, 21, -1, 0, -1, -1, -1, -1, -1, 4,
-	-1, -1, 25, 28, -1, 27, 11, 23, 0, 0,
-	24, -1, -1, 0, 3, 0, -1, 24, 0, 0,
-	-1, 28, 12, -1, 20, 13, -1, 5, -1, 1,
-	0, 0, -1, 0, 10, 19, 13, 9, -1, 2,
-	-1, -1, 
+	12, 18, 7, 25, 30, 5, -1, -1, -1, 7,
+	-1, 0, 33, 0, 4, -1, -1, 13, 29, 0,
+	-1, 28, -1, 28, -1, 0, -1, 27, 4, 34,
+	-1, -1, -1, 30, 13, 10, -1, -1, 0, 10,
+	24, -1, -1, -1, 0, 6, 0, 0, -1, 23,
+	-1, -1, -1, 0, -1, 23, -1, -1, 19, 4,
+	-1, 31, 12, 16, -1, 20, 22, 9, 0, -1,
+	-1, 9, 4, 0, 
 };
 
 static const u_char keyword_T0[] = {
-	32, 10, 54, 61, 2, 35, 62, 50, 52, 53,
-	70, 7, 62, 18, 24, 30, 31, 66, 10, 61,
-	52, 71, 56, 56, 28, 6, 33, 67, 12, 41,
-	39, 45, 51, 21, 34, 53, 56, 40, 47, 52,
-	21, 61, 60, 12, 7, 28, 42, 38, 38, 52,
+	34, 28, 50, 61, 14, 57, 48, 60, 20, 67,
+	60, 63, 0, 24, 28, 2, 49, 64, 18, 23,
+	36, 33, 40, 14, 38, 42, 71, 49, 2, 53,
+	53, 37, 7, 29, 24, 21, 12, 50, 59, 10,
+	43, 23, 0, 44, 47, 6, 46, 22, 48, 64,
 };
 
 static const u_char keyword_T1[] = {
-	0, 39, 65, 48, 13, 62, 46, 42, 5, 50,
-	69, 69, 69, 43, 2, 46, 12, 6, 11, 9,
-	24, 10, 25, 64, 68, 13, 57, 55, 17, 33,
-	1, 18, 0, 67, 10, 14, 57, 56, 0, 6,
-	50, 13, 3, 47, 56, 22, 37, 13, 28, 48,
+	18, 67, 39, 60, 7, 70, 2, 26, 31, 18,
+	73, 47, 61, 17, 38, 50, 22, 52, 13, 55,
+	56, 32, 63, 4, 64, 55, 49, 21, 47, 67,
+	33, 66, 60, 73, 30, 68, 69, 32, 72, 4,
+	28, 49, 51, 15, 66, 68, 43, 67, 46, 56,
 };
 
 
@@ -113,7 +113,7 @@ keyword_hash(const u_char *key, size_t l
 	unsigned f0, f1;
 	const u_char *kp = key;
 
-	if (len < 4 || len > 12)
+	if (len < 4 || len > 13)
 		return -1;
 
 	for (f0=f1=0; *kp; ++kp) {
@@ -123,8 +123,8 @@ keyword_hash(const u_char *key, size_t l
 		f1 += keyword_T1[-46 + *kp];
 	}
 
-	f0 %= 72;
-	f1 %= 72;
+	f0 %= 74;
+	f1 %= 74;
 
-	return (keyword_g[f0] + keyword_g[f1]) % 34;
+	return (keyword_g[f0] + keyword_g[f1]) % 35;
 }
Index: main.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/main.c,v
retrieving revision 1.165
diff -u -p -r1.165 main.c
--- main.c	4 Mar 2008 06:08:59 -0000	1.165
+++ main.c	4 Mar 2008 22:14:20 -0000
@@ -123,6 +123,7 @@ Lst create = Lst_Initializer(create);
 
 Boolean		allPrecious;	/* .PRECIOUS given on line by itself */
 Boolean		is_posix;	/* .POSIX target seen */
+Boolean		mfAutoDeps;	/* .MAKEFILEDEPS target seen */
 Boolean		beSilent;	/* -s flag */
 Boolean		beVerbose;	/* -v flag */
 Boolean		compatMake;	/* -B argument */
@@ -1250,7 +1251,7 @@ main(int argc, char **argv)
 		 */
 		Lst targs = Lst_Initializer(targs);
 
-		if (!is_posix) {
+		if (!is_posix && mfAutoDeps) {
 			/*
 			 * Check if any of the makefiles are out-of-date.
 			 */
Index: parse.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/parse.c,v
retrieving revision 1.113
diff -u -p -r1.113 parse.c
--- parse.c	12 Apr 2007 18:14:00 -0000	1.113
+++ parse.c	4 Mar 2008 22:14:47 -0000
@@ -168,6 +168,7 @@ typedef enum {
 	ExPath,		/* .PATH */
 	Phony,		/* .PHONY */
 	Posix,		/* .POSIX */
+	MakefileDeps,	/* .MAKEFILEDEPS */
 	Precious,	/* .PRECIOUS */
 	ExShell,	/* .SHELL */
 	Silent,		/* .SILENT */
@@ -213,6 +214,7 @@ static const struct keyword {
 	{ ".LIBS",		Libs,		0 },
 	{ ".MAIN",		Main,		0 },
 	{ ".MAKE",		Attribute,	OP_MAKE },
+	{ ".MAKEFILEDEPS",	MakefileDeps,	0 },
 	{ ".MAKEFLAGS",		MFlags,		0 },
 	{ ".MFLAGS",		MFlags,		0 },
 	{ ".NOTMAIN",		Attribute,	OP_NOTMAIN },
@@ -1069,6 +1071,9 @@ ParseDoDependency(char *line)
 			LST_FOREACH(ln, &paths)
 			Path_Clear(Lst_Datum(ln));
 			break;
+		  case MakefileDeps:
+			mfAutoDeps = TRUE;
+			break;
 		  case Posix:
 			is_posix = TRUE;
 			Var_Set("%POSIX", "1003.2", VAR_GLOBAL);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080304233016.GA2334>