From 4e6c593faabfd45028e88e42b3456080669bdabf Mon Sep 17 00:00:00 2001 From: "Simon J. Gerraty" Date: Sat, 22 Dec 2018 21:32:17 +0000 Subject: [PATCH] Import bmake-20181221 o parse.c: ParseVErrorInternal use .PARSEDIR and apply if relative, and then use .PARSEFILE for consistent result. o var.c: avoid SEGFAULT in .unexport-env when MAKELEVEL is not set --- ChangeLog | 23 +++++++++++++++++++++++ VERSION | 2 +- dirname.c | 10 ++++++++-- mk/mk-files.txt | 26 ++++++++++++++++++++++++-- parse.c | 33 ++++++++++++++++++++++----------- unit-tests/varquote.mk | 4 ++-- var.c | 9 +++++---- 7 files changed, 85 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25edb9e496ae..fb56f8435389 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2018-12-21 Simon J Gerraty + + * VERSION: 20181221 + Merge with NetBSD make, pick up + o parse.c: ParseVErrorInternal use .PARSEDIR + and apply if relative, and then use .PARSEFILE + for consistent result. + +2018-12-20 Simon J Gerraty + + * VERSION: 20181220 + Merge with NetBSD make, pick up + o parse.c: ParseVErrorInternal use .CURDIR if .PARSEDIR + is relative + o var.c: avoid SEGFAULT in .unexport-env + when MAKELEVEL is not set + +2018-12-16 Simon J Gerraty + + * VERSION: 20181216 + Merge with NetBSD make, pick up + o fix for unit-tests/varquote.mk on Debian + 2018-09-21 Simon J. Gerraty * VERSION: 20180919 diff --git a/VERSION b/VERSION index e390075f472b..701dfd7db98f 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ # keep this compatible with sh and make -_MAKE_VERSION=20180919 +_MAKE_VERSION=20181221 diff --git a/dirname.c b/dirname.c index 154593b1d523..2b1fdd29521b 100644 --- a/dirname.c +++ b/dirname.c @@ -1,4 +1,4 @@ -/* $NetBSD: dirname.c,v 1.13 2014/07/16 10:52:26 christos Exp $ */ +/* $NetBSD: dirname.c,v 1.14 2018/09/27 00:45:34 kre Exp $ */ /*- * Copyright (c) 1997, 2002 The NetBSD Foundation, Inc. @@ -35,6 +35,11 @@ #ifndef HAVE_DIRNAME #include +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD: dirname.c,v 1.14 2018/09/27 00:45:34 kre Exp $"); +#endif /* !LIBC_SCCS && !lint */ + +#include "namespace.h" #include #ifdef HAVE_LIBGEN_H #include @@ -92,7 +97,8 @@ xdirname_r(const char *path, char *buf, size_t buflen) out: if (buf != NULL && buflen != 0) { buflen = MIN(len, buflen - 1); - memcpy(buf, path, buflen); + if (buf != path) + memcpy(buf, path, buflen); buf[buflen] = '\0'; } return len; diff --git a/mk/mk-files.txt b/mk/mk-files.txt index 7eebfd6bcb36..4e69dfec0808 100644 --- a/mk/mk-files.txt +++ b/mk/mk-files.txt @@ -25,7 +25,8 @@ of mk-files (mk.tar.gz_). NetBSD provided much of the original structure. Since then I've added a lot of features to NetBSD's make and hence to bmake which is kept closely in sync. The mk-files however have -diverged quite a bit, though ideas are still picked up from NetBSD. +diverged quite a bit, though ideas are still picked up from NetBSD +and FreeBSD. Basics ------ @@ -399,6 +400,20 @@ to avoid possible conflicts during parallel builds. This precludes the use of suffix rules to drive ``make depend``, so dep.mk_ handles that if specifically requested. +options.mk +---------- + +Inspired by FreeBSD's ``bsd.own.mk`` more flexible. +FreeBSD now have similar functionality in ``bsd.mkopt.mk``. + +It allows users to express their intent with respect to options +``MK_*`` by setting ``WITH_*`` or ``WITHOUT_*``. + +Note: ``WITHOUT_*`` wins if both are set, and makefiles can set +``NO_*`` to say they cannot handle that option, or even ``MK_*`` if +they really need to. + + own.mk ------ @@ -407,6 +422,13 @@ Normally included by ``init.mk`` (included by ``lib.mk`` and It includes ``${MAKECONF}`` if it is defined and exists. +ldorder.mk +---------- + +Leverages ``bmake`` to compute optimal link order for libraries. +This works nicely and makes refactoring a breeze - so long as you +have not (or few) cicular dependencies between libraries. + man.mk ------ @@ -477,5 +499,5 @@ where you unpacked the tar file, you can:: .. _mk.tar.gz: http://www.crufty.net/ftp/pub/sjg/mk.tar.gz :Author: sjg@crufty.net -:Revision: $Id: mk-files.txt,v 1.16 2014/09/05 04:41:16 sjg Exp $ +:Revision: $Id: mk-files.txt,v 1.18 2018/12/08 07:27:15 sjg Exp $ :Copyright: Crufty.NET diff --git a/parse.c b/parse.c index 7f18fdc91433..a7d7a4d94ef5 100644 --- a/parse.c +++ b/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.229 2018/04/05 16:31:54 christos Exp $ */ +/* $NetBSD: parse.c,v 1.231 2018/12/22 00:36:32 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: parse.c,v 1.229 2018/04/05 16:31:54 christos Exp $"; +static char rcsid[] = "$NetBSD: parse.c,v 1.231 2018/12/22 00:36:32 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: parse.c,v 1.229 2018/04/05 16:31:54 christos Exp $"); +__RCSID("$NetBSD: parse.c,v 1.231 2018/12/22 00:36:32 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -691,21 +691,32 @@ ParseVErrorInternal(FILE *f, const char *cfname, size_t clineno, int type, if (cfname != NULL) { (void)fprintf(f, "\""); if (*cfname != '/' && strcmp(cfname, "(stdin)") != 0) { - char *cp; - const char *dir; + char *cp, *cp2; + const char *dir, *fname; /* * Nothing is more annoying than not knowing - * which Makefile is the culprit. + * which Makefile is the culprit; we try ${.PARSEDIR} + * and apply realpath(3) if not absolute. */ dir = Var_Value(".PARSEDIR", VAR_GLOBAL, &cp); - if (dir == NULL || *dir == '\0' || - (*dir == '.' && dir[1] == '\0')) - dir = Var_Value(".CURDIR", VAR_GLOBAL, &cp); if (dir == NULL) dir = "."; - - (void)fprintf(f, "%s/%s", dir, cfname); + if (*dir != '/') { + dir = cp2 = realpath(dir, NULL); + free(cp); + cp = cp2; /* cp2 set to NULL by Var_Value */ + } + fname = Var_Value(".PARSEFILE", VAR_GLOBAL, &cp2); + if (fname == NULL) { + if ((fname = strrchr(cfname, '/'))) + fname++; + else + fname = cfname; + } + (void)fprintf(f, "%s/%s", dir, fname); + free(cp2); + free(cp); } else (void)fprintf(f, "%s", cfname); diff --git a/unit-tests/varquote.mk b/unit-tests/varquote.mk index 571f262fd91e..fb8b1066ac15 100644 --- a/unit-tests/varquote.mk +++ b/unit-tests/varquote.mk @@ -1,4 +1,4 @@ -# $NetBSD: varquote.mk,v 1.2 2018/05/27 01:14:51 christos Exp $ +# $NetBSD: varquote.mk,v 1.4 2018/12/16 18:53:34 christos Exp $ # # Test VAR:q modifier @@ -10,5 +10,5 @@ all: @${MAKE} -f ${MAKEFILE} REPROFLAGS=${REPROFLAGS:q} .else all: - @echo ${REPROFLAGS} + @printf "%s %s\n" ${REPROFLAGS} .endif diff --git a/var.c b/var.c index b9b316939492..6f8d4c3268b5 100644 --- a/var.c +++ b/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.220 2018/05/27 01:14:51 christos Exp $ */ +/* $NetBSD: var.c,v 1.221 2018/12/21 05:50:19 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.220 2018/05/27 01:14:51 christos Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.221 2018/12/21 05:50:19 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.220 2018/05/27 01:14:51 christos Exp $"); +__RCSID("$NetBSD: var.c,v 1.221 2018/12/21 05:50:19 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -835,7 +835,8 @@ Var_UnExport(char *str) environ = savedEnv = newenv; newenv[0] = NULL; newenv[1] = NULL; - setenv(MAKE_LEVEL_ENV, cp, 1); + if (cp && *cp) + setenv(MAKE_LEVEL_ENV, cp, 1); } else { for (; *str != '\n' && isspace((unsigned char) *str); str++) continue;