Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): extract InitVarMake from main
details: https://anonhg.NetBSD.org/src/rev/20aeca479ce2
branches: trunk
changeset: 956360:20aeca479ce2
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Oct 27 17:36:17 2020 +0000
description:
make(1): extract InitVarMake from main
diffstat:
usr.bin/make/main.c | 52 ++++++++++++++++++++++++++++++----------------------
1 files changed, 30 insertions(+), 22 deletions(-)
diffs (87 lines):
diff -r b17d744ccadd -r 20aeca479ce2 usr.bin/make/main.c
--- a/usr.bin/make/main.c Tue Oct 27 17:16:24 2020 +0000
+++ b/usr.bin/make/main.c Tue Oct 27 17:36:17 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.404 2020/10/27 17:09:09 rillig Exp $ */
+/* $NetBSD: main.c,v 1.405 2020/10/27 17:36:17 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.404 2020/10/27 17:09:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.405 2020/10/27 17:36:17 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -1096,6 +1096,33 @@
}
static void
+InitVarMake(char **argv)
+{
+ char mdpath[MAXPATHLEN];
+ const char *p1;
+
+ if (argv[0][0] == '/' || strchr(argv[0], '/') == NULL) {
+ /*
+ * Leave alone if it is an absolute path, or if it does
+ * not contain a '/' in which case we need to find it in
+ * the path, like execvp(3) and the shells do.
+ */
+ p1 = argv[0];
+ } else {
+ struct stat sb;
+ /*
+ * A relative path, canonicalize it.
+ */
+ p1 = cached_realpath(argv[0], mdpath);
+ if (!p1 || *p1 != '/' || stat(p1, &sb) < 0) {
+ p1 = argv[0]; /* realpath failed */
+ }
+ }
+ Var_Set("MAKE", p1, VAR_GLOBAL);
+ Var_Set(".MAKE", p1, VAR_GLOBAL);
+}
+
+static void
InitDefIncPath(char *syspath)
{
static char defsyspath[] = _PATH_DEFSYSPATH;
@@ -1260,7 +1287,6 @@
Boolean outOfDate; /* FALSE if all targets up to date */
struct stat sa;
char *p1;
- char mdpath[MAXPATHLEN];
const char *machine;
const char *machine_arch;
char *syspath = getenv("MAKESYSPATH");
@@ -1344,25 +1370,7 @@
* MFLAGS also gets initialized empty, for compatibility.
*/
Parse_Init();
- if (argv[0][0] == '/' || strchr(argv[0], '/') == NULL) {
- /*
- * Leave alone if it is an absolute path, or if it does
- * not contain a '/' in which case we need to find it in
- * the path, like execvp(3) and the shells do.
- */
- p1 = argv[0];
- } else {
- struct stat sb;
- /*
- * A relative path, canonicalize it.
- */
- p1 = cached_realpath(argv[0], mdpath);
- if (!p1 || *p1 != '/' || stat(p1, &sb) < 0) {
- p1 = argv[0]; /* realpath failed */
- }
- }
- Var_Set("MAKE", p1, VAR_GLOBAL);
- Var_Set(".MAKE", p1, VAR_GLOBAL);
+ InitVarMake(argv);
Var_Set(MAKEFLAGS, "", VAR_GLOBAL);
Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL);
Var_Set("MFLAGS", "", VAR_GLOBAL);
Home |
Main Index |
Thread Index |
Old Index