Module Name: src Committed By: uebayasi Date: Sun Aug 30 21:58:19 UTC 2015
Modified Files: src/usr.bin/config: defs.h mkmakefile.c Log Message: Revert "Accept only relative paths ...". This will be redone in much better, stricter way. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/usr.bin/config/defs.h cvs rdiff -u -r1.48 -r1.49 src/usr.bin/config/mkmakefile.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/config/defs.h diff -u src/usr.bin/config/defs.h:1.72 src/usr.bin/config/defs.h:1.73 --- src/usr.bin/config/defs.h:1.72 Sun Aug 30 05:12:00 2015 +++ src/usr.bin/config/defs.h Sun Aug 30 21:58:19 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.72 2015/08/30 05:12:00 uebayasi Exp $ */ +/* $NetBSD: defs.h,v 1.73 2015/08/30 21:58:19 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -107,7 +107,7 @@ extern const char *progname; * The next two lines define the current version of the config(1) binary, * and the minimum version of the configuration files it supports. */ -#define CONFIG_VERSION 20150832 +#define CONFIG_VERSION 20150833 #define CONFIG_MINVERSION 0 /* Index: src/usr.bin/config/mkmakefile.c diff -u src/usr.bin/config/mkmakefile.c:1.48 src/usr.bin/config/mkmakefile.c:1.49 --- src/usr.bin/config/mkmakefile.c:1.48 Sun Aug 30 05:12:00 2015 +++ src/usr.bin/config/mkmakefile.c Sun Aug 30 21:58:19 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: mkmakefile.c,v 1.48 2015/08/30 05:12:00 uebayasi Exp $ */ +/* $NetBSD: mkmakefile.c,v 1.49 2015/08/30 21:58:19 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: mkmakefile.c,v 1.48 2015/08/30 05:12:00 uebayasi Exp $"); +__RCSID("$NetBSD: mkmakefile.c,v 1.49 2015/08/30 21:58:19 uebayasi Exp $"); #include <sys/param.h> #include <ctype.h> @@ -62,6 +62,12 @@ __RCSID("$NetBSD: mkmakefile.c,v 1.48 20 * Make the Makefile. */ +static const char *srcpath(struct files *); + +static const char *prefix_prologue(const char *); +static const char *filetype_prologue(struct filetype *); + + static void emitdefs(FILE *); static void emitfiles(FILE *, int, int); @@ -257,6 +263,46 @@ emitsubs(FILE *fp, const char *line, con } } +/* + * Return (possibly in a static buffer) the name of the `source' for a + * file. If we have `options source', or if the file is marked `always + * source', this is always the path from the `file' line; otherwise we + * get the .o from the obj-directory. + */ +static const char * +srcpath(struct files *fi) +{ +#if 1 + /* Always have source, don't support object dirs for kernel builds. */ + return (fi->fi_path); +#else + static char buf[MAXPATHLEN]; + + if (have_source || (fi->fi_flags & FI_ALWAYSSRC) != 0) + return (fi->fi_path); + if (objpath == NULL) { + cfgerror("obj-directory not set"); + return (NULL); + } + (void)snprintf(buf, sizeof buf, "%s/%s.o", objpath, fi->fi_base); + return (buf); +#endif +} + +static const char * +filetype_prologue(struct filetype *fit) +{ + + return (*fit->fit_path == '/') ? "" : "$S/"; +} + +static const char * +prefix_prologue(const char *path) +{ + + return (*path == '/') ? "" : "$S/"; +} + static void emitdefs(FILE *fp) { @@ -304,17 +350,21 @@ emitobjs(FILE *fp) fprintf(fp, "\t%s.o \\\n", fi->fi_base); } TAILQ_FOREACH(oi, &allobjects, oi_next) { - const char *prefix, *sep; + const char *prologue, *prefix, *sep; if ((oi->oi_flags & OI_SEL) == 0) continue; - if (oi->oi_prefix != NULL) { - prefix = oi->oi_prefix; - sep = "/"; - } else { - prefix = sep = ""; + prologue = prefix = sep = ""; + if (*oi->oi_path != '/') { + if (oi->oi_prefix != NULL) { + prologue = prefix_prologue(oi->oi_path); + prefix = oi->oi_prefix; + sep = "/"; + } else { + prologue = filetype_prologue(&oi->oi_fit); + } } - fprintf(fp, "\t%s%s%s%s \\\n", "$S/", prefix, sep, + fprintf(fp, "\t%s%s%s%s \\\n", prologue, prefix, sep, oi->oi_path); } putc('\n', fp); @@ -448,25 +498,31 @@ static void emitfiles(FILE *fp, int suffix, int upper_suffix) { struct files *fi; + const char *fpath; struct config *cf; char swapname[100]; fprintf(fp, "%cFILES= \\\n", toupper(suffix)); TAILQ_FOREACH(fi, &allfiles, fi_next) { - const char *prefix, *sep; + const char *prologue, *prefix, *sep; if ((fi->fi_flags & FI_SEL) == 0) continue; + fpath = srcpath(fi); if (fi->fi_suffix != suffix && fi->fi_suffix != upper_suffix) continue; - if (fi->fi_prefix != NULL) { - prefix = fi->fi_prefix; - sep = "/"; - } else { - prefix = sep = ""; + prologue = prefix = sep = ""; + if (*fi->fi_path != '/') { + if (fi->fi_prefix != NULL) { + prologue = prefix_prologue(fi->fi_prefix); + prefix = fi->fi_prefix; + sep = "/"; + } else { + prologue = filetype_prologue(&fi->fi_fit); + } } - fprintf(fp, "\t%s%s%s%s \\\n", "$S/", prefix, sep, - fi->fi_path); + fprintf(fp, "\t%s%s%s%s \\\n", + prologue, prefix, sep, fpath); } /* @@ -491,22 +547,28 @@ static void emitrules(FILE *fp) { struct files *fi; + const char *fpath; TAILQ_FOREACH(fi, &allfiles, fi_next) { - const char *prefix, *sep; + const char *prologue, *prefix, *sep; if ((fi->fi_flags & FI_SEL) == 0) continue; if (fi->fi_mkrule == NULL) continue; - if (fi->fi_prefix != NULL) { - prefix = fi->fi_prefix; - sep = "/"; - } else { - prefix = sep = ""; - } - fprintf(fp, "%s.o: %s%s%s%s\n", fi->fi_base, "$S/", prefix, - sep, fi->fi_path); + fpath = srcpath(fi); + prologue = prefix = sep = ""; + if (*fpath != '/') { + if (fi->fi_prefix != NULL) { + prologue = prefix_prologue(fi->fi_prefix); + prefix = fi->fi_prefix; + sep = "/"; + } else { + prologue = filetype_prologue(&fi->fi_fit); + } + } + fprintf(fp, "%s.o: %s%s%s%s\n", fi->fi_base, + prologue, prefix, sep, fpath); fprintf(fp, "\t%s\n\n", fi->fi_mkrule); } } @@ -566,7 +628,7 @@ emitincludes(FILE *fp) SLIST_FOREACH(pf, &allprefixes, pf_next) { fprintf(fp, "EXTRA_INCLUDES+=\t-I%s%s\n", - "$S/", pf->pf_prefix); + prefix_prologue(pf->pf_prefix), pf->pf_prefix); } }