Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Jul 2018 21:24:28 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r336938 - stable/11/usr.sbin/config
Message-ID:  <201807302124.w6ULOSsT096076@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Mon Jul 30 21:24:27 2018
New Revision: 336938
URL: https://svnweb.freebsd.org/changeset/base/336938

Log:
  MFC r307967,324082,325955: config(8) fixes
  
  r307967: Allow config to be compiled from another source directory, such as
  one for building tools. This boils down to replacing ${.CURDIR} with
  ${SRCDIR}, where the latter is the directory in which this makefile
  lives.
  
  Also allow overriding where file2c comes from using ${FILE2C}.
  
  r324082: Typo in filename in comment.
  
  r325955: Fix 'local' to not look in the source tree for the file.
  
  Usually 'local' is used along with other rules such as 'no-implicit-rule' or
  'dependency' which avoids this problem.  It's possible to need to use
  'local' while relying on the default rules though for a file which is not in
  the source tree nor generated in the kernel.

Modified:
  stable/11/usr.sbin/config/Makefile
  stable/11/usr.sbin/config/config.h
  stable/11/usr.sbin/config/configvers.h
  stable/11/usr.sbin/config/mkmakefile.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/config/Makefile
==============================================================================
--- stable/11/usr.sbin/config/Makefile	Mon Jul 30 21:13:42 2018	(r336937)
+++ stable/11/usr.sbin/config/Makefile	Mon Jul 30 21:24:27 2018	(r336938)
@@ -1,15 +1,20 @@
 # 	@(#)Makefile	8.1 (Berkeley) 6/6/93
 # $FreeBSD$
 
+SRCDIR:=${.PARSEDIR:tA}
+
 PROG=	config
 MAN=	config.5 config.8
 SRCS=	config.y main.c lang.l mkmakefile.c mkheaders.c \
 	mkoptions.c y.tab.h kernconf.c
 
+FILE2C?=file2c
+
 kernconf.c: kernconf.tmpl
-	file2c 'char kernconfstr[] = {' ',0};' < ${.CURDIR}/kernconf.tmpl > kernconf.c
+	${FILE2C} 'char kernconfstr[] = {' ',0};' < \
+	    ${SRCDIR}/kernconf.tmpl > kernconf.c
 
-CFLAGS+= -I. -I${.CURDIR}
+CFLAGS+= -I. -I${SRCDIR}
 
 NO_WMISSING_VARIABLE_DECLARATIONS=
 

Modified: stable/11/usr.sbin/config/config.h
==============================================================================
--- stable/11/usr.sbin/config/config.h	Mon Jul 30 21:13:42 2018	(r336937)
+++ stable/11/usr.sbin/config/config.h	Mon Jul 30 21:24:27 2018	(r336938)
@@ -55,6 +55,7 @@ struct file_list {
 	char	*f_clean;		/* File list to add to clean rule */
 	char	*f_warn;		/* warning message */
 	const char *f_objprefix;	/* prefix string for object name */
+	const char *f_srcprefix;	/* source prefix such as $S/ */
 };
 
 struct files_name {
@@ -161,7 +162,7 @@ struct includepath {
 SLIST_HEAD(, includepath) includepath;
 
 /*
- * Tag present in the kernelconf.tmlp template file. It's mandatory for those
+ * Tag present in the kernconf.tmpl template file. It's mandatory for those
  * two strings to be the same. Otherwise you'll get into trouble.
  */
 #define	KERNCONFTAG	"%%KERNCONFFILE%%"

Modified: stable/11/usr.sbin/config/configvers.h
==============================================================================
--- stable/11/usr.sbin/config/configvers.h	Mon Jul 30 21:13:42 2018	(r336937)
+++ stable/11/usr.sbin/config/configvers.h	Mon Jul 30 21:24:27 2018	(r336938)
@@ -49,5 +49,5 @@
  *
  * $FreeBSD$
  */
-#define	CONFIGVERS	600014
+#define	CONFIGVERS	600015
 #define	MAJOR_VERS(x)	((x) / 100000)

Modified: stable/11/usr.sbin/config/mkmakefile.c
==============================================================================
--- stable/11/usr.sbin/config/mkmakefile.c	Mon Jul 30 21:13:42 2018	(r336937)
+++ stable/11/usr.sbin/config/mkmakefile.c	Mon Jul 30 21:24:27 2018	(r336938)
@@ -535,6 +535,10 @@ nextparam:;
 		tp = new_fent();
 		tp->f_fn = this;
 		tp->f_type = filetype;
+		if (filetype == LOCAL)
+			tp->f_srcprefix = "";
+		else
+			tp->f_srcprefix = "$S/";
 		if (imp_rule)
 			tp->f_flags |= NO_IMPLCT_RULE;
 		if (no_obj)
@@ -610,7 +614,8 @@ do_before_depend(FILE *fp)
 			if (tp->f_flags & NO_IMPLCT_RULE)
 				fprintf(fp, "%s ", tp->f_fn);
 			else
-				fprintf(fp, "$S/%s ", tp->f_fn);
+				fprintf(fp, "%s%s ", tp->f_srcprefix,
+				    tp->f_fn);
 			lpos += len + 1;
 		}
 	if (lpos != 8)
@@ -675,10 +680,7 @@ do_xxfiles(char *tag, FILE *fp)
 				lpos = 8;
 				fputs("\\\n\t", fp);
 			}
