summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/main.c53
-rw-r--r--usr.bin/make/make.162
2 files changed, 28 insertions, 87 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 4ac8a32fa55..60d46355912 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.101 2013/07/07 09:41:08 espie Exp $ */
+/* $OpenBSD: main.c,v 1.102 2013/11/24 12:36:13 espie Exp $ */
/* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */
/*
@@ -114,7 +114,6 @@ static char *figure_out_MACHINE_ARCH(void);
static char *figure_out_MACHINE_CPU(void);
static char *chdir_verify_path(const char *, struct dirs *);
-static char *concat_verify(const char *, const char *, char, struct dirs *);
static char *figure_out_CURDIR(void);
static void setup_CURDIR_OBJDIR(struct dirs *, const char *);
@@ -515,66 +514,34 @@ figure_out_CURDIR()
static char *
chdir_verify_path(const char *path, struct dirs *d)
{
- 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 NULL;
- } else {
- if (path[0] != '/')
- return Str_concat(d->current, path, '/');
- else
- return estrdup(path);
- }
+ if (chdir(path) == 0) {
+ if (path[0] != '/')
+ return Str_concat(d->current, path, '/');
+ else
+ return estrdup(path);
}
-
return NULL;
}
-static char *
-concat_verify(const char *p1, const char *p2, char c, struct dirs *d)
-{
- char *tmp = Str_concat(p1, p2, c);
- char *result = chdir_verify_path(tmp, d);
- free(tmp);
- return result;
-}
-
static void
setup_CURDIR_OBJDIR(struct dirs *d, const char *machine)
{
char *path, *prefix;
d->current = figure_out_CURDIR();
- d->object = NULL;
/*
* 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.
+ * exists, change into it and build there.
*
* Once things are initted,
* have to add the original directory to the search path,
* and modify the paths for the Makefiles appropriately. The
* current directory is also placed as a variable for make scripts.
*/
- if ((prefix = getenv("MAKEOBJDIRPREFIX")) != NULL) {
- d->object = concat_verify(prefix, d->current, 0, d);
- } else if ((path = getenv("MAKEOBJDIR")) != NULL) {
- d->object = chdir_verify_path(path, d);
- } else {
+ if ((path = getenv("MAKEOBJDIR")) == NULL) {
path = _PATH_OBJDIR;
- prefix = _PATH_OBJDIRPREFIX;
- d->object = concat_verify(path, machine, '.', d);
- if (!d->object)
- d->object=chdir_verify_path(path, d);
- if (!d->object)
- d->object = concat_verify(prefix, d->current, 0, d);
- }
+ }
+ d->object = chdir_verify_path(path, d);
if (d->object == NULL)
d->object = d->current;
}
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index b83f20a3a19..191f025c40e 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: make.1,v 1.108 2013/10/19 18:15:39 schwarze Exp $
+.\" $OpenBSD: make.1,v 1.109 2013/11/24 12:36:13 espie Exp $
.\" $NetBSD: make.1,v 1.18 1997/03/10 21:19:53 christos Exp $
.\"
.\" Copyright (c) 1990, 1993
@@ -30,7 +30,7 @@
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd $Mdocdate: October 19 2013 $
+.Dd $Mdocdate: November 24 2013 $
.Dt MAKE 1
.Os
.Sh NAME
@@ -698,49 +698,27 @@ A path to the directory where
.Nm
was executed.
.It Va .OBJDIR
-A path to the directory where the targets are built.
+Path to the directory where targets are built.
At startup,
.Nm
-searches for an alternate directory to place target files -- it
-will attempt to change into this special directory.
-First, if
-.Ev MAKEOBJDIRPREFIX
-is defined,
-.Nm
-prepends its contents to the current directory name and tries for
-the resulting directory.
-If that fails,
-.Nm
-remains in the current directory.
-If
-.Ev MAKEOBJDIRPREFIX
-is not defined,
+searches for an alternate directory to place target files.
.Nm
-checks
+tries to
+.Xr chdir 2
+into
.Ev MAKEOBJDIR
-and tries to change into that directory.
-Should that fail,
-.Nm
-remains in the current directory.
-If
+(or
+.Pa obj
+if
.Ev MAKEOBJDIR
-is not defined, it tries to change into the directory named
-.Pa obj.${MACHINE}
-(see
-.Va MACHINE
-variable).
-If it still has found no special directory,
-.Nm
-next tries the directory named
-.Pa obj .
-If this fails,
-.Nm
-tries to prepend
-.Pa /usr/obj
-to the current directory name.
-Finally, if none of these directories are available
-.Nm
-will settle for and use the current directory.
+is not defined),
+and sets
+.Va .OBJDIR
+accordingly.
+Should that fail,
+.Va .OBJDIR
+is set to
+.Va .CURDIR .
.It Va .MAKEFLAGS
The environment variable
.Ev MAKEFLAGS
@@ -1572,10 +1550,6 @@ This implementation is a distant derivative of
.Nm pmake ,
originally written by Adam de Boor.
.Sh BUGS
-The determination of
-.Va .OBJDIR
-is contorted to the point of absurdity.
-.Pp
If the same target is specified several times in complete target rules,
.Nm
silently ignores all commands after the first non empty set of commands,