summaryrefslogtreecommitdiffstats
path: root/usr.bin/make
diff options
context:
space:
mode:
authorswallace <swallace@FreeBSD.org>1996-09-18 06:06:39 +0000
committerswallace <swallace@FreeBSD.org>1996-09-18 06:06:39 +0000
commit61bc096e33ee817e7457d3f20f9218cae76fd257 (patch)
treed48f3eb8307b7b55563a9315f849283995c6a1ff /usr.bin/make
parent7438a7f7a8a831d67d05e34b842fef1eebea33b1 (diff)
downloadFreeBSD-src-61bc096e33ee817e7457d3f20f9218cae76fd257.zip
FreeBSD-src-61bc096e33ee817e7457d3f20f9218cae76fd257.tar.gz
Restore previous compatibility of ${.CURDIR}/obj.`uname -m` and
$(.CURDIR}/obj search while retaining compatability of new prefix with cwd for the current source tree builds. .TARGETOBJDIR has been removed from make and CANONICALOBJDIR set in bsd.obj.mk The builtin object directory searching is defined specifically as: If MAKEOBJDIRPREFIX is defined, the search order is ${MAKEOBJDIRPREFIX}${.CURDIR} ${.CURDIR} Else if MAKEOBJDIR is defined, the search order is ${MAKEOBJDIR} ${.CURDIR} Otherwise, default to the search order ${.CURDIR}/obj.`uname -m` $(.CURDIR}/obj /usr/obj${.CURDIR} ${.CURDIR} Reviewed by: bde
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/main.c92
-rw-r--r--usr.bin/make/pathnames.h5
2 files changed, 67 insertions, 30 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 971eadd..81c5b39 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -354,6 +354,34 @@ Main_ParseArgLine(line)
MainParseArgs(argc, argv);
}
+char *
+chdir_verify_path(path, obpath)
+ char *path;
+ char *obpath;
+{
+ struct stat sb;
+
+ if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
+ if (chdir(path)) {
+ (void)fprintf(stderr, "make warning: %s: %s.\n",
+ path, strerror(errno));
+ return 0;
+ }
+ else {
+ if (path[0] != '/') {
+ (void) snprintf(obpath, MAXPATHLEN, "%s/%s",
+ curdir, path);
+ return obpath;
+ }
+ else
+ return path;
+ }
+ }
+
+ return 0;
+}
+
+
/*-
* main --
* The main function, for obvious reasons. Initializes variables
@@ -379,11 +407,10 @@ main(argc, argv)
Lst targs; /* target nodes to create -- passed to Make_Init */
Boolean outOfDate = TRUE; /* FALSE if all targets up to date */
struct stat sb, sa;
- char *p, *p1, *path, *pwd, *getenv(), *getwd();
+ char *p, *p1, *path, *pathp, *pwd, *getenv(), *getwd();
char mdpath[MAXPATHLEN + 1];
char obpath[MAXPATHLEN + 1];
char cdpath[MAXPATHLEN + 1];
- char *realobjdir; /* Where we'd like to go */
struct utsname utsname;
char *machine = getenv("MACHINE");
@@ -419,43 +446,53 @@ main(argc, argv)
* MACHINE_ARCH is always known at compile time.
*/
if (!machine) {
- if (uname(&utsname)) {
+#ifndef MACHINE
+ if (uname(&utsname) == -1) {
perror("make: uname");
exit(2);
}
machine = utsname.machine;
+#else
+ machine = MACHINE;
+#endif
}
/*
- * if the MAKEOBJDIR (or by default, the _PATH_OBJDIR) directory
- * exists, change into it and build there. Once things are
- * initted, have to add the original directory to the search path,
+ * If the MAKEOBJDIR (or by default, the _PATH_OBJDIR) directory
+ * exists, change into it and build there. (If a .${MACHINE} suffix
+ * exists, use that directory instead).
+ * Otherwise check MAKEOBJDIRPREFIX`cwd` (or by default,
+ * _PATH_OBJDIRPREFIX`cwd`) and build there if it exists.
+ * If all fails, use the current directory to build.
+ *
+ * Once things are initted,
+ * have to add the original directory to the search path,
* and modify the paths for the Makefiles apropriately. The
* current directory is also placed as a variable for make scripts.
*/
- if (!(path = getenv("MAKEOBJDIR")))
- path = _PATH_OBJDIR;
- (void) snprintf(mdpath, MAXPATHLEN, "%s%s", path, curdir);
- realobjdir = mdpath; /* This is where we'd _like_ to be, anyway */
-
- if (stat(mdpath, &sb) == 0 && S_ISDIR(sb.st_mode)) {
-
- if (chdir(mdpath)) {
- (void)fprintf(stderr, "make warning: %s: %s.\n",
- mdpath, strerror(errno));
- objdir = curdir;
- }
- else {
- if (mdpath[0] != '/') {
- (void) sprintf(obpath, "%s/%s", curdir, mdpath);
- objdir = obpath;
- }
- else
- objdir = mdpath;
+ if (!(pathp = getenv("MAKEOBJDIRPREFIX"))) {
+ if (!(path = getenv("MAKEOBJDIR"))) {
+ path = _PATH_OBJDIR;
+ pathp = _PATH_OBJDIRPREFIX;
+ (void) snprintf(mdpath, MAXPATHLEN, "%s.%s",
+ path, machine);
+ if (!(objdir = chdir_verify_path(mdpath, obpath)))
+ if (!(objdir=chdir_verify_path(path, obpath))) {
+ (void) snprintf(mdpath, MAXPATHLEN,
+ "%s%s", pathp, curdir);
+ if (!(objdir=chdir_verify_path(mdpath,
+ obpath)))
+ objdir = curdir;
+ }
}
+ else if (!(objdir = chdir_verify_path(path, obpath)))
+ objdir = curdir;
+ }
+ else {
+ (void) snprintf(mdpath, MAXPATHLEN, "%s%s", pathp, curdir);
+ if (!(objdir = chdir_verify_path(mdpath, obpath)))
+ objdir = curdir;
}
- else
- objdir = curdir;
setenv("PWD", objdir, 1);
@@ -499,7 +536,6 @@ main(argc, argv)
if (objdir != curdir)
Dir_AddDir(dirSearchPath, curdir);
Var_Set(".CURDIR", curdir, VAR_GLOBAL);
- Var_Set(".TARGETOBJDIR", realobjdir, VAR_GLOBAL);
Var_Set(".OBJDIR", objdir, VAR_GLOBAL);
/*
diff --git a/usr.bin/make/pathnames.h b/usr.bin/make/pathnames.h
index a96942c..74a2e50 100644
--- a/usr.bin/make/pathnames.h
+++ b/usr.bin/make/pathnames.h
@@ -31,10 +31,11 @@
* SUCH DAMAGE.
*
* from: @(#)pathnames.h 5.2 (Berkeley) 6/1/90
- * $Id: pathnames.h,v 1.2 1995/01/23 21:01:52 jkh Exp $
+ * $Id: pathnames.h,v 1.3 1996/06/24 04:24:35 jkh Exp $
*/
-#define _PATH_OBJDIR "/usr/obj"
+#define _PATH_OBJDIR "obj"
+#define _PATH_OBJDIRPREFIX "/usr/obj"
#define _PATH_DEFSHELLDIR "/bin"
#define _PATH_DEFSYSMK "/usr/share/mk/sys.mk"
#define _PATH_DEFSYSPATH "/usr/share/mk"
OpenPOWER on IntegriCloud