Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jun 2010 08:04:42 +0000 (UTC)
From:      Jeff Roberson <jeff@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r209421 - projects/ofed/head/usr.sbin/config
Message-ID:  <201006220804.o5M84gwB083001@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jeff
Date: Tue Jun 22 08:04:42 2010
New Revision: 209421
URL: http://svn.freebsd.org/changeset/base/209421

Log:
   - Add support for per-file object prefixes that can be used to
     disambiguate source files with the same name.
  
  Reviewed by:	bsdimp
  Sponsored by:	Isilon Systems, iX Systems, and Panasas.

Modified:
  projects/ofed/head/usr.sbin/config/config.h
  projects/ofed/head/usr.sbin/config/mkmakefile.c

Modified: projects/ofed/head/usr.sbin/config/config.h
==============================================================================
--- projects/ofed/head/usr.sbin/config/config.h	Tue Jun 22 08:02:50 2010	(r209420)
+++ projects/ofed/head/usr.sbin/config/config.h	Tue Jun 22 08:04:42 2010	(r209421)
@@ -53,6 +53,7 @@ struct file_list {
 	char	*f_depends;		/* additional dependancies */
 	char	*f_clean;		/* File list to add to clean rule */
 	char	*f_warn;		/* warning message */
+	const char *f_objprefix;	/* prefix string for object name */
 };
 
 struct files_name {

Modified: projects/ofed/head/usr.sbin/config/mkmakefile.c
==============================================================================
--- projects/ofed/head/usr.sbin/config/mkmakefile.c	Tue Jun 22 08:02:50 2010	(r209420)
+++ projects/ofed/head/usr.sbin/config/mkmakefile.c	Tue Jun 22 08:04:42 2010	(r209421)
@@ -310,6 +310,7 @@ read_file(char *fname)
 	struct device *dp;
 	struct opt *op;
 	char *wd, *this, *compilewith, *depends, *clean, *warning;
+	const char *objprefix;
 	int compile, match, nreqs, std, filetype,
 	    imp_rule, no_obj, before_depend, mandatory, nowerror;
 
@@ -324,6 +325,7 @@ next:
 	 *	[ compile-with "compile rule" [no-implicit-rule] ]
 	 *      [ dependency "dependency-list"] [ before-depend ]
 	 *	[ clean "file-list"] [ warning "text warning" ]
+	 *	[ obj-prefix "file prefix"]
 	 */
 	wd = get_word(fp);
 	if (wd == (char *)EOF) {
@@ -371,6 +373,7 @@ next:
 	before_depend = 0;
 	nowerror = 0;
 	filetype = NORMAL;
+	objprefix = "";
 	if (eq(wd, "standard")) {
 		std = 1;
 	/*
@@ -461,6 +464,16 @@ nextparam:
 		warning = ns(wd);
 		goto nextparam;
 	}
+	if (eq(wd, "obj-prefix")) {
+		next_quoted_word(fp, wd);
+		if (wd == 0) {
+			printf("%s: %s missing object prefix string.\n",
+				fname, this);
+			exit(1);
+		}
+		objprefix = ns(wd);
+		goto nextparam;
+	}
 	nreqs++;
 	if (eq(wd, "local")) {
 		filetype = LOCAL;
@@ -528,6 +541,7 @@ doneparam:
 	tp->f_depends = depends;
 	tp->f_clean = clean;
 	tp->f_warn = warning;
+	tp->f_objprefix = objprefix;
 	goto next;
 }
 
@@ -612,11 +626,12 @@ do_objs(FILE *fp)
 		cp = sp + (len = strlen(sp)) - 1;
 		och = *cp;
 		*cp = 'o';
+		len += strlen(tp->f_objprefix);
 		if (len + lpos > 72) {
 			lpos = 8;
 			fprintf(fp, "\\\n\t");
 		}
-		fprintf(fp, "%s ", sp);
+		fprintf(fp, "%s%s ", tp->f_objprefix, sp);
 		lpos += len + 1;
 		*cp = och;
 	}
@@ -691,30 +706,33 @@ do_rules(FILE *f)
 		och = *cp;
 		if (ftp->f_flags & NO_IMPLCT_RULE) {
 			if (ftp->f_depends)
-				fprintf(f, "%s: %s\n", np, ftp->f_depends);
+				fprintf(f, "%s%s: %s\n",
+					ftp->f_objprefix, np, ftp->f_depends);
 			else
-				fprintf(f, "%s: \n", np);
+				fprintf(f, "%s%s: \n", ftp->f_objprefix, np);
 		}
 		else {
 			*cp = '\0';
 			if (och == 'o') {
-				fprintf(f, "%so:\n\t-cp $S/%so .\n\n",
-					tail(np), np);
+				fprintf(f, "%s%so:\n\t-cp $S/%so .\n\n",
+					ftp->f_objprefix, tail(np), np);
 				continue;
 			}
 			if (ftp->f_depends) {
-				fprintf(f, "%sln: $S/%s%c %s\n", tail(np),
-					np, och, ftp->f_depends);
+				fprintf(f, "%s%sln: $S/%s%c %s\n",
+					ftp->f_objprefix, tail(np), np, och,
+					ftp->f_depends);
 				fprintf(f, "\t${NORMAL_LINT}\n\n");
-				fprintf(f, "%so: $S/%s%c %s\n", tail(np),
-					np, och, ftp->f_depends);
+				fprintf(f, "%s%so: $S/%s%c %s\n",
+					ftp->f_objprefix, tail(np), np, och,
+					ftp->f_depends);
 			}
 			else {
-				fprintf(f, "%sln: $S/%s%c\n", tail(np),
-					np, och);
+				fprintf(f, "%s%sln: $S/%s%c\n",
+					ftp->f_objprefix, tail(np), np, och);
 				fprintf(f, "\t${NORMAL_LINT}\n\n");
-				fprintf(f, "%so: $S/%s%c\n", tail(np),
-					np, och);
+				fprintf(f, "%s%so: $S/%s%c\n",
+					ftp->f_objprefix, tail(np), np, och);
 			}
 		}
 		compilewith = ftp->f_compilewith;
@@ -744,7 +762,10 @@ do_rules(FILE *f)
 			compilewith = cmd;
 		}
 		*cp = och;
-		fprintf(f, "\t%s\n\n", compilewith);
+		if (strlen(ftp->f_objprefix))
+			fprintf(f, "\t%s $S/%s\n\n", compilewith, np);
+		else
+			fprintf(f, "\t%s\n\n", compilewith);
 	}
 }
 



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