-			if (tp->f_type != LOCAL)
-				fprintf(fp, "$S/%s ", tp->f_fn);
-			else
-				fprintf(fp, "%s ", tp->f_fn);
+			fprintf(fp, "%s%s ", tp->f_srcprefix, tp->f_fn);
 			lpos += len + 1;
 		}
 	free(suff);
@@ -724,25 +726,30 @@ do_rules(FILE *f)
 		else {
 			*cp = '\0';
 			if (och == 'o') {
-				fprintf(f, "%s%so:\n\t-cp $S/%so .\n\n",
-					ftp->f_objprefix, tail(np), np);
+				fprintf(f, "%s%so:\n\t-cp %s%so .\n\n",
+					ftp->f_objprefix, tail(np),
+					ftp->f_srcprefix, np);
 				continue;
 			}
 			if (ftp->f_depends) {
-				fprintf(f, "%s%sln: $S/%s%c %s\n",
-					ftp->f_objprefix, tail(np), np, och,
+				fprintf(f, "%s%sln: %s%s%c %s\n",
+					ftp->f_objprefix, tail(np),
+					ftp->f_srcprefix, np, och,
 					ftp->f_depends);
 				fprintf(f, "\t${NORMAL_LINT}\n\n");
-				fprintf(f, "%s%so: $S/%s%c %s\n",
-					ftp->f_objprefix, tail(np), np, och,
+				fprintf(f, "%s%so: %s%s%c %s\n",
+					ftp->f_objprefix, tail(np),
+					ftp->f_srcprefix, np, och,
 					ftp->f_depends);
 			}
 			else {
-				fprintf(f, "%s%sln: $S/%s%c\n",
-					ftp->f_objprefix, tail(np), np, och);
+				fprintf(f, "%s%sln: %s%s%c\n",
+					ftp->f_objprefix, tail(np),
+					ftp->f_srcprefix, np, och);
 				fprintf(f, "\t${NORMAL_LINT}\n\n");
-				fprintf(f, "%s%so: $S/%s%c\n",
-					ftp->f_objprefix, tail(np), np, och);
+				fprintf(f, "%s%so: %s%s%c\n",
+					ftp->f_objprefix, tail(np),
+					ftp->f_srcprefix, np, och);
 			}
 		}
 		compilewith = ftp->f_compilewith;
@@ -771,7 +778,8 @@ do_rules(FILE *f)
 		}
 		*cp = och;
 		if (strlen(ftp->f_objprefix))
-			fprintf(f, "\t%s $S/%s\n", compilewith, np);
+			fprintf(f, "\t%s %s%s\n", compilewith,
+			    ftp->f_srcprefix, np);
 		else
 			fprintf(f, "\t%s\n", compilewith);
 



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